compiler/spirv: fix image sample queries

this was only implemented for textures (I assume because drivers which implement
the corresponding intrinsic don't support multisampled images), but it's also
used for shader images

Fixes: 22fdb2f855 ("nir/spirv: Update to the latest revision")

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9682>
This commit is contained in:
Mike Blumenkrantz 2021-03-18 09:47:54 -04:00 committed by Marge Bot
parent 861c6a86dc
commit 50881d59e6

View file

@ -3147,6 +3147,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
break; break;
case SpvOpImageQuerySize: case SpvOpImageQuerySize:
case SpvOpImageQuerySamples:
res_val = vtn_untyped_value(b, w[3]); res_val = vtn_untyped_value(b, w[3]);
image.image = vtn_get_image(b, w[3], &access); image.image = vtn_get_image(b, w[3], &access);
image.coord = NULL; image.coord = NULL;
@ -3280,6 +3281,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
OP(AtomicFMaxEXT, atomic_fmax) OP(AtomicFMaxEXT, atomic_fmax)
OP(ImageQueryFormat, format) OP(ImageQueryFormat, format)
OP(ImageQueryOrder, order) OP(ImageQueryOrder, order)
OP(ImageQuerySamples, samples)
#undef OP #undef OP
default: default:
vtn_fail_with_opcode("Invalid image opcode", opcode); vtn_fail_with_opcode("Invalid image opcode", opcode);
@ -3290,6 +3292,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
intrin->src[0] = nir_src_for_ssa(&image.image->dest.ssa); intrin->src[0] = nir_src_for_ssa(&image.image->dest.ssa);
switch (opcode) { switch (opcode) {
case SpvOpImageQuerySamples:
case SpvOpImageQuerySize: case SpvOpImageQuerySize:
case SpvOpImageQuerySizeLod: case SpvOpImageQuerySizeLod:
case SpvOpImageQueryFormat: case SpvOpImageQueryFormat:
@ -3321,6 +3324,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
nir_intrinsic_set_access(intrin, access); nir_intrinsic_set_access(intrin, access);
switch (opcode) { switch (opcode) {
case SpvOpImageQuerySamples:
case SpvOpImageQueryFormat: case SpvOpImageQueryFormat:
case SpvOpImageQueryOrder: case SpvOpImageQueryOrder:
/* No additional sources */ /* No additional sources */
@ -5359,7 +5363,6 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
case SpvOpImageSparseDrefGather: case SpvOpImageSparseDrefGather:
case SpvOpImageQueryLod: case SpvOpImageQueryLod:
case SpvOpImageQueryLevels: case SpvOpImageQueryLevels:
case SpvOpImageQuerySamples:
vtn_handle_texture(b, opcode, w, count); vtn_handle_texture(b, opcode, w, count);
break; break;
@ -5372,6 +5375,7 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
vtn_handle_image(b, opcode, w, count); vtn_handle_image(b, opcode, w, count);
break; break;
case SpvOpImageQuerySamples:
case SpvOpImageQuerySizeLod: case SpvOpImageQuerySizeLod:
case SpvOpImageQuerySize: { case SpvOpImageQuerySize: {
struct vtn_type *image_type = vtn_get_value_type(b, w[3]); struct vtn_type *image_type = vtn_get_value_type(b, w[3]);