Re: [dx39] Avoid use of glGet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le Samedi 24 Mai 2003 17:16, Ann and Jason Edmeades a écrit :
> As pointed out to me (thanks Lucho), a glGet has a large overhead
> compared to a simple lookup, and if we already know the information, we
> might as well use it. I changed all the ones used by the SDK sample
> Billboard and if improved things by about half a frame/sec, which isnt
> much but every bit of performance counts. I'll probably fix the stencil
> pass/fail ones at some point too.
>
> Changelog
>
> Avoids the use of glGet when we know the information locally
>
> Jason

Updated patch without conflict with dx37->dx38 patches

Regards,
Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+1Sp0p7NA3AmQTU4RAsZ6AKCToChIsuNyn1A/TIZwsF6dxktRswCaAp8a
wmFxoE/DanK7dKNLGRO/jck=
=oGna
-----END PGP SIGNATURE-----
Les sous-répertoires ../winefree/dlls/d3d8/CVS et dlls/d3d8/CVS sont identiques.
diff -u ../winefree/dlls/d3d8/d3d8_private.h dlls/d3d8/d3d8_private.h
--- ../winefree/dlls/d3d8/d3d8_private.h	2003-05-28 23:26:15.000000000 +0200
+++ dlls/d3d8/d3d8_private.h	2003-05-28 23:22:24.000000000 +0200
@@ -322,6 +322,8 @@
 
     UINT                          srcBlend;
     UINT                          dstBlend;
+    UINT                          alphafunc;
+    UINT                          stencilfunc;
 
     /* State block related */
     BOOL                          isRecordingState;
diff -u ../winefree/dlls/d3d8/device.c dlls/d3d8/device.c
--- ../winefree/dlls/d3d8/device.c	2003-05-28 23:26:15.000000000 +0200
+++ dlls/d3d8/device.c	2003-05-28 23:23:16.000000000 +0200
@@ -1234,7 +1234,8 @@
     ENTER_GL();
 
     glXSwapBuffers(This->display, This->drawable);
-    checkGLcall("glXSwapBuffers");
+    /* Dont call checkGLcall, as glGetError is not applicable here */
+    TRACE("glXSwapBuffers called, Starting new frame");
 
     LEAVE_GL();
 
@@ -2922,10 +2923,7 @@
     case D3DRS_ALPHAFUNC                 :
         {
             int glParm = GL_LESS;
-            float ref = 1.0;
-
-            glGetFloatv(GL_ALPHA_TEST_REF, &ref);
-            checkGLcall("glGetFloatv(GL_ALPHA_TEST_REF, &ref);");
+            float ref = ((float) This->StateBlock->renderstate[D3DRS_ALPHAREF]) / 255.0f;
 
             switch ((D3DCMPFUNC) Value) {
             case D3DCMP_NEVER:         glParm=GL_NEVER; break;
@@ -2941,18 +2939,16 @@
             }
             TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref);
             glAlphaFunc(glParm, ref);
+            This->alphafunc = glParm;
             checkGLcall("glAlphaFunc");
         }
         break;
 
     case D3DRS_ALPHAREF                  :
         {
-            int glParm = GL_LESS;
+            int glParm = This->alphafunc;
             float ref = 1.0f;
 
-            glGetIntegerv(GL_ALPHA_TEST_FUNC, &glParm);
-            checkGLcall("glGetFloatv(GL_ALPHA_TEST_FUNC, &glParm);");
-
             ref = ((float) Value) / 255.0f;
             TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref);
             glAlphaFunc(glParm, ref);
@@ -3075,13 +3071,8 @@
     case D3DRS_STENCILFUNC               :
         {
            int glParm = GL_ALWAYS;
-           int ref = 0;
-           GLuint mask = 0xFFFFFFFF;
-
-           glGetIntegerv(GL_STENCIL_REF, &ref);
-           checkGLcall("glGetFloatv(GL_STENCIL_REF, &ref);");
-           glGetIntegerv(GL_STENCIL_VALUE_MASK, &mask);
-           checkGLcall("glGetFloatv(GL_STENCIL_VALUE_MASK, &glParm);");
+           int ref = This->StateBlock->renderstate[D3DRS_STENCILREF];
+           GLuint mask = This->StateBlock->renderstate[D3DRS_STENCILMASK];
 
            switch ((D3DCMPFUNC) Value) {
            case D3DCMP_NEVER:         glParm=GL_NEVER; break;
@@ -3103,14 +3094,9 @@
 
     case D3DRS_STENCILREF                :
         {
-           int glParm = GL_ALWAYS;
+           int glParm = This->stencilfunc;
            int ref = 0;
-           GLuint mask = 0xFFFFFFFF;
-
-           glGetIntegerv(GL_STENCIL_FUNC, &glParm);
-           checkGLcall("glGetFloatv(GL_STENCIL_FUNC, &glParm);");
-           glGetIntegerv(GL_STENCIL_VALUE_MASK, &mask);
-           checkGLcall("glGetFloatv(GL_STENCIL_VALUE_MASK, &glParm);");
+           GLuint mask = This->StateBlock->renderstate[D3DRS_STENCILMASK];
 
            ref = Value;
            TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask);
@@ -3121,15 +3107,10 @@
 
     case D3DRS_STENCILMASK               :
         {
-           int glParm = GL_ALWAYS;
-           int ref = 0.0;
+           int glParm = This->stencilfunc;
+           int ref = This->StateBlock->renderstate[D3DRS_STENCILREF];
            GLuint mask = Value;
 
-           glGetIntegerv(GL_STENCIL_REF, &ref);
-           checkGLcall("glGetFloatv(GL_STENCIL_REF, &ref);");
-           glGetIntegerv(GL_STENCIL_FUNC, &glParm);
-           checkGLcall("glGetFloatv(GL_STENCIL_FUNC, &glParm);");
-
            TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask);
            glStencilFunc(glParm, ref, mask);
            checkGLcall("glStencilFunc");
diff -u ../winefree/dlls/d3d8/stateblock.c dlls/d3d8/stateblock.c
--- ../winefree/dlls/d3d8/stateblock.c	2003-05-28 23:26:15.000000000 +0200
+++ dlls/d3d8/stateblock.c	2003-05-28 23:22:24.000000000 +0200
@@ -106,9 +106,16 @@
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
+
+    /* Setting stencil func also uses values for stencil ref/mask, so manually set defaults
+     * so only a single call performed (and ensure defaults initialized before making that call)    
+     *
+     * IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILREF, 0);
+     * IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILMASK, 0xFFFFFFFF);
+     */
+    This->StateBlock->renderstate[D3DRS_STENCILREF] = 0;
+    This->StateBlock->renderstate[D3DRS_STENCILMASK] = 0xFFFFFFFF;
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
-    IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILREF, 0);
-    IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILMASK, 0xFFFFFFFF);
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_TEXTUREFACTOR, 0xFFFFFFFF);
     IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_WRAP0, 0);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux