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; }