Module: Mesa
Branch: master
Commit: 41d958d073c52088aa831e4485e67c3e0ce175a5
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=41d958d073c52088aa831e4485e67c3e0ce175a5

Author: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
Date:   Sun Jan 21 15:53:03 2018 +0100

radv: Implement VK_KHR_maintenance3.

Reviewed-by: Dave Airlie <airl...@redhat.com>

---

 src/amd/vulkan/radv_descriptor_set.c | 83 ++++++++++++++++++++++++++++++++++--
 src/amd/vulkan/radv_device.c         | 10 +++++
 src/amd/vulkan/radv_extensions.py    |  1 +
 3 files changed, 90 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/radv_descriptor_set.c 
b/src/amd/vulkan/radv_descriptor_set.c
index 38b8dc78e1..c1a8f630f1 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -31,6 +31,20 @@
 #include "radv_private.h"
 #include "sid.h"
 
+
+static bool has_equal_immutable_samplers(const VkSampler *samplers, uint32_t 
count)
+{
+       if (!samplers)
+               return false;
+       for(uint32_t i = 1; i < count; ++i) {
+               if (memcmp(radv_sampler_from_handle(samplers[0])->state,
+                          radv_sampler_from_handle(samplers[i])->state, 16)) {
+                       return false;
+               }
+       }
+       return true;
+}
+
 VkResult radv_CreateDescriptorSetLayout(
        VkDevice                                    _device,
        const VkDescriptorSetLayoutCreateInfo*      pCreateInfo,
@@ -132,15 +146,13 @@ VkResult radv_CreateDescriptorSetLayout(
 
                if (binding->pImmutableSamplers) {
                        set_layout->binding[b].immutable_samplers_offset = 
samplers_offset;
-                       set_layout->binding[b].immutable_samplers_equal = true;
+                       set_layout->binding[b].immutable_samplers_equal =
+                               
has_equal_immutable_samplers(binding->pImmutableSamplers, 
binding->descriptorCount);
                        set_layout->has_immutable_samplers = true;
 
 
                        for (uint32_t i = 0; i < binding->descriptorCount; i++)
                                memcpy(samplers + 4 * i, 
&radv_sampler_from_handle(binding->pImmutableSamplers[i])->state, 16);
-                       for (uint32_t i = 1; i < binding->descriptorCount; i++)
-                               if (memcmp(samplers + 4 * i, samplers, 16) != 0)
-                                       
set_layout->binding[b].immutable_samplers_equal = false;
 
                        /* Don't reserve space for the samplers if they're not 
accessed. */
                        if (set_layout->binding[b].immutable_samplers_equal) {
@@ -182,6 +194,69 @@ void radv_DestroyDescriptorSetLayout(
        vk_free2(&device->alloc, pAllocator, set_layout);
 }
 
+void radv_GetDescriptorSetLayoutSupport(VkDevice device,
+                                        const VkDescriptorSetLayoutCreateInfo* 
pCreateInfo,
+                                        VkDescriptorSetLayoutSupport* pSupport)
+{
+       bool supported = true;
+       uint64_t size = 0;
+       for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
+               const VkDescriptorSetLayoutBinding *binding = 
&pCreateInfo->pBindings[i];
+
+               if (binding->descriptorCount == 0)
+                       continue;
+
+               uint64_t descriptor_size = 0;
+               uint64_t descriptor_alignment = 1;
+               switch (binding->descriptorType) {
+               case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
+               case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
+                       break;
+               case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
+               case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
+               case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
+               case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
+                       descriptor_size = 16;
+                       descriptor_alignment = 16;
+                       break;
+               case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
+               case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
+               case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
+                       descriptor_size = 64;
+                       descriptor_alignment = 32;
+                       break;
+               case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
+                       if 
(!has_equal_immutable_samplers(binding->pImmutableSamplers, 
binding->descriptorCount)) {
+                               descriptor_size = 64;
+                       } else {
+                               descriptor_size = 96;
+                       }
+                       descriptor_alignment = 32;
+                       break;
+               case VK_DESCRIPTOR_TYPE_SAMPLER:
+                       if 
(!has_equal_immutable_samplers(binding->pImmutableSamplers, 
binding->descriptorCount)) {
+                               descriptor_size = 16;
+                               descriptor_alignment = 16;
+                       }
+                       break;
+               default:
+                       unreachable("unknown descriptor type\n");
+                       break;
+               }
+
+               if (size && !align_u64(size, descriptor_alignment)) {
+                       supported = false;
+               }
+               size = align_u64(size, descriptor_alignment);
+               if (descriptor_size && (UINT64_MAX - size) / descriptor_size < 
binding->descriptorCount) {
+                       supported = false;
+               }
+               size += binding->descriptorCount * descriptor_size;
+       }
+
+       pSupport->supported = supported;
+}
+
 /*
  * Pipeline layouts.  These have nothing to do with the pipeline.  They are
  * just muttiple descriptor set layouts pasted together
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 00bb70612e..4eab9faf3f 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -875,6 +875,16 @@ void radv_GetPhysicalDeviceProperties2(
                        properties->quadOperationsInAllStages = false;
                        break;
                }
+               case 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES: {
+                       VkPhysicalDeviceMaintenance3Properties *properties =
+                           (VkPhysicalDeviceMaintenance3Properties*)ext;
+                       /* Make sure everything is addressable by a signed 
32-bit int, and
+                        * our largest descriptors are 96 bytes. */
+                       properties->maxPerSetDescriptors = (1ull << 31) / 96;
+                       /* Our buffer size fields allow only this much */
+                       properties->maxMemoryAllocationSize = 0xFFFFFFFFull;
+                       break;
+               }
                default:
                        break;
                }
diff --git a/src/amd/vulkan/radv_extensions.py 
b/src/amd/vulkan/radv_extensions.py
index ff6a070d4d..aa02bcac9b 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -70,6 +70,7 @@ EXTENSIONS = [
     Extension('VK_KHR_incremental_present',               1, 
'RADV_HAS_SURFACE'),
     Extension('VK_KHR_maintenance1',                      1, True),
     Extension('VK_KHR_maintenance2',                      1, True),
+    Extension('VK_KHR_maintenance3',                      1, True),
     Extension('VK_KHR_push_descriptor',                   1, True),
     Extension('VK_KHR_relaxed_block_layout',              1, True),
     Extension('VK_KHR_sampler_mirror_clamp_to_edge',      1, True),

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to