[Mesa-dev] [PATCH] anv: add KHR_get_physical_device_properties2 support

Lionel Landwerlin lionel.g.landwerlin at intel.com
Tue Jan 24 01:02:43 UTC 2017


Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/vulkan/anv_device.c  | 593 +++++++++++++++++++++++++----------------
 src/intel/vulkan/anv_formats.c |  42 +++
 2 files changed, 398 insertions(+), 237 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index f80a36a940..9f5bd8ea53 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -253,6 +253,10 @@ static const VkExtensionProperties global_extensions[] = {
       .specVersion = 5,
    },
 #endif
+   {
+      .extensionName = VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
+      .specVersion = 1,
+   },
 };
 
 static const VkExtensionProperties device_extensions[] = {
@@ -263,7 +267,7 @@ static const VkExtensionProperties device_extensions[] = {
    {
       .extensionName = VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME,
       .specVersion = 1,
-   }
+   },
 };
 
 static void *
@@ -433,64 +437,299 @@ VkResult anv_EnumeratePhysicalDevices(
    return VK_SUCCESS;
 }
 
+static void
+anv_physical_device_get(struct anv_physical_device *device,
+                        VkStructureType type,
+                        void *structure)
+{
+   switch (type) {
+   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR: {
+      VkPhysicalDeviceFeatures2KHR *pFeatures = structure;
+
+      pFeatures->features = (VkPhysicalDeviceFeatures) {
+         .robustBufferAccess                       = true,
+         .fullDrawIndexUint32                      = true,
+         .imageCubeArray                           = true,
+         .independentBlend                         = true,
+         .geometryShader                           = true,
+         .tessellationShader                       = true,
+         .sampleRateShading                        = true,
+         .dualSrcBlend                             = true,
+         .logicOp                                  = true,
+         .multiDrawIndirect                        = false,
+         .drawIndirectFirstInstance                = true,
+         .depthClamp                               = true,
+         .depthBiasClamp                           = true,
+         .fillModeNonSolid                         = true,
+         .depthBounds                              = false,
+         .wideLines                                = true,
+         .largePoints                              = true,
+         .alphaToOne                               = true,
+         .multiViewport                            = true,
+         .samplerAnisotropy                        = true,
+         .textureCompressionETC2                   = device->info.gen >= 8 ||
+                                                     device->info.is_baytrail,
+         .textureCompressionASTC_LDR               = device->info.gen >= 9, /* FINISHME CHV */
+         .textureCompressionBC                     = true,
+         .occlusionQueryPrecise                    = true,
+         .pipelineStatisticsQuery                  = false,
+         .fragmentStoresAndAtomics                 = true,
+         .shaderTessellationAndGeometryPointSize   = true,
+         .shaderImageGatherExtended                = true,
+         .shaderStorageImageExtendedFormats        = true,
+         .shaderStorageImageMultisample            = false,
+         .shaderStorageImageReadWithoutFormat      = false,
+         .shaderStorageImageWriteWithoutFormat     = false,
+         .shaderUniformBufferArrayDynamicIndexing  = true,
+         .shaderSampledImageArrayDynamicIndexing   = true,
+         .shaderStorageBufferArrayDynamicIndexing  = true,
+         .shaderStorageImageArrayDynamicIndexing   = true,
+         .shaderClipDistance                       = true,
+         .shaderCullDistance                       = true,
+         .shaderFloat64                            = device->info.gen >= 8,
+         .shaderInt64                              = false,
+         .shaderInt16                              = false,
+         .shaderResourceMinLod                     = false,
+         .variableMultisampleRate                  = false,
+         .inheritedQueries                         = false,
+      };
+
+      /* We can't do image stores in vec4 shaders */
+      pFeatures->features.vertexPipelineStoresAndAtomics =
+         device->compiler->scalar_stage[MESA_SHADER_VERTEX] &&
+         device->compiler->scalar_stage[MESA_SHADER_GEOMETRY];
+      break;
+   }
+
+   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR: {
+      const struct gen_device_info *devinfo = &device->info;
+      const float time_stamp_base = devinfo->gen >= 9 ? 83.333 : 80.0;
+
+      /* See assertions made when programming the buffer surface state. */
+      const uint32_t max_raw_buffer_sz = devinfo->gen >= 7 ?
+                                         (1ul << 30) : (1ul << 27);
+
+      VkSampleCountFlags sample_counts =
+         isl_device_get_sample_counts(&device->isl_dev);
+
+      VkPhysicalDeviceLimits limits = {
+         .maxImageDimension1D                      = (1 << 14),
+         .maxImageDimension2D                      = (1 << 14),
+         .maxImageDimension3D                      = (1 << 11),
+         .maxImageDimensionCube                    = (1 << 14),
+         .maxImageArrayLayers                      = (1 << 11),
+         .maxTexelBufferElements                   = 128 * 1024 * 1024,
+         .maxUniformBufferRange                    = (1ul << 27),
+         .maxStorageBufferRange                    = max_raw_buffer_sz,
+         .maxPushConstantsSize                     = MAX_PUSH_CONSTANTS_SIZE,
+         .maxMemoryAllocationCount                 = UINT32_MAX,
+         .maxSamplerAllocationCount                = 64 * 1024,
+         .bufferImageGranularity                   = 64, /* A cache line */
+         .sparseAddressSpaceSize                   = 0,
+         .maxBoundDescriptorSets                   = MAX_SETS,
+         .maxPerStageDescriptorSamplers            = 64,
+         .maxPerStageDescriptorUniformBuffers      = 64,
+         .maxPerStageDescriptorStorageBuffers      = 64,
+         .maxPerStageDescriptorSampledImages       = 64,
+         .maxPerStageDescriptorStorageImages       = 64,
+         .maxPerStageDescriptorInputAttachments    = 64,
+         .maxPerStageResources                     = 128,
+         .maxDescriptorSetSamplers                 = 256,
+         .maxDescriptorSetUniformBuffers           = 256,
+         .maxDescriptorSetUniformBuffersDynamic    = 256,
+         .maxDescriptorSetStorageBuffers           = 256,
+         .maxDescriptorSetStorageBuffersDynamic    = 256,
+         .maxDescriptorSetSampledImages            = 256,
+         .maxDescriptorSetStorageImages            = 256,
+         .maxDescriptorSetInputAttachments         = 256,
+         .maxVertexInputAttributes                 = 32,
+         .maxVertexInputBindings                   = 32,
+         .maxVertexInputAttributeOffset            = 2047,
+         .maxVertexInputBindingStride              = 2048,
+         .maxVertexOutputComponents                = 128,
+         .maxTessellationGenerationLevel           = 64,
+         .maxTessellationPatchSize                 = 32,
+         .maxTessellationControlPerVertexInputComponents = 128,
+         .maxTessellationControlPerVertexOutputComponents = 128,
+         .maxTessellationControlPerPatchOutputComponents = 128,
+         .maxTessellationControlTotalOutputComponents = 2048,
+         .maxTessellationEvaluationInputComponents = 128,
+         .maxTessellationEvaluationOutputComponents = 128,
+         .maxGeometryShaderInvocations             = 32,
+         .maxGeometryInputComponents               = 64,
+         .maxGeometryOutputComponents              = 128,
+         .maxGeometryOutputVertices                = 256,
+         .maxGeometryTotalOutputComponents         = 1024,
+         .maxFragmentInputComponents               = 128,
+         .maxFragmentOutputAttachments             = 8,
+         .maxFragmentDualSrcAttachments            = 1,
+         .maxFragmentCombinedOutputResources       = 8,
+         .maxComputeSharedMemorySize               = 32768,
+         .maxComputeWorkGroupCount                 = { 65535, 65535, 65535 },
+         .maxComputeWorkGroupInvocations           = 16 * devinfo->max_cs_threads,
+         .maxComputeWorkGroupSize = {
+            16 * devinfo->max_cs_threads,
+            16 * devinfo->max_cs_threads,
+            16 * devinfo->max_cs_threads,
+         },
+         .subPixelPrecisionBits                    = 4 /* FIXME */,
+         .subTexelPrecisionBits                    = 4 /* FIXME */,
+         .mipmapPrecisionBits                      = 4 /* FIXME */,
+         .maxDrawIndexedIndexValue                 = UINT32_MAX,
+         .maxDrawIndirectCount                     = UINT32_MAX,
+         .maxSamplerLodBias                        = 16,
+         .maxSamplerAnisotropy                     = 16,
+         .maxViewports                             = MAX_VIEWPORTS,
+         .maxViewportDimensions                    = { (1 << 14), (1 << 14) },
+         .viewportBoundsRange                      = { INT16_MIN, INT16_MAX },
+         .viewportSubPixelBits                     = 13, /* We take a float? */
+         .minMemoryMapAlignment                    = 4096, /* A page */
+         .minTexelBufferOffsetAlignment            = 1,
+         .minUniformBufferOffsetAlignment          = 16,
+         .minStorageBufferOffsetAlignment          = 4,
+         .minTexelOffset                           = -8,
+         .maxTexelOffset                           = 7,
+         .minTexelGatherOffset                     = -32,
+         .maxTexelGatherOffset                     = 31,
+         .minInterpolationOffset                   = -0.5,
+         .maxInterpolationOffset                   = 0.4375,
+         .subPixelInterpolationOffsetBits          = 4,
+         .maxFramebufferWidth                      = (1 << 14),
+         .maxFramebufferHeight                     = (1 << 14),
+         .maxFramebufferLayers                     = (1 << 11),
+         .framebufferColorSampleCounts             = sample_counts,
+         .framebufferDepthSampleCounts             = sample_counts,
+         .framebufferStencilSampleCounts           = sample_counts,
+         .framebufferNoAttachmentsSampleCounts     = sample_counts,
+         .maxColorAttachments                      = MAX_RTS,
+         .sampledImageColorSampleCounts            = sample_counts,
+         .sampledImageIntegerSampleCounts          = VK_SAMPLE_COUNT_1_BIT,
+         .sampledImageDepthSampleCounts            = sample_counts,
+         .sampledImageStencilSampleCounts          = sample_counts,
+         .storageImageSampleCounts                 = VK_SAMPLE_COUNT_1_BIT,
+         .maxSampleMaskWords                       = 1,
+         .timestampComputeAndGraphics              = false,
+         .timestampPeriod                          = time_stamp_base,
+         .maxClipDistances                         = 8,
+         .maxCullDistances                         = 8,
+         .maxCombinedClipAndCullDistances          = 8,
+         .discreteQueuePriorities                  = 1,
+         .pointSizeRange                           = { 0.125, 255.875 },
+         .lineWidthRange                           = { 0.0, 7.9921875 },
+         .pointSizeGranularity                     = (1.0 / 8.0),
+         .lineWidthGranularity                     = (1.0 / 128.0),
+         .strictLines                              = false, /* FINISHME */
+         .standardSampleLocations                  = true,
+         .optimalBufferCopyOffsetAlignment         = 128,
+         .optimalBufferCopyRowPitchAlignment       = 128,
+         .nonCoherentAtomSize                      = 64,
+      };
+
+      VkPhysicalDeviceProperties2KHR *pProperties = structure;
+      pProperties->properties.apiVersion = VK_MAKE_VERSION(1, 0, 5);
+      pProperties->properties.driverVersion = 1;
+      pProperties->properties.vendorID = 0x8086;
+      pProperties->properties.deviceID = device->chipset_id;
+      pProperties->properties.deviceType =
+         VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
+      pProperties->properties.limits = limits;
+
+      VkPhysicalDeviceSparseProperties sparseProperties = {
+         0, /* Broadwell doesn't do sparse. */
+      };
+      pProperties->properties.sparseProperties = sparseProperties;
+
+      strcpy(pProperties->properties.deviceName, device->name);
+      memcpy(pProperties->properties.pipelineCacheUUID,
+             device->uuid, VK_UUID_SIZE);
+      break;
+   }
+
+   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR: {
+      VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties = structure;
+      VkDeviceSize heap_size;
+
+      /* Reserve some wiggle room for the driver by exposing only 75% of the
+       * aperture to the heap.
+       */
+      heap_size = 3 * device->aperture_size / 4;
+
+      if (device->info.has_llc) {
+         /* Big core GPUs share LLC with the CPU and thus one memory type can
+          * be both cached and coherent at the same time.
+          */
+         pMemoryProperties->memoryProperties.memoryTypeCount = 1;
+         pMemoryProperties->memoryProperties.memoryTypes[0] = (VkMemoryType) {
+            .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
+                             VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+                             VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
+                             VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
+            .heapIndex = 0,
+         };
+      } else {
+         /* The spec requires that we expose a host-visible, coherent memory
+          * type, but Atom GPUs don't share LLC. Thus we offer two memory
+          * types to give the application a choice between cached, but not
+          * coherent and coherent but uncached (WC though).
+          */
+         pMemoryProperties->memoryProperties.memoryTypeCount = 2;
+         pMemoryProperties->memoryProperties.memoryTypes[0] = (VkMemoryType) {
+            .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
+                             VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+                             VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+            .heapIndex = 0,
+         };
+         pMemoryProperties->memoryProperties.memoryTypes[1] = (VkMemoryType) {
+            .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
+                             VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+                             VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
+            .heapIndex = 0,
+         };
+      }
+
+      pMemoryProperties->memoryProperties.memoryHeapCount = 1;
+      pMemoryProperties->memoryProperties.memoryHeaps[0] = (VkMemoryHeap) {
+         .size = heap_size,
+         .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
+      };
+      break;
+   }
+
+   default:
+      break;
+   }
+}
+
+struct anv_structure_type {
+   VkStructureType type;
+   struct anv_structure_type *next;
+};
+
 void anv_GetPhysicalDeviceFeatures(
     VkPhysicalDevice                            physicalDevice,
     VkPhysicalDeviceFeatures*                   pFeatures)
 {
    ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+   struct anv_structure_type *iter = ((struct anv_structure_type *) pFeatures) - 1;
 
-   *pFeatures = (VkPhysicalDeviceFeatures) {
-      .robustBufferAccess                       = true,
-      .fullDrawIndexUint32                      = true,
-      .imageCubeArray                           = true,
-      .independentBlend                         = true,
-      .geometryShader                           = true,
-      .tessellationShader                       = true,
-      .sampleRateShading                        = true,
-      .dualSrcBlend                             = true,
-      .logicOp                                  = true,
-      .multiDrawIndirect                        = false,
-      .drawIndirectFirstInstance                = true,
-      .depthClamp                               = true,
-      .depthBiasClamp                           = true,
-      .fillModeNonSolid                         = true,
-      .depthBounds                              = false,
-      .wideLines                                = true,
-      .largePoints                              = true,
-      .alphaToOne                               = true,
-      .multiViewport                            = true,
-      .samplerAnisotropy                        = true,
-      .textureCompressionETC2                   = pdevice->info.gen >= 8 ||
-                                                  pdevice->info.is_baytrail,
-      .textureCompressionASTC_LDR               = pdevice->info.gen >= 9, /* FINISHME CHV */
-      .textureCompressionBC                     = true,
-      .occlusionQueryPrecise                    = true,
-      .pipelineStatisticsQuery                  = false,
-      .fragmentStoresAndAtomics                 = true,
-      .shaderTessellationAndGeometryPointSize   = true,
-      .shaderImageGatherExtended                = true,
-      .shaderStorageImageExtendedFormats        = true,
-      .shaderStorageImageMultisample            = false,
-      .shaderStorageImageReadWithoutFormat      = false,
-      .shaderStorageImageWriteWithoutFormat     = false,
-      .shaderUniformBufferArrayDynamicIndexing  = true,
-      .shaderSampledImageArrayDynamicIndexing   = true,
-      .shaderStorageBufferArrayDynamicIndexing  = true,
-      .shaderStorageImageArrayDynamicIndexing   = true,
-      .shaderClipDistance                       = true,
-      .shaderCullDistance                       = true,
-      .shaderFloat64                            = pdevice->info.gen >= 8,
-      .shaderInt64                              = false,
-      .shaderInt16                              = false,
-      .shaderResourceMinLod                     = false,
-      .variableMultisampleRate                  = false,
-      .inheritedQueries                         = false,
-   };
+   anv_physical_device_get(pdevice,
+                           VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR,
+                           iter);
+}
+
+void anv_GetPhysicalDeviceFeatures2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    VkPhysicalDeviceFeatures2KHR*               pFeatures)
+{
+   assert(pFeatures->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR);
 
-   /* We can't do image stores in vec4 shaders */
-   pFeatures->vertexPipelineStoresAndAtomics =
-      pdevice->compiler->scalar_stage[MESA_SHADER_VERTEX] &&
-      pdevice->compiler->scalar_stage[MESA_SHADER_GEOMETRY];
+   ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+   struct anv_structure_type *iter = (struct anv_structure_type *) pFeatures;
+
+   while (iter) {
+      anv_physical_device_get(pdevice, iter->type, iter);
+      iter = iter->next;
+   }
 }
 
 void anv_GetPhysicalDeviceProperties(
@@ -498,144 +737,37 @@ void anv_GetPhysicalDeviceProperties(
     VkPhysicalDeviceProperties*                 pProperties)
 {
    ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
-   const struct gen_device_info *devinfo = &pdevice->info;
-
-   const float time_stamp_base = devinfo->gen >= 9 ? 83.333 : 80.0;
-
-   /* See assertions made when programming the buffer surface state. */
-   const uint32_t max_raw_buffer_sz = devinfo->gen >= 7 ?
-                                      (1ul << 30) : (1ul << 27);
-
-   VkSampleCountFlags sample_counts =
-      isl_device_get_sample_counts(&pdevice->isl_dev);
-
-   VkPhysicalDeviceLimits limits = {
-      .maxImageDimension1D                      = (1 << 14),
-      .maxImageDimension2D                      = (1 << 14),
-      .maxImageDimension3D                      = (1 << 11),
-      .maxImageDimensionCube                    = (1 << 14),
-      .maxImageArrayLayers                      = (1 << 11),
-      .maxTexelBufferElements                   = 128 * 1024 * 1024,
-      .maxUniformBufferRange                    = (1ul << 27),
-      .maxStorageBufferRange                    = max_raw_buffer_sz,
-      .maxPushConstantsSize                     = MAX_PUSH_CONSTANTS_SIZE,
-      .maxMemoryAllocationCount                 = UINT32_MAX,
-      .maxSamplerAllocationCount                = 64 * 1024,
-      .bufferImageGranularity                   = 64, /* A cache line */
-      .sparseAddressSpaceSize                   = 0,
-      .maxBoundDescriptorSets                   = MAX_SETS,
-      .maxPerStageDescriptorSamplers            = 64,
-      .maxPerStageDescriptorUniformBuffers      = 64,
-      .maxPerStageDescriptorStorageBuffers      = 64,
-      .maxPerStageDescriptorSampledImages       = 64,
-      .maxPerStageDescriptorStorageImages       = 64,
-      .maxPerStageDescriptorInputAttachments    = 64,
-      .maxPerStageResources                     = 128,
-      .maxDescriptorSetSamplers                 = 256,
-      .maxDescriptorSetUniformBuffers           = 256,
-      .maxDescriptorSetUniformBuffersDynamic    = 256,
-      .maxDescriptorSetStorageBuffers           = 256,
-      .maxDescriptorSetStorageBuffersDynamic    = 256,
-      .maxDescriptorSetSampledImages            = 256,
-      .maxDescriptorSetStorageImages            = 256,
-      .maxDescriptorSetInputAttachments         = 256,
-      .maxVertexInputAttributes                 = 32,
-      .maxVertexInputBindings                   = 32,
-      .maxVertexInputAttributeOffset            = 2047,
-      .maxVertexInputBindingStride              = 2048,
-      .maxVertexOutputComponents                = 128,
-      .maxTessellationGenerationLevel           = 64,
-      .maxTessellationPatchSize                 = 32,
-      .maxTessellationControlPerVertexInputComponents = 128,
-      .maxTessellationControlPerVertexOutputComponents = 128,
-      .maxTessellationControlPerPatchOutputComponents = 128,
-      .maxTessellationControlTotalOutputComponents = 2048,
-      .maxTessellationEvaluationInputComponents = 128,
-      .maxTessellationEvaluationOutputComponents = 128,
-      .maxGeometryShaderInvocations             = 32,
-      .maxGeometryInputComponents               = 64,
-      .maxGeometryOutputComponents              = 128,
-      .maxGeometryOutputVertices                = 256,
-      .maxGeometryTotalOutputComponents         = 1024,
-      .maxFragmentInputComponents               = 128,
-      .maxFragmentOutputAttachments             = 8,
-      .maxFragmentDualSrcAttachments            = 1,
-      .maxFragmentCombinedOutputResources       = 8,
-      .maxComputeSharedMemorySize               = 32768,
-      .maxComputeWorkGroupCount                 = { 65535, 65535, 65535 },
-      .maxComputeWorkGroupInvocations           = 16 * devinfo->max_cs_threads,
-      .maxComputeWorkGroupSize = {
-         16 * devinfo->max_cs_threads,
-         16 * devinfo->max_cs_threads,
-         16 * devinfo->max_cs_threads,
-      },
-      .subPixelPrecisionBits                    = 4 /* FIXME */,
-      .subTexelPrecisionBits                    = 4 /* FIXME */,
-      .mipmapPrecisionBits                      = 4 /* FIXME */,
-      .maxDrawIndexedIndexValue                 = UINT32_MAX,
-      .maxDrawIndirectCount                     = UINT32_MAX,
-      .maxSamplerLodBias                        = 16,
-      .maxSamplerAnisotropy                     = 16,
-      .maxViewports                             = MAX_VIEWPORTS,
-      .maxViewportDimensions                    = { (1 << 14), (1 << 14) },
-      .viewportBoundsRange                      = { INT16_MIN, INT16_MAX },
-      .viewportSubPixelBits                     = 13, /* We take a float? */
-      .minMemoryMapAlignment                    = 4096, /* A page */
-      .minTexelBufferOffsetAlignment            = 1,
-      .minUniformBufferOffsetAlignment          = 16,
-      .minStorageBufferOffsetAlignment          = 4,
-      .minTexelOffset                           = -8,
-      .maxTexelOffset                           = 7,
-      .minTexelGatherOffset                     = -32,
-      .maxTexelGatherOffset                     = 31,
-      .minInterpolationOffset                   = -0.5,
-      .maxInterpolationOffset                   = 0.4375,
-      .subPixelInterpolationOffsetBits          = 4,
-      .maxFramebufferWidth                      = (1 << 14),
-      .maxFramebufferHeight                     = (1 << 14),
-      .maxFramebufferLayers                     = (1 << 11),
-      .framebufferColorSampleCounts             = sample_counts,
-      .framebufferDepthSampleCounts             = sample_counts,
-      .framebufferStencilSampleCounts           = sample_counts,
-      .framebufferNoAttachmentsSampleCounts     = sample_counts,
-      .maxColorAttachments                      = MAX_RTS,
-      .sampledImageColorSampleCounts            = sample_counts,
-      .sampledImageIntegerSampleCounts          = VK_SAMPLE_COUNT_1_BIT,
-      .sampledImageDepthSampleCounts            = sample_counts,
-      .sampledImageStencilSampleCounts          = sample_counts,
-      .storageImageSampleCounts                 = VK_SAMPLE_COUNT_1_BIT,
-      .maxSampleMaskWords                       = 1,
-      .timestampComputeAndGraphics              = false,
-      .timestampPeriod                          = time_stamp_base,
-      .maxClipDistances                         = 8,
-      .maxCullDistances                         = 8,
-      .maxCombinedClipAndCullDistances          = 8,
-      .discreteQueuePriorities                  = 1,
-      .pointSizeRange                           = { 0.125, 255.875 },
-      .lineWidthRange                           = { 0.0, 7.9921875 },
-      .pointSizeGranularity                     = (1.0 / 8.0),
-      .lineWidthGranularity                     = (1.0 / 128.0),
-      .strictLines                              = false, /* FINISHME */
-      .standardSampleLocations                  = true,
-      .optimalBufferCopyOffsetAlignment         = 128,
-      .optimalBufferCopyRowPitchAlignment       = 128,
-      .nonCoherentAtomSize                      = 64,
-   };
+   struct anv_structure_type *iter = ((struct anv_structure_type *) pProperties) - 1;
 
-   *pProperties = (VkPhysicalDeviceProperties) {
-      .apiVersion = VK_MAKE_VERSION(1, 0, 5),
-      .driverVersion = 1,
-      .vendorID = 0x8086,
-      .deviceID = pdevice->chipset_id,
-      .deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
-      .limits = limits,
-      .sparseProperties = {0}, /* Broadwell doesn't do sparse. */
-   };
+   anv_physical_device_get(pdevice,
+                           VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR,
+                           iter);
+}
+
+void anv_GetPhysicalDeviceProperties2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    VkPhysicalDeviceProperties2KHR*             pProperties)
+{
+   assert(pProperties->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR);
+
+   ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+   struct anv_structure_type *iter = (struct anv_structure_type *) pProperties;
 
-   strcpy(pProperties->deviceName, pdevice->name);
-   memcpy(pProperties->pipelineCacheUUID, pdevice->uuid, VK_UUID_SIZE);
+   while (iter) {
+      anv_physical_device_get(pdevice, iter->type, iter);
+      iter = iter->next;
+   }
 }
 
+static const VkQueueFamilyProperties queue_family = {
+   .queueFlags = (VK_QUEUE_GRAPHICS_BIT |
+                  VK_QUEUE_COMPUTE_BIT |
+                  VK_QUEUE_TRANSFER_BIT),
+   .queueCount = 1,
+   .timestampValidBits = 36, /* XXX: Real value here */
+   .minImageTransferGranularity = (VkExtent3D) { 1, 1, 1 },
+};
+
 void anv_GetPhysicalDeviceQueueFamilyProperties(
     VkPhysicalDevice                            physicalDevice,
     uint32_t*                                   pCount,
@@ -655,68 +787,55 @@ void anv_GetPhysicalDeviceQueueFamilyProperties(
    if (*pCount == 0)
       return;
 
-   *pQueueFamilyProperties = (VkQueueFamilyProperties) {
-      .queueFlags = VK_QUEUE_GRAPHICS_BIT |
-                    VK_QUEUE_COMPUTE_BIT |
-                    VK_QUEUE_TRANSFER_BIT,
-      .queueCount = 1,
-      .timestampValidBits = 36, /* XXX: Real value here */
-      .minImageTransferGranularity = (VkExtent3D) { 1, 1, 1 },
-   };
-
+   *pQueueFamilyProperties = queue_family;
    *pCount = 1;
 }
 
+void anv_GetPhysicalDeviceQueueFamilyProperties2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    uint32_t*                                   pQueueFamilyPropertyCount,
+    VkQueueFamilyProperties2KHR*                pQueueFamilyProperties)
+{
+   if (pQueueFamilyProperties == NULL) {
+      *pQueueFamilyPropertyCount = 1;
+      return;
+   }
+
+   if (*pQueueFamilyPropertyCount == 0)
+      return;
+
+   assert(pQueueFamilyProperties->sType == VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR);
+
+   pQueueFamilyProperties->queueFamilyProperties = queue_family;
+   *pQueueFamilyPropertyCount = 1;
+}
+
 void anv_GetPhysicalDeviceMemoryProperties(
     VkPhysicalDevice                            physicalDevice,
     VkPhysicalDeviceMemoryProperties*           pMemoryProperties)
 {
    ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
-   VkDeviceSize heap_size;
+   struct anv_structure_type *iter =
+      ((struct anv_structure_type *) pMemoryProperties) - 1;
 
-   /* Reserve some wiggle room for the driver by exposing only 75% of the
-    * aperture to the heap.
-    */
-   heap_size = 3 * physical_device->aperture_size / 4;
+   anv_physical_device_get(physical_device,
+                           VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR,
+                           iter);
+}
 
-   if (physical_device->info.has_llc) {
-      /* Big core GPUs share LLC with the CPU and thus one memory type can be
-       * both cached and coherent at the same time.
-       */
-      pMemoryProperties->memoryTypeCount = 1;
-      pMemoryProperties->memoryTypes[0] = (VkMemoryType) {
-         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
-                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
-                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
-                          VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
-         .heapIndex = 0,
-      };
-   } else {
-      /* The spec requires that we expose a host-visible, coherent memory
-       * type, but Atom GPUs don't share LLC. Thus we offer two memory types
-       * to give the application a choice between cached, but not coherent and
-       * coherent but uncached (WC though).
-       */
-      pMemoryProperties->memoryTypeCount = 2;
-      pMemoryProperties->memoryTypes[0] = (VkMemoryType) {
-         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
-                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
-                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-         .heapIndex = 0,
-      };
-      pMemoryProperties->memoryTypes[1] = (VkMemoryType) {
-         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
-                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
-                          VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
-         .heapIndex = 0,
-      };
-   }
+void anv_GetPhysicalDeviceMemoryProperties2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    VkPhysicalDeviceMemoryProperties2KHR*       pMemoryProperties)
+{
+   assert(pMemoryProperties->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR);
 
-   pMemoryProperties->memoryHeapCount = 1;
-   pMemoryProperties->memoryHeaps[0] = (VkMemoryHeap) {
-      .size = heap_size,
-      .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
-   };
+   ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+   struct anv_structure_type *iter = (struct anv_structure_type *) pMemoryProperties;
+
+   while (iter) {
+      anv_physical_device_get(physical_device, iter->type, iter);
+      iter = iter->next;
+   }
 }
 
 PFN_vkVoidFunction anv_GetInstanceProcAddr(
diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index a5d783e689..b599377308 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -450,6 +450,21 @@ void anv_GetPhysicalDeviceFormatProperties(
                pFormatProperties);
 }
 
+void anv_GetPhysicalDeviceFormatProperties2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    VkFormat                                    format,
+    VkFormatProperties2KHR*                     pFormatProperties)
+{
+   assert(pFormatProperties->sType == VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR);
+
+   ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+
+   anv_physical_device_get_format_properties(
+               physical_device,
+               format,
+               &pFormatProperties->formatProperties);
+}
+
 VkResult anv_GetPhysicalDeviceImageFormatProperties(
     VkPhysicalDevice                            physicalDevice,
     VkFormat                                    format,
@@ -604,6 +619,23 @@ unsupported:
    return VK_ERROR_FORMAT_NOT_SUPPORTED;
 }
 
+VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    const VkPhysicalDeviceImageFormatInfo2KHR*  pImageFormatInfo,
+    VkImageFormatProperties2KHR*                pImageFormatProperties)
+{
+   assert(pImageFormatProperties->sType == VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR);
+
+   return anv_GetPhysicalDeviceImageFormatProperties(
+      physicalDevice,
+      pImageFormatInfo->format,
+      pImageFormatInfo->type,
+      pImageFormatInfo->tiling,
+      pImageFormatInfo->usage,
+      pImageFormatInfo->flags,
+      &pImageFormatProperties->imageFormatProperties);
+}
+
 void anv_GetPhysicalDeviceSparseImageFormatProperties(
     VkPhysicalDevice                            physicalDevice,
     VkFormat                                    format,
@@ -617,3 +649,13 @@ void anv_GetPhysicalDeviceSparseImageFormatProperties(
    /* Sparse images are not yet supported. */
    *pNumProperties = 0;
 }
+
+void anv_GetPhysicalDeviceSparseImageFormatProperties2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo,
+    uint32_t*                                   pPropertyCount,
+    VkSparseImageFormatProperties2KHR*          pProperties)
+{
+   /* Sparse images are not yet supported. */
+   *pPropertyCount = 0;
+}
-- 
2.11.0



More information about the mesa-dev mailing list