From: Elizabeth Figura zfigura@codeweavers.com
We still need to pass it through the CS, for the sake of wined3d_ffp_vs_settings. --- dlls/wined3d/glsl_shader.c | 8 -------- dlls/wined3d/shader.c | 4 ++-- dlls/wined3d/shader_spirv.c | 2 -- dlls/wined3d/stateblock.c | 15 +++++++++++++-- dlls/wined3d/utils.c | 9 ++++++--- dlls/wined3d/wined3d_private.h | 2 ++ 6 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 48943dbbe2a..f906d7caa82 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -12074,12 +12074,6 @@ static void glsl_fragment_pipe_shader(struct wined3d_context *context, context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL; }
-static void glsl_fragment_pipe_fog(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL; -} - static void glsl_fragment_pipe_vdecl(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { @@ -12158,8 +12152,6 @@ static const struct wined3d_state_entry_template glsl_fragment_pipe_state_templa {STATE_RENDER(WINED3D_RS_ALPHAFUNC), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), glsl_fragment_pipe_core_alpha_test }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), state_nop }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_FOGENABLE), {STATE_RENDER(WINED3D_RS_FOGENABLE), glsl_fragment_pipe_fog }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_FOGTABLEMODE), {STATE_RENDER(WINED3D_RS_FOGTABLEMODE), glsl_fragment_pipe_fog }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), state_srgbwrite }, ARB_FRAMEBUFFER_SRGB}, {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), NULL }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 1c0aada0681..6d4e07ed82e 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3064,9 +3064,9 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 else { args->vp_mode = WINED3D_VP_MODE_SHADER; - if (state->render_states[WINED3D_RS_FOGENABLE]) + if (state->extra_ps_args.fog_enable) { - switch (state->render_states[WINED3D_RS_FOGTABLEMODE]) + switch (state->extra_ps_args.fog_mode) { case WINED3D_FOG_NONE: case WINED3D_FOG_LINEAR: args->fog = WINED3D_FFP_PS_FOG_LINEAR; break; diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index a033c69feec..93fbdbf864e 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1285,8 +1285,6 @@ static const struct wined3d_state_entry_template spirv_fragment_pipe_vk_fp_state { {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_ALPHAFUNC), {STATE_RENDER(WINED3D_RS_ALPHAFUNC), state_nop}}, - {STATE_RENDER(WINED3D_RS_FOGENABLE), {STATE_RENDER(WINED3D_RS_FOGENABLE), state_nop}}, - {STATE_RENDER(WINED3D_RS_FOGTABLEMODE), {STATE_RENDER(WINED3D_RS_FOGTABLEMODE), state_nop}}, {STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), {STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), state_nop}}, {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), state_nop}}, {0}, /* Terminate */ diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index cb26f01a0b9..a586d102fb7 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1670,7 +1670,6 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb case WINED3D_RS_COLORVERTEX: case WINED3D_RS_DIFFUSEMATERIALSOURCE: case WINED3D_RS_EMISSIVEMATERIALSOURCE: - case WINED3D_RS_FOGENABLE: case WINED3D_RS_LIGHTING: case WINED3D_RS_LOCALVIEWER: case WINED3D_RS_NORMALIZENORMALS: @@ -1704,7 +1703,6 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb stateblock->changed.fog_constants = 1; break;
- case WINED3D_RS_FOGTABLEMODE: case WINED3D_RS_FOGVERTEXMODE: stateblock->changed.ffp_vs_settings = 1; stateblock->changed.fog_constants = 1; @@ -1715,6 +1713,17 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb stateblock->changed.extra_ps_args = 1; break;
+ case WINED3D_RS_FOGENABLE: + stateblock->changed.ffp_vs_settings = 1; + stateblock->changed.extra_ps_args = 1; + break; + + case WINED3D_RS_FOGTABLEMODE: + stateblock->changed.ffp_vs_settings = 1; + stateblock->changed.fog_constants = 1; + stateblock->changed.extra_ps_args = 1; + break; + default: break; } @@ -3954,6 +3963,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
args.point_sprite = state->rs[WINED3D_RS_POINTSPRITEENABLE]; args.flat_shading = state->rs[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT; + args.fog_enable = state->rs[WINED3D_RS_FOGENABLE]; + args.fog_mode = state->rs[WINED3D_RS_FOGTABLEMODE]; wined3d_device_context_emit_set_extra_ps_args(context, &args); }
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index f068c6ebf77..fd0715a004f 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6362,11 +6362,11 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_state *state, for (; i < WINED3D_MAX_FFP_TEXTURES; ++i) memset(&settings->op[i], 0xff, sizeof(settings->op[i]));
- if (!state->render_states[WINED3D_RS_FOGENABLE]) + if (!state->extra_ps_args.fog_enable) { settings->fog = WINED3D_FFP_PS_FOG_OFF; } - else if (state->render_states[WINED3D_RS_FOGTABLEMODE] == WINED3D_FOG_NONE) + else if (state->extra_ps_args.fog_mode == WINED3D_FOG_NONE) { if (use_vs(state) || state->vertex_declaration->position_transformed) { @@ -6391,7 +6391,7 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_state *state, } else { - switch (state->render_states[WINED3D_RS_FOGTABLEMODE]) + switch (state->extra_ps_args.fog_mode) { case WINED3D_FOG_LINEAR: settings->fog = WINED3D_FFP_PS_FOG_LINEAR; @@ -6402,6 +6402,9 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_state *state, case WINED3D_FOG_EXP2: settings->fog = WINED3D_FFP_PS_FOG_EXP2; break; + case WINED3D_FOG_NONE: + /* unreachable */ + break; } } settings->sRGB_write = !d3d_info->srgb_write_control && needs_srgb_write(d3d_info, state, &state->fb); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9a391475ba8..f9674643983 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2877,6 +2877,8 @@ struct wined3d_extra_ps_args { bool point_sprite; bool flat_shading; + bool fog_enable; + enum wined3d_fog_mode fog_mode; };
struct wined3d_blend_state
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/ffp_gl.c | 3 +-- dlls/wined3d/glsl_shader.c | 30 +----------------------------- dlls/wined3d/shader.c | 4 +--- dlls/wined3d/shader_spirv.c | 2 -- dlls/wined3d/stateblock.c | 5 +++++ dlls/wined3d/utils.c | 4 +--- dlls/wined3d/wined3d_private.h | 1 + 8 files changed, 11 insertions(+), 40 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 8443952cff8..69f0bc4e786 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3192,7 +3192,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) { gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHATESTENABLE)); + context_invalidate_state(context, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); } gl_info->gl_ops.gl.p_glDisable(GL_BLEND); gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index a0411214733..c04499e553e 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1560,8 +1560,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) rs_holes[] = { { 1, 8}, - { 11, 14}, - { 16, 24}, + { 11, 25}, { 27, 27}, { 30, 34}, { 36, 40}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index f906d7caa82..ba0314a6bae 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -12110,7 +12110,7 @@ static void glsl_fragment_pipe_alpha_test_func(struct wined3d_context_gl *contex GLfloat ref; GLint func;
- if ((func = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ALPHAFUNC]))) + if ((func = wined3d_gl_compare_func(state->extra_ps_args.alpha_func))) { if ((buffer = context_gl->c.device->push_constants[WINED3D_PUSH_CONSTANTS_PS_FFP])) ref = (constants = wined3d_buffer_load_sysmem(buffer, &context_gl->c))->alpha_test_ref; @@ -12121,36 +12121,11 @@ static void glsl_fragment_pipe_alpha_test_func(struct wined3d_context_gl *contex } }
-static void glsl_fragment_pipe_core_alpha_test(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL; -} - -static void glsl_fragment_pipe_alpha_test(struct wined3d_context_gl *context_gl, - const struct wined3d_state *state) -{ - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - - if (state->render_states[WINED3D_RS_ALPHATESTENABLE]) - { - gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST); - checkGLcall("glEnable(GL_ALPHA_TEST)"); - } - else - { - gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST); - checkGLcall("glDisable(GL_ALPHA_TEST)"); - } -} - static const struct wined3d_state_entry_template glsl_fragment_pipe_state_template[] = { {STATE_VDECL, {STATE_VDECL, glsl_fragment_pipe_vdecl }, WINED3D_GL_EXT_NONE }, {STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), {STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), glsl_fragment_pipe_vs }, WINED3D_GL_EXT_NONE }, {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), glsl_fragment_pipe_shader }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_ALPHAFUNC), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), glsl_fragment_pipe_core_alpha_test }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), state_nop }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), state_srgbwrite }, ARB_FRAMEBUFFER_SRGB}, {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE }, @@ -12270,10 +12245,7 @@ static void shader_glsl_update_legacy_states(struct wined3d_context_gl *context_ return;
if (context_gl->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_PIXEL)) - { - glsl_fragment_pipe_alpha_test(context_gl, state); glsl_fragment_pipe_alpha_test_func(context_gl, state); - }
if (context_gl->c.constant_update_mask & WINED3D_SHADER_CONST_PS_ALPHA_TEST) glsl_fragment_pipe_alpha_test_func(context_gl, state); diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 6d4e07ed82e..6c198f9d23b 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3115,9 +3115,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 if (d3d_info->ffp_alpha_test) args->alpha_test_func = WINED3D_CMP_ALWAYS - 1; else - args->alpha_test_func = (state->render_states[WINED3D_RS_ALPHATESTENABLE] - ? wined3d_sanitize_cmp_func(state->render_states[WINED3D_RS_ALPHAFUNC]) - : WINED3D_CMP_ALWAYS) - 1; + args->alpha_test_func = state->extra_ps_args.alpha_func - 1;
if (d3d_info->emulated_flatshading) args->flatshading = state->extra_ps_args.flat_shading; diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index 93fbdbf864e..5f01bb3ea03 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1283,8 +1283,6 @@ static void spirv_fragment_pipe_vk_fp_free_context_data(struct wined3d_context *
static const struct wined3d_state_entry_template spirv_fragment_pipe_vk_fp_states[] = { - {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), state_nop}}, - {STATE_RENDER(WINED3D_RS_ALPHAFUNC), {STATE_RENDER(WINED3D_RS_ALPHAFUNC), state_nop}}, {STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), {STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), state_nop}}, {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), state_nop}}, {0}, /* Terminate */ diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index a586d102fb7..c4f0ae1fed0 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1708,6 +1708,8 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb stateblock->changed.fog_constants = 1; break;
+ case WINED3D_RS_ALPHAFUNC: + case WINED3D_RS_ALPHATESTENABLE: case WINED3D_RS_POINTSPRITEENABLE: case WINED3D_RS_SHADEMODE: stateblock->changed.extra_ps_args = 1; @@ -3217,6 +3219,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, case WINED3D_RS_FOGEND: case WINED3D_RS_FOGSTART: case WINED3D_RS_POINTSPRITEENABLE: + case WINED3D_RS_ALPHAFUNC: + case WINED3D_RS_ALPHATESTENABLE: break;
case WINED3D_RS_ANTIALIAS: @@ -3965,6 +3969,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, args.flat_shading = state->rs[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT; args.fog_enable = state->rs[WINED3D_RS_FOGENABLE]; args.fog_mode = state->rs[WINED3D_RS_FOGTABLEMODE]; + args.alpha_func = state->rs[WINED3D_RS_ALPHATESTENABLE] ? state->rs[WINED3D_RS_ALPHAFUNC] : WINED3D_CMP_ALWAYS; wined3d_device_context_emit_set_extra_ps_args(context, &args); }
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index fd0715a004f..33b30b1d0bd 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6455,9 +6455,7 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_state *state, if (d3d_info->ffp_alpha_test) settings->alpha_test_func = WINED3D_CMP_ALWAYS - 1; else - settings->alpha_test_func = (state->render_states[WINED3D_RS_ALPHATESTENABLE] - ? wined3d_sanitize_cmp_func(state->render_states[WINED3D_RS_ALPHAFUNC]) - : WINED3D_CMP_ALWAYS) - 1; + settings->alpha_test_func = state->extra_ps_args.alpha_func - 1;
if (d3d_info->emulated_flatshading) settings->flatshading = state->extra_ps_args.flat_shading; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f9674643983..d9f8c939194 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2879,6 +2879,7 @@ struct wined3d_extra_ps_args bool flat_shading; bool fog_enable; enum wined3d_fog_mode fog_mode; + enum wined3d_cmp_func alpha_func; };
struct wined3d_blend_state
From: Elizabeth Figura zfigura@codeweavers.com
We still need to pass them through the CS, for the sake of wined3d_ffp_vs_settings and ffp_frag_settings. --- dlls/wined3d/shader.c | 9 ++++----- dlls/wined3d/stateblock.c | 6 ++++++ dlls/wined3d/wined3d_private.h | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 6c198f9d23b..728a5204f39 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2893,7 +2893,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 { for (i = 0; i < shader->limits->sampler; ++i) { - uint32_t flags = state->texture_states[i][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS]; + uint32_t flags = state->extra_ps_args.texture_transform_flags[i];
if (flags & WINED3D_TTFF_PROJECTED) { @@ -2903,7 +2903,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 { enum wined3d_shader_resource_type resource_type = shader->reg_maps.resource_info[i].type; unsigned int j; - unsigned int index = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; + unsigned int index = state->extra_ps_args.texcoord_index[i]; uint32_t max_valid = WINED3D_TTFF_COUNT4;
for (j = 0; j < state->vertex_declaration->element_count; ++j) @@ -3095,10 +3095,9 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 else { const struct wined3d_stream_info *si = &context->stream_info; - unsigned int coord_idx = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; + unsigned int coord_idx = state->extra_ps_args.texcoord_index[i];
- if ((state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] >> WINED3D_FFP_TCI_SHIFT) - & WINED3D_FFP_TCI_MASK + if (((state->extra_ps_args.texcoord_index[i] >> WINED3D_FFP_TCI_SHIFT) & WINED3D_FFP_TCI_MASK) || (coord_idx < WINED3D_MAX_FFP_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx))))) args->texcoords_initialized |= 1u << i; } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index c4f0ae1fed0..c89fa9df0c6 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1781,6 +1781,7 @@ void CDECL wined3d_stateblock_set_texture_stage_state(struct wined3d_stateblock case WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS: stateblock->changed.texture_matrices = 1; stateblock->changed.ffp_ps_settings = 1; + stateblock->changed.extra_ps_args = 1; break;
case WINED3D_TSS_ALPHA_ARG0: @@ -3970,6 +3971,11 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, args.fog_enable = state->rs[WINED3D_RS_FOGENABLE]; args.fog_mode = state->rs[WINED3D_RS_FOGTABLEMODE]; args.alpha_func = state->rs[WINED3D_RS_ALPHATESTENABLE] ? state->rs[WINED3D_RS_ALPHAFUNC] : WINED3D_CMP_ALWAYS; + for (unsigned int i = 0; i < 4; ++i) + { + args.texture_transform_flags[i] = state->texture_states[i][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS]; + args.texcoord_index[i] = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX]; + } wined3d_device_context_emit_set_extra_ps_args(context, &args); }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d9f8c939194..0bb86cc8b9c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2880,6 +2880,9 @@ struct wined3d_extra_ps_args bool fog_enable; enum wined3d_fog_mode fog_mode; enum wined3d_cmp_func alpha_func; + uint32_t texcoord_index[WINED3D_MAX_FFP_TEXTURES]; + /* These flags are only relevant to 1.1-1.3, which only allow 4 textures. */ + uint32_t texture_transform_flags[4]; };
struct wined3d_blend_state
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/ffp_gl.c | 22 ---------------------- dlls/wined3d/glsl_shader.c | 23 +++++++++++++++++++++++ dlls/wined3d/wined3d_gl.h | 2 -- 3 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index c04499e553e..1b9a9b90285 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -997,28 +997,6 @@ void clipplane(struct wined3d_context *context, const struct wined3d_state *stat context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES; }
-void ffp_vertex_update_clip_plane_constants(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state) -{ - for (unsigned int i = 0; i < gl_info->limits.user_clip_distances; ++i) - { - GLdouble plane[4]; - - gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); - gl_info->gl_ops.gl.p_glPushMatrix(); - gl_info->gl_ops.gl.p_glLoadIdentity(); - - plane[0] = state->clip_planes[i].x; - plane[1] = state->clip_planes[i].y; - plane[2] = state->clip_planes[i].z; - plane[3] = state->clip_planes[i].w; - - gl_info->gl_ops.gl.p_glClipPlane(GL_CLIP_PLANE0 + i, plane); - checkGLcall("glClipPlane"); - - gl_info->gl_ops.gl.p_glPopMatrix(); - } -} - static void streamsrc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { wined3d_context_gl_update_stream_sources(wined3d_context_gl(context), state); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ba0314a6bae..afa7d1248cc 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1704,6 +1704,29 @@ static void shader_glsl_clip_plane_uniform(const struct wined3d_context_gl *cont GL_EXTCALL(glUniform4fv(prog->vs.clip_planes_location + index, 1, &state->clip_planes[index].x)); }
+static void ffp_vertex_update_clip_plane_constants(const struct wined3d_gl_info *gl_info, + const struct wined3d_state *state) +{ + for (unsigned int i = 0; i < gl_info->limits.user_clip_distances; ++i) + { + GLdouble plane[4]; + + gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); + gl_info->gl_ops.gl.p_glPushMatrix(); + gl_info->gl_ops.gl.p_glLoadIdentity(); + + plane[0] = state->clip_planes[i].x; + plane[1] = state->clip_planes[i].y; + plane[2] = state->clip_planes[i].z; + plane[3] = state->clip_planes[i].w; + + gl_info->gl_ops.gl.p_glClipPlane(GL_CLIP_PLANE0 + i, plane); + checkGLcall("glClipPlane"); + + gl_info->gl_ops.gl.p_glPopMatrix(); + } +} + static void shader_glsl_load_constants(struct shader_glsl_priv *priv, struct wined3d_context *context, const struct wined3d_state *state) { diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 358f0599266..5e35e723958 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -790,8 +790,6 @@ void wined3d_ffp_blitter_create(struct wined3d_blitter **next, const struct wine struct wined3d_blitter *wined3d_glsl_blitter_create(struct wined3d_blitter **next, const struct wined3d_device *device); void wined3d_raw_blitter_create(struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info);
-void ffp_vertex_update_clip_plane_constants(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state); - struct wined3d_caps_gl_ctx { HDC dc;
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/cs.c | 31 ------------------ dlls/wined3d/glsl_shader.c | 57 +++++++--------------------------- dlls/wined3d/stateblock.c | 28 +++++------------ dlls/wined3d/utils.c | 2 -- dlls/wined3d/wined3d_private.h | 11 +++---- 5 files changed, 22 insertions(+), 107 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 0404674fa9d..8fd7af86442 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -119,7 +119,6 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_RENDER_STATE, WINED3D_CS_OP_SET_TEXTURE_STATE, WINED3D_CS_OP_SET_TRANSFORM, - WINED3D_CS_OP_SET_CLIP_PLANE, WINED3D_CS_OP_SET_COLOR_KEY, WINED3D_CS_OP_SET_LIGHT, WINED3D_CS_OP_SET_LIGHT_ENABLE, @@ -386,13 +385,6 @@ struct wined3d_cs_set_transform struct wined3d_matrix matrix; };
-struct wined3d_cs_set_clip_plane -{ - enum wined3d_cs_op opcode; - UINT plane_idx; - struct wined3d_vec4 plane; -}; - struct wined3d_cs_set_light { enum wined3d_cs_op opcode; @@ -612,7 +604,6 @@ static const char *debug_cs_op(enum wined3d_cs_op op) WINED3D_TO_STR(WINED3D_CS_OP_SET_RENDER_STATE); WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE_STATE); WINED3D_TO_STR(WINED3D_CS_OP_SET_TRANSFORM); - WINED3D_TO_STR(WINED3D_CS_OP_SET_CLIP_PLANE); WINED3D_TO_STR(WINED3D_CS_OP_SET_COLOR_KEY); WINED3D_TO_STR(WINED3D_CS_OP_SET_LIGHT); WINED3D_TO_STR(WINED3D_CS_OP_SET_LIGHT_ENABLE); @@ -1958,27 +1949,6 @@ void wined3d_device_context_emit_set_transform(struct wined3d_device_context *co wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
-static void wined3d_cs_exec_set_clip_plane(struct wined3d_cs *cs, const void *data) -{ - const struct wined3d_cs_set_clip_plane *op = data; - - cs->state.clip_planes[op->plane_idx] = op->plane; - device_invalidate_state(cs->c.device, STATE_CLIPPLANE(op->plane_idx)); -} - -void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context *context, - unsigned int plane_idx, const struct wined3d_vec4 *plane) -{ - struct wined3d_cs_set_clip_plane *op; - - op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_SET_CLIP_PLANE; - op->plane_idx = plane_idx; - op->plane = *plane; - - wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); -} - static void wined3d_cs_exec_set_color_key(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_color_key *op = data; @@ -3016,7 +2986,6 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state, /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, /* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform, - /* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane, /* WINED3D_CS_OP_SET_COLOR_KEY */ wined3d_cs_exec_set_color_key, /* WINED3D_CS_OP_SET_LIGHT */ wined3d_cs_exec_set_light, /* WINED3D_CS_OP_SET_LIGHT_ENABLE */ wined3d_cs_exec_set_light_enable, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index afa7d1248cc..4082c96f60c 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1696,16 +1696,8 @@ static void shader_glsl_load_fog_uniform(struct wined3d_context_gl *context_gl, checkGLcall("fog emulation uniforms"); }
-static void shader_glsl_clip_plane_uniform(const struct wined3d_context_gl *context_gl, - const struct wined3d_state *state, unsigned int index, struct glsl_shader_prog_link *prog) -{ - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - - GL_EXTCALL(glUniform4fv(prog->vs.clip_planes_location + index, 1, &state->clip_planes[index].x)); -} - static void ffp_vertex_update_clip_plane_constants(const struct wined3d_gl_info *gl_info, - const struct wined3d_state *state) + const struct wined3d_ffp_vs_constants *constants) { for (unsigned int i = 0; i < gl_info->limits.user_clip_distances; ++i) { @@ -1715,10 +1707,10 @@ static void ffp_vertex_update_clip_plane_constants(const struct wined3d_gl_info gl_info->gl_ops.gl.p_glPushMatrix(); gl_info->gl_ops.gl.p_glLoadIdentity();
- plane[0] = state->clip_planes[i].x; - plane[1] = state->clip_planes[i].y; - plane[2] = state->clip_planes[i].z; - plane[3] = state->clip_planes[i].w; + plane[0] = constants->clip_planes[i].x; + plane[1] = constants->clip_planes[i].y; + plane[2] = constants->clip_planes[i].z; + plane[3] = constants->clip_planes[i].w;
gl_info->gl_ops.gl.p_glClipPlane(GL_CLIP_PLANE0 + i, plane); checkGLcall("glClipPlane"); @@ -1784,14 +1776,18 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv,
if (update_mask & WINED3D_SHADER_CONST_VS_CLIP_PLANES) { + const struct wined3d_ffp_vs_constants *constants; + + constants = wined3d_buffer_load_sysmem(context->device->push_constants[WINED3D_PUSH_CONSTANTS_VS_FFP], context); + if (gl_info->supported[WINED3D_GLSL_130]) { for (i = 0; i < gl_info->limits.user_clip_distances; ++i) - shader_glsl_clip_plane_uniform(context_gl, state, i, prog); + GL_EXTCALL(glUniform4fv(prog->vs.clip_planes_location + i, 1, &constants->clip_planes[i].x)); } else { - ffp_vertex_update_clip_plane_constants(gl_info, state); + ffp_vertex_update_clip_plane_constants(gl_info, constants); } }
@@ -11908,19 +11904,6 @@ static void glsl_vertex_pipe_shademode(struct wined3d_context *context, context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_VERTEX; }
-static void glsl_vertex_pipe_clip_plane(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - struct wined3d_context_gl *context_gl = wined3d_context_gl(context); - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - UINT index = state_id - STATE_CLIPPLANE(0); - - if (index >= gl_info->limits.user_clip_distances) - return; - - context->constant_update_mask |= WINED3D_SHADER_CONST_VS_CLIP_PLANES; -} - static const struct wined3d_state_entry_template glsl_vertex_pipe_vp_states[] = { {STATE_VDECL, {STATE_VDECL, glsl_vertex_pipe_vdecl }, WINED3D_GL_EXT_NONE }, @@ -11928,24 +11911,6 @@ static const struct wined3d_state_entry_template glsl_vertex_pipe_vp_states[] = {STATE_SHADER(WINED3D_SHADER_TYPE_HULL), {STATE_SHADER(WINED3D_SHADER_TYPE_HULL), glsl_vertex_pipe_hs }, WINED3D_GL_EXT_NONE }, {STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY), {STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY), glsl_vertex_pipe_geometry_shader}, WINED3D_GL_EXT_NONE }, {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), glsl_vertex_pipe_pixel_shader}, WINED3D_GL_EXT_NONE }, - /* Clip planes */ - {STATE_CLIPPLANE(0), {STATE_CLIPPLANE(0), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(0), {STATE_CLIPPLANE(0), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(1), {STATE_CLIPPLANE(1), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(1), {STATE_CLIPPLANE(1), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(2), {STATE_CLIPPLANE(2), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(2), {STATE_CLIPPLANE(2), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(3), {STATE_CLIPPLANE(3), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(3), {STATE_CLIPPLANE(3), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(4), {STATE_CLIPPLANE(4), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(4), {STATE_CLIPPLANE(4), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(5), {STATE_CLIPPLANE(5), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(5), {STATE_CLIPPLANE(5), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(6), {STATE_CLIPPLANE(6), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(6), {STATE_CLIPPLANE(6), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(7), {STATE_CLIPPLANE(7), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(7), {STATE_CLIPPLANE(7), clipplane }, WINED3D_GL_EXT_NONE }, - /* Viewport */ {STATE_VIEWPORT, {STATE_VIEWPORT, glsl_vertex_pipe_viewport}, WINED3D_GL_EXT_NONE }, /* Fog */ {STATE_RENDER(WINED3D_RS_AMBIENTMATERIALSOURCE), {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index c89fa9df0c6..3cc9bd429a4 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -2727,24 +2727,6 @@ static void wined3d_device_set_light_enable(struct wined3d_device *device, unsig wined3d_device_context_emit_set_light_enable(&device->cs->c, light_idx, enable); }
-static void wined3d_device_set_clip_plane(struct wined3d_device *device, - unsigned int plane_idx, const struct wined3d_vec4 *plane) -{ - struct wined3d_vec4 *clip_planes = device->cs->c.state->clip_planes; - - TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane); - - if (!memcmp(&clip_planes[plane_idx], plane, sizeof(*plane))) - { - TRACE("Application is setting old values over, nothing to do.\n"); - return; - } - - clip_planes[plane_idx] = *plane; - - wined3d_device_context_emit_set_clip_plane(&device->cs->c, plane_idx, plane); -} - static void resolve_depth_buffer(struct wined3d_device *device) { const struct wined3d_state *state = device->cs->c.state; @@ -3735,6 +3717,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, map = changed->clipplane; while (map) { + struct wined3d_vec4 plane; + i = wined3d_bit_scan(&map);
/* In Direct3D, clipping is done based on the position as transformed @@ -3757,17 +3741,19 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, if (!state->vs) { struct wined3d_matrix matrix; - struct wined3d_vec4 plane;
invert_matrix(&matrix, &state->transforms[WINED3D_TS_VIEW]); transpose_matrix(&matrix, &matrix); wined3d_vec4_transform(&plane, &state->clip_planes[i], &matrix); - wined3d_device_set_clip_plane(device, i, &plane); } else { - wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]); + plane = state->clip_planes[i]; } + + wined3d_device_context_push_constants(context, + WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_VS_CLIP_PLANES, + offsetof(struct wined3d_ffp_vs_constants, clip_planes[i]), sizeof(plane), &plane); }
if (changed->material) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 33b30b1d0bd..731be808f50 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5451,8 +5451,6 @@ const char *debug_d3dstate(uint32_t state) return "STATE_VIEWPORT"; if (STATE_IS_SCISSORRECT(state)) return "STATE_SCISSORRECT"; - if (STATE_IS_CLIPPLANE(state)) - return wine_dbg_sprintf("STATE_CLIPPLANE(%#x)", state - STATE_CLIPPLANE(0)); if (STATE_IS_RASTERIZER(state)) return "STATE_RASTERIZER"; if (STATE_IS_DEPTH_BOUNDS(state)) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0bb86cc8b9c..7f20d618c5c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1752,10 +1752,7 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state #define STATE_SCISSORRECT (STATE_VIEWPORT + 1) #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
-#define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a)) -#define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1)) - -#define STATE_RASTERIZER (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES)) +#define STATE_RASTERIZER (STATE_SCISSORRECT + 1) #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
#define STATE_DEPTH_BOUNDS (STATE_RASTERIZER + 1) @@ -2819,6 +2816,9 @@ struct wined3d_ffp_vs_constants struct wined3d_color ambient; struct wined3d_light_constants lights[8]; } light; + + /* States not used by the HLSL pipeline. */ + struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES]; };
struct wined3d_ffp_ps_constants @@ -2971,7 +2971,6 @@ struct wined3d_state uint32_t texture_states[WINED3D_MAX_FFP_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1]; - struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES]; struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS]; unsigned int viewport_count; RECT scissor_rects[WINED3D_MAX_VIEWPORTS]; @@ -3764,8 +3763,6 @@ void wined3d_device_context_emit_reset_state(struct wined3d_device_context *cont void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context *context, struct wined3d_blend_state *state, const struct wined3d_color *blend_factor, unsigned int sample_mask); -void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context *context, unsigned int plane_idx, - const struct wined3d_vec4 *plane); void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, const struct wined3d_constant_buffer_state *buffers);
This merge request was approved by Jan Sikorski.