From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/device.c | 6 ++++++ dlls/wined3d/stateblock.c | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index acc70256462..e445679ec2f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5020,6 +5020,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, wined3d_texture_decref(device->cursor_texture); device->cursor_texture = NULL; } + for (unsigned int i = 0; i < ARRAY_SIZE(device->push_constants); ++i) + { + if (device->push_constants[i]) + wined3d_buffer_decref(device->push_constants[i]); + device->push_constants[i] = NULL; + } state_unbind_resources(state); }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 28aa2a46f08..104affe6e56 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -2193,6 +2193,14 @@ static void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state
}
+/* FFP push constant buffers do not have a "default" state on the CS side. + * We need to explicitly invalidate them when initializing the context or + * resetting. */ +static void wined3d_stateblock_invalidate_push_constants(struct wined3d_stateblock *stateblock) +{ + stateblock->changed.ffp_ps_constants = 1; +} + static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state, struct wined3d_device *device, enum wined3d_stateblock_type type) { @@ -2207,9 +2215,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const stru stateblock->changed.store_stream_offset = 1; list_init(&stateblock->changed.changed_lights);
- /* FFP push constant buffers need to be set if used; the backend does not - * have a default state for them. */ - stateblock->changed.ffp_ps_constants = 1; + wined3d_stateblock_invalidate_push_constants(stateblock);
if (type == WINED3D_SBT_RECORDED || type == WINED3D_SBT_PRIMARY) return WINED3D_OK; @@ -2286,6 +2292,7 @@ void CDECL wined3d_stateblock_reset(struct wined3d_stateblock *stateblock) memset(&stateblock->stateblock_state, 0, sizeof(stateblock->stateblock_state)); stateblock->stateblock_state.light_state = &stateblock->light_state; wined3d_stateblock_state_init(&stateblock->stateblock_state, stateblock->device, WINED3D_STATE_INIT_DEFAULT); + wined3d_stateblock_invalidate_push_constants(stateblock); }
static void wined3d_device_set_base_vertex_index(struct wined3d_device *device, int base_index)
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/glsl_shader.c | 12 +----------- dlls/wined3d/shader_spirv.c | 1 - dlls/wined3d/stateblock.c | 5 +++++ dlls/wined3d/wined3d_private.h | 3 +++ 4 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 41e6949b7af..69f65b57a8c 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1901,10 +1901,7 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, if (prog->ps.tex_factor_location != -1) GL_EXTCALL(glUniform4fv(prog->ps.tex_factor_location, 1, &constants->texture_factor.r));
- if (state->render_states[WINED3D_RS_SPECULARENABLE]) - GL_EXTCALL(glUniform4f(prog->ps.specular_enable_location, 1.0f, 1.0f, 1.0f, 0.0f)); - else - GL_EXTCALL(glUniform4f(prog->ps.specular_enable_location, 0.0f, 0.0f, 0.0f, 0.0f)); + GL_EXTCALL(glUniform4fv(prog->ps.specular_enable_location, 1, &constants->specular_enable.r));
for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) { @@ -12286,12 +12283,6 @@ static void glsl_fragment_pipe_tex_transform(struct wined3d_context *context, context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL; }
-static void glsl_fragment_pipe_invalidate_constants(struct wined3d_context *context, - const struct wined3d_state *state, DWORD state_id) -{ - context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_PS; -} - static void glsl_fragment_pipe_alpha_test_func(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { @@ -12451,7 +12442,6 @@ static const struct wined3d_state_entry_template glsl_fragment_pipe_state_templa {STATE_TEXTURESTAGE(5,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(6,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(7,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_fragment_pipe_tex_transform }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_SPECULARENABLE), {STATE_RENDER(WINED3D_RS_SPECULARENABLE), glsl_fragment_pipe_invalidate_constants}, WINED3D_GL_EXT_NONE }, {STATE_POINT_ENABLE, {STATE_POINT_ENABLE, glsl_fragment_pipe_shader }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_SHADEMODE), {STATE_RENDER(WINED3D_RS_SHADEMODE), glsl_fragment_pipe_shademode }, WINED3D_GLSL_130 }, {STATE_RENDER(WINED3D_RS_SHADEMODE), {STATE_RENDER(WINED3D_RS_SHADEMODE), state_shademode }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index b4ef9f61f43..61a64f07a6f 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1253,7 +1253,6 @@ static const struct wined3d_state_entry_template spirv_fragment_pipe_vk_fp_state {STATE_RENDER(WINED3D_RS_ALPHAREF), {STATE_RENDER(WINED3D_RS_ALPHAREF), 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_SPECULARENABLE), {STATE_RENDER(WINED3D_RS_SPECULARENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_FOGCOLOR), {STATE_RENDER(WINED3D_RS_FOGCOLOR), state_nop}}, {STATE_RENDER(WINED3D_RS_FOGTABLEMODE), {STATE_RENDER(WINED3D_RS_FOGTABLEMODE), state_nop}}, {STATE_RENDER(WINED3D_RS_FOGSTART), {STATE_RENDER(WINED3D_RS_FOGSTART), state_nop}}, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 104affe6e56..f97b03e508e 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1542,6 +1542,7 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb } break;
+ case WINED3D_RS_SPECULARENABLE: case WINED3D_RS_TEXTUREFACTOR: stateblock->changed.ffp_ps_constants = 1; break; @@ -3326,6 +3327,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if (changed->ffp_ps_constants) { + static const struct wined3d_color specular_enabled = {1.0f, 1.0f, 1.0f, 0.0f}; + static const struct wined3d_color specular_disabled; struct wined3d_ffp_ps_constants constants;
for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) @@ -3333,6 +3336,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
wined3d_color_from_d3dcolor(&constants.texture_factor, state->rs[WINED3D_RS_TEXTUREFACTOR]);
+ 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); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 46cc0ec30ce..5bfc13f3b88 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2771,6 +2771,9 @@ struct wined3d_ffp_ps_constants { struct wined3d_color texture_constants[WINED3D_MAX_FFP_TEXTURES]; struct wined3d_color texture_factor; + /* (1, 1, 1, 0) or (0, 0, 0, 0), which shaders will multiply with the + * specular color. */ + struct wined3d_color specular_enable; };
enum wined3d_push_constants
From: Elizabeth Figura zfigura@codeweavers.com
--- 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 69f65b57a8c..c88a8658bea 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;
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/stateblock.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 7b09b874137..11276ffd419 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -2749,19 +2749,6 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, wined3d_device_set_ps_consts_b(device, range.offset, range.size, &state->ps_consts_b[range.offset]); }
- if (changed->lights) - { - struct wined3d_light_info *light, *cursor; - - LIST_FOR_EACH_ENTRY_SAFE(light, cursor, &changed->changed_lights, struct wined3d_light_info, changed_entry) - { - wined3d_device_context_set_light(context, light->OriginalIndex, &light->OriginalParms); - wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); - list_remove(&light->changed_entry); - light->changed = false; - } - } - for (i = 0; i < ARRAY_SIZE(changed->renderState); ++i) { map = changed->renderState[i]; @@ -3337,6 +3324,19 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]); }
+ if (changed->lights) + { + struct wined3d_light_info *light, *cursor; + + LIST_FOR_EACH_ENTRY_SAFE(light, cursor, &changed->changed_lights, struct wined3d_light_info, changed_entry) + { + wined3d_device_context_set_light(context, light->OriginalIndex, &light->OriginalParms); + wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); + list_remove(&light->changed_entry); + light->changed = false; + } + } + if (changed->ffp_ps_constants) { static const struct wined3d_color specular_enabled = {1.0f, 1.0f, 1.0f, 0.0f};
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/cs.c | 1 + dlls/wined3d/ffp_gl.c | 2 +- dlls/wined3d/glsl_shader.c | 19 ++++++------------- dlls/wined3d/shader_spirv.c | 1 - dlls/wined3d/stateblock.c | 12 +++++++++++- dlls/wined3d/wined3d_private.h | 9 +++++++++ 6 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index cc6153ce257..275941dd183 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2148,6 +2148,7 @@ wined3d_cs_push_constant_info[] = [WINED3D_PUSH_CONSTANTS_PS_I] = {sizeof(struct wined3d_ivec4), WINED3D_MAX_CONSTS_I, WINED3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_D3DBC_INT_CONSTANT_REGISTER}, [WINED3D_PUSH_CONSTANTS_VS_B] = {sizeof(BOOL), WINED3D_MAX_CONSTS_B, WINED3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_D3DBC_BOOL_CONSTANT_REGISTER}, [WINED3D_PUSH_CONSTANTS_PS_B] = {sizeof(BOOL), WINED3D_MAX_CONSTS_B, WINED3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_D3DBC_BOOL_CONSTANT_REGISTER}, + [WINED3D_PUSH_CONSTANTS_VS_FFP] = {1, sizeof(struct wined3d_ffp_vs_constants), WINED3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_D3DBC_FLOAT_CONSTANT_REGISTER}, [WINED3D_PUSH_CONSTANTS_PS_FFP] = {1, sizeof(struct wined3d_ffp_ps_constants), WINED3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_D3DBC_FLOAT_CONSTANT_REGISTER}, };
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index ddb461bb56f..d0d82181c1e 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1679,7 +1679,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table) { 39, 40}, { 42, 47}, { 49, 135}, - {138, 138}, + {138, 139}, {144, 144}, {149, 150}, {153, 153}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index c88a8658bea..72e26443a2e 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1535,17 +1535,6 @@ static void shader_glsl_ffp_vertex_material_uniform(const struct wined3d_context checkGLcall("setting FFP material uniforms"); }
-static void shader_glsl_ffp_vertex_lightambient_uniform(const struct wined3d_context_gl *context_gl, - const struct wined3d_state *state, struct glsl_shader_prog_link *prog) -{ - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - struct wined3d_color color; - - wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_AMBIENT]); - GL_EXTCALL(glUniform3fv(prog->vs.light_ambient_location, 1, &color.r)); - checkGLcall("glUniform3fv"); -} - static void shader_glsl_ffp_vertex_light_uniform(const struct wined3d_context_gl *context_gl, const struct wined3d_state *state, unsigned int light, const struct wined3d_light_info *light_info, struct glsl_shader_prog_link *prog) @@ -1780,10 +1769,13 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, if (update_mask & WINED3D_SHADER_CONST_FFP_LIGHTS) { unsigned int point_idx, spot_idx, directional_idx, parallel_point_idx; + const struct wined3d_ffp_vs_constants *constants; DWORD point_count = 0; DWORD spot_count = 0; DWORD directional_count = 0;
+ constants = wined3d_buffer_load_sysmem(context->device->push_constants[WINED3D_PUSH_CONSTANTS_VS_FFP], context); + for (i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i) { if (!state->light_state.lights[i]) @@ -1812,7 +1804,9 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, directional_idx = spot_idx + spot_count; parallel_point_idx = directional_idx + directional_count;
- shader_glsl_ffp_vertex_lightambient_uniform(context_gl, state, prog); + GL_EXTCALL(glUniform3fv(prog->vs.light_ambient_location, 1, &constants->light.ambient.r)); + checkGLcall("glUniform3fv"); + for (i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i) { const struct wined3d_light_info *light_info = state->light_state.lights[i]; @@ -12066,7 +12060,6 @@ static const struct wined3d_state_entry_template glsl_vertex_pipe_vp_states[] = {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_LIGHTING), {STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), NULL }, WINED3D_GL_EXT_NONE }, - {STATE_RENDER(WINED3D_RS_AMBIENT), {STATE_RENDER(WINED3D_RS_AMBIENT), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_COLORVERTEX), {STATE_RENDER(WINED3D_RS_COLORVERTEX), glsl_vertex_pipe_shader}, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_LOCALVIEWER), {STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), NULL }, WINED3D_GL_EXT_NONE }, {STATE_RENDER(WINED3D_RS_NORMALIZENORMALS), {STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX), NULL }, WINED3D_GL_EXT_NONE }, diff --git a/dlls/wined3d/shader_spirv.c b/dlls/wined3d/shader_spirv.c index dc1c3a13131..a4b311ae8d2 100644 --- a/dlls/wined3d/shader_spirv.c +++ b/dlls/wined3d/shader_spirv.c @@ -1160,7 +1160,6 @@ static const struct wined3d_state_entry_template spirv_vertex_pipe_vk_vp_states[ {STATE_RENDER(WINED3D_RS_RANGEFOGENABLE), {STATE_RENDER(WINED3D_RS_RANGEFOGENABLE), state_nop}}, {STATE_RENDER(WINED3D_RS_CLIPPING), {STATE_RENDER(WINED3D_RS_CLIPPING), state_nop}}, {STATE_RENDER(WINED3D_RS_LIGHTING), {STATE_RENDER(WINED3D_RS_LIGHTING), state_nop}}, - {STATE_RENDER(WINED3D_RS_AMBIENT), {STATE_RENDER(WINED3D_RS_AMBIENT), state_nop}}, {STATE_RENDER(WINED3D_RS_COLORVERTEX), {STATE_RENDER(WINED3D_RS_COLORVERTEX), state_nop}}, {STATE_RENDER(WINED3D_RS_LOCALVIEWER), {STATE_RENDER(WINED3D_RS_LOCALVIEWER), state_nop}}, {STATE_RENDER(WINED3D_RS_NORMALIZENORMALS), {STATE_RENDER(WINED3D_RS_NORMALIZENORMALS), state_nop}}, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 11276ffd419..548bf9aa477 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -2200,6 +2200,7 @@ static void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state static void wined3d_stateblock_invalidate_push_constants(struct wined3d_stateblock *stateblock) { stateblock->changed.ffp_ps_constants = 1; + stateblock->changed.lights = 1; }
static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state, @@ -2682,8 +2683,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, bool set_blend_state = false, set_depth_stencil_state = false, set_rasterizer_state = false;
const struct wined3d_stateblock_state *state = &stateblock->stateblock_state; - const struct wined3d_saved_states *changed = &stateblock->changed; const unsigned int word_bit_count = sizeof(DWORD) * CHAR_BIT; + struct wined3d_saved_states *changed = &stateblock->changed; struct wined3d_device_context *context = &device->cs->c; unsigned int i, j, start, idx; bool set_depth_bounds = false; @@ -2810,6 +2811,10 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, set_depth_bounds = true; break;
+ case WINED3D_RS_AMBIENT: + changed->lights = 1; + break; + case WINED3D_RS_ADAPTIVETESS_Y: case WINED3D_RS_TEXTUREFACTOR: break; @@ -3326,6 +3331,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if (changed->lights) { + struct wined3d_ffp_light_constants constants; struct wined3d_light_info *light, *cursor;
LIST_FOR_EACH_ENTRY_SAFE(light, cursor, &changed->changed_lights, struct wined3d_light_info, changed_entry) @@ -3335,6 +3341,10 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, list_remove(&light->changed_entry); light->changed = false; } + + wined3d_color_from_d3dcolor(&constants.ambient, state->rs[WINED3D_RS_AMBIENT]); + wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_SHADER_CONST_FFP_LIGHTS, + offsetof(struct wined3d_ffp_vs_constants, light), sizeof(constants), &constants); }
if (changed->ffp_ps_constants) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f6adc96887d..9ad1d0f8ba5 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2764,6 +2764,14 @@ BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size); * i.e. only used when shaders are disabled. */
+struct wined3d_ffp_vs_constants +{ + struct wined3d_ffp_light_constants + { + struct wined3d_color ambient; + } light; +}; + struct wined3d_ffp_ps_constants { struct wined3d_color texture_constants[WINED3D_MAX_FFP_TEXTURES]; @@ -2782,6 +2790,7 @@ enum wined3d_push_constants WINED3D_PUSH_CONSTANTS_PS_I, WINED3D_PUSH_CONSTANTS_VS_B, WINED3D_PUSH_CONSTANTS_PS_B, + WINED3D_PUSH_CONSTANTS_VS_FFP, WINED3D_PUSH_CONSTANTS_PS_FFP, WINED3D_PUSH_CONSTANTS_COUNT, };
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=146632
Your paranoid android.
=== debian11b (64 bit WoW report) ===
ddraw: ddraw2.c:9801: Test failed: Got unexpected color 0x000000ff. ddraw2.c:9805: Test failed: Got unexpected color 0x00000080. ddraw4.c:11358: Test failed: Got unexpected color 0x000000ff. ddraw4.c:11362: Test failed: Got unexpected color 0x00000080.
kernel32: comm.c:1574: Test failed: AbortWaitCts hComPortEvent failed comm.c:1586: Test failed: Unexpected time 1001, expected around 500