[PATCH 3/5] wined3d: Move lowest_disabled_stage to the context.

Henri Verbeet hverbeet at codeweavers.com
Sun Oct 6 10:33:06 CDT 2013


---
 dlls/wined3d/arb_program_shader.c    |    8 ++----
 dlls/wined3d/context.c               |   21 ++++++++++++--
 dlls/wined3d/device.c                |   50 ----------------------------------
 dlls/wined3d/nvidia_texture_shader.c |    8 +++---
 dlls/wined3d/state.c                 |    6 ++--
 dlls/wined3d/stateblock.c            |    2 --
 dlls/wined3d/utils.c                 |    2 +-
 dlls/wined3d/wined3d_private.h       |    4 +--
 8 files changed, 32 insertions(+), 69 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index e1d2faa..11bc35a 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -144,9 +144,9 @@ static const char *arb_get_helper_value(enum wined3d_shader_type shader, enum ar
     }
 }
 
-static inline BOOL ffp_clip_emul(const struct wined3d_state *state)
+static inline BOOL ffp_clip_emul(const struct wined3d_context *context)
 {
-    return state->lowest_disabled_stage < 7;
+    return context->lowest_disabled_stage < 7;
 }
 
 /* ARB_program_shader private data */
@@ -4596,9 +4596,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
     {
         args->ps_signature = ~0;
         if (!d3d_info->vs_clipping && adapter->fragment_pipe == &arbfp_fragment_pipeline)
-        {
-            args->clip.boolclip.clip_texcoord = ffp_clip_emul(state) ? d3d_info->limits.ffp_blend_stages : 0;
-        }
+            args->clip.boolclip.clip_texcoord = ffp_clip_emul(context) ? d3d_info->limits.ffp_blend_stages : 0;
         /* Otherwise: Setting boolclip_compare set clip_texcoord to 0 */
     }
 
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 4f8021c..b1f2f8a 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2368,7 +2368,7 @@ static void context_invalidate_texture_stage(struct wined3d_context *context, DW
 static void context_update_fixed_function_usage_map(struct wined3d_context *context,
         const struct wined3d_state *state)
 {
-    UINT i;
+    UINT i, start, end;
 
     context->fixed_function_usage_map = 0;
     for (i = 0; i < MAX_TEXTURES; ++i)
@@ -2400,6 +2400,23 @@ static void context_update_fixed_function_usage_map(struct wined3d_context *cont
                 && i < MAX_TEXTURES - 1)
             context->fixed_function_usage_map |= (1 << (i + 1));
     }
+
+    if (i < context->lowest_disabled_stage)
+    {
+        start = i;
+        end = context->lowest_disabled_stage;
+    }
+    else
+    {
+        start = context->lowest_disabled_stage;
+        end = i;
+    }
+
+    context->lowest_disabled_stage = i;
+    for (i = start + 1; i < end; ++i)
+    {
+        context_invalidate_state(context, STATE_TEXTURESTAGE(i, WINED3D_TSS_COLOR_OP));
+    }
 }
 
 static void context_map_fixed_function_samplers(struct wined3d_context *context,
@@ -2413,7 +2430,7 @@ static void context_map_fixed_function_samplers(struct wined3d_context *context,
     ffu_map = context->fixed_function_usage_map;
 
     if (d3d_info->limits.ffp_textures == d3d_info->limits.ffp_blend_stages
-            || state->lowest_disabled_stage <= d3d_info->limits.ffp_textures)
+            || context->lowest_disabled_stage <= d3d_info->limits.ffp_textures)
     {
         for (i = 0; ffu_map; ffu_map >>= 1, ++i)
         {
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 705ffb3..9b050cd 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3074,56 +3074,6 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
         return;
     }
 
-    if (stage > device->state.lowest_disabled_stage
-            && device->StateTable[STATE_TEXTURESTAGE(0, state)].representative
-            == STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP))
-    {
-        /* Colorop change above lowest disabled stage? That won't change
-         * anything in the GL setup. Changes in other states are important on
-         * disabled stages too. */
-        return;
-    }
-
-    if (state == WINED3D_TSS_COLOR_OP)
-    {
-        unsigned int i;
-
-        if (value == WINED3D_TOP_DISABLE && old_value != WINED3D_TOP_DISABLE)
-        {
-            /* Previously enabled stage disabled now. Make sure to dirtify
-             * all enabled stages above stage, they have to be disabled.
-             *
-             * The current stage is dirtified below. */
-            for (i = stage + 1; i < device->state.lowest_disabled_stage; ++i)
-            {
-                TRACE("Additionally dirtifying stage %u.\n", i);
-                device_invalidate_state(device, STATE_TEXTURESTAGE(i, WINED3D_TSS_COLOR_OP));
-            }
-            device->state.lowest_disabled_stage = stage;
-            TRACE("New lowest disabled: %u.\n", stage);
-        }
-        else if (value != WINED3D_TOP_DISABLE && old_value == WINED3D_TOP_DISABLE)
-        {
-            /* Previously disabled stage enabled. Stages above it may need
-             * enabling. Stage must be lowest_disabled_stage here, if it's
-             * bigger success is returned above, and stages below the lowest
-             * disabled stage can't be enabled (because they are enabled
-             * already).
-             *
-             * Again stage stage doesn't need to be dirtified here, it is
-             * handled below. */
-            for (i = stage + 1; i < d3d_info->limits.ffp_blend_stages; ++i)
-            {
-                if (device->update_state->texture_states[i][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_DISABLE)
-                    break;
-                TRACE("Additionally dirtifying stage %u due to enable.\n", i);
-                device_invalidate_state(device, STATE_TEXTURESTAGE(i, WINED3D_TSS_COLOR_OP));
-            }
-            device->state.lowest_disabled_stage = i;
-            TRACE("New lowest disabled: %u.\n", i);
-        }
-    }
-
     device_invalidate_state(device, STATE_TEXTURESTAGE(stage, state));
 }
 
diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c
index 285952a..58af33e 100644
--- a/dlls/wined3d/nvidia_texture_shader.c
+++ b/dlls/wined3d/nvidia_texture_shader.c
@@ -498,16 +498,16 @@ static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_s
         context_active_texture(context, gl_info, mapped_stage);
     }
 
-    if (state->lowest_disabled_stage > 0)
+    if (context->lowest_disabled_stage > 0)
     {
         gl_info->gl_ops.gl.p_glEnable(GL_REGISTER_COMBINERS_NV);
-        GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, state->lowest_disabled_stage));
+        GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, context->lowest_disabled_stage));
     }
     else
     {
         gl_info->gl_ops.gl.p_glDisable(GL_REGISTER_COMBINERS_NV);
     }
-    if (stage >= state->lowest_disabled_stage)
+    if (stage >= context->lowest_disabled_stage)
     {
         TRACE("Stage disabled\n");
         if (mapped_stage != WINED3D_UNMAPPED_STAGE)
@@ -590,7 +590,7 @@ static void nvts_texdim(struct wined3d_context *context, const struct wined3d_st
     * will take care of this business. */
     if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures)
         return;
-    if (sampler >= state->lowest_disabled_stage)
+    if (sampler >= context->lowest_disabled_stage)
         return;
     if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP)))
         return;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 8ffd3e2..159fe86 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3151,7 +3151,7 @@ static void tex_colorop(struct wined3d_context *context, const struct wined3d_st
         context_active_texture(context, gl_info, mapped_stage);
     }
 
-    if (stage >= state->lowest_disabled_stage)
+    if (stage >= context->lowest_disabled_stage)
     {
         TRACE("Stage disabled\n");
         if (mapped_stage != WINED3D_UNMAPPED_STAGE)
@@ -3655,7 +3655,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
             checkGLcall("glTexEnvf(GL_TEXTURE_LOD_BIAS_EXT, ...)");
         }
 
-        if (!use_ps(state) && sampler < state->lowest_disabled_stage)
+        if (!use_ps(state) && sampler < context->lowest_disabled_stage)
         {
             if (state->render_states[WINED3D_RS_COLORKEYENABLE] && !sampler)
             {
@@ -3671,7 +3671,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
     }
     else
     {
-        if (sampler < state->lowest_disabled_stage)
+        if (sampler < context->lowest_disabled_stage)
         {
             /* TODO: What should I do with pixel shaders here ??? */
             if (state->render_states[WINED3D_RS_COLORKEYENABLE] && !sampler)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 2a1cb12..b086d61 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1318,9 +1318,7 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
         state->texture_states[i][WINED3D_TSS_ALPHA_ARG0] = WINED3DTA_CURRENT;
         state->texture_states[i][WINED3D_TSS_RESULT_ARG] = WINED3DTA_CURRENT;
     }
-    state->lowest_disabled_stage = 1;
 
-        /* Sampler states*/
     for (i = 0 ; i <  MAX_COMBINED_SAMPLERS; ++i)
     {
         TRACE("Setting up default samplers states for sampler %u.\n", i);
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index ccb3da6..cefdf9b 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3569,7 +3569,7 @@ void sampler_texdim(struct wined3d_context *context, const struct wined3d_state
      * shaders, or if tex_colorop will take care of this business. */
     if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures)
         return;
-    if (sampler >= state->lowest_disabled_stage)
+    if (sampler >= context->lowest_disabled_stage)
         return;
     if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP)))
         return;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 328d864..b31908d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1087,7 +1087,8 @@ struct wined3d_context
     DWORD texShaderBumpMap : 8;         /* MAX_TEXTURES, 8 */
     DWORD lastWasPow2Texture : 8;       /* MAX_TEXTURES, 8 */
     DWORD fixed_function_usage_map : 8; /* MAX_TEXTURES, 8 */
-    DWORD padding : 24;
+    DWORD lowest_disabled_stage : 4;    /* Max MAX_TEXTURES, 8 */
+    DWORD padding : 20;
     DWORD shader_update_mask;
     DWORD constant_update_mask;
     DWORD                   numbered_array_mask;
@@ -1842,7 +1843,6 @@ struct wined3d_state
     struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS];
     DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
     DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
-    DWORD lowest_disabled_stage;
 
     struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
     struct wined3d_vec4 clip_planes[MAX_CLIPPLANES];
-- 
1.7.10.4




More information about the wine-patches mailing list