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

Author: Jesse Natalie <[email protected]>
Date:   Fri Jul 22 15:48:24 2022 -0700

dzn: Use D3D12 constants instead of naked numbers for device limits

Reviewed-by: Giancarlo Devich <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17915>

---

 src/microsoft/vulkan/dzn_device.c  | 97 +++++++++++++++++++-------------------
 src/microsoft/vulkan/dzn_private.h |  6 +--
 2 files changed, 51 insertions(+), 52 deletions(-)

diff --git a/src/microsoft/vulkan/dzn_device.c 
b/src/microsoft/vulkan/dzn_device.c
index c6b5a76c72f..d46d06522d4 100644
--- a/src/microsoft/vulkan/dzn_device.c
+++ b/src/microsoft/vulkan/dzn_device.c
@@ -1388,24 +1388,21 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice 
physicalDevice,
       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 = {
-
-      /* TODO: support older feature levels */
-      .maxImageDimension1D                      = (1 << 14),
-      .maxImageDimension2D                      = (1 << 14),
-      .maxImageDimension3D                      = (1 << 11),
-      .maxImageDimensionCube                    = (1 << 14),
-      .maxImageArrayLayers                      = (1 << 11),
+      .maxImageDimension1D                      = 
D3D12_REQ_TEXTURE1D_U_DIMENSION,
+      .maxImageDimension2D                      = 
D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION,
+      .maxImageDimension3D                      = 
D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION,
+      .maxImageDimensionCube                    = 
D3D12_REQ_TEXTURECUBE_DIMENSION,
+      .maxImageArrayLayers                      = 
D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION,
 
       /* from here on, we simply use the minimum values from the spec for now 
*/
-      .maxTexelBufferElements                   = 65536,
-      .maxUniformBufferRange                    = 16384,
-      .maxStorageBufferRange                    = (1ul << 27),
+      .maxTexelBufferElements                   = 1 << 
D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP,
+      .maxUniformBufferRange                    = 
D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * D3D12_STANDARD_VECTOR_SIZE * 
sizeof(float),
+      .maxStorageBufferRange                    = 1 << 
D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP,
       .maxPushConstantsSize                     = 128,
       .maxMemoryAllocationCount                 = 4096,
       .maxSamplerAllocationCount                = 4000,
-      .bufferImageGranularity                   = 131072,
+      .bufferImageGranularity                   = 
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
       .sparseAddressSpaceSize                   = 0,
       .maxBoundDescriptorSets                   = MAX_SETS,
       .maxPerStageDescriptorSamplers            =
@@ -1437,9 +1434,9 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice 
physicalDevice,
       .maxDescriptorSetInputAttachments         = 
MAX_DESCS_PER_CBV_SRV_UAV_HEAP,
       .maxVertexInputAttributes                 = 
MIN2(D3D12_STANDARD_VERTEX_ELEMENT_COUNT, MAX_VERTEX_GENERIC_ATTRIBS),
       .maxVertexInputBindings                   = MAX_VBS,
-      .maxVertexInputAttributeOffset            = 2047,
-      .maxVertexInputBindingStride              = 2048,
-      .maxVertexOutputComponents                = 64,
+      .maxVertexInputAttributeOffset            = 
D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES - 1,
+      .maxVertexInputBindingStride              = 
D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES,
+      .maxVertexOutputComponents                = 
D3D12_VS_OUTPUT_REGISTER_COUNT * D3D12_VS_OUTPUT_REGISTER_COMPONENTS,
       .maxTessellationGenerationLevel           = 0,
       .maxTessellationPatchSize                 = 0,
       .maxTessellationControlPerVertexInputComponents = 0,
@@ -1448,44 +1445,46 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice 
physicalDevice,
       .maxTessellationControlTotalOutputComponents = 0,
       .maxTessellationEvaluationInputComponents = 0,
       .maxTessellationEvaluationOutputComponents = 0,
-      .maxGeometryShaderInvocations             = 0,
-      .maxGeometryInputComponents               = 0,
-      .maxGeometryOutputComponents              = 0,
-      .maxGeometryOutputVertices                = 0,
-      .maxGeometryTotalOutputComponents         = 0,
-      .maxFragmentInputComponents               = 64,
-      .maxFragmentOutputAttachments             = 4,
+      .maxGeometryShaderInvocations             = D3D12_GS_MAX_INSTANCE_COUNT,
+      .maxGeometryInputComponents               = 
D3D12_GS_INPUT_REGISTER_COUNT * D3D12_GS_INPUT_REGISTER_COMPONENTS,
+      .maxGeometryOutputComponents              = 
D3D12_GS_OUTPUT_REGISTER_COUNT * D3D12_GS_OUTPUT_REGISTER_COMPONENTS,
+      .maxGeometryOutputVertices                = 
D3D12_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES,
+      .maxGeometryTotalOutputComponents         = 
D3D12_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT,
+      .maxFragmentInputComponents               = 
D3D12_PS_INPUT_REGISTER_COUNT * D3D12_PS_INPUT_REGISTER_COMPONENTS,
+      .maxFragmentOutputAttachments             = 
D3D12_PS_OUTPUT_REGISTER_COUNT,
       .maxFragmentDualSrcAttachments            = 0,
-      .maxFragmentCombinedOutputResources       = 4,
-      .maxComputeSharedMemorySize               = 16384,
-      .maxComputeWorkGroupCount                 = { 65535, 65535, 65535 },
-      .maxComputeWorkGroupInvocations           = 128,
-      .maxComputeWorkGroupSize                  = { 128, 128, 64 },
-      .subPixelPrecisionBits                    = 4,
-      .subTexelPrecisionBits                    = 4,
-      .mipmapPrecisionBits                      = 4,
+      .maxFragmentCombinedOutputResources       = 
D3D12_PS_OUTPUT_REGISTER_COUNT,
+      .maxComputeSharedMemorySize               = D3D12_CS_TGSM_REGISTER_COUNT 
* sizeof(float),
+      .maxComputeWorkGroupCount                 = { 
D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION,
+                                                    
D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION,
+                                                    
D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION },
+      .maxComputeWorkGroupInvocations           = 
D3D12_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP,
+      .maxComputeWorkGroupSize                  = { 
D3D12_CS_THREAD_GROUP_MAX_X, D3D12_CS_THREAD_GROUP_MAX_Y, 
D3D12_CS_THREAD_GROUP_MAX_Z },
+      .subPixelPrecisionBits                    = 
D3D12_SUBPIXEL_FRACTIONAL_BIT_COUNT,
+      .subTexelPrecisionBits                    = 
D3D12_SUBTEXEL_FRACTIONAL_BIT_COUNT,
+      .mipmapPrecisionBits                      = 
D3D12_MIP_LOD_FRACTIONAL_BIT_COUNT,
       .maxDrawIndexedIndexValue                 = 0x00ffffff,
       .maxDrawIndirectCount                     = UINT32_MAX,
-      .maxSamplerLodBias                        = 2.0f,
-      .maxSamplerAnisotropy                     = 1.0f,
-      .maxViewports                             = 1,
-      .maxViewportDimensions                    = { 4096, 4096 },
-      .viewportBoundsRange                      = { -8192, 8191 },
+      .maxSamplerLodBias                        = D3D12_MIP_LOD_BIAS_MAX,
+      .maxSamplerAnisotropy                     = D3D12_REQ_MAXANISOTROPY,
+      .maxViewports                             = MAX_VP,
+      .maxViewportDimensions                    = { 
D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION },
+      .viewportBoundsRange                      = { D3D12_VIEWPORT_BOUNDS_MIN, 
D3D12_VIEWPORT_BOUNDS_MAX },
       .viewportSubPixelBits                     = 0,
       .minMemoryMapAlignment                    = 64,
-      .minTexelBufferOffsetAlignment            = 256,
-      .minUniformBufferOffsetAlignment          = 256,
-      .minStorageBufferOffsetAlignment          = 256,
-      .minTexelOffset                           = -8,
-      .maxTexelOffset                           = 7,
-      .minTexelGatherOffset                     = 0,
-      .maxTexelGatherOffset                     = 0,
+      .minTexelBufferOffsetAlignment            = 32,
+      .minUniformBufferOffsetAlignment          = 
D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT,
+      .minStorageBufferOffsetAlignment          = 
D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT,
+      .minTexelOffset                           = 
D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE,
+      .maxTexelOffset                           = 
D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE,
+      .minTexelGatherOffset                     = -32,
+      .maxTexelGatherOffset                     = 31,
       .minInterpolationOffset                   = -0.5f,
       .maxInterpolationOffset                   = 0.5f,
       .subPixelInterpolationOffsetBits          = 4,
-      .maxFramebufferWidth                      = 4096,
-      .maxFramebufferHeight                     = 4096,
-      .maxFramebufferLayers                     = 256,
+      .maxFramebufferWidth                      = 
D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION,
+      .maxFramebufferHeight                     = 
D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION,
+      .maxFramebufferLayers                     = 
D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION,
       .framebufferColorSampleCounts             = supported_sample_counts,
       .framebufferDepthSampleCounts             = supported_sample_counts,
       .framebufferStencilSampleCounts           = supported_sample_counts,
@@ -1499,16 +1498,16 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice 
physicalDevice,
       .maxSampleMaskWords                       = 1,
       .timestampComputeAndGraphics              = true,
       .timestampPeriod                          = pdevice->timestamp_period,
-      .maxClipDistances                         = 8,
-      .maxCullDistances                         = 8,
-      .maxCombinedClipAndCullDistances          = 8,
+      .maxClipDistances                         = 
D3D12_CLIP_OR_CULL_DISTANCE_COUNT,
+      .maxCullDistances                         = 
D3D12_CLIP_OR_CULL_DISTANCE_COUNT,
+      .maxCombinedClipAndCullDistances          = 
D3D12_CLIP_OR_CULL_DISTANCE_COUNT,
       .discreteQueuePriorities                  = 2,
       .pointSizeRange                           = { 1.0f, 1.0f },
       .lineWidthRange                           = { 1.0f, 1.0f },
       .pointSizeGranularity                     = 0.0f,
       .lineWidthGranularity                     = 0.0f,
       .strictLines                              = 0,
-      .standardSampleLocations                  = false,
+      .standardSampleLocations                  = true,
       .optimalBufferCopyOffsetAlignment         = 
D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT,
       .optimalBufferCopyRowPitchAlignment       = 
D3D12_TEXTURE_DATA_PITCH_ALIGNMENT,
       .nonCoherentAtomSize                      = 256,
diff --git a/src/microsoft/vulkan/dzn_private.h 
b/src/microsoft/vulkan/dzn_private.h
index dc017f3b43d..f7779954cde 100644
--- a/src/microsoft/vulkan/dzn_private.h
+++ b/src/microsoft/vulkan/dzn_private.h
@@ -307,9 +307,9 @@ enum dzn_cmd_dirty {
    DZN_CMD_DIRTY_DEPTH_BOUNDS = 1 << 7,
 };
 
-#define MAX_VBS 16
-#define MAX_VP 16
-#define MAX_SCISSOR 16
+#define MAX_VBS D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
+#define MAX_VP D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
+#define MAX_SCISSOR D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
 #define MAX_SETS 4
 #define MAX_DYNAMIC_UNIFORM_BUFFERS 8
 #define MAX_DYNAMIC_STORAGE_BUFFERS 4

Reply via email to