Module: wine Branch: master Commit: 65165cf8520f85ac327115536749cda1aabef77b URL: https://gitlab.winehq.org/wine/wine/-/commit/65165cf8520f85ac327115536749cda...
Author: Elizabeth Figura zfigura@codeweavers.com Date: Sun Jun 9 12:50:26 2024 -0500
wined3d: Feed the FFP color key through a push constant buffer.
---
dlls/wined3d/cs.c | 4 ---- dlls/wined3d/ffp_gl.c | 1 - dlls/wined3d/glsl_shader.c | 25 ++++++------------------- dlls/wined3d/shader_spirv.c | 1 - dlls/wined3d/stateblock.c | 16 ++++++++++++++-- dlls/wined3d/texture.c | 3 +++ dlls/wined3d/utils.c | 2 -- dlls/wined3d/wined3d_private.h | 9 +++++---- 8 files changed, 28 insertions(+), 33 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 81a66ab3cf7..cc6153ce257 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -1580,9 +1580,6 @@ static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data)
if (new_use_color_key != old_use_color_key) device_invalidate_state(cs->c.device, STATE_RENDER(WINED3D_RS_COLORKEYENABLE)); - - if (new_use_color_key) - device_invalidate_state(cs->c.device, STATE_COLOR_KEY); }
void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, @@ -1957,7 +1954,6 @@ static void wined3d_cs_exec_set_color_key(struct wined3d_cs *cs, const void *dat case WINED3D_CKEY_SRC_BLT: if (texture == wined3d_state_get_ffp_texture(&cs->state, 0)) { - device_invalidate_state(cs->c.device, STATE_COLOR_KEY); if (!(texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT)) device_invalidate_state(cs->c.device, STATE_RENDER(WINED3D_RS_COLORKEYENABLE)); } diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index bab0f752df8..ddb461bb56f 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1717,7 +1717,6 @@ static void validate_state_table(struct wined3d_state_entry *state_table) STATE_BASEVERTEXINDEX, STATE_FRAMEBUFFER, STATE_POINT_ENABLE, - STATE_COLOR_KEY, STATE_BLEND, STATE_BLEND_FACTOR, STATE_DEPTH_STENCIL, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 4f7929923b8..118ea7c926d 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1670,17 +1670,6 @@ static void shader_glsl_clip_plane_uniform(const struct wined3d_context_gl *cont GL_EXTCALL(glUniform4fv(prog->vs.clip_planes_location + index, 1, &plane.x)); }
-/* Context activation is done by the caller (state handler). */ -static void shader_glsl_load_color_key_constant(const struct glsl_ps_program *ps, - const struct wined3d_gl_info *gl_info, const struct wined3d_state *state) -{ - struct wined3d_color float_key[2]; - const struct wined3d_texture *texture = wined3d_state_get_ffp_texture(state, 0); - - wined3d_format_get_float_color_key(texture->resource.format, &texture->async.src_blt_color_key, float_key); - GL_EXTCALL(glUniform4fv(ps->color_key_location, 2, &float_key[0].r)); -} - static void shader_glsl_load_constants(struct shader_glsl_priv *priv, struct wined3d_context *context, const struct wined3d_state *state) { @@ -1889,7 +1878,12 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, }
if (update_mask & WINED3D_SHADER_CONST_FFP_COLOR_KEY) - shader_glsl_load_color_key_constant(&prog->ps, gl_info, state); + { + const struct wined3d_ffp_ps_constants *constants = wined3d_buffer_load_sysmem( + context_gl->c.device->push_constants[WINED3D_PUSH_CONSTANTS_PS_FFP], &context_gl->c); + + GL_EXTCALL(glUniform4fv(prog->ps.color_key_location, 2, &constants->color_key[0].r)); + }
if (update_mask & WINED3D_SHADER_CONST_FFP_PS) { @@ -12326,12 +12320,6 @@ static void glsl_fragment_pipe_core_alpha_test_ref(struct wined3d_context *conte context->constant_update_mask |= WINED3D_SHADER_CONST_PS_ALPHA_TEST; }
-static void glsl_fragment_pipe_color_key(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_COLOR_KEY; -} - static void glsl_fragment_pipe_shademode(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { @@ -12422,7 +12410,6 @@ static const struct wined3d_state_entry_template glsl_fragment_pipe_state_templa {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), {STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), glsl_fragment_pipe_alpha_test }, WINED3D_GL_LEGACY_CONTEXT}, {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_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE }, - {STATE_COLOR_KEY, { STATE_COLOR_KEY, glsl_fragment_pipe_color_key }, 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_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index 61a64f07a6f..dc1c3a13131 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1263,7 +1263,6 @@ static const struct wined3d_state_entry_template spirv_fragment_pipe_vk_fp_state {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), {STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), state_nop}}, {STATE_POINT_ENABLE, {STATE_POINT_ENABLE, state_nop}}, - {STATE_COLOR_KEY, {STATE_COLOR_KEY, state_nop}}, {0}, /* Terminate */ };
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index f97b03e508e..7b09b874137 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -3314,8 +3314,20 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, map = changed->textures; while (map) { + struct wined3d_color float_key[2]; + struct wined3d_texture *texture; + i = wined3d_bit_scan(&map); - wined3d_device_set_texture(device, i, state->textures[i]); + texture = state->textures[i]; + wined3d_device_set_texture(device, i, texture); + + if (!i && texture) + { + wined3d_format_get_float_color_key(texture->resource.format, &texture->src_blt_color_key, float_key); + wined3d_device_context_push_constants(context, + WINED3D_PUSH_CONSTANTS_PS_FFP, WINED3D_SHADER_CONST_FFP_COLOR_KEY, + offsetof(struct wined3d_ffp_ps_constants, color_key), sizeof(float_key), float_key); + } }
map = changed->clipplane; @@ -3339,7 +3351,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, constants.specular_enable = state->rs[WINED3D_RS_SPECULARENABLE] ? specular_enabled : specular_disabled;
wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_PS_FFP, - WINED3D_SHADER_CONST_FFP_PS, 0, sizeof(constants), &constants); + WINED3D_SHADER_CONST_FFP_PS, 0, offsetof(struct wined3d_ffp_ps_constants, color_key), &constants); }
assert(list_empty(&stateblock->changed.changed_lights)); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index eeb2ea3a7cc..99c6a89764d 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1770,6 +1770,9 @@ HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture, return WINED3DERR_INVALIDCALL; }
+ if ((flags & WINED3D_CKEY_SRC_BLT) && color_key) + texture->src_blt_color_key = *color_key; + wined3d_cs_emit_set_color_key(device->cs, texture, flags, color_key);
return WINED3D_OK; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 779af782b6c..c43995b06ea 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5383,8 +5383,6 @@ const char *debug_d3dstate(uint32_t state) return "STATE_FRAMEBUFFER"; if (STATE_IS_POINT_ENABLE(state)) return "STATE_POINT_ENABLE"; - if (STATE_IS_COLOR_KEY(state)) - return "STATE_COLOR_KEY"; if (STATE_IS_STREAM_OUTPUT(state)) return "STATE_STREAM_OUTPUT"; if (STATE_IS_BLEND(state)) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5bfc13f3b88..f6adc96887d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1777,10 +1777,7 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1) #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
-#define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1) -#define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY) - -#define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1) +#define STATE_STREAM_OUTPUT (STATE_POINT_ENABLE + 1) #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
#define STATE_BLEND (STATE_STREAM_OUTPUT + 1) @@ -2774,6 +2771,7 @@ struct wined3d_ffp_ps_constants /* (1, 1, 1, 0) or (0, 0, 0, 0), which shaders will multiply with the * specular color. */ struct wined3d_color specular_enable; + struct wined3d_color color_key[2]; };
enum wined3d_push_constants @@ -3333,6 +3331,9 @@ struct wined3d_texture DWORD color_key_flags; } async;
+ /* Color key field accessed from the client side. */ + struct wined3d_color_key src_blt_color_key; + struct wined3d_dirty_regions { struct wined3d_box *boxes;