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,