nvk: Support inline uniform blocks
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:11:50 +0000 (20:11 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:55 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/nvk_nir_lower_descriptors.c
src/nouveau/vulkan/nvk_physical_device.c

index 874a849..75a7986 100644 (file)
@@ -5,6 +5,7 @@
 #include "nvk_pipeline_layout.h"
 
 #include "nir_builder.h"
+#include "nir_deref.h"
 
 struct lower_descriptors_ctx {
    const struct nvk_pipeline_layout *layout;
@@ -55,6 +56,22 @@ load_descriptor(nir_builder *b, unsigned num_components, unsigned bit_size,
                           .align_mul = 16, .align_offset = 0, .range = ~0);
    }
 
+   case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK: {
+      nir_ssa_def *base_addr =
+         nir_iadd_imm(b, load_descriptor_set_addr(b, set, ctx),
+                          binding_layout->offset);
+
+      assert(binding_layout->stride == 1);
+      const uint32_t binding_size = binding_layout->array_size;
+
+      /* Convert it to nir_address_format_64bit_bounded_global */
+      assert(num_components == 4 && bit_size == 32);
+      return nir_vec4(b, nir_unpack_64_2x32_split_x(b, base_addr),
+                         nir_unpack_64_2x32_split_y(b, base_addr),
+                         nir_imm_int(b, binding_size),
+                         nir_imm_int(b, 0));
+   }
+
    default: {
       assert(binding_layout->stride > 0);
       nir_ssa_def *desc_ubo_offset =
index 093de13..8c74f1b 100644 (file)
@@ -56,6 +56,7 @@ nvk_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
    VkPhysicalDeviceVulkan13Features core_1_3 = {
       .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
       /* Vulkan 1.3 features */
+      .inlineUniformBlock = true,
    };
 
    vk_foreach_struct(ext, pFeatures->pNext)
@@ -140,6 +141,8 @@ nvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
    VkPhysicalDeviceVulkan13Properties core_1_3 = {
       .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES,
       /* Vulkan 1.3 properties */
+      .maxInlineUniformBlockSize = 1 << 16,
+      .maxPerStageDescriptorInlineUniformBlocks = 32,
    };
 
    vk_foreach_struct(ext, pProperties->pNext)
@@ -181,6 +184,7 @@ nvk_get_device_extensions(const struct nvk_physical_device *device,
 #endif
       .KHR_variable_pointers = true,
       .EXT_custom_border_color = true,
+      .EXT_inline_uniform_block = true,
    };
 }