1 // Copyright 2018 The SwiftShader Authors. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #include "VkPhysicalDevice.hpp"
18 #include "Pipeline/SpirvShader.hpp" // sw::SIMD::Width
25 PhysicalDevice::PhysicalDevice(const void*, void* mem)
29 const VkPhysicalDeviceFeatures& PhysicalDevice::getFeatures() const
31 static const VkPhysicalDeviceFeatures features
33 true, // robustBufferAccess
34 false, // fullDrawIndexUint32
35 false, // imageCubeArray
36 false, // independentBlend
37 false, // geometryShader
38 false, // tessellationShader
39 false, // sampleRateShading
40 false, // dualSrcBlend
42 false, // multiDrawIndirect
43 false, // drawIndirectFirstInstance
45 false, // depthBiasClamp
46 false, // fillModeNonSolid
51 false, // multiViewport
52 false, // samplerAnisotropy
53 true, // textureCompressionETC2
54 false, // textureCompressionASTC_LDR
55 false, // textureCompressionBC
56 false, // occlusionQueryPrecise
57 false, // pipelineStatisticsQuery
58 false, // vertexPipelineStoresAndAtomics
59 false, // fragmentStoresAndAtomics
60 false, // shaderTessellationAndGeometryPointSize
61 false, // shaderImageGatherExtended
62 false, // shaderStorageImageExtendedFormats
63 false, // shaderStorageImageMultisample
64 false, // shaderStorageImageReadWithoutFormat
65 false, // shaderStorageImageWriteWithoutFormat
66 false, // shaderUniformBufferArrayDynamicIndexing
67 false, // shaderSampledImageArrayDynamicIndexing
68 false, // shaderStorageBufferArrayDynamicIndexing
69 false, // shaderStorageImageArrayDynamicIndexing
70 false, // shaderClipDistance
71 false, // shaderCullDistance
72 false, // shaderFloat64
75 false, // shaderResourceResidency
76 false, // shaderResourceMinLod
77 false, // sparseBinding
78 false, // sparseResidencyBuffer
79 false, // sparseResidencyImage2D
80 false, // sparseResidencyImage3D
81 false, // sparseResidency2Samples
82 false, // sparseResidency4Samples
83 false, // sparseResidency8Samples
84 false, // sparseResidency16Samples
85 false, // sparseResidencyAliased
86 false, // variableMultisampleRate
87 false, // inheritedQueries
93 void PhysicalDevice::getFeatures(VkPhysicalDeviceSamplerYcbcrConversionFeatures* features) const
95 features->samplerYcbcrConversion = VK_FALSE;
98 void PhysicalDevice::getFeatures(VkPhysicalDevice16BitStorageFeatures* features) const
100 features->storageBuffer16BitAccess = VK_FALSE;
101 features->storageInputOutput16 = VK_FALSE;
102 features->storagePushConstant16 = VK_FALSE;
103 features->uniformAndStorageBuffer16BitAccess = VK_FALSE;
106 void PhysicalDevice::getFeatures(VkPhysicalDeviceVariablePointerFeatures* features) const
108 features->variablePointersStorageBuffer = VK_FALSE;
109 features->variablePointers = VK_FALSE;
112 void PhysicalDevice::getFeatures(VkPhysicalDevice8BitStorageFeaturesKHR* features) const
114 features->storageBuffer8BitAccess = VK_FALSE;
115 features->uniformAndStorageBuffer8BitAccess = VK_FALSE;
116 features->storagePushConstant8 = VK_FALSE;
119 void PhysicalDevice::getFeatures(VkPhysicalDeviceMultiviewFeatures* features) const
121 features->multiview = VK_FALSE;
122 features->multiviewGeometryShader = VK_FALSE;
123 features->multiviewTessellationShader = VK_FALSE;
126 void PhysicalDevice::getFeatures(VkPhysicalDeviceProtectedMemoryFeatures* features) const
128 features->protectedMemory = VK_FALSE;
131 VkSampleCountFlags PhysicalDevice::getSampleCounts() const
133 return VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT;
136 const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const
138 VkSampleCountFlags sampleCounts = getSampleCounts();
140 static const VkPhysicalDeviceLimits limits =
142 1 << (vk::MAX_IMAGE_LEVELS_1D - 1), // maxImageDimension1D
143 1 << (vk::MAX_IMAGE_LEVELS_2D - 1), // maxImageDimension2D
144 1 << (vk::MAX_IMAGE_LEVELS_3D - 1), // maxImageDimension3D
145 1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1), // maxImageDimensionCube
146 vk::MAX_IMAGE_ARRAY_LAYERS, // maxImageArrayLayers
147 65536, // maxTexelBufferElements
148 16384, // maxUniformBufferRange
149 (1ul << 27), // maxStorageBufferRange
150 vk::MAX_PUSH_CONSTANT_SIZE, // maxPushConstantsSize
151 4096, // maxMemoryAllocationCount
152 4000, // maxSamplerAllocationCount
153 131072, // bufferImageGranularity
154 0, // sparseAddressSpaceSize (unsupported)
155 MAX_BOUND_DESCRIPTOR_SETS, // maxBoundDescriptorSets
156 16, // maxPerStageDescriptorSamplers
157 12, // maxPerStageDescriptorUniformBuffers
158 4, // maxPerStageDescriptorStorageBuffers
159 16, // maxPerStageDescriptorSampledImages
160 4, // maxPerStageDescriptorStorageImages
161 4, // maxPerStageDescriptorInputAttachments
162 128, // maxPerStageResources
163 96, // maxDescriptorSetSamplers
164 72, // maxDescriptorSetUniformBuffers
165 8, // maxDescriptorSetUniformBuffersDynamic
166 24, // maxDescriptorSetStorageBuffers
167 4, // maxDescriptorSetStorageBuffersDynamic
168 96, // maxDescriptorSetSampledImages
169 24, // maxDescriptorSetStorageImages
170 4, // maxDescriptorSetInputAttachments
171 16, // maxVertexInputAttributes
172 vk::MAX_VERTEX_INPUT_BINDINGS, // maxVertexInputBindings
173 2047, // maxVertexInputAttributeOffset
174 2048, // maxVertexInputBindingStride
175 64, // maxVertexOutputComponents
176 0, // maxTessellationGenerationLevel (unsupported)
177 0, // maxTessellationPatchSize (unsupported)
178 0, // maxTessellationControlPerVertexInputComponents (unsupported)
179 0, // maxTessellationControlPerVertexOutputComponents (unsupported)
180 0, // maxTessellationControlPerPatchOutputComponents (unsupported)
181 0, // maxTessellationControlTotalOutputComponents (unsupported)
182 0, // maxTessellationEvaluationInputComponents (unsupported)
183 0, // maxTessellationEvaluationOutputComponents (unsupported)
184 0, // maxGeometryShaderInvocations (unsupported)
185 0, // maxGeometryInputComponents (unsupported)
186 0, // maxGeometryOutputComponents (unsupported)
187 0, // maxGeometryOutputVertices (unsupported)
188 0, // maxGeometryTotalOutputComponents (unsupported)
189 64, // maxFragmentInputComponents
190 4, // maxFragmentOutputAttachments
191 1, // maxFragmentDualSrcAttachments
192 4, // maxFragmentCombinedOutputResources
193 16384, // maxComputeSharedMemorySize
194 { 65535, 65535, 65535 }, // maxComputeWorkGroupCount[3]
195 128, // maxComputeWorkGroupInvocations
196 { 128, 128, 64, }, // maxComputeWorkGroupSize[3]
197 4, // subPixelPrecisionBits
198 4, // subTexelPrecisionBits
199 4, // mipmapPrecisionBits
200 UINT32_MAX, // maxDrawIndexedIndexValue
201 UINT32_MAX, // maxDrawIndirectCount
202 2, // maxSamplerLodBias
203 16, // maxSamplerAnisotropy
205 { 4096, 4096 }, // maxViewportDimensions[2]
206 { -8192, 8191 }, // viewportBoundsRange[2]
207 0, // viewportSubPixelBits
208 64, // minMemoryMapAlignment
209 vk::MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT, // minTexelBufferOffsetAlignment
210 vk::MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT, // minUniformBufferOffsetAlignment
211 vk::MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT, // minStorageBufferOffsetAlignment
212 -8, // minTexelOffset
214 -8, // minTexelGatherOffset
215 7, // maxTexelGatherOffset
216 -0.5, // minInterpolationOffset
217 0.5, // maxInterpolationOffset
218 4, // subPixelInterpolationOffsetBits
219 4096, // maxFramebufferWidth
220 4096, // maxFramebufferHeight
221 256, // maxFramebufferLayers
222 sampleCounts, // framebufferColorSampleCounts
223 sampleCounts, // framebufferDepthSampleCounts
224 sampleCounts, // framebufferStencilSampleCounts
225 sampleCounts, // framebufferNoAttachmentsSampleCounts
226 4, // maxColorAttachments
227 sampleCounts, // sampledImageColorSampleCounts
228 VK_SAMPLE_COUNT_1_BIT, // sampledImageIntegerSampleCounts
229 sampleCounts, // sampledImageDepthSampleCounts
230 sampleCounts, // sampledImageStencilSampleCounts
231 VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts (unsupported)
232 1, // maxSampleMaskWords
233 false, // timestampComputeAndGraphics
234 60, // timestampPeriod
235 8, // maxClipDistances
236 8, // maxCullDistances
237 8, // maxCombinedClipAndCullDistances
238 2, // discreteQueuePriorities
239 { 1.0, vk::MAX_POINT_SIZE }, // pointSizeRange[2]
240 { 1.0, 1.0 }, // lineWidthRange[2] (unsupported)
241 0.0, // pointSizeGranularity (unsupported)
242 0.0, // lineWidthGranularity (unsupported)
243 false, // strictLines
244 true, // standardSampleLocations
245 64, // optimalBufferCopyOffsetAlignment
246 64, // optimalBufferCopyRowPitchAlignment
247 256, // nonCoherentAtomSize
253 const VkPhysicalDeviceProperties& PhysicalDevice::getProperties() const
255 static const VkPhysicalDeviceProperties properties
261 VK_PHYSICAL_DEVICE_TYPE_CPU, // deviceType
262 SWIFTSHADER_DEVICE_NAME, // deviceName
263 SWIFTSHADER_UUID, // pipelineCacheUUID
264 getLimits(), // limits
265 { 0 } // sparseProperties
271 void PhysicalDevice::getProperties(VkPhysicalDeviceIDProperties* properties) const
273 memset(properties->deviceUUID, 0, VK_UUID_SIZE);
274 memset(properties->driverUUID, 0, VK_UUID_SIZE);
275 memset(properties->deviceLUID, 0, VK_LUID_SIZE);
277 memcpy(properties->deviceUUID, SWIFTSHADER_UUID, VK_UUID_SIZE);
278 *((uint64_t*)properties->driverUUID) = DRIVER_VERSION;
280 properties->deviceNodeMask = 0;
281 properties->deviceLUIDValid = VK_FALSE;
284 void PhysicalDevice::getProperties(VkPhysicalDeviceMaintenance3Properties* properties) const
286 properties->maxMemoryAllocationSize = 1 << 31;
287 properties->maxPerSetDescriptors = 1024;
290 void PhysicalDevice::getProperties(VkPhysicalDeviceMultiviewProperties* properties) const
292 properties->maxMultiviewViewCount = 0;
293 properties->maxMultiviewInstanceIndex = 0;
296 void PhysicalDevice::getProperties(VkPhysicalDevicePointClippingProperties* properties) const
298 properties->pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES;
301 void PhysicalDevice::getProperties(VkPhysicalDeviceProtectedMemoryProperties* properties) const
303 properties->protectedNoFault = VK_FALSE;
306 void PhysicalDevice::getProperties(VkPhysicalDeviceSubgroupProperties* properties) const
308 properties->subgroupSize = sw::SIMD::Width;
309 properties->supportedStages = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT | VK_SHADER_STAGE_COMPUTE_BIT;
310 properties->supportedOperations = VK_SUBGROUP_FEATURE_BASIC_BIT;
311 properties->quadOperationsInAllStages = VK_FALSE;
314 bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures& requestedFeatures) const
316 const VkPhysicalDeviceFeatures& supportedFeatures = getFeatures();
317 const VkBool32* supportedFeature = reinterpret_cast<const VkBool32*>(&supportedFeatures);
318 const VkBool32* requestedFeature = reinterpret_cast<const VkBool32*>(&requestedFeatures);
319 constexpr auto featureCount = sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32);
321 for(unsigned int i = 0; i < featureCount; i++)
323 if((requestedFeature[i] == VK_TRUE) && (supportedFeature[i] != VK_TRUE))
332 void PhysicalDevice::getFormatProperties(VkFormat format, VkFormatProperties* pFormatProperties) const
334 pFormatProperties->linearTilingFeatures = 0; // Unsupported format
335 pFormatProperties->optimalTilingFeatures = 0; // Unsupported format
336 pFormatProperties->bufferFeatures = 0; // Unsupported format
340 case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
341 case VK_FORMAT_R5G6B5_UNORM_PACK16:
342 case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
343 case VK_FORMAT_R8_UNORM:
344 case VK_FORMAT_R8_SNORM:
345 case VK_FORMAT_R8G8_UNORM:
346 case VK_FORMAT_R8G8_SNORM:
347 case VK_FORMAT_R8G8B8A8_UNORM:
348 case VK_FORMAT_R8G8B8A8_SNORM:
349 case VK_FORMAT_R8G8B8A8_SRGB:
350 case VK_FORMAT_B8G8R8A8_UNORM:
351 case VK_FORMAT_B8G8R8A8_SRGB:
352 case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
353 case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
354 case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
355 case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
356 case VK_FORMAT_R16_SFLOAT:
357 case VK_FORMAT_R16G16_SFLOAT:
358 case VK_FORMAT_R16G16B16A16_SFLOAT:
359 case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
360 case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
361 pFormatProperties->optimalTilingFeatures |=
362 VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
364 case VK_FORMAT_R8_UINT:
365 case VK_FORMAT_R8_SINT:
366 case VK_FORMAT_R8G8_UINT:
367 case VK_FORMAT_R8G8_SINT:
368 case VK_FORMAT_R8G8B8A8_UINT:
369 case VK_FORMAT_R8G8B8A8_SINT:
370 case VK_FORMAT_A8B8G8R8_UINT_PACK32:
371 case VK_FORMAT_A8B8G8R8_SINT_PACK32:
372 case VK_FORMAT_A2B10G10R10_UINT_PACK32:
373 case VK_FORMAT_R16_UINT:
374 case VK_FORMAT_R16_SINT:
375 case VK_FORMAT_R16G16_UINT:
376 case VK_FORMAT_R16G16_SINT:
377 case VK_FORMAT_R16G16B16A16_UINT:
378 case VK_FORMAT_R16G16B16A16_SINT:
379 case VK_FORMAT_R32_UINT:
380 case VK_FORMAT_R32_SINT:
381 case VK_FORMAT_R32_SFLOAT:
382 case VK_FORMAT_R32G32_UINT:
383 case VK_FORMAT_R32G32_SINT:
384 case VK_FORMAT_R32G32_SFLOAT:
385 case VK_FORMAT_R32G32B32A32_UINT:
386 case VK_FORMAT_R32G32B32A32_SINT:
387 case VK_FORMAT_R32G32B32A32_SFLOAT:
388 case VK_FORMAT_D16_UNORM:
389 case VK_FORMAT_D32_SFLOAT:
390 pFormatProperties->optimalTilingFeatures |=
391 VK_FORMAT_FEATURE_BLIT_SRC_BIT |
392 VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
393 VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
395 case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
396 case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
397 case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
398 case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
399 case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
400 case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
401 case VK_FORMAT_EAC_R11_UNORM_BLOCK:
402 case VK_FORMAT_EAC_R11_SNORM_BLOCK:
403 case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
404 case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
405 pFormatProperties->optimalTilingFeatures |=
406 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
407 VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
408 VK_FORMAT_FEATURE_TRANSFER_DST_BIT |
409 VK_FORMAT_FEATURE_BLIT_SRC_BIT |
410 VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
418 case VK_FORMAT_R32_UINT:
419 case VK_FORMAT_R32_SINT:
420 pFormatProperties->optimalTilingFeatures |=
421 VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
422 pFormatProperties->bufferFeatures |=
423 VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
425 case VK_FORMAT_R8G8B8A8_UNORM:
426 case VK_FORMAT_R8G8B8A8_SNORM:
427 case VK_FORMAT_R8G8B8A8_UINT:
428 case VK_FORMAT_R8G8B8A8_SINT:
429 case VK_FORMAT_R16G16B16A16_UINT:
430 case VK_FORMAT_R16G16B16A16_SINT:
431 case VK_FORMAT_R16G16B16A16_SFLOAT:
432 case VK_FORMAT_R32_SFLOAT:
433 case VK_FORMAT_R32G32_UINT:
434 case VK_FORMAT_R32G32_SINT:
435 case VK_FORMAT_R32G32_SFLOAT:
436 case VK_FORMAT_R32G32B32A32_UINT:
437 case VK_FORMAT_R32G32B32A32_SINT:
438 case VK_FORMAT_R32G32B32A32_SFLOAT:
439 pFormatProperties->optimalTilingFeatures |=
440 VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
442 case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
443 case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
444 case VK_FORMAT_A8B8G8R8_UINT_PACK32:
445 case VK_FORMAT_A8B8G8R8_SINT_PACK32:
446 pFormatProperties->bufferFeatures |=
447 VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
455 case VK_FORMAT_R5G6B5_UNORM_PACK16:
456 case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
457 case VK_FORMAT_R8_UNORM:
458 case VK_FORMAT_R8G8_UNORM:
459 case VK_FORMAT_R8G8B8A8_UNORM:
460 case VK_FORMAT_R8G8B8A8_SRGB:
461 case VK_FORMAT_B8G8R8A8_UNORM:
462 case VK_FORMAT_B8G8R8A8_SRGB:
463 case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
464 case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
465 case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
466 case VK_FORMAT_R16_SFLOAT:
467 case VK_FORMAT_R16G16_SFLOAT:
468 case VK_FORMAT_R16G16B16A16_SFLOAT:
469 pFormatProperties->optimalTilingFeatures |=
470 VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
472 case VK_FORMAT_R8_UINT:
473 case VK_FORMAT_R8_SINT:
474 case VK_FORMAT_R8G8_UINT:
475 case VK_FORMAT_R8G8_SINT:
476 case VK_FORMAT_R8G8B8A8_UINT:
477 case VK_FORMAT_R8G8B8A8_SINT:
478 case VK_FORMAT_A8B8G8R8_UINT_PACK32:
479 case VK_FORMAT_A8B8G8R8_SINT_PACK32:
480 case VK_FORMAT_A2B10G10R10_UINT_PACK32:
481 case VK_FORMAT_R16_UINT:
482 case VK_FORMAT_R16_SINT:
483 case VK_FORMAT_R16G16_UINT:
484 case VK_FORMAT_R16G16_SINT:
485 case VK_FORMAT_R16G16B16A16_UINT:
486 case VK_FORMAT_R16G16B16A16_SINT:
487 case VK_FORMAT_R32_UINT:
488 case VK_FORMAT_R32_SINT:
489 case VK_FORMAT_R32_SFLOAT:
490 case VK_FORMAT_R32G32_UINT:
491 case VK_FORMAT_R32G32_SINT:
492 case VK_FORMAT_R32G32_SFLOAT:
493 case VK_FORMAT_R32G32B32A32_UINT:
494 case VK_FORMAT_R32G32B32A32_SINT:
495 case VK_FORMAT_R32G32B32A32_SFLOAT:
496 pFormatProperties->optimalTilingFeatures |=
497 VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
498 VK_FORMAT_FEATURE_BLIT_DST_BIT;
500 case VK_FORMAT_D16_UNORM:
501 case VK_FORMAT_D32_SFLOAT: // Note: either VK_FORMAT_D32_SFLOAT or VK_FORMAT_X8_D24_UNORM_PACK32 must be supported
502 case VK_FORMAT_D32_SFLOAT_S8_UINT: // Note: either VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT must be supported
503 pFormatProperties->optimalTilingFeatures |=
504 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
512 case VK_FORMAT_R8_UNORM:
513 case VK_FORMAT_R8_SNORM:
514 case VK_FORMAT_R8_UINT:
515 case VK_FORMAT_R8_SINT:
516 case VK_FORMAT_R8G8_UNORM:
517 case VK_FORMAT_R8G8_SNORM:
518 case VK_FORMAT_R8G8_UINT:
519 case VK_FORMAT_R8G8_SINT:
520 case VK_FORMAT_R8G8B8A8_UNORM:
521 case VK_FORMAT_R8G8B8A8_SNORM:
522 case VK_FORMAT_R8G8B8A8_UINT:
523 case VK_FORMAT_R8G8B8A8_SINT:
524 case VK_FORMAT_B8G8R8A8_UNORM:
525 case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
526 case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
527 case VK_FORMAT_A8B8G8R8_UINT_PACK32:
528 case VK_FORMAT_A8B8G8R8_SINT_PACK32:
529 case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
530 case VK_FORMAT_R16_UNORM:
531 case VK_FORMAT_R16_SNORM:
532 case VK_FORMAT_R16_UINT:
533 case VK_FORMAT_R16_SINT:
534 case VK_FORMAT_R16_SFLOAT:
535 case VK_FORMAT_R16G16_UNORM:
536 case VK_FORMAT_R16G16_SNORM:
537 case VK_FORMAT_R16G16_UINT:
538 case VK_FORMAT_R16G16_SINT:
539 case VK_FORMAT_R16G16_SFLOAT:
540 case VK_FORMAT_R16G16B16A16_UNORM:
541 case VK_FORMAT_R16G16B16A16_SNORM:
542 case VK_FORMAT_R16G16B16A16_UINT:
543 case VK_FORMAT_R16G16B16A16_SINT:
544 case VK_FORMAT_R16G16B16A16_SFLOAT:
545 case VK_FORMAT_R32_UINT:
546 case VK_FORMAT_R32_SINT:
547 case VK_FORMAT_R32_SFLOAT:
548 case VK_FORMAT_R32G32_UINT:
549 case VK_FORMAT_R32G32_SINT:
550 case VK_FORMAT_R32G32_SFLOAT:
551 case VK_FORMAT_R32G32B32_UINT:
552 case VK_FORMAT_R32G32B32_SINT:
553 case VK_FORMAT_R32G32B32_SFLOAT:
554 case VK_FORMAT_R32G32B32A32_UINT:
555 case VK_FORMAT_R32G32B32A32_SINT:
556 case VK_FORMAT_R32G32B32A32_SFLOAT:
557 pFormatProperties->bufferFeatures |=
558 VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
566 case VK_FORMAT_R8_UNORM:
567 case VK_FORMAT_R8_SNORM:
568 case VK_FORMAT_R8_UINT:
569 case VK_FORMAT_R8_SINT:
570 case VK_FORMAT_R8G8_UNORM:
571 case VK_FORMAT_R8G8_SNORM:
572 case VK_FORMAT_R8G8_UINT:
573 case VK_FORMAT_R8G8_SINT:
574 case VK_FORMAT_R8G8B8A8_UNORM:
575 case VK_FORMAT_R8G8B8A8_SNORM:
576 case VK_FORMAT_R8G8B8A8_UINT:
577 case VK_FORMAT_R8G8B8A8_SINT:
578 case VK_FORMAT_B8G8R8A8_UNORM:
579 case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
580 case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
581 case VK_FORMAT_A8B8G8R8_UINT_PACK32:
582 case VK_FORMAT_A8B8G8R8_SINT_PACK32:
583 case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
584 case VK_FORMAT_A2B10G10R10_UINT_PACK32:
585 case VK_FORMAT_R16_UINT:
586 case VK_FORMAT_R16_SINT:
587 case VK_FORMAT_R16_SFLOAT:
588 case VK_FORMAT_R16G16_UINT:
589 case VK_FORMAT_R16G16_SINT:
590 case VK_FORMAT_R16G16_SFLOAT:
591 case VK_FORMAT_R16G16B16A16_UINT:
592 case VK_FORMAT_R16G16B16A16_SINT:
593 case VK_FORMAT_R16G16B16A16_SFLOAT:
594 case VK_FORMAT_R32_UINT:
595 case VK_FORMAT_R32_SINT:
596 case VK_FORMAT_R32_SFLOAT:
597 case VK_FORMAT_R32G32_UINT:
598 case VK_FORMAT_R32G32_SINT:
599 case VK_FORMAT_R32G32_SFLOAT:
600 case VK_FORMAT_R32G32B32A32_UINT:
601 case VK_FORMAT_R32G32B32A32_SINT:
602 case VK_FORMAT_R32G32B32A32_SFLOAT:
603 case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
604 pFormatProperties->bufferFeatures |=
605 VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
612 void PhysicalDevice::getImageFormatProperties(VkFormat format, VkImageType type, VkImageTiling tiling,
613 VkImageUsageFlags usage, VkImageCreateFlags flags,
614 VkImageFormatProperties* pImageFormatProperties) const
616 pImageFormatProperties->sampleCounts = VK_SAMPLE_COUNT_1_BIT;
617 pImageFormatProperties->maxArrayLayers = vk::MAX_IMAGE_ARRAY_LAYERS;
618 pImageFormatProperties->maxExtent.depth = 1;
622 case VK_IMAGE_TYPE_1D:
623 pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_1D;
624 pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_1D - 1);
625 pImageFormatProperties->maxExtent.height = 1;
627 case VK_IMAGE_TYPE_2D:
628 if(flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)
630 pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_CUBE;
631 pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1);
632 pImageFormatProperties->maxExtent.height = 1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1);
636 pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_2D;
637 pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_2D - 1);
638 pImageFormatProperties->maxExtent.height = 1 << (vk::MAX_IMAGE_LEVELS_2D - 1);
640 VkFormatProperties props;
641 getFormatProperties(format, &props);
642 auto features = tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures;
643 if (features & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
645 // Only renderable formats make sense for multisample
646 pImageFormatProperties->sampleCounts = getSampleCounts();
650 case VK_IMAGE_TYPE_3D:
651 pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_3D;
652 pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_3D - 1);
653 pImageFormatProperties->maxExtent.height = 1 << (vk::MAX_IMAGE_LEVELS_3D - 1);
654 pImageFormatProperties->maxExtent.depth = 1 << (vk::MAX_IMAGE_LEVELS_3D - 1);
655 pImageFormatProperties->maxArrayLayers = 1; // no 3D + layers
658 UNREACHABLE("VkImageType: %d", int(type));
662 pImageFormatProperties->maxResourceSize = 1 << 31; // Minimum value for maxResourceSize
665 uint32_t PhysicalDevice::getQueueFamilyPropertyCount() const
670 void PhysicalDevice::getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
671 VkQueueFamilyProperties* pQueueFamilyProperties) const
673 for(uint32_t i = 0; i < pQueueFamilyPropertyCount; i++)
675 pQueueFamilyProperties[i].minImageTransferGranularity.width = 1;
676 pQueueFamilyProperties[i].minImageTransferGranularity.height = 1;
677 pQueueFamilyProperties[i].minImageTransferGranularity.depth = 1;
678 pQueueFamilyProperties[i].queueCount = 1;
679 pQueueFamilyProperties[i].queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT;
680 pQueueFamilyProperties[i].timestampValidBits = 0; // No support for time stamps
684 const VkPhysicalDeviceMemoryProperties& PhysicalDevice::getMemoryProperties() const
686 static const VkPhysicalDeviceMemoryProperties properties
688 1, // memoryTypeCount
690 // vk::MEMORY_TYPE_GENERIC_BIT
692 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
693 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
694 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
695 VK_MEMORY_PROPERTY_HOST_CACHED_BIT, // propertyFlags
699 1, // memoryHeapCount
702 1ull << 31, // size, FIXME(sugoi): This should be configurable based on available RAM
703 VK_MEMORY_HEAP_DEVICE_LOCAL_BIT // flags