From 9fe211bec4533bd5cebeb61b38343ae9c174abb7 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Mar 2016 13:32:32 -0700 Subject: glsl: Consolidate gl_VertexIDMESA -> gl_VertexID query hacks. A program will either have gl_VertexID or gl_VertexIDMESA (the lowered zero-based version), not both. Just spoof it in the resource list so the hacks are done in a single place. Signed-off-by: Kenneth Graunke Reviewed-by: Timothy Arceri --- src/compiler/glsl/linker.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/compiler/glsl') diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 064e7f5ca21..c0d310746f3 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -3503,12 +3503,20 @@ create_shader_variable(struct gl_shader_program *shProg, const ir_variable *in) if (!out) return NULL; - out->type = in->type; - out->name = ralloc_strdup(shProg, in->name); + /* Since gl_VertexID may be lowered to gl_VertexIDMESA, but applications + * expect to see gl_VertexID in the program resource list. Pretend. + */ + if (in->data.mode == ir_var_system_value && + in->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) { + out->name = ralloc_strdup(shProg, "gl_VertexID"); + } else { + out->name = ralloc_strdup(shProg, in->name); + } if (!out->name) return NULL; + out->type = in->type; out->location = in->data.location; out->index = in->data.index; out->patch = in->data.patch; -- cgit v1.2.3