From: Jesse Natalie Date: Mon, 11 May 2020 16:09:47 +0000 (-0700) Subject: nir/vtn: Add intrinsics for CL image format/order queries X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=397730edd5bac440853af8018dda76e0807bc51c;p=mesa.git nir/vtn: Add intrinsics for CL image format/order queries Reviewed-by: Jason Ekstrand Part-of: --- diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index 546428eeef3..73a5bce6a27 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -411,6 +411,9 @@ image("size", dest_comp=0, src_comp=[1], flags=[CAN_ELIMINATE, CAN_REORDER]) image("samples", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER]) image("atomic_inc_wrap", src_comp=[4, 1, 1], dest_comp=1) image("atomic_dec_wrap", src_comp=[4, 1, 1], dest_comp=1) +# CL-specific format queries +image("format", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER]) +image("order", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER]) # Vulkan descriptor set intrinsics # diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index dfe325e8989..a2e132bda5c 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -3016,6 +3016,15 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode, image.lod = NULL; break; + case SpvOpImageQueryFormat: + case SpvOpImageQueryOrder: + res_val = vtn_untyped_value(b, w[3]); + image.image = vtn_get_image(b, w[3]); + image.coord = NULL; + image.sample = NULL; + image.lod = NULL; + break; + case SpvOpImageRead: { res_val = vtn_untyped_value(b, w[3]); image.image = vtn_get_image(b, w[3]); @@ -3122,6 +3131,8 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode, OP(AtomicOr, atomic_or) OP(AtomicXor, atomic_xor) OP(AtomicFAddEXT, atomic_fadd) + OP(ImageQueryFormat, format) + OP(ImageQueryOrder, order) #undef OP default: vtn_fail_with_opcode("Invalid image opcode", opcode); @@ -3131,13 +3142,19 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode, intrin->src[0] = nir_src_for_ssa(&image.image->dest.ssa); - /* size doesn't take non-lod coordinate parameters */ - if (opcode != SpvOpImageQuerySize && opcode != SpvOpImageQuerySizeLod) { + switch (opcode) { + case SpvOpImageQuerySize: + case SpvOpImageQuerySizeLod: + case SpvOpImageQueryFormat: + case SpvOpImageQueryOrder: + break; + default: /* The image coordinate is always 4 components but we may not have that * many. Swizzle to compensate. */ intrin->src[1] = nir_src_for_ssa(expand_to_vec4(&b->nb, image.coord)); intrin->src[2] = nir_src_for_ssa(image.sample); + break; } /* The Vulkan spec says: @@ -3157,6 +3174,10 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode, nir_intrinsic_set_access(intrin, access); switch (opcode) { + case SpvOpImageQueryFormat: + case SpvOpImageQueryOrder: + /* No additional sources */ + break; case SpvOpImageQuerySize: intrin->src[1] = nir_src_for_ssa(nir_imm_int(&b->nb, 0)); break; @@ -5087,6 +5108,8 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode, case SpvOpImageRead: case SpvOpImageWrite: case SpvOpImageTexelPointer: + case SpvOpImageQueryFormat: + case SpvOpImageQueryOrder: vtn_handle_image(b, opcode, w, count); break;