[PATCH] WineD3D: Don't load INT and BOOL constants needlessly=0A=
Stefan Doesinger
stefan at codeweavers.com
Thu Nov 27 01:21:36 CST 2008
=0A=
Should give a small performance boost. The constants weren't=0A=
actually loaded before either, but they were rejected on a=0A=
per-constant basis. Most shaders don't use any of those=0A=
constants, so we can skip checking the constants=0A=
---=0A=
dlls/wined3d/baseshader.c | 8 ++++++++=0A=
dlls/wined3d/glsl_shader.c | 24 ++++++++++++++++--------=0A=
dlls/wined3d/wined3d_private.h | 1 +=0A=
3 files changed, 25 insertions(+), 8 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c=0A=
index c9f9124..92f0d8a 100644=0A=
--- a/dlls/wined3d/baseshader.c=0A=
+++ b/dlls/wined3d/baseshader.c=0A=
@@ -327,6 +327,8 @@ HRESULT shader_get_registers_used(=0A=
max_loop_depth =3D cur_loop_depth;=0A=
pToken +=3D curOpcode->num_params;=0A=
=0A=
+ /* Rep and Loop always use an integer constant for the =
control parameters */=0A=
+ This->baseShader.uses_int_consts =3D TRUE;=0A=
} else if (WINED3DSIO_ENDLOOP =3D=3D curOpcode->opcode ||=0A=
WINED3DSIO_ENDREP =3D=3D curOpcode->opcode) {=0A=
cur_loop_depth--;=0A=
@@ -472,6 +474,12 @@ HRESULT shader_get_registers_used(=0A=
reg_maps->usesrelconstF =3D TRUE;=0A=
}=0A=
}=0A=
+ else if(WINED3DSPR_CONSTINT =3D=3D regtype) {=0A=
+ This->baseShader.uses_int_consts =3D TRUE;=0A=
+ }=0A=
+ else if(WINED3DSPR_CONSTBOOL =3D=3D regtype) {=0A=
+ This->baseShader.uses_bool_consts =3D TRUE;=0A=
+ }=0A=
=0A=
/* WINED3DSPR_TEXCRDOUT is the same as =
WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and is used=0A=
* in >=3D 3.0 shaders. Filter 3.0 shaders to prevent =
overflows, and also filter pixel shaders because TECRDOUT=0A=
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c=0A=
index 7e9353c..424f7bc 100644=0A=
--- a/dlls/wined3d/glsl_shader.c=0A=
+++ b/dlls/wined3d/glsl_shader.c=0A=
@@ -416,12 +416,16 @@ static void shader_glsl_load_constants(=0A=
stateBlock->vertexShaderConstantF, constant_locations, =
constant_list);=0A=
=0A=
/* Load DirectX 9 integer constants/uniforms for vertex shader =
*/=0A=
- shader_glsl_load_constantsI(vshader, gl_info, =
prog->vuniformI_locations,=0A=
- stateBlock->vertexShaderConstantI, =
stateBlock->changed.vertexShaderConstantsI);=0A=
+ if(vshader->baseShader.uses_int_consts) {=0A=
+ shader_glsl_load_constantsI(vshader, gl_info, =
prog->vuniformI_locations,=0A=
+ stateBlock->vertexShaderConstantI, =
stateBlock->changed.vertexShaderConstantsI);=0A=
+ }=0A=
=0A=
/* Load DirectX 9 boolean constants/uniforms for vertex shader =
*/=0A=
- shader_glsl_load_constantsB(vshader, gl_info, programId,=0A=
- stateBlock->vertexShaderConstantB, =
stateBlock->changed.vertexShaderConstantsB);=0A=
+ if(vshader->baseShader.uses_bool_consts) {=0A=
+ shader_glsl_load_constantsB(vshader, gl_info, programId,=0A=
+ stateBlock->vertexShaderConstantB, =
stateBlock->changed.vertexShaderConstantsB);=0A=
+ }=0A=
=0A=
/* Upload the position fixup params */=0A=
GL_EXTCALL(glUniform4fvARB(prog->posFixup_location, 1, =
&deviceImpl->posFixup[0]));=0A=
@@ -440,12 +444,16 @@ static void shader_glsl_load_constants(=0A=
stateBlock->pixelShaderConstantF, constant_locations, =
constant_list);=0A=
=0A=
/* Load DirectX 9 integer constants/uniforms for pixel shader */=0A=
- shader_glsl_load_constantsI(pshader, gl_info, =
prog->puniformI_locations,=0A=
- stateBlock->pixelShaderConstantI, =
stateBlock->changed.pixelShaderConstantsI);=0A=
+ if(pshader->baseShader.uses_int_consts) {=0A=
+ shader_glsl_load_constantsI(pshader, gl_info, =
prog->puniformI_locations,=0A=
+ stateBlock->pixelShaderConstantI, =
stateBlock->changed.pixelShaderConstantsI);=0A=
+ }=0A=
=0A=
/* Load DirectX 9 boolean constants/uniforms for pixel shader */=0A=
- shader_glsl_load_constantsB(pshader, gl_info, programId,=0A=
- stateBlock->pixelShaderConstantB, =
stateBlock->changed.pixelShaderConstantsB);=0A=
+ if(pshader->baseShader.uses_bool_consts) {=0A=
+ shader_glsl_load_constantsB(pshader, gl_info, programId,=0A=
+ stateBlock->pixelShaderConstantB, =
stateBlock->changed.pixelShaderConstantsB);=0A=
+ }=0A=
=0A=
/* Upload the environment bump map matrix if needed. The =
needsbumpmat member specifies the texture stage to load the matrix from.=0A=
* It can't be 0 for a valid texbem instruction.=0A=
diff --git a/dlls/wined3d/wined3d_private.h =
b/dlls/wined3d/wined3d_private.h=0A=
index 2a6a064..9c74fbe 100644=0A=
--- a/dlls/wined3d/wined3d_private.h=0A=
+++ b/dlls/wined3d/wined3d_private.h=0A=
@@ -2119,6 +2119,7 @@ typedef struct IWineD3DBaseShaderClass=0A=
BOOL is_compiled;=0A=
UINT cur_loop_depth, cur_loop_regno;=0A=
BOOL load_local_constsF;=0A=
+ BOOL uses_bool_consts, uses_int_consts;=0A=
=0A=
/* Type of shader backend */=0A=
int shader_mode;=0A=
-- =0A=
1.5.6.4=0A=
=0A=
------=_NextPart_000_000C_01C958CA.519DBD60--
More information about the wine-patches
mailing list