glsl_to_nir: upcast array indices
array indices need to match the pointer size, otherwise we fail NIR assertions. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6075 Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34016>
This commit is contained in:
committed by
Marge Bot
parent
1d5c42528b
commit
e5097a7c9d
@@ -2796,6 +2796,12 @@ nir_visitor::visit(ir_dereference_array *ir)
|
||||
{
|
||||
nir_def *index = evaluate_rvalue(ir->array_index);
|
||||
|
||||
/* In NIR, array indices must match the pointer size (32-bits for arrays),
|
||||
* but in GLSL IR, we might "optimize" the array index to a 16-bit integer.
|
||||
* We need to upcast in that case to keep the NIR valid.
|
||||
*/
|
||||
index = nir_i2iN(&b, index, this->deref->def.bit_size);
|
||||
|
||||
ir->array->accept(this);
|
||||
|
||||
this->deref = nir_build_deref_array(&b, this->deref, index);
|
||||
|
||||
Reference in New Issue
Block a user