From 4cfa13c5335b06d1c877994d9309da7a984498cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B3zef=20Kucia?= Date: Tue, 7 Nov 2017 14:29:17 +0100 Subject: [PATCH] wined3d: Invalidate pixel shader only when rasterization is toggled. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/drawprim.c | 2 +- dlls/wined3d/glsl_shader.c | 16 +++++++++++----- dlls/wined3d/wined3d_private.h | 6 ++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 99f3ce22e16..95e79f777ac 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -648,7 +648,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s { const struct wined3d_shader *shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]; - if (shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM) + if (is_rasterization_disabled(shader)) { glEnable(GL_RASTERIZER_DISCARD); checkGLcall("enable rasterizer discard"); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 6d0e6a19ef9..0ff9ee44bb2 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -266,6 +266,7 @@ struct glsl_context_data { struct glsl_shader_prog_link *glsl_program; GLenum vertex_color_clamp; + BOOL rasterization_disabled; }; struct glsl_ps_compiled_shader @@ -8062,7 +8063,6 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context struct shader_glsl_priv *priv, const struct wined3d_shader *shader, const struct gs_compile_args *args) { struct wined3d_string_buffer_list *string_buffers = &priv->string_buffers; - const struct wined3d_stream_output_desc *so_desc = &shader->u.gs.so_desc; const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps; struct wined3d_string_buffer *buffer = &priv->shader_buffer; const struct wined3d_gl_info *gl_info = context->gl_info; @@ -8089,9 +8089,9 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context if (!gl_info->supported[ARB_CLIP_CONTROL]) shader_addline(buffer, "uniform vec4 pos_fixup;\n"); - if (so_desc->rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM) + if (is_rasterization_disabled(shader)) { - shader_glsl_generate_stream_output_setup(priv, shader, so_desc); + shader_glsl_generate_stream_output_setup(priv, shader, &shader->u.gs.so_desc); } else { @@ -10013,7 +10013,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const } /* A pixel shader is not used when rasterization is disabled. */ - if (gshader && gshader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM) + if (is_rasterization_disabled(gshader)) { ps_id = 0; ps_list = NULL; @@ -11366,7 +11366,13 @@ static void glsl_vertex_pipe_hs(struct wined3d_context *context, static void glsl_vertex_pipe_geometry_shader(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL; + struct glsl_context_data *ctx_data = context->shader_backend_data; + BOOL rasterization_disabled; + + rasterization_disabled = is_rasterization_disabled(state->shader[WINED3D_SHADER_TYPE_GEOMETRY]); + if (ctx_data->rasterization_disabled != rasterization_disabled) + context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL; + ctx_data->rasterization_disabled = rasterization_disabled; if (state->shader[WINED3D_SHADER_TYPE_DOMAIN]) context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_DOMAIN; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 31d83c76c16..5368be44015 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4325,6 +4325,12 @@ static inline BOOL needs_interpolation_qualifiers_for_shader_outputs(const struc return gl_info->glsl_version < MAKEDWORD_VERSION(4, 40); } +static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader) +{ + return geometry_shader + && geometry_shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM; +} + static inline DWORD wined3d_extract_bits(const DWORD *bitstream, unsigned int offset, unsigned int count) { -- 2.11.4.GIT