mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-24 03:50:32 +01:00
asahi: Be robust with arrays of images
fixes imageLoad/index bounds test subcase. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26614>
This commit is contained in:
parent
b0f4b0a9ef
commit
0cd032e4bb
1 changed files with 14 additions and 0 deletions
|
|
@ -124,6 +124,16 @@ lower(nir_builder *b, nir_instr *instr, void *data)
|
|||
if (nir_intrinsic_has_atomic_op(intr))
|
||||
nir_intrinsic_set_atomic_op(intr, op);
|
||||
|
||||
/* The driver uploads enough null texture/PBE descriptors for robustness
|
||||
* given the shader limit, but we still need to clamp since we're lowering
|
||||
* to bindless so the hardware doesn't know the limit.
|
||||
*
|
||||
* The GL spec says out-of-bounds image indexing is undefined, but
|
||||
* faulting is not acceptable for robustness.
|
||||
*/
|
||||
index =
|
||||
nir_umin(b, index, nir_imm_int(b, b->shader->info.num_images - 1));
|
||||
|
||||
index = nir_iadd_imm(b, nir_imul_imm(b, index, 2), offset);
|
||||
nir_src_rewrite(&intr->src[0], nir_load_texture_handle_agx(b, index));
|
||||
} else if (instr->type == nir_instr_type_tex) {
|
||||
|
|
@ -153,6 +163,10 @@ lower(nir_builder *b, nir_instr *instr, void *data)
|
|||
if (!index)
|
||||
index = nir_imm_int(b, tex->texture_index);
|
||||
|
||||
/* As above */
|
||||
index =
|
||||
nir_umin(b, index, nir_imm_int(b, b->shader->info.num_textures - 1));
|
||||
|
||||
nir_tex_instr_add_src(tex, nir_tex_src_texture_handle,
|
||||
nir_load_texture_handle_agx(b, index));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue