summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2018-01-21 15:53:03 +0100
committerBas Nieuwenhuizen <[email protected]>2018-03-07 21:18:35 +0100
commit41d958d073c52088aa831e4485e67c3e0ce175a5 (patch)
tree2e5fe79b865b092bc9de8559d53b6a93385ba2f5 /src/amd
parent8f9af587a2dd33580145779275203334d3acdc21 (diff)
radv: Implement VK_KHR_maintenance3.
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/vulkan/radv_descriptor_set.c83
-rw-r--r--src/amd/vulkan/radv_device.c10
-rw-r--r--src/amd/vulkan/radv_extensions.py1
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 38b8dc78e1b..c1a8f630f1d 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 00bb70612eb..4eab9faf3f3 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 ff6a070d4df..aa02bcac9bf 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),