mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 02:20:11 +01:00
glsl: add AoA support to subroutines
process_parameters() will now be called earlier because we need actual_parameters processed earlier so we can use it with match_subroutine_by_name() to get the subroutine variable, we need to do this inside the recursive function generate_array_index() because we can't create the ir_dereference_array() until we have gotten to the outermost array. For the remainder of the array dimensions the type doesn't matter so we can just use the existing _mesa_ast_array_index_to_hir() function to process the ast. Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
a59c1adcc6
commit
fd01840c0b
2 changed files with 39 additions and 6 deletions
|
|
@ -610,6 +610,37 @@ match_subroutine_by_name(const char *name,
|
|||
return sig;
|
||||
}
|
||||
|
||||
static ir_rvalue *
|
||||
generate_array_index(void *mem_ctx, exec_list *instructions,
|
||||
struct _mesa_glsl_parse_state *state, YYLTYPE loc,
|
||||
const ast_expression *array, ast_expression *idx,
|
||||
const char **function_name, exec_list *actual_parameters)
|
||||
{
|
||||
if (array->oper == ast_array_index) {
|
||||
/* This handles arrays of arrays */
|
||||
ir_rvalue *outer_array = generate_array_index(mem_ctx, instructions,
|
||||
state, loc,
|
||||
array->subexpressions[0],
|
||||
array->subexpressions[1],
|
||||
function_name, actual_parameters);
|
||||
ir_rvalue *outer_array_idx = idx->hir(instructions, state);
|
||||
|
||||
YYLTYPE index_loc = idx->get_location();
|
||||
return _mesa_ast_array_index_to_hir(mem_ctx, state, outer_array,
|
||||
outer_array_idx, loc,
|
||||
index_loc);
|
||||
} else {
|
||||
ir_variable *sub_var = NULL;
|
||||
*function_name = array->primary_expression.identifier;
|
||||
|
||||
match_subroutine_by_name(*function_name, actual_parameters,
|
||||
state, &sub_var);
|
||||
|
||||
ir_rvalue *outer_array_idx = idx->hir(instructions, state);
|
||||
return new(mem_ctx) ir_dereference_array(sub_var, outer_array_idx);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_function_prototypes(_mesa_glsl_parse_state *state, YYLTYPE *loc,
|
||||
ir_function *f)
|
||||
|
|
@ -1989,16 +2020,18 @@ ast_function_expression::hir(exec_list *instructions,
|
|||
ir_variable *sub_var = NULL;
|
||||
ir_rvalue *array_idx = NULL;
|
||||
|
||||
process_parameters(instructions, &actual_parameters, &this->expressions,
|
||||
state);
|
||||
|
||||
if (id->oper == ast_array_index) {
|
||||
func_name = id->subexpressions[0]->primary_expression.identifier;
|
||||
array_idx = id->subexpressions[1]->hir(instructions, state);
|
||||
array_idx = generate_array_index(ctx, instructions, state, loc,
|
||||
id->subexpressions[0],
|
||||
id->subexpressions[1], &func_name,
|
||||
&actual_parameters);
|
||||
} else {
|
||||
func_name = id->primary_expression.identifier;
|
||||
}
|
||||
|
||||
process_parameters(instructions, &actual_parameters, &this->expressions,
|
||||
state);
|
||||
|
||||
ir_function_signature *sig =
|
||||
match_function_by_name(func_name, &actual_parameters, state);
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ lower_subroutine_visitor::visit_leave(ir_call *ir)
|
|||
continue;
|
||||
|
||||
if (ir->array_idx != NULL)
|
||||
var = new(mem_ctx) ir_dereference_array(ir->sub_var, ir->array_idx->clone(mem_ctx, NULL));
|
||||
var = ir->array_idx->clone(mem_ctx, NULL);
|
||||
else
|
||||
var = new(mem_ctx) ir_dereference_variable(ir->sub_var);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue