[PATCH] WineD3D: Make sure the arbfp pipeline replacement =

Stefan Doesinger stefan at codeweavers.com
Wed Nov 19 14:29:34 CST 2008


constants are loaded=0A=
=0A=
The code here skipped constant loading when a pixel shader was in use, =
and only reloaded them on ffp use if the shader=0A=
implementation used ARB too. This way a e.g. texfactor change could get =
lost if GLSL shaders are used, and the texfactor changed=0A=
while a pixel shader was in use.=0A=
=0A=
This patch makes the code load arbfp constants if a non-arbfp pixel =
shader implementation is used even if a pixel shader is=0A=
active. We can happily do this because the constant sets do not collide =
with each other.=0A=
---=0A=
 dlls/wined3d/arb_program_shader.c |   65 =
++++++++++++++++++++----------------=0A=
 1 files changed, 36 insertions(+), 29 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/arb_program_shader.c =
b/dlls/wined3d/arb_program_shader.c=0A=
index 47a03ca..cb89892 100644=0A=
--- a/dlls/wined3d/arb_program_shader.c=0A=
+++ b/dlls/wined3d/arb_program_shader.c=0A=
@@ -2470,26 +2470,37 @@ static void state_texfactor_arbfp(DWORD state, =
IWineD3DStateBlockImpl *statebloc=0A=
     float col[4];=0A=
     IWineD3DDeviceImpl *device =3D stateblock->wineD3DDevice;=0A=
 =0A=
-    /* Do not overwrite pixel shader constants if a pshader is in use */=0A=
-    if(use_ps(device)) return;=0A=
-=0A=
-    =
D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], =
col);=0A=
-    GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_TFACTOR, col));=0A=
-    checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_TFACTOR, col)");=0A=
-=0A=
+    /* Don't load the parameter if we're using an arbfp pixel shader, =
otherwise we'll overwrite=0A=
+     * application provided constants=0A=
+     */=0A=
     if(device->shader_backend =3D=3D &arb_program_shader_backend) {=0A=
+        if(use_ps(device)) return;=0A=
+=0A=
         device =3D stateblock->wineD3DDevice;=0A=
         =
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_TFACTOR] =3D 1;=0A=
         device->highest_dirty_ps_const =3D =
max(device->highest_dirty_ps_const, ARB_FFP_CONST_TFACTOR + 1);=0A=
     }=0A=
+=0A=
+    =
D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], =
col);=0A=
+    GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_TFACTOR, col));=0A=
+    checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_TFACTOR, col)");=0A=
+=0A=
 }=0A=
 =0A=
 static void state_arb_specularenable(DWORD state, =
IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {=0A=
     float col[4];=0A=
     IWineD3DDeviceImpl *device =3D stateblock->wineD3DDevice;=0A=
 =0A=
-    /* Do not overwrite pixel shader constants if a pshader is in use */=0A=
-    if(use_ps(device)) return;=0A=
+    /* Don't load the parameter if we're using an arbfp pixel shader, =
otherwise we'll overwrite=0A=
+     * application provided constants=0A=
+     */=0A=
+    if(device->shader_backend =3D=3D &arb_program_shader_backend) {=0A=
+        if(use_ps(device)) return;=0A=
+=0A=
+        device =3D stateblock->wineD3DDevice;=0A=
+        =
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_SPECULAR_ENABLE]=
 =3D 1;=0A=
+        device->highest_dirty_ps_const =3D =
max(device->highest_dirty_ps_const, ARB_FFP_CONST_SPECULAR_ENABLE + 1);=0A=
+    }=0A=
 =0A=
     if(stateblock->renderState[WINED3DRS_SPECULARENABLE]) {=0A=
         /* The specular color has no alpha */=0A=
@@ -2501,12 +2512,6 @@ static void state_arb_specularenable(DWORD state, =
IWineD3DStateBlockImpl *stateb=0A=
     }=0A=
     GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_SPECULAR_ENABLE, col));=0A=
     checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_SPECULAR_ENABLE, col)");=0A=
-=0A=
-    if(device->shader_backend =3D=3D &arb_program_shader_backend) {=0A=
-        device =3D stateblock->wineD3DDevice;=0A=
-        =
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_SPECULAR_ENABLE]=
 =3D 1;=0A=
-        device->highest_dirty_ps_const =3D =
max(device->highest_dirty_ps_const, ARB_FFP_CONST_SPECULAR_ENABLE + 1);=0A=
-    }=0A=
 }=0A=
 =0A=
 static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
@@ -2524,8 +2529,14 @@ static void set_bumpmat_arbfp(DWORD state, =
IWineD3DStateBlockImpl *stateblock, W=0A=
                 =
device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONS=
TANT, stateblock, context);=0A=
             }=0A=
         }=0A=
-        /* Exit now, don't set the bumpmat below, otherwise we may =
overwrite pixel shader constants */=0A=
-        return;=0A=
+=0A=
+        if(device->shader_backend =3D=3D &arb_program_shader_backend) {=0A=
+            /* Exit now, don't set the bumpmat below, otherwise we may =
overwrite pixel shader constants */=0A=
+            return;=0A=
+        }=0A=
+    } else if(device->shader_backend =3D=3D =
&arb_program_shader_backend) {=0A=
+        =
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_BUMPMAT(stage)] =
=3D 1;=0A=
+        device->highest_dirty_ps_const =3D =
max(device->highest_dirty_ps_const, ARB_FFP_CONST_BUMPMAT(stage) + 1);=0A=
     }=0A=
 =0A=
     mat[0][0] =3D *((float *) =
&stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]);=0A=
@@ -2535,11 +2546,6 @@ static void set_bumpmat_arbfp(DWORD state, =
IWineD3DStateBlockImpl *stateblock, W=0A=
 =0A=
     GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_BUMPMAT(stage), &mat[0][0]));=0A=
     checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_BUMPMAT(stage), &mat[0][0])");=0A=
-=0A=
-    if(device->shader_backend =3D=3D &arb_program_shader_backend) {=0A=
-        =
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_BUMPMAT(stage)] =
=3D 1;=0A=
-        device->highest_dirty_ps_const =3D =
max(device->highest_dirty_ps_const, ARB_FFP_CONST_BUMPMAT(stage) + 1);=0A=
-    }=0A=
 }=0A=
 =0A=
 static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
@@ -2557,8 +2563,14 @@ static void tex_bumpenvlum_arbfp(DWORD state, =
IWineD3DStateBlockImpl *stateblock=0A=
                 =
device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONS=
TANT, stateblock, context);=0A=
             }=0A=
         }=0A=
-        /* Exit now, don't set the bumpmat below, otherwise we may =
overwrite pixel shader constants */=0A=
-        return;=0A=
+=0A=
+        if(device->shader_backend =3D=3D &arb_program_shader_backend) {=0A=
+            /* Exit now, don't set the bumpmat below, otherwise we may =
overwrite pixel shader constants */=0A=
+            return;=0A=
+        }=0A=
+    } else if(device->shader_backend =3D=3D =
&arb_program_shader_backend) {=0A=
+        =
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_LUMINANCE(stage)=
] =3D 1;=0A=
+        device->highest_dirty_ps_const =3D =
max(device->highest_dirty_ps_const, ARB_FFP_CONST_LUMINANCE(stage) + 1);=0A=
     }=0A=
 =0A=
     param[0] =3D *((float *) =
&stateblock->textureState[stage][WINED3DTSS_BUMPENVLSCALE]);=0A=
@@ -2568,11 +2580,6 @@ static void tex_bumpenvlum_arbfp(DWORD state, =
IWineD3DStateBlockImpl *stateblock=0A=
 =0A=
     GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_LUMINANCE(stage), param));=0A=
     checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, =
ARB_FFP_CONST_LUMINANCE(stage), param)");=0A=
-=0A=
-    if(device->shader_backend =3D=3D &arb_program_shader_backend) {=0A=
-        =
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_LUMINANCE(stage)=
] =3D 1;=0A=
-        device->highest_dirty_ps_const =3D =
max(device->highest_dirty_ps_const, ARB_FFP_CONST_LUMINANCE(stage) + 1);=0A=
-    }=0A=
 }=0A=
 =0A=
 static const char *get_argreg(SHADER_BUFFER *buffer, DWORD argnum, =
unsigned int stage, DWORD arg) {=0A=
-- =0A=
1.5.6.4=0A=
=0A=

------=_NextPart_000_002D_01C94A69.B512F5F0--




More information about the wine-patches mailing list