From: Elizabeth Figura zfigura@codeweavers.com
This contians pixel shader states part of the Direct3D 1-9 FFP, which are also used when using shaders, which are not implemented as uniforms but rather will eventually affect ps_compile_args. We don't use ps_compile_args directly, because it contains states other than those controlled by the stateblock.
Simply put, the point here is to provide a more directed alternative to the render states array, which should itself go away, and at the same time to invalidate STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL) immediately rather than through the state table. --- dlls/wined3d/cs.c | 29 +++++++++++++++++++++++++++++ dlls/wined3d/ffp_gl.c | 2 +- dlls/wined3d/glsl_shader.c | 2 -- dlls/wined3d/shader.c | 2 +- dlls/wined3d/shader_spirv.c | 1 - dlls/wined3d/stateblock.c | 15 +++++++++++++++ dlls/wined3d/utils.c | 2 +- dlls/wined3d/wined3d_private.h | 12 ++++++++++++ 8 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 9bac7afdba2..0404674fa9d 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -123,6 +123,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_PS_ARGS, WINED3D_CS_OP_SET_FEATURE_LEVEL, WINED3D_CS_OP_PUSH_CONSTANTS, WINED3D_CS_OP_RESET_STATE, @@ -405,6 +406,12 @@ struct wined3d_cs_set_light_enable BOOL enable; };
+struct wined3d_cs_set_extra_ps_args +{ + enum wined3d_cs_op opcode; + struct wined3d_extra_ps_args args; +}; + struct wined3d_cs_set_feature_level { enum wined3d_cs_op opcode; @@ -609,6 +616,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op) 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); + WINED3D_TO_STR(WINED3D_CS_OP_SET_EXTRA_PS_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); @@ -2119,6 +2127,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_ps_args(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_extra_ps_args *op = data; + + cs->state.extra_ps_args = op->args; + device_invalidate_state(cs->c.device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); +} + +void wined3d_device_context_emit_set_extra_ps_args(struct wined3d_device_context *context, + const struct wined3d_extra_ps_args *args) +{ + struct wined3d_cs_set_extra_ps_args *op; + + op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); + op->opcode = WINED3D_CS_OP_SET_EXTRA_PS_ARGS; + op->args = *args; + + wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); +} + static void wined3d_cs_exec_set_feature_level(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_set_feature_level *op = data; @@ -2992,6 +3020,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_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, /* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state, diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index b75c5b1aef7..4c587f2edc4 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1578,7 +1578,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) {144, 144}, {149, 150}, {153, 153}, - {157, 160}, + {156, 160}, {162, 165}, {167, 193}, {195, 209}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index fe7042c9c3c..df43a5d1025 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -12168,8 +12168,6 @@ static const struct wined3d_state_entry_template glsl_fragment_pipe_state_templa {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_RENDER(WINED3D_RS_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), glsl_fragment_pipe_shader }, ARB_POINT_SPRITE }, - {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), glsl_fragment_pipe_shader }, WINED3D_GL_VERSION_2_0}, {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.c b/dlls/wined3d/shader.c index bbf873954b8..4c9ea349bc9 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3109,7 +3109,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 args->texcoords_initialized = wined3d_mask_from_size(WINED3D_MAX_FFP_TEXTURES); }
- args->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE] + args->pointsprite = state->extra_ps_args.point_sprite && state->primitive_type == WINED3D_PT_POINTLIST;
if (d3d_info->ffp_alpha_test) diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index cc67760d1dc..062929f9265 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1289,7 +1289,6 @@ static const struct wined3d_state_entry_template spirv_fragment_pipe_vk_fp_state {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_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), 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 ed9c8ec19b3..390694ca852 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_ps_args : 1; };
struct stage_state @@ -329,6 +330,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_ps_args = 1;
list_init(&stateblock->changed.changed_lights); RB_FOR_EACH_ENTRY(light, lights_tree, struct wined3d_light_info, entry) @@ -1708,6 +1710,10 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb stateblock->changed.fog_constants = 1; break;
+ case WINED3D_RS_POINTSPRITEENABLE: + stateblock->changed.extra_ps_args = 1; + break; + default: break; } @@ -3200,6 +3206,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, case WINED3D_RS_FOGDENSITY: case WINED3D_RS_FOGEND: case WINED3D_RS_FOGSTART: + case WINED3D_RS_POINTSPRITEENABLE: break;
case WINED3D_RS_ANTIALIAS: @@ -3940,6 +3947,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_ps_args) + { + struct wined3d_extra_ps_args args; + + args.point_sprite = state->rs[WINED3D_RS_POINTSPRITEENABLE]; + 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/utils.c b/dlls/wined3d/utils.c index f35c11ebbd6..11b72e6ebc6 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6446,7 +6446,7 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_state *state, settings->texcoords_initialized = wined3d_mask_from_size(WINED3D_MAX_FFP_TEXTURES); }
- settings->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE] + settings->pointsprite = state->extra_ps_args.point_sprite && state->primitive_type == WINED3D_PT_POINTLIST;
if (d3d_info->ffp_alpha_test) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2a7746a8762..6dca6452201 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2869,6 +2869,15 @@ enum wined3d_push_constants WINED3D_PUSH_CONSTANTS_COUNT, };
+/* Pixel shader 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_ps_args +{ + bool point_sprite; +}; + struct wined3d_blend_state { LONG refcount; @@ -2969,6 +2978,7 @@ struct wined3d_state uint32_t sample_mask; struct wined3d_depth_stencil_state *depth_stencil_state; unsigned int stencil_ref; + struct wined3d_extra_ps_args extra_ps_args; bool depth_bounds_enable; float depth_bounds_min, depth_bounds_max; struct wined3d_rasterizer_state *rasterizer_state; @@ -3756,6 +3766,8 @@ void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_c struct wined3d_depth_stencil_state *state, unsigned int stencil_ref); void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context *context, 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_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,