Commit 3702e2bc authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Avoid using gl_ViewportIndex unnecessarily.

Fixes geometry shaders when ARB_viewport_array is not available. Signed-off-by: 's avatarJózef Kucia <jkucia@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent ca8e0515
...@@ -5152,11 +5152,11 @@ static void shader_glsl_else(const struct wined3d_shader_instruction *ins) ...@@ -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) 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; 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"); shader_addline(ins->ctx->buffer, "setup_gs_output(gs_out);\n");
if (!ins->ctx->gl_info->supported[ARB_CLIP_CONTROL]) 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) if (!stream)
shader_addline(ins->ctx->buffer, "EmitVertex();\n"); shader_addline(ins->ctx->buffer, "EmitVertex();\n");
...@@ -8244,7 +8244,12 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context ...@@ -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); shader_addline(buffer, "in shader_in_out { vec4 reg[%u]; } shader_in[];\n", shader->limits->packed_input);
if (!gl_info->supported[ARB_CLIP_CONTROL]) 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)) if (is_rasterization_disabled(shader))
{ {
...@@ -8274,10 +8279,7 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context ...@@ -8274,10 +8279,7 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context
} }
shader_addline(buffer, "setup_gs_output(gs_out);\n"); shader_addline(buffer, "setup_gs_output(gs_out);\n");
if (!gl_info->supported[ARB_CLIP_CONTROL]) if (!gl_info->supported[ARB_CLIP_CONTROL])
{ shader_glsl_fixup_position(buffer, FALSE);
shader_addline(buffer, "gl_ViewportIndex = 0;\n");
shader_glsl_fixup_position(buffer, TRUE);
}
shader_addline(buffer, "EmitVertex();\n"); shader_addline(buffer, "EmitVertex();\n");
} }
} }
......
...@@ -1807,6 +1807,10 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st ...@@ -1807,6 +1807,10 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
return hr; return hr;
reg_maps->cull_distance_mask |= mask; 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) else if (reg_maps->output_registers)
......
...@@ -1030,7 +1030,8 @@ struct wined3d_shader_reg_maps ...@@ -1030,7 +1030,8 @@ struct wined3d_shader_reg_maps
DWORD point_size : 1; DWORD point_size : 1;
DWORD vocp : 1; DWORD vocp : 1;
DWORD input_rel_addressing : 1; DWORD input_rel_addressing : 1;
DWORD padding : 16; DWORD viewport_array : 1;
DWORD padding : 15;
DWORD rt_mask; /* Used render targets, 32 max. */ DWORD rt_mask; /* Used render targets, 32 max. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment