vtn: set is_gather_implicit_lod
authorRhys Perry <pendingchaos02@gmail.com>
Fri, 31 Mar 2023 18:40:27 +0000 (19:40 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 18 Apr 2023 10:42:07 +0000 (10:42 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22315>

src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_private.h

index 5cb7691..9f2e91b 100644 (file)
@@ -3086,6 +3086,14 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
       is_shadow && glsl_get_components(ret_type->type) == 1;
    instr->component = gather_component;
 
+   /* If SpvCapabilityImageGatherBiasLodAMD is enabled, texture gather without an explicit LOD
+    * has an implicit one (instead of using level 0).
+    */
+   if (texop == nir_texop_tg4 && b->image_gather_bias_lod &&
+       !(operands & SpvImageOperandsLodMask)) {
+      instr->is_gather_implicit_lod = true;
+   }
+
    /* The Vulkan spec says:
     *
     *    "If an instruction loads from or stores to a resource (including
@@ -4797,6 +4805,7 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
 
       case SpvCapabilityImageGatherBiasLodAMD:
          spv_check_supported(amd_image_gather_bias_lod, cap);
+         b->image_gather_bias_lod = true;
          break;
 
       case SpvCapabilityAtomicFloat16AddEXT:
index bd65a60..72d81fd 100644 (file)
@@ -738,6 +738,7 @@ struct vtn_builder {
    struct vtn_value *entry_point;
    struct vtn_value *workgroup_size_builtin;
    bool variable_pointers;
+   bool image_gather_bias_lod;
 
    uint32_t *interface_ids;
    size_t interface_ids_count;