mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 16:30:10 +01:00
mesa: refactor GetFragDataLocation
Use program_resource_location to fetch location. Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
This commit is contained in:
parent
3d1544cc91
commit
62057c77f1
1 changed files with 16 additions and 22 deletions
|
|
@ -484,31 +484,25 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
|
|||
if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)
|
||||
return -1;
|
||||
|
||||
exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir;
|
||||
foreach_in_list(ir_instruction, node, ir) {
|
||||
const ir_variable *const var = node->as_variable();
|
||||
struct gl_program_resource *res =
|
||||
_mesa_program_resource_find_name(shProg, GL_PROGRAM_OUTPUT, name);
|
||||
|
||||
/* The extra check against FRAG_RESULT_DATA0 is because
|
||||
* glGetFragDataLocation cannot be used on "conventional" attributes.
|
||||
*
|
||||
* From page 95 of the OpenGL 3.0 spec:
|
||||
*
|
||||
* "If name is not an active attribute, if name is a conventional
|
||||
* attribute, or if an error occurs, -1 will be returned."
|
||||
*/
|
||||
if (var == NULL
|
||||
|| var->data.mode != ir_var_shader_out
|
||||
|| var->data.location == -1
|
||||
|| var->data.location < FRAG_RESULT_DATA0)
|
||||
continue;
|
||||
if (!res)
|
||||
return -1;
|
||||
|
||||
int index = get_matching_index(var, (const char *) name);
|
||||
GLint loc = program_resource_location(shProg, res, name);
|
||||
|
||||
if (index >= 0)
|
||||
return var->data.location + index - FRAG_RESULT_DATA0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
/* The extra check against against 0 is made because of builtin-attribute
|
||||
* locations that have offset applied. Function program_resource_location
|
||||
* can return built-in attribute locations < 0 and glGetFragDataLocation
|
||||
* cannot be used on "conventional" attributes.
|
||||
*
|
||||
* From page 95 of the OpenGL 3.0 spec:
|
||||
*
|
||||
* "If name is not an active attribute, if name is a conventional
|
||||
* attribute, or if an error occurs, -1 will be returned."
|
||||
*/
|
||||
return (loc >= 0) ? loc : -1;
|
||||
}
|
||||
|
||||
const char*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue