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 <kenneth@whitecape.org> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
This commit is contained in:
@@ -3503,12 +3503,20 @@ create_shader_variable(struct gl_shader_program *shProg, const ir_variable *in)
|
|||||||
if (!out)
|
if (!out)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
out->type = in->type;
|
/* Since gl_VertexID may be lowered to gl_VertexIDMESA, but applications
|
||||||
out->name = ralloc_strdup(shProg, in->name);
|
* 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)
|
if (!out->name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
out->type = in->type;
|
||||||
out->location = in->data.location;
|
out->location = in->data.location;
|
||||||
out->index = in->data.index;
|
out->index = in->data.index;
|
||||||
out->patch = in->data.patch;
|
out->patch = in->data.patch;
|
||||||
|
@@ -164,15 +164,6 @@ _mesa_GetActiveAttrib(GLuint program, GLuint desired_index,
|
|||||||
|
|
||||||
const char *var_name = var->name;
|
const char *var_name = var->name;
|
||||||
|
|
||||||
/* Since gl_VertexID may be lowered to gl_VertexIDMESA, we need to
|
|
||||||
* consider gl_VertexIDMESA as gl_VertexID for purposes of checking
|
|
||||||
* active attributes.
|
|
||||||
*/
|
|
||||||
if (var->mode == ir_var_system_value &&
|
|
||||||
var->location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
|
|
||||||
var_name = "gl_VertexID";
|
|
||||||
}
|
|
||||||
|
|
||||||
_mesa_copy_string(name, maxLength, length, var_name);
|
_mesa_copy_string(name, maxLength, length, var_name);
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
@@ -421,7 +412,6 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
|
|||||||
const char*
|
const char*
|
||||||
_mesa_program_resource_name(struct gl_program_resource *res)
|
_mesa_program_resource_name(struct gl_program_resource *res)
|
||||||
{
|
{
|
||||||
const gl_shader_variable *var;
|
|
||||||
switch (res->Type) {
|
switch (res->Type) {
|
||||||
case GL_UNIFORM_BLOCK:
|
case GL_UNIFORM_BLOCK:
|
||||||
case GL_SHADER_STORAGE_BLOCK:
|
case GL_SHADER_STORAGE_BLOCK:
|
||||||
@@ -429,13 +419,6 @@ _mesa_program_resource_name(struct gl_program_resource *res)
|
|||||||
case GL_TRANSFORM_FEEDBACK_VARYING:
|
case GL_TRANSFORM_FEEDBACK_VARYING:
|
||||||
return RESOURCE_XFV(res)->Name;
|
return RESOURCE_XFV(res)->Name;
|
||||||
case GL_PROGRAM_INPUT:
|
case GL_PROGRAM_INPUT:
|
||||||
var = RESOURCE_VAR(res);
|
|
||||||
/* Special case gl_VertexIDMESA -> gl_VertexID. */
|
|
||||||
if (var->mode == ir_var_system_value &&
|
|
||||||
var->location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
|
|
||||||
return "gl_VertexID";
|
|
||||||
}
|
|
||||||
/* fallthrough */
|
|
||||||
case GL_PROGRAM_OUTPUT:
|
case GL_PROGRAM_OUTPUT:
|
||||||
return RESOURCE_VAR(res)->name;
|
return RESOURCE_VAR(res)->name;
|
||||||
case GL_UNIFORM:
|
case GL_UNIFORM:
|
||||||
|
Reference in New Issue
Block a user