diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index 6fc0aa40c00..a41f6862e8a 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -958,6 +958,14 @@ static const struct StateEntryTemplate atifs_fragmentstate_template[] = { {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }}, {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }}, {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), set_bumpmat }}, + { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }}, + { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }}, + { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }}, + { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }}, + { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }}, + { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }}, + { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }}, + { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }}, {0 /* Terminate */, { 0, 0 }}, }; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index b96f80f49e0..d1d64fe042b 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -2430,10 +2430,6 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont glEnable(stateblock->textureDimensions[sampler]); checkGLcall("glEnable(stateblock->textureDimensions[sampler])"); } else if(sampler < stateblock->lowest_disabled_stage) { - if(!isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) { - texture_activate_dimensions(sampler, stateblock, context); - } - if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) { /* If color keying is enabled update the alpha test, it depends on the existence * of a color key in stage 0 @@ -2444,10 +2440,6 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont } else if(mapped_stage < GL_LIMITS(textures)) { if(sampler < stateblock->lowest_disabled_stage) { /* TODO: What should I do with pixel shaders here ??? */ - if(!isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) { - texture_activate_dimensions(sampler, stateblock, context); - } - if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) { /* If color keying is enabled update the alpha test, it depends on the existence * of a color key in stage 0 @@ -4460,6 +4452,14 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = { { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), { STATE_PIXELSHADER, pixelshader }}, { STATE_RENDER(WINED3DRS_BORDERCOLOR), { STATE_RENDER(WINED3DRS_BORDERCOLOR), state_bordercolor }}, { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor }}, + { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }}, + { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }}, + { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }}, + { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }}, + { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }}, + { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }}, + { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }}, + { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }}, {0 /* Terminate */, { 0, 0 }}, }; #undef GLINFO_LOCATION diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 5a0271740ff..71833d51549 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -3498,4 +3498,20 @@ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock } } } + +void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { + DWORD sampler = state - STATE_SAMPLER(0); + DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler]; + + /* No need to enable / disable anything here for unused samplers. The tex_colorop + * handler takes care. Also no action is needed with pixel shaders, or if tex_colorop + * will take care of this business + */ + if(mapped_stage == -1 || mapped_stage >= GL_LIMITS(textures)) return; + if(sampler >= stateblock->lowest_disabled_stage) return; + if(use_ps(stateblock->wineD3DDevice)) return; + if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return; + + texture_activate_dimensions(sampler, stateblock, context); +} #undef GLINFO_LOCATION diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d5352eac31d..5c067edbda7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1733,6 +1733,7 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTURE void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst); void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, BOOL transformed, DWORD coordtype); void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context); +void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context); void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int width, unsigned int height); GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain);