svga: Check float type when emitting atomic instructions

When translating atomic instructions, the base type of the imageView can be
float only for image_atomic_exchange. If a float type image is used with other
atomic instructions the results are undefined.
Enforce this check in the shader translator and don't emit any instruction if
it fails.
Fixes crash in piglit test arb_shader_image_load_store@invalid.

Signed-off-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33749>
This commit is contained in:
Maaz Mombasawala 2025-02-19 15:14:52 -08:00 committed by Marge Bot
parent 3da0774be1
commit f04287c0be

View file

@ -10793,6 +10793,17 @@ emit_atomic(struct svga_shader_emitter_v10 *emit,
emit->cur_atomic_opcode = opcode;
/* Float types are only supported for image atomic exchange instruction,
* if this check fails then don't emit any intruction.
*/
if (resourceType == TGSI_FILE_IMAGE &&
emit->key.images[resourceIndex].return_type == VGPU10_RETURN_TYPE_FLOAT &&
opcode != VGPU10_OPCODE_IMM_ATOMIC_EXCH) {
debug_printf("Unexpected atomic TGSI opcode %s with float type image.",
tgsi_get_opcode_name(inst->Instruction.Opcode));
return true;
}
/* If the resource register has indirect index, we will need
* to expand it since SM5 device does not support indirect indexing
* for uav.