From 03c472bff09e702689c1d97a32bb832013dee8de Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 1 Apr 2010 11:34:44 +0200 Subject: [PATCH] wined3d: Don't call directly into the state table. --- dlls/wined3d/arb_program_shader.c | 19 +++++++------------ dlls/wined3d/ati_fragment_shader.c | 5 ++--- dlls/wined3d/state.c | 21 ++++++--------------- dlls/wined3d/wined3d_private.h | 8 ++++++++ 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 8e613c96e0d..3c678775388 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -5377,9 +5377,8 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, s /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled * anyway */ - if(!isStateDirty(context, STATE_PIXELSHADERCONSTANT)) { - device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context); - } + if (!isStateDirty(context, STATE_PIXELSHADERCONSTANT)) + stateblock_apply_state(STATE_PIXELSHADERCONSTANT, stateblock, context); } if(device->shader_backend == &arb_program_shader_backend) { @@ -5414,9 +5413,8 @@ static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock /* The pixel shader has to know the luminance offset. Do a constants update if it * isn't scheduled anyway */ - if(!isStateDirty(context, STATE_PIXELSHADERCONSTANT)) { - device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context); - } + if (!isStateDirty(context, STATE_PIXELSHADERCONSTANT)) + stateblock_apply_state(STATE_PIXELSHADERCONSTANT, stateblock, context); } if(device->shader_backend == &arb_program_shader_backend) { @@ -6007,13 +6005,10 @@ static void fragment_prog_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, if(!isStateDirty(context, device->StateTable[STATE_VSHADER].representative)) { device->shader_backend->shader_select(context, use_pshader, use_vshader); - if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && (use_vshader || use_pshader)) { - device->StateTable[STATE_VERTEXSHADERCONSTANT].apply(STATE_VERTEXSHADERCONSTANT, stateblock, context); - } - } - if(use_pshader) { - device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context); + if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && (use_vshader || use_pshader)) + stateblock_apply_state(STATE_VERTEXSHADERCONSTANT, stateblock, context); } + if (use_pshader) stateblock_apply_state(STATE_PIXELSHADERCONSTANT, stateblock, context); } /* We can't link the fog states to the fragment state directly since the vertex pipeline links them diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index 0f911e9dc15..c81dffcbbd6 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -907,9 +907,8 @@ static void atifs_apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *statebl if(!isStateDirty(context, device->StateTable[STATE_VSHADER].representative)) { device->shader_backend->shader_select(context, FALSE, use_vshader); - if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && use_vshader) { - device->StateTable[STATE_VERTEXSHADERCONSTANT].apply(STATE_VERTEXSHADERCONSTANT, stateblock, context); - } + if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && use_vshader) + stateblock_apply_state(STATE_VERTEXSHADERCONSTANT, stateblock, context); } } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index f7e6f13264f..04de86fd537 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -450,10 +450,7 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct /* colorkey fixup for stage 0 alphaop depends on WINED3DRS_ALPHABLENDENABLE state, so it may need updating */ if (stateblock->renderState[WINED3DRS_COLORKEYENABLE]) - { - const struct StateEntry *StateTable = stateblock->device->StateTable; - StateTable[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context); - } + stateblock_apply_state(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context); } static void state_blendfactor_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) @@ -506,10 +503,7 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct } if (enable_ckey || context->last_was_ckey) - { - const struct StateEntry *StateTable = stateblock->device->StateTable; - StateTable[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context); - } + stateblock_apply_state(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context); context->last_was_ckey = enable_ckey; if (stateblock->renderState[WINED3DRS_ALPHATESTENABLE] || @@ -3633,10 +3627,8 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w * while it was enabled, so re-apply them. */ for (i = 0; i < context->gl_info->limits.texture_stages; ++i) { - if(!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) { - device->StateTable[STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP)].apply - (STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context); - } + if (!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) + stateblock_apply_state(STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context); } context->last_was_pshader = FALSE; } @@ -4648,9 +4640,8 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, s context->last_was_vshader = useVertexShaderFunction; - if(updateFog) { - device->StateTable[STATE_RENDER(WINED3DRS_FOGVERTEXMODE)].apply(STATE_RENDER(WINED3DRS_FOGVERTEXMODE), stateblock, context); - } + if (updateFog) stateblock_apply_state(STATE_RENDER(WINED3DRS_FOGVERTEXMODE), stateblock, context); + if(!useVertexShaderFunction) { int i; for(i = 0; i < MAX_TEXTURES; i++) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index a812114344e..097232e34ca 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2432,6 +2432,14 @@ HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *device, WINED3DSTATEBLOCKTYPE type) DECLSPEC_HIDDEN; void stateblock_init_contained_states(IWineD3DStateBlockImpl *object) DECLSPEC_HIDDEN; +static inline void stateblock_apply_state(DWORD state, IWineD3DStateBlockImpl *stateblock, + struct wined3d_context *context) +{ + const struct StateEntry *statetable = stateblock->device->StateTable; + DWORD rep = statetable[state].representative; + statetable[rep].apply(rep, stateblock, context); +} + /* Direct3D terminology with little modifications. We do not have an issued state * because only the driver knows about it, but we have a created state because d3d * allows GetData on a created issue, but opengl doesn't -- 2.11.4.GIT