Mesa (main): dzn: Report actual device limits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 20 22:53:32 UTC 2022


Module: Mesa
Branch: main
Commit: b8fd1e8844f46c830aed455feb891790600e5ba2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8fd1e8844f46c830aed455feb891790600e5ba2

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Mon Apr  4 06:13:44 2022 -0700

dzn: Report actual device limits

Report actual device limits instead of pseudo-random numbers.

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15911>

---

 src/microsoft/vulkan/dzn_descriptor_set.c |  4 +--
 src/microsoft/vulkan/dzn_device.c         | 52 ++++++++++++++++++++-----------
 src/microsoft/vulkan/dzn_private.h        |  3 ++
 3 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/src/microsoft/vulkan/dzn_descriptor_set.c b/src/microsoft/vulkan/dzn_descriptor_set.c
index b19da113a33..e111bdca3b6 100644
--- a/src/microsoft/vulkan/dzn_descriptor_set.c
+++ b/src/microsoft/vulkan/dzn_descriptor_set.c
@@ -1456,8 +1456,8 @@ dzn_descriptor_heap_pool_alloc_slots(struct dzn_descriptor_heap_pool *pool,
       /* Maximum of 2048 samplers per heap when shader_visible is true. */
       if (pool->shader_visible &&
           pool->type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER) {
-         assert(desc_count <= 2048);
-         heap_desc_count = MIN2(heap_desc_count, 2048);
+         assert(desc_count <= MAX_DESCS_PER_SAMPLER_HEAP);
+         heap_desc_count = MIN2(heap_desc_count, MAX_DESCS_PER_SAMPLER_HEAP);
       }
 
       struct dzn_descriptor_heap_pool_entry *new_heap = NULL;
diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c
index a5ef670cb69..144ef1a77fb 100644
--- a/src/microsoft/vulkan/dzn_device.c
+++ b/src/microsoft/vulkan/dzn_device.c
@@ -1262,9 +1262,12 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
 {
    VK_FROM_HANDLE(dzn_physical_device, pdevice, physicalDevice);
 
+   (void)dzn_physical_device_get_d3d12_dev(pdevice);
+
    /* minimum from the spec */
    const VkSampleCountFlags supported_sample_counts =
-      VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT;
+      VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_2_BIT | VK_SAMPLE_COUNT_4_BIT |
+      VK_SAMPLE_COUNT_8_BIT | VK_SAMPLE_COUNT_16_BIT;
 
    /* FIXME: this is mostly bunk for now */
    VkPhysicalDeviceLimits limits = {
@@ -1286,23 +1289,35 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
       .bufferImageGranularity                   = 131072,
       .sparseAddressSpaceSize                   = 0,
       .maxBoundDescriptorSets                   = MAX_SETS,
-      .maxPerStageDescriptorSamplers            = 16,
-      .maxPerStageDescriptorUniformBuffers      = 12,
-      .maxPerStageDescriptorStorageBuffers      = 4,
-      .maxPerStageDescriptorSampledImages       = 16,
-      .maxPerStageDescriptorStorageImages       = 4,
-      .maxPerStageDescriptorInputAttachments    = 4,
-      .maxPerStageResources                     = 128,
-      .maxDescriptorSetSamplers                 = 96,
-      .maxDescriptorSetUniformBuffers           = 72,
+      .maxPerStageDescriptorSamplers            =
+         pdevice->options.ResourceHeapTier == D3D12_RESOURCE_HEAP_TIER_1 ?
+         16u : MAX_DESCS_PER_SAMPLER_HEAP,
+      .maxPerStageDescriptorUniformBuffers      =
+         pdevice->options.ResourceHeapTier <= D3D12_RESOURCE_HEAP_TIER_2 ?
+         14u : MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxPerStageDescriptorStorageBuffers      =
+         pdevice->options.ResourceHeapTier <= D3D12_RESOURCE_HEAP_TIER_2 ?
+         64u : MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxPerStageDescriptorSampledImages       =
+         pdevice->options.ResourceHeapTier == D3D12_RESOURCE_HEAP_TIER_1 ?
+         128u : MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxPerStageDescriptorStorageImages       =
+         pdevice->options.ResourceHeapTier <= D3D12_RESOURCE_HEAP_TIER_2 ?
+         64u : MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxPerStageDescriptorInputAttachments    =
+         pdevice->options.ResourceHeapTier == D3D12_RESOURCE_HEAP_TIER_1 ?
+         128u : MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxPerStageResources                     = MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxDescriptorSetSamplers                 = MAX_DESCS_PER_SAMPLER_HEAP,
+      .maxDescriptorSetUniformBuffers           = MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
       .maxDescriptorSetUniformBuffersDynamic    = MAX_DYNAMIC_UNIFORM_BUFFERS,
-      .maxDescriptorSetStorageBuffers           = 24,
+      .maxDescriptorSetStorageBuffers           = MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
       .maxDescriptorSetStorageBuffersDynamic    = MAX_DYNAMIC_STORAGE_BUFFERS,
-      .maxDescriptorSetSampledImages            = 96,
-      .maxDescriptorSetStorageImages            = 24,
-      .maxDescriptorSetInputAttachments         = 4,
-      .maxVertexInputAttributes                 = 16,
-      .maxVertexInputBindings                   = 16,
+      .maxDescriptorSetSampledImages            = MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxDescriptorSetStorageImages            = MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxDescriptorSetInputAttachments         = MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
+      .maxVertexInputAttributes                 = D3D12_STANDARD_VERTEX_ELEMENT_COUNT,
+      .maxVertexInputBindings                   = MAX_VBS,
       .maxVertexInputAttributeOffset            = 2047,
       .maxVertexInputBindingStride              = 2048,
       .maxVertexOutputComponents                = 64,
@@ -1356,7 +1371,7 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
       .framebufferDepthSampleCounts             = supported_sample_counts,
       .framebufferStencilSampleCounts           = supported_sample_counts,
       .framebufferNoAttachmentsSampleCounts     = supported_sample_counts,
-      .maxColorAttachments                      = 4,
+      .maxColorAttachments                      = MAX_RTS,
       .sampledImageColorSampleCounts            = supported_sample_counts,
       .sampledImageIntegerSampleCounts          = VK_SAMPLE_COUNT_1_BIT,
       .sampledImageDepthSampleCounts            = supported_sample_counts,
@@ -1426,7 +1441,8 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
        * heap when descriptor sets are bound to the command buffer, hence the
        * division by MAX_SETS.
        */
-      .maxPerSetDescriptors                  = 2048 / MAX_SETS,
+      .maxPerSetDescriptors                  =
+         MAX_DESCS_PER_SAMPLER_HEAP / MAX_SETS,
       /* According to the spec, the maximum D3D12 resource size is
        * min(max(128MB, 0.25f * (amount of dedicated VRAM)), 2GB),
        * but the limit actually depends on the max(system_ram, VRAM) not
diff --git a/src/microsoft/vulkan/dzn_private.h b/src/microsoft/vulkan/dzn_private.h
index c64143699f4..55ba1ed7c34 100644
--- a/src/microsoft/vulkan/dzn_private.h
+++ b/src/microsoft/vulkan/dzn_private.h
@@ -361,6 +361,9 @@ struct dzn_buffer_desc {
    VkDeviceSize offset;
 };
 
+#define MAX_DESCS_PER_SAMPLER_HEAP 2048u
+#define MAX_DESCS_PER_CBV_SRV_UAV_HEAP 1000000u
+
 struct dzn_descriptor_heap {
    ID3D12Device1 *dev;
    ID3D12DescriptorHeap *heap;



More information about the mesa-commit mailing list