glsl: always copy bindless sampler packing constructors to a temp

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11648
Fixes: 3cdcc5f02f ("glsl: implement ARB_bindless_texture conversions")

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30586>
(cherry picked from commit 3da4b5eaa5)
This commit is contained in:
Timothy Arceri 2024-08-09 16:30:22 +10:00 committed by Eric Engestrom
parent 5c903880f9
commit 946f5692f4
2 changed files with 19 additions and 1 deletions

View file

@ -1504,7 +1504,7 @@
"description": "glsl: always copy bindless sampler packing constructors to a temp",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "3cdcc5f02f39bd4dc78b88eb80bca4ac208f7f2f",
"notes": null

View file

@ -2395,6 +2395,24 @@ ast_function_expression::hir(exec_list *instructions,
ir_rvalue *result = convert_component(ir, desired_type);
/* If the bindless packing constructors are used directly as function
* params to bultin functions the compiler doesn't know what to do
* with them. To avoid this make sure we always copy the results from
* the pack to a temp first.
*/
if (result->as_expression() &&
result->as_expression()->operation == ir_unop_pack_sampler_2x32) {
ir_variable *var =
new(ctx) ir_variable(desired_type, "sampler_ctor",
ir_var_temporary);
instructions->push_tail(var);
ir_dereference *lhs = new(ctx) ir_dereference_variable(var);
ir_instruction *assignment = new(ctx) ir_assignment(lhs, result);
instructions->push_tail(assignment);
result = lhs;
}
/* Attempt to convert the parameter to a constant valued expression.
* After doing so, track whether or not all the parameters to the
* constructor are trivially constant valued expressions.