[PATCH] WineD3D: Move the pshader fog update to the vertex =
Stefan Doesinger
stefan at codeweavers.com
Mon Aug 4 10:55:26 CDT 2008
pipeline=0A=
=0A=
I hope we can get rid of the different fog start/end setup for pixel =
shaders somewhen. For ARB this=0A=
would be easy, I am still looking at GLSL=0A=
---=0A=
dlls/wined3d/arb_program_shader.c | 1 -=0A=
dlls/wined3d/state.c | 27 ++++++++++++++++++---------=0A=
2 files changed, 18 insertions(+), 10 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/arb_program_shader.c =
b/dlls/wined3d/arb_program_shader.c=0A=
index 4e1fe09..dbb7f3f 100644=0A=
--- a/dlls/wined3d/arb_program_shader.c=0A=
+++ b/dlls/wined3d/arb_program_shader.c=0A=
@@ -2816,7 +2816,6 @@ static void fragment_prog_arbfp(DWORD state, =
IWineD3DStateBlockImpl *stateblock,=0A=
=
device->StateTable[STATE_VERTEXSHADERCONSTANT].apply(STATE_VERTEXSHADERCO=
NSTANT, stateblock, context);=0A=
}=0A=
}=0A=
- context->last_was_pshader =3D use_pshader;=0A=
if(use_pshader) {=0A=
=
device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONS=
TANT, stateblock, context);=0A=
}=0A=
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c=0A=
index a6903c6..dd81378 100644=0A=
--- a/dlls/wined3d/state.c=0A=
+++ b/dlls/wined3d/state.c=0A=
@@ -3562,11 +3562,26 @@ static void sampler(DWORD state, =
IWineD3DStateBlockImpl *stateblock, WineD3DCont=0A=
}=0A=
}=0A=
=0A=
+void apply_pshader_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, =
WineD3DContext *context) {=0A=
+ IWineD3DDeviceImpl *device =3D stateblock->wineD3DDevice;=0A=
+=0A=
+ if (use_ps(device)) {=0A=
+ if(!context->last_was_pshader) {=0A=
+ state_fog(state, stateblock, context);=0A=
+ }=0A=
+ context->last_was_pshader =3D TRUE;=0A=
+ } else {=0A=
+ if(context->last_was_pshader) {=0A=
+ state_fog(state, stateblock, context);=0A=
+ }=0A=
+ context->last_was_pshader =3D FALSE;=0A=
+ }=0A=
+}=0A=
+=0A=
void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, =
WineD3DContext *context) {=0A=
IWineD3DDeviceImpl *device =3D stateblock->wineD3DDevice;=0A=
BOOL use_pshader =3D use_ps(device);=0A=
BOOL use_vshader =3D use_vs(device);=0A=
- BOOL update_fog =3D FALSE;=0A=
int i;=0A=
=0A=
if (use_pshader) {=0A=
@@ -3580,7 +3595,6 @@ void apply_pixelshader(DWORD state, =
IWineD3DStateBlockImpl *stateblock, WineD3DC=0A=
sampler(STATE_SAMPLER(i), stateblock, context);=0A=
}=0A=
}=0A=
- update_fog =3D TRUE;=0A=
} else {=0A=
/* Otherwise all samplers were activated by the code above =
in earlier draws, or by sampler()=0A=
* if a different texture was bound. I don't have to do =
anything.=0A=
@@ -3599,8 +3613,6 @@ void apply_pixelshader(DWORD state, =
IWineD3DStateBlockImpl *stateblock, WineD3DC=0A=
(STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), =
stateblock, context);=0A=
}=0A=
}=0A=
- if(context->last_was_pshader)=0A=
- update_fog =3D TRUE;=0A=
}=0A=
=0A=
if(!isStateDirty(context, =
device->StateTable[STATE_VSHADER].representative)) {=0A=
@@ -3610,11 +3622,6 @@ void apply_pixelshader(DWORD state, =
IWineD3DStateBlockImpl *stateblock, WineD3DC=0A=
shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, =
context);=0A=
}=0A=
}=0A=
-=0A=
- if(update_fog)=0A=
- state_fog(state, stateblock, context);=0A=
-=0A=
- context->last_was_pshader =3D use_pshader;=0A=
}=0A=
=0A=
static void shader_bumpenvmat(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
@@ -5406,6 +5413,8 @@ const struct StateEntryTemplate =
ffp_vertexstate_template[] =3D {=0A=
{ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), { =
STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax_arb =
}, ARB_POINT_PARAMETERS },=0A=
{ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), { =
STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax_ext =
}, EXT_POINT_PARAMETERS },=0A=
{ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), { =
STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax_w =
}, 0 },=0A=
+ /* pixel shaders need a different fog input */=0A=
+ { STATE_PIXELSHADER, { =
STATE_PIXELSHADER, apply_pshader_fog =
}, 0 },=0A=
/* Samplers for NP2 texture matrix adjustions. They are not needed =
if GL_ARB_texture_non_power_of_two is supported,=0A=
* so register a NULL state handler in that case to get the vertex =
part of sampler() skipped(VTF is handled in the misc states.=0A=
* otherwise, register sampler_texmatrix, which takes care of =
updating the texture matrix=0A=
-- =0A=
1.5.4.5=0A=
=0A=
------=_NextPart_000_0035_01C8F640.99F88500--
More information about the wine-patches
mailing list