Fixes geometry shaders when ARB_viewport_array is not available.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/glsl_shader.c | 16 +++++++++------- dlls/wined3d/shader.c | 4 ++++ dlls/wined3d/wined3d_private.h | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 56f7968be6d5..e29730cce24b 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5152,11 +5152,11 @@ static void shader_glsl_else(const struct wined3d_shader_instruction *ins) static void shader_glsl_emit(const struct wined3d_shader_instruction *ins) { unsigned int stream = ins->handler_idx == WINED3DSIH_EMIT ? 0 : ins->src[0].reg.idx[0].offset; + const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
- shader_addline(ins->ctx->buffer, "gl_ViewportIndex = 0;\n"); shader_addline(ins->ctx->buffer, "setup_gs_output(gs_out);\n"); if (!ins->ctx->gl_info->supported[ARB_CLIP_CONTROL]) - shader_glsl_fixup_position(ins->ctx->buffer, TRUE); + shader_glsl_fixup_position(ins->ctx->buffer, reg_maps->viewport_array);
if (!stream) shader_addline(ins->ctx->buffer, "EmitVertex();\n"); @@ -8244,7 +8244,12 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context shader_addline(buffer, "in shader_in_out { vec4 reg[%u]; } shader_in[];\n", shader->limits->packed_input);
if (!gl_info->supported[ARB_CLIP_CONTROL]) - shader_addline(buffer, "uniform vec4 pos_fixup[%u];\n", WINED3D_MAX_VIEWPORTS); + { + shader_addline(buffer, "uniform vec4 pos_fixup"); + if (reg_maps->viewport_array) + shader_addline(buffer, "[%u]", WINED3D_MAX_VIEWPORTS); + shader_addline(buffer, ";\n"); + }
if (is_rasterization_disabled(shader)) { @@ -8274,10 +8279,7 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context } shader_addline(buffer, "setup_gs_output(gs_out);\n"); if (!gl_info->supported[ARB_CLIP_CONTROL]) - { - shader_addline(buffer, "gl_ViewportIndex = 0;\n"); - shader_glsl_fixup_position(buffer, TRUE); - } + shader_glsl_fixup_position(buffer, FALSE); shader_addline(buffer, "EmitVertex();\n"); } } diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 07e810cc2dde..b757d930da88 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1807,6 +1807,10 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st return hr; reg_maps->cull_distance_mask |= mask; } + else if (e->sysval_semantic == WINED3D_SV_VIEWPORT_ARRAY_INDEX) + { + reg_maps->viewport_array = 1; + } } } else if (reg_maps->output_registers) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 55abee4225ba..ca392e25f843 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1030,7 +1030,8 @@ struct wined3d_shader_reg_maps DWORD point_size : 1; DWORD vocp : 1; DWORD input_rel_addressing : 1; - DWORD padding : 16; + DWORD viewport_array : 1; + DWORD padding : 15;
DWORD rt_mask; /* Used render targets, 32 max. */