From 4916cd5478ff6fcf212eae3707bc5be063498040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Thu, 27 Nov 2008 01:21:36 +0100 Subject: [PATCH] wined3d: Don't load INT and BOOL constants needlessly. --- dlls/wined3d/baseshader.c | 8 ++++++++ dlls/wined3d/glsl_shader.c | 24 ++++++++++++++++-------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c index 65dcf2a8fe6..8d6c28ce8ec 100644 --- a/dlls/wined3d/baseshader.c +++ b/dlls/wined3d/baseshader.c @@ -349,6 +349,8 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m max_loop_depth = cur_loop_depth; pToken += curOpcode->num_params; + /* Rep and Loop always use an integer constant for the control parameters */ + This->baseShader.uses_int_consts = TRUE; } else if (WINED3DSIO_ENDLOOP == curOpcode->opcode || WINED3DSIO_ENDREP == curOpcode->opcode) { cur_loop_depth--; @@ -494,6 +496,12 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m reg_maps->usesrelconstF = TRUE; } } + else if(WINED3DSPR_CONSTINT == regtype) { + This->baseShader.uses_int_consts = TRUE; + } + else if(WINED3DSPR_CONSTBOOL == regtype) { + This->baseShader.uses_bool_consts = TRUE; + } /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and is used * in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel shaders because TECRDOUT diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 6ec2591be46..3f54170033e 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -418,12 +418,16 @@ static void shader_glsl_load_constants( stateBlock->vertexShaderConstantF, constant_locations, constant_list); /* Load DirectX 9 integer constants/uniforms for vertex shader */ - shader_glsl_load_constantsI(vshader, gl_info, prog->vuniformI_locations, - stateBlock->vertexShaderConstantI, stateBlock->changed.vertexShaderConstantsI); + if(vshader->baseShader.uses_int_consts) { + shader_glsl_load_constantsI(vshader, gl_info, prog->vuniformI_locations, + stateBlock->vertexShaderConstantI, stateBlock->changed.vertexShaderConstantsI); + } /* Load DirectX 9 boolean constants/uniforms for vertex shader */ - shader_glsl_load_constantsB(vshader, gl_info, programId, - stateBlock->vertexShaderConstantB, stateBlock->changed.vertexShaderConstantsB); + if(vshader->baseShader.uses_bool_consts) { + shader_glsl_load_constantsB(vshader, gl_info, programId, + stateBlock->vertexShaderConstantB, stateBlock->changed.vertexShaderConstantsB); + } /* Upload the position fixup params */ GL_EXTCALL(glUniform4fvARB(prog->posFixup_location, 1, &deviceImpl->posFixup[0])); @@ -442,12 +446,16 @@ static void shader_glsl_load_constants( stateBlock->pixelShaderConstantF, constant_locations, constant_list); /* Load DirectX 9 integer constants/uniforms for pixel shader */ - shader_glsl_load_constantsI(pshader, gl_info, prog->puniformI_locations, - stateBlock->pixelShaderConstantI, stateBlock->changed.pixelShaderConstantsI); + if(pshader->baseShader.uses_int_consts) { + shader_glsl_load_constantsI(pshader, gl_info, prog->puniformI_locations, + stateBlock->pixelShaderConstantI, stateBlock->changed.pixelShaderConstantsI); + } /* Load DirectX 9 boolean constants/uniforms for pixel shader */ - shader_glsl_load_constantsB(pshader, gl_info, programId, - stateBlock->pixelShaderConstantB, stateBlock->changed.pixelShaderConstantsB); + if(pshader->baseShader.uses_bool_consts) { + shader_glsl_load_constantsB(pshader, gl_info, programId, + stateBlock->pixelShaderConstantB, stateBlock->changed.pixelShaderConstantsB); + } /* Upload the environment bump map matrix if needed. The needsbumpmat member specifies the texture stage to load the matrix from. * It can't be 0 for a valid texbem instruction. diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5ac771fa7b7..b10b6440c2e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2194,6 +2194,7 @@ typedef struct IWineD3DBaseShaderClass BOOL is_compiled; UINT cur_loop_depth, cur_loop_regno; BOOL load_local_constsF; + BOOL uses_bool_consts, uses_int_consts; /* Type of shader backend */ int shader_mode;