mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
mesa: remove now unused subscript validations
Cc: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
This commit is contained in:
parent
8cd2f88845
commit
7f5f7d15fb
2 changed files with 0 additions and 108 deletions
|
|
@ -203,27 +203,6 @@ is_xfb_marker(const char *str)
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if given name index is legal for GetProgramResourceIndex,
|
||||
* check is written to be compatible with GL_ARB_array_of_arrays.
|
||||
*/
|
||||
static bool
|
||||
valid_program_resource_index_name(const GLchar *name)
|
||||
{
|
||||
const char *array = strstr(name, "[");
|
||||
const char *close = strrchr(name, ']');
|
||||
|
||||
/* Not array, no need for the check. */
|
||||
if (!array)
|
||||
return true;
|
||||
|
||||
/* Last array index has to be zero. */
|
||||
if (!close || *--close != '0')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GLuint GLAPIENTRY
|
||||
_mesa_GetProgramResourceIndex(GLuint program, GLenum programInterface,
|
||||
const GLchar *name)
|
||||
|
|
@ -345,36 +324,6 @@ _mesa_GetProgramResourceiv(GLuint program, GLenum programInterface,
|
|||
propCount, props, bufSize, length, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function verifies syntax of given name for GetProgramResourceLocation
|
||||
* and GetProgramResourceLocationIndex for the following cases:
|
||||
*
|
||||
* "array element portion of a string passed to GetProgramResourceLocation
|
||||
* or GetProgramResourceLocationIndex must not have, a "+" sign, extra
|
||||
* leading zeroes, or whitespace".
|
||||
*
|
||||
* Check is written to be compatible with GL_ARB_array_of_arrays.
|
||||
*/
|
||||
static bool
|
||||
invalid_array_element_syntax(const GLchar *name)
|
||||
{
|
||||
char *first = strchr(name, '[');
|
||||
char *last = strrchr(name, '[');
|
||||
|
||||
if (!first)
|
||||
return false;
|
||||
|
||||
/* No '+' or ' ' allowed anywhere. */
|
||||
if (strchr(first, '+') || strchr(first, ' '))
|
||||
return true;
|
||||
|
||||
/* Check that last array index is 0. */
|
||||
if (last[1] == '0' && last[2] != ']')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct gl_shader_program *
|
||||
lookup_linked_program(GLuint program, const char *caller)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -191,63 +191,6 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
|
|||
(GLint *) type, "glGetActiveAttrib");
|
||||
}
|
||||
|
||||
/* Locations associated with shader variables (array or non-array) can be
|
||||
* queried using its base name or using the base name appended with the
|
||||
* valid array index. For example, in case of below vertex shader, valid
|
||||
* queries can be made to know the location of "xyz", "array", "array[0]",
|
||||
* "array[1]", "array[2]" and "array[3]". In this example index reurned
|
||||
* will be 0, 0, 0, 1, 2, 3 respectively.
|
||||
*
|
||||
* [Vertex Shader]
|
||||
* layout(location=0) in vec4 xyz;
|
||||
* layout(location=1) in vec4[4] array;
|
||||
* void main()
|
||||
* { }
|
||||
*
|
||||
* This requirement came up with the addition of ARB_program_interface_query
|
||||
* to OpenGL 4.3 specification. See page 101 (page 122 of the PDF) for details.
|
||||
*
|
||||
* This utility function is used by:
|
||||
* _mesa_GetAttribLocation
|
||||
* _mesa_GetFragDataLocation
|
||||
* _mesa_GetFragDataIndex
|
||||
*
|
||||
* Returns 0:
|
||||
* if the 'name' string matches var->name.
|
||||
* Returns 'matched index':
|
||||
* if the 'name' string matches var->name appended with valid array index.
|
||||
*/
|
||||
int static inline
|
||||
get_matching_index(const ir_variable *const var, const char *name) {
|
||||
unsigned idx = 0;
|
||||
const char *const paren = strchr(name, '[');
|
||||
const unsigned len = (paren != NULL) ? paren - name : strlen(name);
|
||||
|
||||
if (paren != NULL) {
|
||||
if (!var->type->is_array())
|
||||
return -1;
|
||||
|
||||
char *endptr;
|
||||
idx = (unsigned) strtol(paren + 1, &endptr, 10);
|
||||
const unsigned idx_len = endptr != (paren + 1) ? endptr - paren - 1 : 0;
|
||||
|
||||
/* Validate the sub string representing index in 'name' string */
|
||||
if ((idx > 0 && paren[1] == '0') /* leading zeroes */
|
||||
|| (idx == 0 && idx_len > 1) /* all zeroes */
|
||||
|| paren[1] == ' ' /* whitespace */
|
||||
|| endptr[0] != ']' /* closing brace */
|
||||
|| endptr[1] != '\0' /* null char */
|
||||
|| idx_len == 0 /* missing index */
|
||||
|| idx >= var->type->length) /* exceeding array bound */
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strncmp(var->name, name, len) == 0 && var->name[len] == '\0')
|
||||
return idx;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
GLint GLAPIENTRY
|
||||
_mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue