Stefan Dösinger : wined3d: Make sure the arbfp pipeline replacement constants are loaded.
Alexandre Julliard
julliard at winehq.org
Thu Nov 20 08:20:36 CST 2008
Module: wine
Branch: master
Commit: 234e995bdc25bc47a6c7adea736d81a1cba68ee5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=234e995bdc25bc47a6c7adea736d81a1cba68ee5
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Wed Nov 19 14:29:34 2008 +0100
wined3d: Make sure the arbfp pipeline replacement constants are loaded.
The code here skipped constant loading when a pixel shader was in use,
and only reloaded them on ffp use if the shader implementation used
ARB too. This way a e.g. texfactor change could get lost if GLSL
shaders are used, and the texfactor changed while a pixel shader was
in use.
---
dlls/wined3d/arb_program_shader.c | 65 ++++++++++++++++++++----------------
1 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 47a03ca..cb89892 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -2470,26 +2470,37 @@ static void state_texfactor_arbfp(DWORD state, IWineD3DStateBlockImpl *statebloc
float col[4];
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
- /* Do not overwrite pixel shader constants if a pshader is in use */
- if(use_ps(device)) return;
-
- D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
- GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, col));
- checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, col)");
-
+ /* Don't load the parameter if we're using an arbfp pixel shader, otherwise we'll overwrite
+ * application provided constants
+ */
if(device->shader_backend == &arb_program_shader_backend) {
+ if(use_ps(device)) return;
+
device = stateblock->wineD3DDevice;
device->activeContext->pshader_const_dirty[ARB_FFP_CONST_TFACTOR] = 1;
device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_TFACTOR + 1);
}
+
+ D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
+ GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, col));
+ checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_TFACTOR, col)");
+
}
static void state_arb_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
float col[4];
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
- /* Do not overwrite pixel shader constants if a pshader is in use */
- if(use_ps(device)) return;
+ /* Don't load the parameter if we're using an arbfp pixel shader, otherwise we'll overwrite
+ * application provided constants
+ */
+ if(device->shader_backend == &arb_program_shader_backend) {
+ if(use_ps(device)) return;
+
+ device = stateblock->wineD3DDevice;
+ device->activeContext->pshader_const_dirty[ARB_FFP_CONST_SPECULAR_ENABLE] = 1;
+ device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_SPECULAR_ENABLE + 1);
+ }
if(stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
/* The specular color has no alpha */
@@ -2501,12 +2512,6 @@ static void state_arb_specularenable(DWORD state, IWineD3DStateBlockImpl *stateb
}
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_SPECULAR_ENABLE, col));
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_SPECULAR_ENABLE, col)");
-
- if(device->shader_backend == &arb_program_shader_backend) {
- device = stateblock->wineD3DDevice;
- device->activeContext->pshader_const_dirty[ARB_FFP_CONST_SPECULAR_ENABLE] = 1;
- device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_SPECULAR_ENABLE + 1);
- }
}
static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
@@ -2524,8 +2529,14 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, W
device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context);
}
}
- /* Exit now, don't set the bumpmat below, otherwise we may overwrite pixel shader constants */
- return;
+
+ if(device->shader_backend == &arb_program_shader_backend) {
+ /* Exit now, don't set the bumpmat below, otherwise we may overwrite pixel shader constants */
+ return;
+ }
+ } else if(device->shader_backend == &arb_program_shader_backend) {
+ device->activeContext->pshader_const_dirty[ARB_FFP_CONST_BUMPMAT(stage)] = 1;
+ device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_BUMPMAT(stage) + 1);
}
mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]);
@@ -2535,11 +2546,6 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, W
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_BUMPMAT(stage), &mat[0][0]));
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_BUMPMAT(stage), &mat[0][0])");
-
- if(device->shader_backend == &arb_program_shader_backend) {
- device->activeContext->pshader_const_dirty[ARB_FFP_CONST_BUMPMAT(stage)] = 1;
- device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_BUMPMAT(stage) + 1);
- }
}
static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
@@ -2557,8 +2563,14 @@ static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock
device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context);
}
}
- /* Exit now, don't set the bumpmat below, otherwise we may overwrite pixel shader constants */
- return;
+
+ if(device->shader_backend == &arb_program_shader_backend) {
+ /* Exit now, don't set the bumpmat below, otherwise we may overwrite pixel shader constants */
+ return;
+ }
+ } else if(device->shader_backend == &arb_program_shader_backend) {
+ device->activeContext->pshader_const_dirty[ARB_FFP_CONST_LUMINANCE(stage)] = 1;
+ device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_LUMINANCE(stage) + 1);
}
param[0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVLSCALE]);
@@ -2568,11 +2580,6 @@ static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_LUMINANCE(stage), param));
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_LUMINANCE(stage), param)");
-
- if(device->shader_backend == &arb_program_shader_backend) {
- device->activeContext->pshader_const_dirty[ARB_FFP_CONST_LUMINANCE(stage)] = 1;
- device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_LUMINANCE(stage) + 1);
- }
}
static const char *get_argreg(SHADER_BUFFER *buffer, DWORD argnum, unsigned int stage, DWORD arg) {
More information about the wine-cvs
mailing list