radv: Enable VK_EXT_descriptor_indexing.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 11 Apr 2018 17:08:30 +0000 (19:08 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 18 Apr 2018 20:56:54 +0000 (22:56 +0200)
This adds everything except non-uniform indexing, which needs a bit
more work and testing.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_extensions.py
src/amd/vulkan/radv_shader.c

index fda21fa998a95d231a98a1ebb910538593db4d99..fd11cedcbfef6eaa326635fe9d1ebe3bfa5ba6dd 100644 (file)
@@ -735,6 +735,31 @@ void radv_GetPhysicalDeviceFeatures2(
                        features->samplerYcbcrConversion = false;
                        break;
                }
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT: {
+                       VkPhysicalDeviceDescriptorIndexingFeaturesEXT *features =
+                               (VkPhysicalDeviceDescriptorIndexingFeaturesEXT*)features;
+                       features->shaderInputAttachmentArrayDynamicIndexing = true;
+                       features->shaderUniformTexelBufferArrayDynamicIndexing = true;
+                       features->shaderStorageTexelBufferArrayDynamicIndexing = true;
+                       features->shaderUniformBufferArrayNonUniformIndexing = false;
+                       features->shaderSampledImageArrayNonUniformIndexing = false;
+                       features->shaderStorageBufferArrayNonUniformIndexing = false;
+                       features->shaderStorageImageArrayNonUniformIndexing = false;
+                       features->shaderInputAttachmentArrayNonUniformIndexing = false;
+                       features->shaderUniformTexelBufferArrayNonUniformIndexing = false;
+                       features->shaderStorageTexelBufferArrayNonUniformIndexing = false;
+                       features->descriptorBindingUniformBufferUpdateAfterBind = true;
+                       features->descriptorBindingSampledImageUpdateAfterBind = true;
+                       features->descriptorBindingStorageImageUpdateAfterBind = true;
+                       features->descriptorBindingStorageBufferUpdateAfterBind = true;
+                       features->descriptorBindingUniformTexelBufferUpdateAfterBind = true;
+                       features->descriptorBindingStorageTexelBufferUpdateAfterBind = true;
+                       features->descriptorBindingUpdateUnusedWhilePending = true;
+                       features->descriptorBindingPartiallyBound = true;
+                       features->descriptorBindingVariableDescriptorCount = true;
+                       features->runtimeDescriptorArray = true;
+                       break;
+               }
                default:
                        break;
                }
@@ -1014,6 +1039,41 @@ void radv_GetPhysicalDeviceProperties2(
                        properties->maxVertexAttribDivisor = UINT32_MAX;
                        break;
                }
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT: {
+                       VkPhysicalDeviceDescriptorIndexingPropertiesEXT *properties =
+                               (VkPhysicalDeviceDescriptorIndexingPropertiesEXT*)ext;
+                       properties->maxUpdateAfterBindDescriptorsInAllPools = UINT32_MAX / 64;
+                       properties->shaderUniformBufferArrayNonUniformIndexingNative = false;
+                       properties->shaderSampledImageArrayNonUniformIndexingNative = false;
+                       properties->shaderStorageBufferArrayNonUniformIndexingNative = false;
+                       properties->shaderStorageImageArrayNonUniformIndexingNative = false;
+                       properties->shaderInputAttachmentArrayNonUniformIndexingNative = false;
+                       properties->robustBufferAccessUpdateAfterBind = false;
+                       properties->quadDivergentImplicitLod = false;
+
+                       size_t max_descriptor_set_size = ((1ull << 31) - 16 * MAX_DYNAMIC_BUFFERS) /
+                                 (32 /* uniform buffer, 32 due to potential space wasted on alignment */ +
+                                  32 /* storage buffer, 32 due to potential space wasted on alignment */ +
+                                  32 /* sampler, largest when combined with image */ +
+                                  64 /* sampled image */ +
+                                  64 /* storage image */);
+                       properties->maxPerStageDescriptorUpdateAfterBindSamplers = max_descriptor_set_size;
+                       properties->maxPerStageDescriptorUpdateAfterBindUniformBuffers = max_descriptor_set_size;
+                       properties->maxPerStageDescriptorUpdateAfterBindStorageBuffers = max_descriptor_set_size;
+                       properties->maxPerStageDescriptorUpdateAfterBindSampledImages = max_descriptor_set_size;
+                       properties->maxPerStageDescriptorUpdateAfterBindStorageImages = max_descriptor_set_size;
+                       properties->maxPerStageDescriptorUpdateAfterBindInputAttachments = max_descriptor_set_size;
+                       properties->maxPerStageUpdateAfterBindResources = max_descriptor_set_size;
+                       properties->maxDescriptorSetUpdateAfterBindSamplers = max_descriptor_set_size;
+                       properties->maxDescriptorSetUpdateAfterBindUniformBuffers = max_descriptor_set_size;
+                       properties->maxDescriptorSetUpdateAfterBindUniformBuffersDynamic = MAX_DYNAMIC_UNIFORM_BUFFERS;
+                       properties->maxDescriptorSetUpdateAfterBindStorageBuffers = max_descriptor_set_size;
+                       properties->maxDescriptorSetUpdateAfterBindStorageBuffersDynamic = MAX_DYNAMIC_STORAGE_BUFFERS;
+                       properties->maxDescriptorSetUpdateAfterBindSampledImages = max_descriptor_set_size;
+                       properties->maxDescriptorSetUpdateAfterBindStorageImages = max_descriptor_set_size;
+                       properties->maxDescriptorSetUpdateAfterBindInputAttachments = max_descriptor_set_size;
+                       break;
+               }
                default:
                        break;
                }
index 099cae78b111fad5278b8d54176b598354394c9e..dbe0ff4ac5a8ccab49e7f849cc06533dc9af0187 100644 (file)
@@ -87,6 +87,7 @@ EXTENSIONS = [
     Extension('VK_KHR_multiview',                         1, True),
     Extension('VK_EXT_debug_report',                      9, True),
     Extension('VK_EXT_depth_range_unrestricted',          1, True),
+    Extension('VK_EXT_descriptor_indexing',               2, True),
     Extension('VK_EXT_discard_rectangles',                1, True),
     Extension('VK_EXT_external_memory_dma_buf',           1, True),
     Extension('VK_EXT_external_memory_host',              1, 'device->rad_info.has_userptr'),
index 9d49bc02a8185860ec74fc6cede6cf49bb5dacef..ac36cecb67498b9248d3724d0e7f18ebee3d001a 100644 (file)
@@ -222,6 +222,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
                                .gcn_shader = true,
                                .trinary_minmax = true,
                                .shader_viewport_index_layer = true,
+                               .descriptor_array_dynamic_indexing = true,
+                               .runtime_descriptor_array = true,
                        },
                };
                entry_point = spirv_to_nir(spirv, module->size / 4,