Commit 8644b627 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Move lowest_disabled_stage to the context.

parent 242a79a9
...@@ -144,9 +144,9 @@ static const char *arb_get_helper_value(enum wined3d_shader_type shader, enum ar ...@@ -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 */ /* ARB_program_shader private data */
...@@ -4596,9 +4596,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state, ...@@ -4596,9 +4596,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
{ {
args->ps_signature = ~0; args->ps_signature = ~0;
if (!d3d_info->vs_clipping && adapter->fragment_pipe == &arbfp_fragment_pipeline) if (!d3d_info->vs_clipping && adapter->fragment_pipe == &arbfp_fragment_pipeline)
{ args->clip.boolclip.clip_texcoord = ffp_clip_emul(context) ? d3d_info->limits.ffp_blend_stages : 0;
args->clip.boolclip.clip_texcoord = ffp_clip_emul(state) ? d3d_info->limits.ffp_blend_stages : 0;
}
/* Otherwise: Setting boolclip_compare set clip_texcoord to 0 */ /* Otherwise: Setting boolclip_compare set clip_texcoord to 0 */
} }
......
...@@ -2368,7 +2368,7 @@ static void context_invalidate_texture_stage(struct wined3d_context *context, DW ...@@ -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, static void context_update_fixed_function_usage_map(struct wined3d_context *context,
const struct wined3d_state *state) const struct wined3d_state *state)
{ {
UINT i; UINT i, start, end;
context->fixed_function_usage_map = 0; context->fixed_function_usage_map = 0;
for (i = 0; i < MAX_TEXTURES; ++i) for (i = 0; i < MAX_TEXTURES; ++i)
...@@ -2400,6 +2400,23 @@ static void context_update_fixed_function_usage_map(struct wined3d_context *cont ...@@ -2400,6 +2400,23 @@ static void context_update_fixed_function_usage_map(struct wined3d_context *cont
&& i < MAX_TEXTURES - 1) && i < MAX_TEXTURES - 1)
context->fixed_function_usage_map |= (1 << (i + 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, 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, ...@@ -2413,7 +2430,7 @@ static void context_map_fixed_function_samplers(struct wined3d_context *context,
ffu_map = context->fixed_function_usage_map; ffu_map = context->fixed_function_usage_map;
if (d3d_info->limits.ffp_textures == d3d_info->limits.ffp_blend_stages 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) for (i = 0; ffu_map; ffu_map >>= 1, ++i)
{ {
......
...@@ -3074,56 +3074,6 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device, ...@@ -3074,56 +3074,6 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
return; 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)); device_invalidate_state(device, STATE_TEXTURESTAGE(stage, state));
} }
......
...@@ -498,16 +498,16 @@ static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_s ...@@ -498,16 +498,16 @@ static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_s
context_active_texture(context, gl_info, mapped_stage); 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_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 else
{ {
gl_info->gl_ops.gl.p_glDisable(GL_REGISTER_COMBINERS_NV); 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"); TRACE("Stage disabled\n");
if (mapped_stage != WINED3D_UNMAPPED_STAGE) if (mapped_stage != WINED3D_UNMAPPED_STAGE)
...@@ -590,7 +590,7 @@ static void nvts_texdim(struct wined3d_context *context, const struct wined3d_st ...@@ -590,7 +590,7 @@ static void nvts_texdim(struct wined3d_context *context, const struct wined3d_st
* will take care of this business. */ * will take care of this business. */
if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures) if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures)
return; return;
if (sampler >= state->lowest_disabled_stage) if (sampler >= context->lowest_disabled_stage)
return; return;
if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP))) if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP)))
return; return;
......
...@@ -3151,7 +3151,7 @@ static void tex_colorop(struct wined3d_context *context, const struct wined3d_st ...@@ -3151,7 +3151,7 @@ static void tex_colorop(struct wined3d_context *context, const struct wined3d_st
context_active_texture(context, gl_info, mapped_stage); context_active_texture(context, gl_info, mapped_stage);
} }
if (stage >= state->lowest_disabled_stage) if (stage >= context->lowest_disabled_stage)
{ {
TRACE("Stage disabled\n"); TRACE("Stage disabled\n");
if (mapped_stage != WINED3D_UNMAPPED_STAGE) if (mapped_stage != WINED3D_UNMAPPED_STAGE)
...@@ -3655,7 +3655,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state ...@@ -3655,7 +3655,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
checkGLcall("glTexEnvf(GL_TEXTURE_LOD_BIAS_EXT, ...)"); 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) if (state->render_states[WINED3D_RS_COLORKEYENABLE] && !sampler)
{ {
...@@ -3671,7 +3671,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state ...@@ -3671,7 +3671,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
} }
else else
{ {
if (sampler < state->lowest_disabled_stage) if (sampler < context->lowest_disabled_stage)
{ {
/* TODO: What should I do with pixel shaders here ??? */ /* TODO: What should I do with pixel shaders here ??? */
if (state->render_states[WINED3D_RS_COLORKEYENABLE] && !sampler) if (state->render_states[WINED3D_RS_COLORKEYENABLE] && !sampler)
......
...@@ -1318,9 +1318,7 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d ...@@ -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_ALPHA_ARG0] = WINED3DTA_CURRENT;
state->texture_states[i][WINED3D_TSS_RESULT_ARG] = 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) for (i = 0 ; i < MAX_COMBINED_SAMPLERS; ++i)
{ {
TRACE("Setting up default samplers states for sampler %u.\n", i); TRACE("Setting up default samplers states for sampler %u.\n", i);
......
...@@ -3569,7 +3569,7 @@ void sampler_texdim(struct wined3d_context *context, const struct wined3d_state ...@@ -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. */ * shaders, or if tex_colorop will take care of this business. */
if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures) if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures)
return; return;
if (sampler >= state->lowest_disabled_stage) if (sampler >= context->lowest_disabled_stage)
return; return;
if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP))) if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP)))
return; return;
......
...@@ -1087,7 +1087,8 @@ struct wined3d_context ...@@ -1087,7 +1087,8 @@ struct wined3d_context
DWORD texShaderBumpMap : 8; /* MAX_TEXTURES, 8 */ DWORD texShaderBumpMap : 8; /* MAX_TEXTURES, 8 */
DWORD lastWasPow2Texture : 8; /* MAX_TEXTURES, 8 */ DWORD lastWasPow2Texture : 8; /* MAX_TEXTURES, 8 */
DWORD fixed_function_usage_map : 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 shader_update_mask;
DWORD constant_update_mask; DWORD constant_update_mask;
DWORD numbered_array_mask; DWORD numbered_array_mask;
...@@ -1842,7 +1843,6 @@ struct wined3d_state ...@@ -1842,7 +1843,6 @@ struct wined3d_state
struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS]; struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS];
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_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_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
struct wined3d_vec4 clip_planes[MAX_CLIPPLANES]; struct wined3d_vec4 clip_planes[MAX_CLIPPLANES];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment