From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/ffp_gl.c | 10 ---------- dlls/wined3d/glsl_shader.c | 3 +++ 2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index 1b9a9b90285..34a9cff2ae4 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -527,21 +527,11 @@ static void blend_dbb(struct wined3d_context *context, const struct wined3d_stat
void state_clipping(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - struct wined3d_context_gl *context_gl = wined3d_context_gl(context); - uint32_t enable_mask; - /* glEnable(GL_CLIP_PLANEx) doesn't apply to (ARB backend) vertex shaders. * The enabled / disabled planes are hardcoded into the shader. Update the * shader to update the enabled clipplanes. In case of fixed function, we * need to update the clipping field from ffp_vertex_settings. */ context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_VERTEX; - - /* If enabling / disabling all - * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum? - */ - enable_mask = state->render_states[WINED3D_RS_CLIPPING] ? - state->render_states[WINED3D_RS_CLIPPLANEENABLE] : 0; - wined3d_context_gl_enable_clip_distances(context_gl, enable_mask); }
static void renderstate_stencil_twosided(struct wined3d_context *context, GLint face, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index f4a11e2cd4d..f9ef78dcb44 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -10858,6 +10858,9 @@ static void shader_glsl_update_graphics_program(struct shader_glsl_priv *priv, current_vertex_color_clamp = glsl_program->vs.vertex_color_clamp; if (glsl_program->shader_controlled_clip_distances) wined3d_context_gl_enable_clip_distances(context_gl, glsl_program->clip_distance_mask); + else if ((context_gl->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_VERTEX)) + && state->render_states[WINED3D_RS_CLIPPING]) + wined3d_context_gl_enable_clip_distances(context_gl, state->render_states[WINED3D_RS_CLIPPLANEENABLE]); } else {
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/glsl_shader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index f9ef78dcb44..e5be72bae09 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -10906,6 +10906,10 @@ static void shader_glsl_apply_draw_state(void *shader_priv, struct wined3d_conte
shader_glsl_update_legacy_states(context_gl, state);
+ if (context_gl->gl_info->supported[ARB_FRAMEBUFFER_SRGB] + && (context_gl->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_PIXEL))) + state_srgbwrite(&context_gl->c, state, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE)); + if (context->shader_update_mask & ~(1u << WINED3D_SHADER_TYPE_COMPUTE)) shader_glsl_update_graphics_program(priv, context_gl, state);
@@ -12119,7 +12123,6 @@ static const struct wined3d_state_entry_template glsl_fragment_pipe_state_templa {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_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 }, {STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), NULL }, WINED3D_GL_EXT_NONE },
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/context_gl.c | 4 ++-- dlls/wined3d/cs.c | 4 ++-- dlls/wined3d/ffp_gl.c | 3 +-- dlls/wined3d/glsl_shader.c | 1 - dlls/wined3d/shader_spirv.c | 1 - dlls/wined3d/stateblock.c | 41 +++++++++++++++++----------------- dlls/wined3d/wined3d_private.h | 3 ++- 7 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 69f0bc4e786..e5f9e805a26 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3206,7 +3206,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, if (gl_info->supported[ARB_FRAMEBUFFER_SRGB]) { gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE)); + context_invalidate_state(context, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); }
context->last_was_rhw = TRUE; @@ -3346,7 +3346,7 @@ BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, gl_info->gl_ops.gl.p_glEnable(GL_FRAMEBUFFER_SRGB); else gl_info->gl_ops.gl.p_glDisable(GL_FRAMEBUFFER_SRGB); - context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE)); + context_invalidate_state(&context_gl->c, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); } checkGLcall("setting up state for clear");
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 8863ea01a2f..ec2afb0ee73 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -1337,12 +1337,12 @@ static void wined3d_cs_exec_set_rendertarget_views(struct wined3d_cs *cs, const device_invalidate_state(device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL));
if (!(device->adapter->d3d_info.wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL) - || cs->state.render_states[WINED3D_RS_SRGBWRITEENABLE]) + || cs->state.extra_ps_args.srgb_write) { prev_srgb_write = prev && prev->format_caps & WINED3D_FORMAT_CAP_SRGB_WRITE; curr_srgb_write = view && view->format_caps & WINED3D_FORMAT_CAP_SRGB_WRITE; if (prev_srgb_write != curr_srgb_write) - device_invalidate_state(device, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE)); + device_invalidate_state(device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); } }
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index 34a9cff2ae4..343029884e2 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1540,8 +1540,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) {153, 153}, {156, 160}, {162, 165}, - {167, 193}, - {195, 209}, + {167, 209}, { 0, 0}, }; static const unsigned int simple_states[] = diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index e5be72bae09..838d0c0f470 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -12123,7 +12123,6 @@ static const struct wined3d_state_entry_template glsl_fragment_pipe_state_templa {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_COLORKEYENABLE), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), state_nop }, WINED3D_GL_EXT_NONE }, - {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 }, {STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0), {STATE_RENDER(WINED3D_RS_COLORKEYENABLE), NULL }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index ba239c78609..89502ce2d5d 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1293,7 +1293,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_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 dacc5c9b360..933e5604755 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1712,6 +1712,7 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb case WINED3D_RS_ALPHATESTENABLE: case WINED3D_RS_POINTSPRITEENABLE: case WINED3D_RS_SHADEMODE: + case WINED3D_RS_SRGBWRITEENABLE: stateblock->changed.extra_ps_args = 1; break;
@@ -2935,7 +2936,8 @@ void CDECL wined3d_stateblock_apply_clear_state(struct wined3d_stateblock *state const struct wined3d_stateblock_state *state = &stateblock->stateblock_state; struct wined3d_device_context *context = &device->cs->c;
- /* Clear state depends on the viewport, scissor rect, and scissor enable. */ + /* Clear state depends on the viewport, scissor rect, scissor enable, + * and SRGB write enable. */
if (stateblock->changed.viewport) wined3d_device_context_set_viewports(context, 1, &state->viewport); @@ -2974,8 +2976,23 @@ void CDECL wined3d_stateblock_apply_clear_state(struct wined3d_stateblock *state } }
- if (wined3d_bitmap_is_set(stateblock->changed.renderState, WINED3D_RS_SRGBWRITEENABLE)) - wined3d_device_set_render_state(device, WINED3D_RS_SRGBWRITEENABLE, state->rs[WINED3D_RS_SRGBWRITEENABLE]); + if (stateblock->changed.extra_ps_args) + { + struct wined3d_extra_ps_args args; + + 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]; + args.alpha_func = state->rs[WINED3D_RS_ALPHATESTENABLE] ? state->rs[WINED3D_RS_ALPHAFUNC] : WINED3D_CMP_ALWAYS; + args.srgb_write = state->rs[WINED3D_RS_SRGBWRITEENABLE]; + 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); + } }
static struct wined3d_shader *get_ffp_vertex_shader(struct wined3d_device *device, const struct wined3d_state *state) @@ -3204,6 +3221,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, case WINED3D_RS_POINTSPRITEENABLE: case WINED3D_RS_ALPHAFUNC: case WINED3D_RS_ALPHATESTENABLE: + case WINED3D_RS_SRGBWRITEENABLE: break;
case WINED3D_RS_ANTIALIAS: @@ -3948,23 +3966,6 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, WINED3D_SHADER_CONST_FFP_PS, 0, offsetof(struct wined3d_ffp_ps_constants, color_key), &constants); }
- if (changed->extra_ps_args) - { - struct wined3d_extra_ps_args args; - - 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]; - 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); - } - if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_ALPHAREF)) { float f = (state->rs[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6ed159ebbc9..026ca3af265 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2878,6 +2878,7 @@ struct wined3d_extra_ps_args bool point_sprite; bool flat_shading; bool fog_enable; + bool srgb_write; enum wined3d_fog_mode fog_mode; enum wined3d_cmp_func alpha_func; uint32_t texcoord_index[WINED3D_MAX_FFP_TEXTURES]; @@ -4709,7 +4710,7 @@ static inline BOOL needs_srgb_write(const struct wined3d_d3d_info *d3d_info, const struct wined3d_state *state, const struct wined3d_fb_state *fb) { return (!(d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL) - || state->render_states[WINED3D_RS_SRGBWRITEENABLE]) + || state->extra_ps_args.srgb_write) && fb->render_targets[0] && fb->render_targets[0]->format_caps & WINED3D_FORMAT_CAP_SRGB_WRITE; }
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/cs.c | 29 +++++++++++++++++++++++++++++ dlls/wined3d/ffp_gl.c | 4 ++-- dlls/wined3d/glsl_shader.c | 7 ++----- dlls/wined3d/shader.c | 3 +-- dlls/wined3d/shader_spirv.c | 2 -- dlls/wined3d/stateblock.c | 17 +++++++++++++++++ dlls/wined3d/utils.c | 3 +-- dlls/wined3d/wined3d_private.h | 11 ++++++++++- 9 files changed, 63 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index e5f9e805a26..ac1b9370fc1 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3213,7 +3213,7 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, context_invalidate_state(context, STATE_VDECL); /* because of last_was_rhw = TRUE */
wined3d_context_gl_enable_clip_distances(context_gl, 0); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_CLIPPING)); + context_invalidate_state(context, STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX));
/* FIXME: Make draw_textured_quad() able to work with a upper left origin. */ if (gl_info->supported[ARB_CLIP_CONTROL]) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index ec2afb0ee73..ee0f926e870 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -122,6 +122,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_COLOR_KEY, WINED3D_CS_OP_SET_LIGHT, WINED3D_CS_OP_SET_LIGHT_ENABLE, + WINED3D_CS_OP_SET_EXTRA_VS_ARGS, WINED3D_CS_OP_SET_EXTRA_PS_ARGS, WINED3D_CS_OP_SET_FEATURE_LEVEL, WINED3D_CS_OP_PUSH_CONSTANTS, @@ -399,6 +400,12 @@ struct wined3d_cs_set_light_enable BOOL enable; };
+struct wined3d_cs_set_extra_vs_args +{ + enum wined3d_cs_op opcode; + struct wined3d_extra_vs_args args; +}; + struct wined3d_cs_set_extra_ps_args { enum wined3d_cs_op opcode; @@ -617,6 +624,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op) WINED3D_TO_STR(WINED3D_CS_OP_SET_LIGHT); WINED3D_TO_STR(WINED3D_CS_OP_SET_LIGHT_ENABLE); WINED3D_TO_STR(WINED3D_CS_OP_SET_EXTRA_PS_ARGS); + WINED3D_TO_STR(WINED3D_CS_OP_SET_EXTRA_VS_ARGS); WINED3D_TO_STR(WINED3D_CS_OP_SET_FEATURE_LEVEL); WINED3D_TO_STR(WINED3D_CS_OP_PUSH_CONSTANTS); WINED3D_TO_STR(WINED3D_CS_OP_RESET_STATE); @@ -2107,6 +2115,26 @@ void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
+static void wined3d_cs_exec_set_extra_vs_args(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_extra_vs_args *op = data; + + cs->state.extra_vs_args = op->args; + device_invalidate_state(cs->c.device, STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX)); +} + +void wined3d_device_context_emit_set_extra_vs_args(struct wined3d_device_context *context, + const struct wined3d_extra_vs_args *args) +{ + struct wined3d_cs_set_extra_vs_args *op; + + op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); + op->opcode = WINED3D_CS_OP_SET_EXTRA_VS_ARGS; + op->args = *args; + + wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); +} + static void wined3d_cs_exec_set_extra_ps_args(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_extra_ps_args *op = data; @@ -3036,6 +3064,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* 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, + /* WINED3D_CS_OP_SET_EXTRA_VS_ARGS */ wined3d_cs_exec_set_extra_vs_args, /* WINED3D_CS_OP_SET_EXTRA_PS_ARGS */ wined3d_cs_exec_set_extra_ps_args, /* WINED3D_CS_OP_SET_FEATURE_LEVEL */ wined3d_cs_exec_set_feature_level, /* WINED3D_CS_OP_PUSH_CONSTANTS */ wined3d_cs_exec_push_constants, diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index 343029884e2..01146ef51fb 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1533,11 +1533,11 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 30, 34}, { 36, 40}, { 42, 47}, - { 49, 135}, + { 49, 136}, {138, 139}, {144, 144}, {149, 150}, - {153, 153}, + {152, 153}, {156, 160}, {162, 165}, {167, 209}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 838d0c0f470..24a3b91bb45 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -10858,9 +10858,8 @@ static void shader_glsl_update_graphics_program(struct shader_glsl_priv *priv, current_vertex_color_clamp = glsl_program->vs.vertex_color_clamp; if (glsl_program->shader_controlled_clip_distances) wined3d_context_gl_enable_clip_distances(context_gl, glsl_program->clip_distance_mask); - else if ((context_gl->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_VERTEX)) - && state->render_states[WINED3D_RS_CLIPPING]) - wined3d_context_gl_enable_clip_distances(context_gl, state->render_states[WINED3D_RS_CLIPPLANEENABLE]); + else if (context_gl->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_VERTEX)) + wined3d_context_gl_enable_clip_distances(context_gl, state->extra_vs_args.clip_planes); } else { @@ -11935,8 +11934,6 @@ static const struct wined3d_state_entry_template glsl_vertex_pipe_vp_states[] = {STATE_RENDER(WINED3D_RS_SPECULARENABLE), {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_SPECULARMATERIALSOURCE), {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_VERTEXBLEND), {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_CLIPPING), {STATE_RENDER(WINED3D_RS_CLIPPING), state_clipping }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE), {STATE_RENDER(WINED3D_RS_CLIPPING), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_POINTSIZE), {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), glsl_vertex_pipe_pointsize}, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_POINTSIZE_MAX), {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), NULL }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 728a5204f39..f2e40d1b055 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2728,8 +2728,7 @@ void find_vs_compile_args(const struct wined3d_state *state, const struct wined3 args->fog_src = VS_FOG_COORD; }
- args->clip_enabled = state->render_states[WINED3D_RS_CLIPPING] - && state->render_states[WINED3D_RS_CLIPPLANEENABLE]; + args->clip_enabled = !!state->extra_vs_args.clip_planes; args->point_size = state->primitive_type == WINED3D_PT_POINTLIST; args->next_shader_type = hull_shader ? WINED3D_SHADER_TYPE_HULL : geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL; diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index 89502ce2d5d..5c84e2b1bfd 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1217,8 +1217,6 @@ static void spirv_vertex_pipe_vk_vp_free(struct wined3d_device *device, struct w
static const struct wined3d_state_entry_template spirv_vertex_pipe_vk_vp_states[] = { - {STATE_RENDER(WINED3D_RS_CLIPPING), {STATE_RENDER(WINED3D_RS_CLIPPING), state_nop}}, - {STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE), {STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_POINTSIZE), {STATE_RENDER(WINED3D_RS_POINTSIZE), state_nop}}, {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), {STATE_RENDER(WINED3D_RS_POINTSIZE_MIN), state_nop}}, {STATE_RENDER(WINED3D_RS_POINTSIZE_MAX), {STATE_RENDER(WINED3D_RS_POINTSIZE_MAX), state_nop}}, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 933e5604755..87ea93f4850 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -70,6 +70,7 @@ struct wined3d_saved_states uint32_t position_transformed : 1; uint32_t bumpenv_constants : 1; uint32_t fog_constants : 1; + uint32_t extra_vs_args : 1; uint32_t extra_ps_args : 1; };
@@ -330,6 +331,7 @@ void CDECL wined3d_stateblock_primary_dirtify_all_states(struct wined3d_device * states->position_transformed = 1; states->bumpenv_constants = 1; states->fog_constants = 1; + states->extra_vs_args = 1; states->extra_ps_args = 1;
list_init(&stateblock->changed.changed_lights); @@ -1708,6 +1710,11 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb stateblock->changed.fog_constants = 1; break;
+ case WINED3D_RS_CLIPPING: + case WINED3D_RS_CLIPPLANEENABLE: + stateblock->changed.extra_vs_args = 1; + break; + case WINED3D_RS_ALPHAFUNC: case WINED3D_RS_ALPHATESTENABLE: case WINED3D_RS_POINTSPRITEENABLE: @@ -3222,6 +3229,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, case WINED3D_RS_ALPHAFUNC: case WINED3D_RS_ALPHATESTENABLE: case WINED3D_RS_SRGBWRITEENABLE: + case WINED3D_RS_CLIPPING: + case WINED3D_RS_CLIPPLANEENABLE: break;
case WINED3D_RS_ANTIALIAS: @@ -3966,6 +3975,14 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, WINED3D_SHADER_CONST_FFP_PS, 0, offsetof(struct wined3d_ffp_ps_constants, color_key), &constants); }
+ if (changed->extra_vs_args) + { + struct wined3d_extra_vs_args args; + + args.clip_planes = state->rs[WINED3D_RS_CLIPPING] ? state->rs[WINED3D_RS_CLIPPLANEENABLE] : 0; + wined3d_device_context_emit_set_extra_vs_args(context, &args); + } + if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_ALPHAREF)) { float f = (state->rs[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 731be808f50..67a99939e1c 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6541,8 +6541,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct break; }
- settings->clipping = state->render_states[WINED3D_RS_CLIPPING] - && state->render_states[WINED3D_RS_CLIPPLANEENABLE]; + settings->clipping = !!state->extra_vs_args.clip_planes; settings->diffuse = vdecl->diffuse; settings->normal = vdecl->normal; settings->normalize = settings->normal && state->render_states[WINED3D_RS_NORMALIZENORMALS]; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 026ca3af265..061cbd8a1c2 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2869,10 +2869,16 @@ enum wined3d_push_constants WINED3D_PUSH_CONSTANTS_COUNT, };
-/* Pixel shader states part of the Direct3D 1-9 FFP, which are also used when +/* States part of the Direct3D 1-9 FFP, which are also used when * using shaders, which are not implemented as uniforms. * These eventually make their way into vs_compile_args / ps_compile_args, but * those structs also include states other than the FFP states. */ + +struct wined3d_extra_vs_args +{ + uint8_t clip_planes; +}; + struct wined3d_extra_ps_args { bool point_sprite; @@ -2985,6 +2991,7 @@ struct wined3d_state uint32_t sample_mask; struct wined3d_depth_stencil_state *depth_stencil_state; unsigned int stencil_ref; + struct wined3d_extra_vs_args extra_vs_args; struct wined3d_extra_ps_args extra_ps_args; bool depth_bounds_enable; float depth_bounds_min, depth_bounds_max; @@ -3775,6 +3782,8 @@ void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_co struct wined3d_rendertarget_view *view); void wined3d_device_context_emit_set_extra_ps_args(struct wined3d_device_context *context, const struct wined3d_extra_ps_args *args); +void wined3d_device_context_emit_set_extra_vs_args(struct wined3d_device_context *context, + const struct wined3d_extra_vs_args *args); void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context *context, enum wined3d_feature_level level); void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context *context, struct wined3d_buffer *buffer,