mesa: add _mesa_lookup_state_param_idx() helper

This will be used in the following patch.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
(cherry picked from commit c3aae0714c)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39969>
This commit is contained in:
Timothy Arceri 2026-02-13 09:56:31 +11:00 committed by Dylan Baker
parent fddb690f53
commit 735d581f7b
3 changed files with 23 additions and 9 deletions

View file

@ -1184,7 +1184,7 @@
"description": "mesa: add _mesa_lookup_state_param_idx() helper",
"nominated": false,
"nomination_type": 0,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -422,15 +422,10 @@ _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
}
GLint
_mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList,
const gl_state_index16 stateTokens[STATE_LENGTH],
const unsigned size, bool pad_and_align)
_mesa_lookup_state_param_idx(struct gl_program_parameter_list *paramList,
const gl_state_index16 stateTokens[STATE_LENGTH])
{
char *name;
GLint index;
/* Check if the state reference is already in the list */
for (index = 0; index < (GLint) paramList->NumParameters; index++) {
for (GLint index = 0; index < (GLint) paramList->NumParameters; index++) {
if (!memcmp(paramList->Parameters[index].StateIndexes,
stateTokens,
sizeof(paramList->Parameters[index].StateIndexes))) {
@ -438,6 +433,21 @@ _mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList,
}
}
return -1;
}
GLint
_mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList,
const gl_state_index16 stateTokens[STATE_LENGTH],
const unsigned size, bool pad_and_align)
{
char *name;
/* Check if the state reference is already in the list */
GLint index = _mesa_lookup_state_param_idx(paramList, stateTokens);
if (index >= 0)
return index;
name = _mesa_program_state_string(stateTokens);
index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
size, GL_NONE, NULL, stateTokens,

View file

@ -188,6 +188,10 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
swizzleOut);
}
extern GLint
_mesa_lookup_state_param_idx(struct gl_program_parameter_list *paramList,
const gl_state_index16 stateTokens[STATE_LENGTH]);
extern GLint
_mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList,
const gl_state_index16 stateTokens[STATE_LENGTH],