From 17a75b4da4417226e4b4c34ae87e9b9453187625 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Thu, 13 Apr 2017 22:34:33 +0200 Subject: radv: Set descriptor set limits. Properly and with comments this time. Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Dave Airlie --- src/amd/vulkan/radv_device.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 69b6a115c14..8783ad4e1ba 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -542,6 +542,20 @@ void radv_GetPhysicalDeviceProperties( { RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice); VkSampleCountFlags sample_counts = 0xf; + + /* make sure that the entire descriptor set is addressable with a signed + * 32-bit int. So the sum of all limits scaled by descriptor size has to + * be at most 2 GiB. the combined image & samples object count as one of + * both. This limit is for the pipeline layout, not for the set layout, but + * there is no set limit, so we just set a pipeline limit. I don't think + * any app is going to hit this soon. */ + size_t max_descriptor_set_size = ((1ull << 31) - 16 * MAX_DYNAMIC_BUFFERS) / + (32 /* uniform buffer, 32 due to potential space wasted on alignement */ + + 32 /* storage buffer, 32 due to potential space wasted on alignement */ + + 32 /* sampler, largest when combined with image */ + + 64 /* sampled image */ + + 64 /* storage image */); + VkPhysicalDeviceLimits limits = { .maxImageDimension1D = (1 << 14), .maxImageDimension2D = (1 << 14), @@ -557,21 +571,21 @@ void radv_GetPhysicalDeviceProperties( .bufferImageGranularity = 64, /* A cache line */ .sparseAddressSpaceSize = 0xffffffffu, /* buffer max size */ .maxBoundDescriptorSets = MAX_SETS, - .maxPerStageDescriptorSamplers = (1u << 31) / 16, - .maxPerStageDescriptorUniformBuffers = (1u << 31) / 16, - .maxPerStageDescriptorStorageBuffers = (1u << 31) / 16, - .maxPerStageDescriptorSampledImages = (1u << 31) / 96, - .maxPerStageDescriptorStorageImages = (1u << 31) / 64, - .maxPerStageDescriptorInputAttachments = (1u << 31) / 64, - .maxPerStageResources = (1u << 31) / 32, - .maxDescriptorSetSamplers = 256, - .maxDescriptorSetUniformBuffers = (1u << 31) / 16, - .maxDescriptorSetUniformBuffersDynamic = 8, - .maxDescriptorSetStorageBuffers = (1u << 31) / 16, - .maxDescriptorSetStorageBuffersDynamic = 8, - .maxDescriptorSetSampledImages = (1u << 31) / 96, - .maxDescriptorSetStorageImages = (1u << 31) / 64, - .maxDescriptorSetInputAttachments = (1u << 31) / 64, + .maxPerStageDescriptorSamplers = max_descriptor_set_size, + .maxPerStageDescriptorUniformBuffers = max_descriptor_set_size, + .maxPerStageDescriptorStorageBuffers = max_descriptor_set_size, + .maxPerStageDescriptorSampledImages = max_descriptor_set_size, + .maxPerStageDescriptorStorageImages = max_descriptor_set_size, + .maxPerStageDescriptorInputAttachments = max_descriptor_set_size, + .maxPerStageResources = max_descriptor_set_size, + .maxDescriptorSetSamplers = max_descriptor_set_size, + .maxDescriptorSetUniformBuffers = max_descriptor_set_size, + .maxDescriptorSetUniformBuffersDynamic = MAX_DYNAMIC_BUFFERS / 2, + .maxDescriptorSetStorageBuffers = max_descriptor_set_size, + .maxDescriptorSetStorageBuffersDynamic = MAX_DYNAMIC_BUFFERS / 2, + .maxDescriptorSetSampledImages = max_descriptor_set_size, + .maxDescriptorSetStorageImages = max_descriptor_set_size, + .maxDescriptorSetInputAttachments = max_descriptor_set_size, .maxVertexInputAttributes = 32, .maxVertexInputBindings = 32, .maxVertexInputAttributeOffset = 2047, -- cgit v1.2.3