Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 1 | // Copyright 2018 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 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 |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 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. |
| 14 | |
| 15 | #include "VkPhysicalDevice.hpp" |
Nicolas Capens | 318d5e0 | 2018-11-16 14:28:36 -0500 | [diff] [blame] | 16 | |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 17 | #include "VkConfig.hpp" |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 18 | #include "Pipeline/SpirvShader.hpp" // sw::SIMD::Width |
Antonio Maiorano | ab210f9 | 2019-12-13 16:26:24 -0500 | [diff] [blame] | 19 | #include "Reactor/Reactor.hpp" |
Ben Clayton | 5ceec2c | 2019-03-13 09:16:50 +0000 | [diff] [blame] | 20 | |
Nicolas Capens | 318d5e0 | 2018-11-16 14:28:36 -0500 | [diff] [blame] | 21 | #include <cstring> |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 22 | #include <limits> |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 23 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 24 | namespace vk { |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 25 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 26 | static void setExternalMemoryProperties(VkExternalMemoryHandleTypeFlagBits handleType, VkExternalMemoryProperties *properties) |
David 'Digit' Turner | 359bc80 | 2019-08-14 17:46:07 +0200 | [diff] [blame] | 27 | { |
David 'Digit' Turner | 3a7101b | 2019-11-22 11:55:53 +0100 | [diff] [blame] | 28 | #if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 29 | if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT) |
David 'Digit' Turner | 359bc80 | 2019-08-14 17:46:07 +0200 | [diff] [blame] | 30 | { |
| 31 | properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT; |
| 32 | properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT; |
| 33 | properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT; |
| 34 | return; |
| 35 | } |
| 36 | #endif |
Chris Forbes | 9f1e03b | 2020-01-09 11:45:28 -0800 | [diff] [blame] | 37 | #if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER |
| 38 | if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) |
| 39 | { |
| 40 | properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID; |
| 41 | properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID; |
| 42 | properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT; |
| 43 | return; |
| 44 | } |
| 45 | #endif |
David 'Digit' Turner | e52e2db | 2019-09-09 17:58:46 +0200 | [diff] [blame] | 46 | #if VK_USE_PLATFORM_FUCHSIA |
| 47 | if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA) |
| 48 | { |
| 49 | properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA; |
| 50 | properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA; |
| 51 | properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT; |
| 52 | return; |
| 53 | } |
| 54 | #endif |
David 'Digit' Turner | 359bc80 | 2019-08-14 17:46:07 +0200 | [diff] [blame] | 55 | properties->compatibleHandleTypes = 0; |
| 56 | properties->exportFromImportedHandleTypes = 0; |
| 57 | properties->externalMemoryFeatures = 0; |
| 58 | } |
| 59 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 60 | PhysicalDevice::PhysicalDevice(const void *, void *mem) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 61 | { |
| 62 | } |
| 63 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 64 | const VkPhysicalDeviceFeatures &PhysicalDevice::getFeatures() const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 65 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 66 | static const VkPhysicalDeviceFeatures features{ |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 67 | VK_TRUE, // robustBufferAccess |
Alexis Hetu | a727d80 | 2019-12-04 13:33:40 -0500 | [diff] [blame] | 68 | VK_TRUE, // fullDrawIndexUint32 |
Alexis Hetu | 7a15cef | 2019-12-02 15:41:22 -0500 | [diff] [blame] | 69 | VK_TRUE, // imageCubeArray |
Alexis Hetu | 51d5108 | 2019-07-15 17:20:40 -0400 | [diff] [blame] | 70 | VK_TRUE, // independentBlend |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 71 | VK_FALSE, // geometryShader |
| 72 | VK_FALSE, // tessellationShader |
| 73 | VK_FALSE, // sampleRateShading |
| 74 | VK_FALSE, // dualSrcBlend |
| 75 | VK_FALSE, // logicOp |
| 76 | VK_TRUE, // multiDrawIndirect |
| 77 | VK_TRUE, // drawIndirectFirstInstance |
| 78 | VK_FALSE, // depthClamp |
| 79 | VK_FALSE, // depthBiasClamp |
Ben Clayton | 2210f80 | 2019-08-12 13:55:43 +0100 | [diff] [blame] | 80 | VK_TRUE, // fillModeNonSolid |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 81 | VK_FALSE, // depthBounds |
| 82 | VK_FALSE, // wideLines |
Marc-Antoine Desroches | b44162f | 2020-03-05 13:35:43 -0500 | [diff] [blame] | 83 | VK_TRUE, // largePoints |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 84 | VK_FALSE, // alphaToOne |
| 85 | VK_FALSE, // multiViewport |
Alexis Hetu | 21be09d | 2019-12-17 16:53:53 -0500 | [diff] [blame] | 86 | VK_TRUE, // samplerAnisotropy |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 87 | VK_TRUE, // textureCompressionETC2 |
Nicolas Capens | a4347a9 | 2020-03-01 08:29:25 -0500 | [diff] [blame] | 88 | #ifdef SWIFTSHADER_ENABLE_ASTC |
| 89 | VK_TRUE, // textureCompressionASTC_LDR |
| 90 | #else |
| 91 | VK_FALSE, // textureCompressionASTC_LDR |
| 92 | #endif |
Sean Risser | c101f74 | 2020-06-04 15:00:15 -0400 | [diff] [blame] | 93 | VK_TRUE, // textureCompressionBC |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 94 | VK_FALSE, // occlusionQueryPrecise |
| 95 | VK_FALSE, // pipelineStatisticsQuery |
Alexis Hetu | 860369f | 2019-08-30 11:55:02 -0400 | [diff] [blame] | 96 | VK_TRUE, // vertexPipelineStoresAndAtomics |
Alexis Hetu | 920100c | 2019-07-15 17:25:02 -0400 | [diff] [blame] | 97 | VK_TRUE, // fragmentStoresAndAtomics |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 98 | VK_FALSE, // shaderTessellationAndGeometryPointSize |
| 99 | VK_FALSE, // shaderImageGatherExtended |
Nicolas Capens | f6f1121 | 2020-07-01 00:27:23 -0400 | [diff] [blame] | 100 | VK_TRUE, // shaderStorageImageExtendedFormats |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 101 | VK_FALSE, // shaderStorageImageMultisample |
| 102 | VK_FALSE, // shaderStorageImageReadWithoutFormat |
| 103 | VK_FALSE, // shaderStorageImageWriteWithoutFormat |
Nicolas Capens | 5faf16f | 2020-04-29 23:22:26 -0400 | [diff] [blame] | 104 | VK_TRUE, // shaderUniformBufferArrayDynamicIndexing |
Nicolas Capens | 25646f4 | 2020-04-29 23:23:02 -0400 | [diff] [blame] | 105 | VK_TRUE, // shaderSampledImageArrayDynamicIndexing |
Nicolas Capens | fe63685 | 2020-04-29 23:23:31 -0400 | [diff] [blame] | 106 | VK_TRUE, // shaderStorageBufferArrayDynamicIndexing |
Nicolas Capens | b798cfa | 2020-04-29 23:24:19 -0400 | [diff] [blame] | 107 | VK_TRUE, // shaderStorageImageArrayDynamicIndexing |
Ben Clayton | 9ad035b | 2019-08-09 23:44:09 +0100 | [diff] [blame] | 108 | VK_TRUE, // shaderClipDistance |
| 109 | VK_TRUE, // shaderCullDistance |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 110 | VK_FALSE, // shaderFloat64 |
| 111 | VK_FALSE, // shaderInt64 |
| 112 | VK_FALSE, // shaderInt16 |
| 113 | VK_FALSE, // shaderResourceResidency |
| 114 | VK_FALSE, // shaderResourceMinLod |
| 115 | VK_FALSE, // sparseBinding |
| 116 | VK_FALSE, // sparseResidencyBuffer |
| 117 | VK_FALSE, // sparseResidencyImage2D |
| 118 | VK_FALSE, // sparseResidencyImage3D |
| 119 | VK_FALSE, // sparseResidency2Samples |
| 120 | VK_FALSE, // sparseResidency4Samples |
| 121 | VK_FALSE, // sparseResidency8Samples |
| 122 | VK_FALSE, // sparseResidency16Samples |
| 123 | VK_FALSE, // sparseResidencyAliased |
Chris Forbes | 0a9fbfe | 2019-12-16 18:06:42 -0800 | [diff] [blame] | 124 | VK_TRUE, // variableMultisampleRate |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 125 | VK_FALSE, // inheritedQueries |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | return features; |
| 129 | } |
| 130 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 131 | void PhysicalDevice::getFeatures(VkPhysicalDeviceSamplerYcbcrConversionFeatures *features) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 132 | { |
Nicolas Capens | e2f5da4 | 2019-05-16 11:01:31 -0400 | [diff] [blame] | 133 | features->samplerYcbcrConversion = VK_TRUE; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 134 | } |
| 135 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 136 | void PhysicalDevice::getFeatures(VkPhysicalDevice16BitStorageFeatures *features) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 137 | { |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 138 | features->storageBuffer16BitAccess = VK_FALSE; |
| 139 | features->storageInputOutput16 = VK_FALSE; |
| 140 | features->storagePushConstant16 = VK_FALSE; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 141 | features->uniformAndStorageBuffer16BitAccess = VK_FALSE; |
| 142 | } |
| 143 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 144 | void PhysicalDevice::getFeatures(VkPhysicalDeviceVariablePointerFeatures *features) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 145 | { |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 146 | features->variablePointersStorageBuffer = VK_FALSE; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 147 | features->variablePointers = VK_FALSE; |
| 148 | } |
| 149 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 150 | void PhysicalDevice::getFeatures(VkPhysicalDevice8BitStorageFeaturesKHR *features) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 151 | { |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 152 | features->storageBuffer8BitAccess = VK_FALSE; |
| 153 | features->uniformAndStorageBuffer8BitAccess = VK_FALSE; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 154 | features->storagePushConstant8 = VK_FALSE; |
| 155 | } |
| 156 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 157 | void PhysicalDevice::getFeatures(VkPhysicalDeviceMultiviewFeatures *features) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 158 | { |
Chris Forbes | 02d4c0d | 2019-08-21 12:04:34 -0700 | [diff] [blame] | 159 | features->multiview = VK_TRUE; |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 160 | features->multiviewGeometryShader = VK_FALSE; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 161 | features->multiviewTessellationShader = VK_FALSE; |
| 162 | } |
| 163 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 164 | void PhysicalDevice::getFeatures(VkPhysicalDeviceProtectedMemoryFeatures *features) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 165 | { |
| 166 | features->protectedMemory = VK_FALSE; |
| 167 | } |
| 168 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 169 | void PhysicalDevice::getFeatures(VkPhysicalDeviceShaderDrawParameterFeatures *features) const |
Chris Forbes | 6408c55 | 2019-04-15 12:59:34 -0700 | [diff] [blame] | 170 | { |
| 171 | features->shaderDrawParameters = VK_FALSE; |
| 172 | } |
| 173 | |
Ben Clayton | a0453d5 | 2020-02-11 18:05:41 +0000 | [diff] [blame] | 174 | void PhysicalDevice::getFeatures(VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *features) const |
Alexis Hetu | aabd085 | 2020-02-10 14:27:29 -0500 | [diff] [blame] | 175 | { |
| 176 | features->separateDepthStencilLayouts = VK_TRUE; |
| 177 | } |
| 178 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 179 | void PhysicalDevice::getFeatures(VkPhysicalDeviceLineRasterizationFeaturesEXT *features) const |
Alexis Hetu | 23f9c25 | 2019-10-17 13:58:25 -0400 | [diff] [blame] | 180 | { |
| 181 | features->rectangularLines = VK_TRUE; |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 182 | features->bresenhamLines = VK_TRUE; |
| 183 | features->smoothLines = VK_FALSE; |
| 184 | features->stippledRectangularLines = VK_FALSE; |
| 185 | features->stippledBresenhamLines = VK_FALSE; |
| 186 | features->stippledSmoothLines = VK_FALSE; |
Alexis Hetu | 23f9c25 | 2019-10-17 13:58:25 -0400 | [diff] [blame] | 187 | } |
| 188 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 189 | void PhysicalDevice::getFeatures(VkPhysicalDeviceProvokingVertexFeaturesEXT *features) const |
Alexis Hetu | e1cda39 | 2019-10-29 14:29:02 -0400 | [diff] [blame] | 190 | { |
| 191 | features->provokingVertexLast = VK_TRUE; |
| 192 | } |
| 193 | |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 194 | VkSampleCountFlags PhysicalDevice::getSampleCounts() const |
| 195 | { |
| 196 | return VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT; |
| 197 | } |
| 198 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 199 | const VkPhysicalDeviceLimits &PhysicalDevice::getLimits() const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 200 | { |
| 201 | VkSampleCountFlags sampleCounts = getSampleCounts(); |
| 202 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 203 | static const VkPhysicalDeviceLimits limits = { |
| 204 | 1 << (vk::MAX_IMAGE_LEVELS_1D - 1), // maxImageDimension1D |
| 205 | 1 << (vk::MAX_IMAGE_LEVELS_2D - 1), // maxImageDimension2D |
| 206 | 1 << (vk::MAX_IMAGE_LEVELS_3D - 1), // maxImageDimension3D |
| 207 | 1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1), // maxImageDimensionCube |
| 208 | vk::MAX_IMAGE_ARRAY_LAYERS, // maxImageArrayLayers |
| 209 | 65536, // maxTexelBufferElements |
| 210 | 16384, // maxUniformBufferRange |
| 211 | (1ul << 27), // maxStorageBufferRange |
| 212 | vk::MAX_PUSH_CONSTANT_SIZE, // maxPushConstantsSize |
| 213 | 4096, // maxMemoryAllocationCount |
| 214 | 4000, // maxSamplerAllocationCount |
| 215 | 131072, // bufferImageGranularity |
| 216 | 0, // sparseAddressSpaceSize (unsupported) |
| 217 | MAX_BOUND_DESCRIPTOR_SETS, // maxBoundDescriptorSets |
| 218 | 16, // maxPerStageDescriptorSamplers |
| 219 | 14, // maxPerStageDescriptorUniformBuffers |
| 220 | 16, // maxPerStageDescriptorStorageBuffers |
| 221 | 16, // maxPerStageDescriptorSampledImages |
| 222 | 4, // maxPerStageDescriptorStorageImages |
| 223 | 4, // maxPerStageDescriptorInputAttachments |
| 224 | 128, // maxPerStageResources |
| 225 | 96, // maxDescriptorSetSamplers |
| 226 | 72, // maxDescriptorSetUniformBuffers |
| 227 | MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC, // maxDescriptorSetUniformBuffersDynamic |
| 228 | 24, // maxDescriptorSetStorageBuffers |
| 229 | MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC, // maxDescriptorSetStorageBuffersDynamic |
| 230 | 96, // maxDescriptorSetSampledImages |
| 231 | 24, // maxDescriptorSetStorageImages |
| 232 | 4, // maxDescriptorSetInputAttachments |
| 233 | 16, // maxVertexInputAttributes |
| 234 | vk::MAX_VERTEX_INPUT_BINDINGS, // maxVertexInputBindings |
| 235 | 2047, // maxVertexInputAttributeOffset |
| 236 | 2048, // maxVertexInputBindingStride |
| 237 | sw::MAX_INTERFACE_COMPONENTS, // maxVertexOutputComponents |
| 238 | 0, // maxTessellationGenerationLevel (unsupported) |
| 239 | 0, // maxTessellationPatchSize (unsupported) |
| 240 | 0, // maxTessellationControlPerVertexInputComponents (unsupported) |
| 241 | 0, // maxTessellationControlPerVertexOutputComponents (unsupported) |
| 242 | 0, // maxTessellationControlPerPatchOutputComponents (unsupported) |
| 243 | 0, // maxTessellationControlTotalOutputComponents (unsupported) |
| 244 | 0, // maxTessellationEvaluationInputComponents (unsupported) |
| 245 | 0, // maxTessellationEvaluationOutputComponents (unsupported) |
| 246 | 0, // maxGeometryShaderInvocations (unsupported) |
| 247 | 0, // maxGeometryInputComponents (unsupported) |
| 248 | 0, // maxGeometryOutputComponents (unsupported) |
| 249 | 0, // maxGeometryOutputVertices (unsupported) |
| 250 | 0, // maxGeometryTotalOutputComponents (unsupported) |
| 251 | sw::MAX_INTERFACE_COMPONENTS, // maxFragmentInputComponents |
| 252 | 4, // maxFragmentOutputAttachments |
| 253 | 1, // maxFragmentDualSrcAttachments |
| 254 | 4, // maxFragmentCombinedOutputResources |
| 255 | 16384, // maxComputeSharedMemorySize |
| 256 | { 65535, 65535, 65535 }, // maxComputeWorkGroupCount[3] |
| 257 | 128, // maxComputeWorkGroupInvocations |
| 258 | { 128, 128, 64 }, // maxComputeWorkGroupSize[3] |
| 259 | vk::SUBPIXEL_PRECISION_BITS, // subPixelPrecisionBits |
| 260 | 4, // subTexelPrecisionBits |
| 261 | 4, // mipmapPrecisionBits |
| 262 | UINT32_MAX, // maxDrawIndexedIndexValue |
| 263 | UINT32_MAX, // maxDrawIndirectCount |
| 264 | vk::MAX_SAMPLER_LOD_BIAS, // maxSamplerLodBias |
| 265 | 16, // maxSamplerAnisotropy |
| 266 | 16, // maxViewports |
| 267 | { 4096, 4096 }, // maxViewportDimensions[2] |
| 268 | { -8192, 8191 }, // viewportBoundsRange[2] |
| 269 | 0, // viewportSubPixelBits |
| 270 | 64, // minMemoryMapAlignment |
| 271 | vk::MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT, // minTexelBufferOffsetAlignment |
| 272 | vk::MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT, // minUniformBufferOffsetAlignment |
| 273 | vk::MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT, // minStorageBufferOffsetAlignment |
| 274 | sw::MIN_TEXEL_OFFSET, // minTexelOffset |
| 275 | sw::MAX_TEXEL_OFFSET, // maxTexelOffset |
| 276 | sw::MIN_TEXEL_OFFSET, // minTexelGatherOffset |
| 277 | sw::MAX_TEXEL_OFFSET, // maxTexelGatherOffset |
| 278 | -0.5, // minInterpolationOffset |
| 279 | 0.5, // maxInterpolationOffset |
| 280 | 4, // subPixelInterpolationOffsetBits |
| 281 | 4096, // maxFramebufferWidth |
| 282 | 4096, // maxFramebufferHeight |
| 283 | 256, // maxFramebufferLayers |
| 284 | sampleCounts, // framebufferColorSampleCounts |
| 285 | sampleCounts, // framebufferDepthSampleCounts |
| 286 | sampleCounts, // framebufferStencilSampleCounts |
| 287 | sampleCounts, // framebufferNoAttachmentsSampleCounts |
| 288 | 4, // maxColorAttachments |
| 289 | sampleCounts, // sampledImageColorSampleCounts |
Ian Elliott | df913b9 | 2020-01-09 15:27:47 -0700 | [diff] [blame] | 290 | sampleCounts, // sampledImageIntegerSampleCounts |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 291 | sampleCounts, // sampledImageDepthSampleCounts |
| 292 | sampleCounts, // sampledImageStencilSampleCounts |
| 293 | VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts (unsupported) |
| 294 | 1, // maxSampleMaskWords |
| 295 | VK_FALSE, // timestampComputeAndGraphics |
| 296 | 60, // timestampPeriod |
| 297 | sw::MAX_CLIP_DISTANCES, // maxClipDistances |
| 298 | sw::MAX_CULL_DISTANCES, // maxCullDistances |
| 299 | sw::MAX_CLIP_DISTANCES + sw::MAX_CULL_DISTANCES, // maxCombinedClipAndCullDistances |
| 300 | 2, // discreteQueuePriorities |
| 301 | { 1.0, vk::MAX_POINT_SIZE }, // pointSizeRange[2] |
| 302 | { 1.0, 1.0 }, // lineWidthRange[2] (unsupported) |
| 303 | 0.0, // pointSizeGranularity (unsupported) |
| 304 | 0.0, // lineWidthGranularity (unsupported) |
| 305 | VK_TRUE, // strictLines |
| 306 | VK_TRUE, // standardSampleLocations |
| 307 | 64, // optimalBufferCopyOffsetAlignment |
| 308 | 64, // optimalBufferCopyRowPitchAlignment |
| 309 | 256, // nonCoherentAtomSize |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | return limits; |
| 313 | } |
| 314 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 315 | const VkPhysicalDeviceProperties &PhysicalDevice::getProperties() const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 316 | { |
Antonio Maiorano | ab210f9 | 2019-12-13 16:26:24 -0500 | [diff] [blame] | 317 | auto getProperties = [&]() -> VkPhysicalDeviceProperties { |
| 318 | VkPhysicalDeviceProperties properties = { |
| 319 | API_VERSION, |
| 320 | DRIVER_VERSION, |
| 321 | VENDOR_ID, |
| 322 | DEVICE_ID, |
| 323 | VK_PHYSICAL_DEVICE_TYPE_CPU, // deviceType |
| 324 | "", // deviceName |
| 325 | SWIFTSHADER_UUID, // pipelineCacheUUID |
| 326 | getLimits(), // limits |
| 327 | {} // sparseProperties |
| 328 | }; |
| 329 | |
| 330 | // Append Reactor JIT backend name and version |
| 331 | snprintf(properties.deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE, |
| 332 | "%s (%s)", SWIFTSHADER_DEVICE_NAME, rr::BackendName().c_str()); |
| 333 | |
| 334 | return properties; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 335 | }; |
| 336 | |
Antonio Maiorano | ab210f9 | 2019-12-13 16:26:24 -0500 | [diff] [blame] | 337 | static const VkPhysicalDeviceProperties properties = getProperties(); |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 338 | return properties; |
| 339 | } |
| 340 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 341 | void PhysicalDevice::getProperties(VkPhysicalDeviceIDProperties *properties) const |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 342 | { |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 343 | memset(properties->deviceUUID, 0, VK_UUID_SIZE); |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 344 | memset(properties->driverUUID, 0, VK_UUID_SIZE); |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 345 | memset(properties->deviceLUID, 0, VK_LUID_SIZE); |
| 346 | |
| 347 | memcpy(properties->deviceUUID, SWIFTSHADER_UUID, VK_UUID_SIZE); |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 348 | *((uint64_t *)properties->driverUUID) = DRIVER_VERSION; |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 349 | |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 350 | properties->deviceNodeMask = 0; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 351 | properties->deviceLUIDValid = VK_FALSE; |
| 352 | } |
| 353 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 354 | void PhysicalDevice::getProperties(VkPhysicalDeviceMaintenance3Properties *properties) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 355 | { |
Nicolas Capens | a57e2ec | 2019-12-27 02:05:18 -0500 | [diff] [blame] | 356 | properties->maxMemoryAllocationSize = MAX_MEMORY_ALLOCATION_SIZE; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 357 | properties->maxPerSetDescriptors = 1024; |
| 358 | } |
| 359 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 360 | void PhysicalDevice::getProperties(VkPhysicalDeviceMultiviewProperties *properties) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 361 | { |
Chris Forbes | 02d4c0d | 2019-08-21 12:04:34 -0700 | [diff] [blame] | 362 | properties->maxMultiviewViewCount = 6; |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 363 | properties->maxMultiviewInstanceIndex = 1u << 27; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 364 | } |
| 365 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 366 | void PhysicalDevice::getProperties(VkPhysicalDevicePointClippingProperties *properties) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 367 | { |
| 368 | properties->pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES; |
| 369 | } |
| 370 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 371 | void PhysicalDevice::getProperties(VkPhysicalDeviceProtectedMemoryProperties *properties) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 372 | { |
| 373 | properties->protectedNoFault = VK_FALSE; |
| 374 | } |
| 375 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 376 | void PhysicalDevice::getProperties(VkPhysicalDeviceSubgroupProperties *properties) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 377 | { |
Ben Clayton | 5ceec2c | 2019-03-13 09:16:50 +0000 | [diff] [blame] | 378 | properties->subgroupSize = sw::SIMD::Width; |
Alexis Hetu | 38ff830 | 2018-10-18 15:08:13 -0400 | [diff] [blame] | 379 | properties->supportedStages = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT | VK_SHADER_STAGE_COMPUTE_BIT; |
Ben Clayton | 2ef02cb | 2019-08-13 11:47:21 +0100 | [diff] [blame] | 380 | properties->supportedOperations = |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 381 | VK_SUBGROUP_FEATURE_BASIC_BIT | |
| 382 | VK_SUBGROUP_FEATURE_VOTE_BIT | |
| 383 | VK_SUBGROUP_FEATURE_ARITHMETIC_BIT | |
| 384 | VK_SUBGROUP_FEATURE_BALLOT_BIT | |
| 385 | VK_SUBGROUP_FEATURE_SHUFFLE_BIT | |
| 386 | VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 387 | properties->quadOperationsInAllStages = VK_FALSE; |
| 388 | } |
| 389 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 390 | void PhysicalDevice::getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 391 | { |
David 'Digit' Turner | 359bc80 | 2019-08-14 17:46:07 +0200 | [diff] [blame] | 392 | setExternalMemoryProperties(*handleType, &properties->externalMemoryProperties); |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 393 | } |
| 394 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 395 | void PhysicalDevice::getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 396 | { |
Nicolas Capens | e2f5da4 | 2019-05-16 11:01:31 -0400 | [diff] [blame] | 397 | properties->combinedImageSamplerDescriptorCount = 1; // Need only one descriptor for YCbCr sampling. |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 398 | } |
| 399 | |
Hernan Liatis | 83a3eb4 | 2019-04-29 17:16:10 -0700 | [diff] [blame] | 400 | #ifdef __ANDROID__ |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 401 | void PhysicalDevice::getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const |
Hernan Liatis | 83a3eb4 | 2019-04-29 17:16:10 -0700 | [diff] [blame] | 402 | { |
| 403 | properties->sharedImage = VK_FALSE; |
| 404 | } |
| 405 | #endif |
| 406 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 407 | void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 408 | { |
David 'Digit' Turner | 359bc80 | 2019-08-14 17:46:07 +0200 | [diff] [blame] | 409 | setExternalMemoryProperties(pExternalBufferInfo->handleType, &pExternalBufferProperties->externalMemoryProperties); |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 410 | } |
| 411 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 412 | void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 413 | { |
| 414 | pExternalFenceProperties->compatibleHandleTypes = 0; |
| 415 | pExternalFenceProperties->exportFromImportedHandleTypes = 0; |
| 416 | pExternalFenceProperties->externalFenceFeatures = 0; |
| 417 | } |
| 418 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 419 | void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties) const |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 420 | { |
David 'Digit' Turner | 3a7101b | 2019-11-22 11:55:53 +0100 | [diff] [blame] | 421 | #if SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 422 | if(pExternalSemaphoreInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT) |
David 'Digit' Turner | 7c4d0a0 | 2019-09-03 17:00:02 +0200 | [diff] [blame] | 423 | { |
| 424 | pExternalSemaphoreProperties->compatibleHandleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT; |
| 425 | pExternalSemaphoreProperties->exportFromImportedHandleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT; |
| 426 | pExternalSemaphoreProperties->externalSemaphoreFeatures = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT | VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT; |
| 427 | return; |
| 428 | } |
| 429 | #endif |
David 'Digit' Turner | 3a7101b | 2019-11-22 11:55:53 +0100 | [diff] [blame] | 430 | #if VK_USE_PLATFORM_FUCHSIA |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 431 | if(pExternalSemaphoreInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA) |
David 'Digit' Turner | fda994c | 2019-09-04 16:36:36 +0200 | [diff] [blame] | 432 | { |
| 433 | pExternalSemaphoreProperties->compatibleHandleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA; |
| 434 | pExternalSemaphoreProperties->exportFromImportedHandleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA; |
| 435 | pExternalSemaphoreProperties->externalSemaphoreFeatures = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT | VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT; |
| 436 | return; |
| 437 | } |
| 438 | #endif |
Alexis Hetu | 0083573 | 2019-04-10 16:36:31 -0400 | [diff] [blame] | 439 | pExternalSemaphoreProperties->compatibleHandleTypes = 0; |
| 440 | pExternalSemaphoreProperties->exportFromImportedHandleTypes = 0; |
| 441 | pExternalSemaphoreProperties->externalSemaphoreFeatures = 0; |
| 442 | } |
| 443 | |
Jonah Ryan-Davis | f9f999f | 2020-01-08 14:41:28 -0500 | [diff] [blame] | 444 | void PhysicalDevice::getProperties(VkPhysicalDeviceExternalMemoryHostPropertiesEXT *properties) const |
| 445 | { |
| 446 | properties->minImportedHostPointerAlignment = REQUIRED_MEMORY_ALIGNMENT; |
| 447 | } |
| 448 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 449 | void PhysicalDevice::getProperties(VkPhysicalDeviceDriverPropertiesKHR *properties) const |
Nicolas Capens | 657dd6c | 2018-11-16 17:41:37 -0500 | [diff] [blame] | 450 | { |
| 451 | properties->driverID = VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR; |
| 452 | strcpy(properties->driverName, "SwiftShader driver"); |
| 453 | strcpy(properties->driverInfo, ""); |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 454 | properties->conformanceVersion = { 1, 1, 3, 3 }; |
Nicolas Capens | 657dd6c | 2018-11-16 17:41:37 -0500 | [diff] [blame] | 455 | } |
| 456 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 457 | void PhysicalDevice::getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const |
Alexis Hetu | 23f9c25 | 2019-10-17 13:58:25 -0400 | [diff] [blame] | 458 | { |
| 459 | properties->lineSubPixelPrecisionBits = vk::SUBPIXEL_PRECISION_BITS; |
| 460 | } |
| 461 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 462 | void PhysicalDevice::getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const |
Alexis Hetu | f8f6103 | 2019-10-10 16:45:30 -0400 | [diff] [blame] | 463 | { |
| 464 | properties->provokingVertexModePerPipeline = VK_TRUE; |
| 465 | } |
| 466 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 467 | bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatures) const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 468 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 469 | const VkPhysicalDeviceFeatures &supportedFeatures = getFeatures(); |
| 470 | const VkBool32 *supportedFeature = reinterpret_cast<const VkBool32 *>(&supportedFeatures); |
| 471 | const VkBool32 *requestedFeature = reinterpret_cast<const VkBool32 *>(&requestedFeatures); |
Nicolas Capens | d5f1489 | 2018-11-13 14:06:37 -0500 | [diff] [blame] | 472 | constexpr auto featureCount = sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32); |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 473 | |
Nicolas Capens | d5f1489 | 2018-11-13 14:06:37 -0500 | [diff] [blame] | 474 | for(unsigned int i = 0; i < featureCount; i++) |
| 475 | { |
Nicolas Capens | 8fff8c3 | 2020-01-22 03:07:14 -0500 | [diff] [blame] | 476 | if((requestedFeature[i] != VK_FALSE) && (supportedFeature[i] == VK_FALSE)) |
Nicolas Capens | d5f1489 | 2018-11-13 14:06:37 -0500 | [diff] [blame] | 477 | { |
| 478 | return false; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | return true; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 483 | } |
| 484 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 485 | void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFormatProperties) const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 486 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 487 | pFormatProperties->linearTilingFeatures = 0; // Unsupported format |
| 488 | pFormatProperties->optimalTilingFeatures = 0; // Unsupported format |
| 489 | pFormatProperties->bufferFeatures = 0; // Unsupported format |
Alexis Hetu | 67c93d2 | 2018-11-26 14:10:44 -0500 | [diff] [blame] | 490 | |
Alexis Hetu | 67c93d2 | 2018-11-26 14:10:44 -0500 | [diff] [blame] | 491 | switch(format) |
Ben Clayton | d531712 | 2019-02-19 16:39:36 +0000 | [diff] [blame] | 492 | { |
Nicolas Capens | d6d0edc | 2020-01-15 22:50:51 -0500 | [diff] [blame] | 493 | // Formats which can be sampled *and* filtered |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 494 | case VK_FORMAT_B4G4R4A4_UNORM_PACK16: |
| 495 | case VK_FORMAT_R5G6B5_UNORM_PACK16: |
| 496 | case VK_FORMAT_A1R5G5B5_UNORM_PACK16: |
| 497 | case VK_FORMAT_R8_UNORM: |
| 498 | case VK_FORMAT_R8_SRGB: |
| 499 | case VK_FORMAT_R8_SNORM: |
| 500 | case VK_FORMAT_R8G8_UNORM: |
| 501 | case VK_FORMAT_R8G8_SRGB: |
| 502 | case VK_FORMAT_R8G8_SNORM: |
| 503 | case VK_FORMAT_R8G8B8A8_UNORM: |
| 504 | case VK_FORMAT_R8G8B8A8_SNORM: |
| 505 | case VK_FORMAT_R8G8B8A8_SRGB: |
| 506 | case VK_FORMAT_B8G8R8A8_UNORM: |
| 507 | case VK_FORMAT_B8G8R8A8_SRGB: |
| 508 | case VK_FORMAT_A8B8G8R8_UNORM_PACK32: |
| 509 | case VK_FORMAT_A8B8G8R8_SNORM_PACK32: |
| 510 | case VK_FORMAT_A8B8G8R8_SRGB_PACK32: |
| 511 | case VK_FORMAT_A2B10G10R10_UNORM_PACK32: |
Alexis Hetu | b8a61bf | 2020-01-09 15:26:34 -0500 | [diff] [blame] | 512 | case VK_FORMAT_A2R10G10B10_UNORM_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 513 | case VK_FORMAT_R16_SFLOAT: |
| 514 | case VK_FORMAT_R16G16_SFLOAT: |
| 515 | case VK_FORMAT_R16G16B16A16_SFLOAT: |
Alexis Hetu | e82d885 | 2019-12-18 10:06:43 -0500 | [diff] [blame] | 516 | case VK_FORMAT_R32_SFLOAT: |
| 517 | case VK_FORMAT_R32G32_SFLOAT: |
| 518 | case VK_FORMAT_R32G32B32A32_SFLOAT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 519 | case VK_FORMAT_B10G11R11_UFLOAT_PACK32: |
| 520 | case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: |
| 521 | case VK_FORMAT_BC1_RGB_UNORM_BLOCK: |
| 522 | case VK_FORMAT_BC1_RGB_SRGB_BLOCK: |
| 523 | case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: |
| 524 | case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: |
| 525 | case VK_FORMAT_BC2_UNORM_BLOCK: |
| 526 | case VK_FORMAT_BC2_SRGB_BLOCK: |
| 527 | case VK_FORMAT_BC3_UNORM_BLOCK: |
| 528 | case VK_FORMAT_BC3_SRGB_BLOCK: |
| 529 | case VK_FORMAT_BC4_UNORM_BLOCK: |
| 530 | case VK_FORMAT_BC4_SNORM_BLOCK: |
| 531 | case VK_FORMAT_BC5_UNORM_BLOCK: |
| 532 | case VK_FORMAT_BC5_SNORM_BLOCK: |
Sean Risser | c101f74 | 2020-06-04 15:00:15 -0400 | [diff] [blame] | 533 | case VK_FORMAT_BC6H_UFLOAT_BLOCK: |
| 534 | case VK_FORMAT_BC6H_SFLOAT_BLOCK: |
Ben Clayton | 5751f9e | 2020-03-11 10:41:32 +0000 | [diff] [blame] | 535 | case VK_FORMAT_BC7_UNORM_BLOCK: |
| 536 | case VK_FORMAT_BC7_SRGB_BLOCK: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 537 | case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: |
| 538 | case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: |
| 539 | case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: |
| 540 | case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: |
| 541 | case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: |
| 542 | case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: |
| 543 | case VK_FORMAT_EAC_R11_UNORM_BLOCK: |
| 544 | case VK_FORMAT_EAC_R11_SNORM_BLOCK: |
| 545 | case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: |
| 546 | case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: |
Nicolas Capens | a4347a9 | 2020-03-01 08:29:25 -0500 | [diff] [blame] | 547 | #ifdef SWIFTSHADER_ENABLE_ASTC |
Alexis Hetu | 1b90087 | 2020-02-24 12:09:16 -0500 | [diff] [blame] | 548 | case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: |
| 549 | case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: |
| 550 | case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: |
| 551 | case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: |
| 552 | case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: |
| 553 | case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: |
| 554 | case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: |
| 555 | case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: |
| 556 | case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: |
| 557 | case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: |
| 558 | case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: |
| 559 | case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: |
| 560 | case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: |
| 561 | case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: |
| 562 | case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: |
| 563 | case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: |
| 564 | case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: |
| 565 | case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: |
| 566 | case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: |
| 567 | case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: |
| 568 | case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: |
| 569 | case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: |
| 570 | case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: |
| 571 | case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: |
| 572 | case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: |
| 573 | case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: |
| 574 | case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: |
| 575 | case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: |
Nicolas Capens | a4347a9 | 2020-03-01 08:29:25 -0500 | [diff] [blame] | 576 | #endif |
Alexis Hetu | 6d29348 | 2019-12-19 13:25:33 -0500 | [diff] [blame] | 577 | case VK_FORMAT_D16_UNORM: |
| 578 | case VK_FORMAT_D32_SFLOAT: |
Alexis Hetu | 110236f | 2020-01-09 16:13:15 -0500 | [diff] [blame] | 579 | case VK_FORMAT_D32_SFLOAT_S8_UINT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 580 | pFormatProperties->optimalTilingFeatures |= |
| 581 | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; |
Nicolas Capens | d6d0edc | 2020-01-15 22:50:51 -0500 | [diff] [blame] | 582 | // [[fallthrough]] |
Chris Forbes | 72631d3 | 2019-04-24 14:43:51 -0700 | [diff] [blame] | 583 | |
Nicolas Capens | d6d0edc | 2020-01-15 22:50:51 -0500 | [diff] [blame] | 584 | // Formats which can be sampled, but don't support filtering |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 585 | case VK_FORMAT_R8_UINT: |
| 586 | case VK_FORMAT_R8_SINT: |
| 587 | case VK_FORMAT_R8G8_UINT: |
| 588 | case VK_FORMAT_R8G8_SINT: |
| 589 | case VK_FORMAT_R8G8B8A8_UINT: |
| 590 | case VK_FORMAT_R8G8B8A8_SINT: |
| 591 | case VK_FORMAT_A8B8G8R8_UINT_PACK32: |
| 592 | case VK_FORMAT_A8B8G8R8_SINT_PACK32: |
| 593 | case VK_FORMAT_A2B10G10R10_UINT_PACK32: |
Alexis Hetu | b8a61bf | 2020-01-09 15:26:34 -0500 | [diff] [blame] | 594 | case VK_FORMAT_A2R10G10B10_UINT_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 595 | case VK_FORMAT_R16_UINT: |
| 596 | case VK_FORMAT_R16_SINT: |
| 597 | case VK_FORMAT_R16G16_UINT: |
| 598 | case VK_FORMAT_R16G16_SINT: |
| 599 | case VK_FORMAT_R16G16B16A16_UINT: |
| 600 | case VK_FORMAT_R16G16B16A16_SINT: |
| 601 | case VK_FORMAT_R32_UINT: |
| 602 | case VK_FORMAT_R32_SINT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 603 | case VK_FORMAT_R32G32_UINT: |
| 604 | case VK_FORMAT_R32G32_SINT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 605 | case VK_FORMAT_R32G32B32A32_UINT: |
| 606 | case VK_FORMAT_R32G32B32A32_SINT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 607 | case VK_FORMAT_S8_UINT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 608 | pFormatProperties->optimalTilingFeatures |= |
| 609 | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | |
| 610 | VK_FORMAT_FEATURE_BLIT_SRC_BIT | |
| 611 | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | |
| 612 | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; |
| 613 | break; |
Nicolas Capens | e2f5da4 | 2019-05-16 11:01:31 -0400 | [diff] [blame] | 614 | |
Nicolas Capens | d6d0edc | 2020-01-15 22:50:51 -0500 | [diff] [blame] | 615 | // YCbCr formats: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 616 | case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: |
| 617 | case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: |
| 618 | pFormatProperties->optimalTilingFeatures |= |
| 619 | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | |
Nicolas Capens | d6d0edc | 2020-01-15 22:50:51 -0500 | [diff] [blame] | 620 | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 621 | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | |
| 622 | VK_FORMAT_FEATURE_TRANSFER_DST_BIT | |
| 623 | VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT; |
| 624 | break; |
| 625 | default: |
| 626 | break; |
Alexis Hetu | 67c93d2 | 2018-11-26 14:10:44 -0500 | [diff] [blame] | 627 | } |
Ben Clayton | d531712 | 2019-02-19 16:39:36 +0000 | [diff] [blame] | 628 | |
Alexis Hetu | 67c93d2 | 2018-11-26 14:10:44 -0500 | [diff] [blame] | 629 | switch(format) |
Ben Clayton | d531712 | 2019-02-19 16:39:36 +0000 | [diff] [blame] | 630 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 631 | case VK_FORMAT_R32_UINT: |
| 632 | case VK_FORMAT_R32_SINT: |
| 633 | pFormatProperties->optimalTilingFeatures |= |
| 634 | VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT; |
| 635 | pFormatProperties->bufferFeatures |= |
| 636 | VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT; |
Nicolas Capens | 77b43d6 | 2020-03-12 00:20:00 -0400 | [diff] [blame] | 637 | // [[fallthrough]] |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 638 | case VK_FORMAT_R8G8B8A8_UNORM: |
| 639 | case VK_FORMAT_R8G8B8A8_SNORM: |
| 640 | case VK_FORMAT_R8G8B8A8_UINT: |
| 641 | case VK_FORMAT_R8G8B8A8_SINT: |
| 642 | case VK_FORMAT_R16G16B16A16_UINT: |
| 643 | case VK_FORMAT_R16G16B16A16_SINT: |
| 644 | case VK_FORMAT_R16G16B16A16_SFLOAT: |
| 645 | case VK_FORMAT_R32_SFLOAT: |
| 646 | case VK_FORMAT_R32G32_UINT: |
| 647 | case VK_FORMAT_R32G32_SINT: |
| 648 | case VK_FORMAT_R32G32_SFLOAT: |
| 649 | case VK_FORMAT_R32G32B32A32_UINT: |
| 650 | case VK_FORMAT_R32G32B32A32_SINT: |
| 651 | case VK_FORMAT_R32G32B32A32_SFLOAT: |
Nicolas Capens | f6f1121 | 2020-07-01 00:27:23 -0400 | [diff] [blame] | 652 | // shaderStorageImageExtendedFormats |
Chris Forbes | 57977c1 | 2019-12-19 16:09:18 -0800 | [diff] [blame] | 653 | case VK_FORMAT_R16G16_SFLOAT: |
Nicolas Capens | f6f1121 | 2020-07-01 00:27:23 -0400 | [diff] [blame] | 654 | case VK_FORMAT_B10G11R11_UFLOAT_PACK32: |
| 655 | case VK_FORMAT_R16_SFLOAT: |
| 656 | case VK_FORMAT_R16G16B16A16_UNORM: |
| 657 | case VK_FORMAT_A2B10G10R10_UNORM_PACK32: |
| 658 | case VK_FORMAT_R16G16_UNORM: |
| 659 | case VK_FORMAT_R8G8_UNORM: |
| 660 | case VK_FORMAT_R16_UNORM: |
| 661 | case VK_FORMAT_R8_UNORM: |
| 662 | case VK_FORMAT_R16G16B16A16_SNORM: |
| 663 | case VK_FORMAT_R16G16_SNORM: |
| 664 | case VK_FORMAT_R8G8_SNORM: |
| 665 | case VK_FORMAT_R16_SNORM: |
| 666 | case VK_FORMAT_R8_SNORM: |
| 667 | case VK_FORMAT_R16G16_SINT: |
| 668 | case VK_FORMAT_R8G8_SINT: |
| 669 | case VK_FORMAT_R16_SINT: |
| 670 | case VK_FORMAT_R8_SINT: |
| 671 | case VK_FORMAT_A2B10G10R10_UINT_PACK32: |
| 672 | case VK_FORMAT_R16G16_UINT: |
| 673 | case VK_FORMAT_R8G8_UINT: |
| 674 | case VK_FORMAT_R16_UINT: |
| 675 | case VK_FORMAT_R8_UINT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 676 | pFormatProperties->optimalTilingFeatures |= |
| 677 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; |
Nicolas Capens | 77b43d6 | 2020-03-12 00:20:00 -0400 | [diff] [blame] | 678 | // [[fallthrough]] |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 679 | case VK_FORMAT_A8B8G8R8_UNORM_PACK32: |
| 680 | case VK_FORMAT_A8B8G8R8_SNORM_PACK32: |
| 681 | case VK_FORMAT_A8B8G8R8_UINT_PACK32: |
| 682 | case VK_FORMAT_A8B8G8R8_SINT_PACK32: |
| 683 | pFormatProperties->bufferFeatures |= |
| 684 | VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT; |
| 685 | break; |
| 686 | default: |
| 687 | break; |
Ben Clayton | d531712 | 2019-02-19 16:39:36 +0000 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | switch(format) |
| 691 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 692 | case VK_FORMAT_R5G6B5_UNORM_PACK16: |
| 693 | case VK_FORMAT_A1R5G5B5_UNORM_PACK16: |
| 694 | case VK_FORMAT_R8_UNORM: |
| 695 | case VK_FORMAT_R8G8_UNORM: |
| 696 | case VK_FORMAT_R8G8B8A8_UNORM: |
| 697 | case VK_FORMAT_R8G8B8A8_SRGB: |
| 698 | case VK_FORMAT_B8G8R8A8_UNORM: |
| 699 | case VK_FORMAT_B8G8R8A8_SRGB: |
| 700 | case VK_FORMAT_A8B8G8R8_UNORM_PACK32: |
| 701 | case VK_FORMAT_A8B8G8R8_SRGB_PACK32: |
| 702 | case VK_FORMAT_A2B10G10R10_UNORM_PACK32: |
Alexis Hetu | b8a61bf | 2020-01-09 15:26:34 -0500 | [diff] [blame] | 703 | case VK_FORMAT_A2R10G10B10_UNORM_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 704 | case VK_FORMAT_R16_SFLOAT: |
| 705 | case VK_FORMAT_R16G16_SFLOAT: |
| 706 | case VK_FORMAT_R16G16B16A16_SFLOAT: |
| 707 | case VK_FORMAT_R32_SFLOAT: |
| 708 | case VK_FORMAT_R32G32_SFLOAT: |
| 709 | case VK_FORMAT_R32G32B32A32_SFLOAT: |
Alexis Hetu | f97fb9d | 2019-12-17 14:40:19 -0500 | [diff] [blame] | 710 | case VK_FORMAT_B10G11R11_UFLOAT_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 711 | case VK_FORMAT_R8_UINT: |
| 712 | case VK_FORMAT_R8_SINT: |
| 713 | case VK_FORMAT_R8G8_UINT: |
| 714 | case VK_FORMAT_R8G8_SINT: |
| 715 | case VK_FORMAT_R8G8B8A8_UINT: |
| 716 | case VK_FORMAT_R8G8B8A8_SINT: |
| 717 | case VK_FORMAT_A8B8G8R8_UINT_PACK32: |
| 718 | case VK_FORMAT_A8B8G8R8_SINT_PACK32: |
| 719 | case VK_FORMAT_A2B10G10R10_UINT_PACK32: |
Alexis Hetu | b8a61bf | 2020-01-09 15:26:34 -0500 | [diff] [blame] | 720 | case VK_FORMAT_A2R10G10B10_UINT_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 721 | case VK_FORMAT_R16_UINT: |
| 722 | case VK_FORMAT_R16_SINT: |
| 723 | case VK_FORMAT_R16G16_UINT: |
| 724 | case VK_FORMAT_R16G16_SINT: |
| 725 | case VK_FORMAT_R16G16B16A16_UINT: |
| 726 | case VK_FORMAT_R16G16B16A16_SINT: |
| 727 | case VK_FORMAT_R32_UINT: |
| 728 | case VK_FORMAT_R32_SINT: |
| 729 | case VK_FORMAT_R32G32_UINT: |
| 730 | case VK_FORMAT_R32G32_SINT: |
| 731 | case VK_FORMAT_R32G32B32A32_UINT: |
| 732 | case VK_FORMAT_R32G32B32A32_SINT: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 733 | pFormatProperties->optimalTilingFeatures |= |
| 734 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | |
| 735 | VK_FORMAT_FEATURE_BLIT_DST_BIT; |
| 736 | break; |
| 737 | case VK_FORMAT_S8_UINT: |
| 738 | case VK_FORMAT_D16_UNORM: |
| 739 | case VK_FORMAT_D32_SFLOAT: // Note: either VK_FORMAT_D32_SFLOAT or VK_FORMAT_X8_D24_UNORM_PACK32 must be supported |
| 740 | 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 |
| 741 | pFormatProperties->optimalTilingFeatures |= |
| 742 | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 743 | break; |
| 744 | default: |
| 745 | break; |
Ben Clayton | d531712 | 2019-02-19 16:39:36 +0000 | [diff] [blame] | 746 | } |
| 747 | |
Nicolas Capens | ae10079 | 2020-06-11 13:48:40 -0400 | [diff] [blame] | 748 | if(format.supportsColorAttachmentBlend()) |
| 749 | { |
| 750 | pFormatProperties->optimalTilingFeatures |= |
| 751 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; |
| 752 | } |
| 753 | |
Ben Clayton | d531712 | 2019-02-19 16:39:36 +0000 | [diff] [blame] | 754 | switch(format) |
| 755 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 756 | case VK_FORMAT_R8_UNORM: |
| 757 | case VK_FORMAT_R8_SNORM: |
| 758 | case VK_FORMAT_R8_UINT: |
| 759 | case VK_FORMAT_R8_SINT: |
| 760 | case VK_FORMAT_R8G8_UNORM: |
| 761 | case VK_FORMAT_R8G8_SNORM: |
| 762 | case VK_FORMAT_R8G8_UINT: |
| 763 | case VK_FORMAT_R8G8_SINT: |
| 764 | case VK_FORMAT_R8G8B8A8_UNORM: |
| 765 | case VK_FORMAT_R8G8B8A8_SNORM: |
| 766 | case VK_FORMAT_R8G8B8A8_UINT: |
| 767 | case VK_FORMAT_R8G8B8A8_SINT: |
| 768 | case VK_FORMAT_B8G8R8A8_UNORM: |
| 769 | case VK_FORMAT_A8B8G8R8_UNORM_PACK32: |
| 770 | case VK_FORMAT_A8B8G8R8_SNORM_PACK32: |
| 771 | case VK_FORMAT_A8B8G8R8_UINT_PACK32: |
| 772 | case VK_FORMAT_A8B8G8R8_SINT_PACK32: |
Alexis Hetu | b766e5e | 2020-01-20 11:40:28 -0500 | [diff] [blame] | 773 | case VK_FORMAT_A2R10G10B10_UNORM_PACK32: |
| 774 | case VK_FORMAT_A2R10G10B10_SNORM_PACK32: |
| 775 | case VK_FORMAT_A2R10G10B10_UINT_PACK32: |
| 776 | case VK_FORMAT_A2R10G10B10_SINT_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 777 | case VK_FORMAT_A2B10G10R10_UNORM_PACK32: |
Alexis Hetu | b766e5e | 2020-01-20 11:40:28 -0500 | [diff] [blame] | 778 | case VK_FORMAT_A2B10G10R10_SNORM_PACK32: |
| 779 | case VK_FORMAT_A2B10G10R10_UINT_PACK32: |
| 780 | case VK_FORMAT_A2B10G10R10_SINT_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 781 | case VK_FORMAT_R16_UNORM: |
| 782 | case VK_FORMAT_R16_SNORM: |
| 783 | case VK_FORMAT_R16_UINT: |
| 784 | case VK_FORMAT_R16_SINT: |
| 785 | case VK_FORMAT_R16_SFLOAT: |
| 786 | case VK_FORMAT_R16G16_UNORM: |
| 787 | case VK_FORMAT_R16G16_SNORM: |
| 788 | case VK_FORMAT_R16G16_UINT: |
| 789 | case VK_FORMAT_R16G16_SINT: |
| 790 | case VK_FORMAT_R16G16_SFLOAT: |
| 791 | case VK_FORMAT_R16G16B16A16_UNORM: |
| 792 | case VK_FORMAT_R16G16B16A16_SNORM: |
| 793 | case VK_FORMAT_R16G16B16A16_UINT: |
| 794 | case VK_FORMAT_R16G16B16A16_SINT: |
| 795 | case VK_FORMAT_R16G16B16A16_SFLOAT: |
| 796 | case VK_FORMAT_R32_UINT: |
| 797 | case VK_FORMAT_R32_SINT: |
| 798 | case VK_FORMAT_R32_SFLOAT: |
| 799 | case VK_FORMAT_R32G32_UINT: |
| 800 | case VK_FORMAT_R32G32_SINT: |
| 801 | case VK_FORMAT_R32G32_SFLOAT: |
| 802 | case VK_FORMAT_R32G32B32_UINT: |
| 803 | case VK_FORMAT_R32G32B32_SINT: |
| 804 | case VK_FORMAT_R32G32B32_SFLOAT: |
| 805 | case VK_FORMAT_R32G32B32A32_UINT: |
| 806 | case VK_FORMAT_R32G32B32A32_SINT: |
| 807 | case VK_FORMAT_R32G32B32A32_SFLOAT: |
| 808 | pFormatProperties->bufferFeatures |= |
| 809 | VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT; |
| 810 | break; |
| 811 | default: |
| 812 | break; |
Ben Clayton | d531712 | 2019-02-19 16:39:36 +0000 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | switch(format) |
| 816 | { |
Nicolas Capens | 2e7cdd8 | 2020-06-24 01:29:59 -0400 | [diff] [blame] | 817 | // Vulkan 1.1 mandatory |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 818 | case VK_FORMAT_R8_UNORM: |
| 819 | case VK_FORMAT_R8_SNORM: |
| 820 | case VK_FORMAT_R8_UINT: |
| 821 | case VK_FORMAT_R8_SINT: |
| 822 | case VK_FORMAT_R8G8_UNORM: |
| 823 | case VK_FORMAT_R8G8_SNORM: |
| 824 | case VK_FORMAT_R8G8_UINT: |
| 825 | case VK_FORMAT_R8G8_SINT: |
| 826 | case VK_FORMAT_R8G8B8A8_UNORM: |
| 827 | case VK_FORMAT_R8G8B8A8_SNORM: |
| 828 | case VK_FORMAT_R8G8B8A8_UINT: |
| 829 | case VK_FORMAT_R8G8B8A8_SINT: |
| 830 | case VK_FORMAT_B8G8R8A8_UNORM: |
| 831 | case VK_FORMAT_A8B8G8R8_UNORM_PACK32: |
| 832 | case VK_FORMAT_A8B8G8R8_SNORM_PACK32: |
| 833 | case VK_FORMAT_A8B8G8R8_UINT_PACK32: |
| 834 | case VK_FORMAT_A8B8G8R8_SINT_PACK32: |
| 835 | case VK_FORMAT_A2B10G10R10_UNORM_PACK32: |
| 836 | case VK_FORMAT_A2B10G10R10_UINT_PACK32: |
| 837 | case VK_FORMAT_R16_UINT: |
| 838 | case VK_FORMAT_R16_SINT: |
| 839 | case VK_FORMAT_R16_SFLOAT: |
| 840 | case VK_FORMAT_R16G16_UINT: |
| 841 | case VK_FORMAT_R16G16_SINT: |
| 842 | case VK_FORMAT_R16G16_SFLOAT: |
| 843 | case VK_FORMAT_R16G16B16A16_UINT: |
| 844 | case VK_FORMAT_R16G16B16A16_SINT: |
| 845 | case VK_FORMAT_R16G16B16A16_SFLOAT: |
| 846 | case VK_FORMAT_R32_UINT: |
| 847 | case VK_FORMAT_R32_SINT: |
| 848 | case VK_FORMAT_R32_SFLOAT: |
| 849 | case VK_FORMAT_R32G32_UINT: |
| 850 | case VK_FORMAT_R32G32_SINT: |
| 851 | case VK_FORMAT_R32G32_SFLOAT: |
| 852 | case VK_FORMAT_R32G32B32A32_UINT: |
| 853 | case VK_FORMAT_R32G32B32A32_SINT: |
| 854 | case VK_FORMAT_R32G32B32A32_SFLOAT: |
| 855 | case VK_FORMAT_B10G11R11_UFLOAT_PACK32: |
Nicolas Capens | 2e7cdd8 | 2020-06-24 01:29:59 -0400 | [diff] [blame] | 856 | // Optional |
| 857 | case VK_FORMAT_A2R10G10B10_UNORM_PACK32: |
| 858 | case VK_FORMAT_A2R10G10B10_UINT_PACK32: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 859 | pFormatProperties->bufferFeatures |= |
| 860 | VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT; |
| 861 | break; |
| 862 | default: |
| 863 | break; |
Alexis Hetu | 67c93d2 | 2018-11-26 14:10:44 -0500 | [diff] [blame] | 864 | } |
Nicolas Capens | 7e01e4e | 2019-05-18 08:19:07 -0400 | [diff] [blame] | 865 | |
| 866 | if(pFormatProperties->optimalTilingFeatures) |
| 867 | { |
| 868 | pFormatProperties->linearTilingFeatures = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | |
| 869 | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; |
| 870 | } |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 871 | } |
| 872 | |
Nicolas Capens | 7e01e4e | 2019-05-18 08:19:07 -0400 | [diff] [blame] | 873 | void PhysicalDevice::getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling, |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 874 | VkImageUsageFlags usage, VkImageCreateFlags flags, |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 875 | VkImageFormatProperties *pImageFormatProperties) const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 876 | { |
Chris Forbes | 82cc0cb | 2019-03-11 14:34:12 -0700 | [diff] [blame] | 877 | pImageFormatProperties->sampleCounts = VK_SAMPLE_COUNT_1_BIT; |
Chris Forbes | abdfa17 | 2019-03-07 17:20:32 -0800 | [diff] [blame] | 878 | pImageFormatProperties->maxArrayLayers = vk::MAX_IMAGE_ARRAY_LAYERS; |
Chris Forbes | 82cc0cb | 2019-03-11 14:34:12 -0700 | [diff] [blame] | 879 | pImageFormatProperties->maxExtent.depth = 1; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 880 | |
| 881 | switch(type) |
| 882 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 883 | case VK_IMAGE_TYPE_1D: |
| 884 | pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_1D; |
| 885 | pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_1D - 1); |
| 886 | pImageFormatProperties->maxExtent.height = 1; |
| 887 | break; |
| 888 | case VK_IMAGE_TYPE_2D: |
| 889 | if(flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) |
Chris Forbes | 82cc0cb | 2019-03-11 14:34:12 -0700 | [diff] [blame] | 890 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 891 | pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_CUBE; |
| 892 | pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1); |
| 893 | pImageFormatProperties->maxExtent.height = 1 << (vk::MAX_IMAGE_LEVELS_CUBE - 1); |
Chris Forbes | 82cc0cb | 2019-03-11 14:34:12 -0700 | [diff] [blame] | 894 | } |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 895 | else |
| 896 | { |
| 897 | pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_2D; |
| 898 | pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_2D - 1); |
| 899 | pImageFormatProperties->maxExtent.height = 1 << (vk::MAX_IMAGE_LEVELS_2D - 1); |
| 900 | |
| 901 | VkFormatProperties props; |
| 902 | getFormatProperties(format, &props); |
| 903 | auto features = tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures; |
| 904 | if(features & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) |
| 905 | { |
| 906 | // Only renderable formats make sense for multisample |
| 907 | pImageFormatProperties->sampleCounts = getSampleCounts(); |
| 908 | } |
| 909 | } |
| 910 | break; |
| 911 | case VK_IMAGE_TYPE_3D: |
| 912 | pImageFormatProperties->maxMipLevels = vk::MAX_IMAGE_LEVELS_3D; |
| 913 | pImageFormatProperties->maxExtent.width = 1 << (vk::MAX_IMAGE_LEVELS_3D - 1); |
| 914 | pImageFormatProperties->maxExtent.height = 1 << (vk::MAX_IMAGE_LEVELS_3D - 1); |
| 915 | pImageFormatProperties->maxExtent.depth = 1 << (vk::MAX_IMAGE_LEVELS_3D - 1); |
| 916 | pImageFormatProperties->maxArrayLayers = 1; // no 3D + layers |
| 917 | break; |
| 918 | default: |
| 919 | UNREACHABLE("VkImageType: %d", int(type)); |
| 920 | break; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 921 | } |
| 922 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 923 | pImageFormatProperties->maxResourceSize = 1u << 31; // Minimum value for maxResourceSize |
Nicolas Capens | 7e01e4e | 2019-05-18 08:19:07 -0400 | [diff] [blame] | 924 | |
| 925 | // "Images created with tiling equal to VK_IMAGE_TILING_LINEAR have further restrictions on their limits and capabilities |
| 926 | // compared to images created with tiling equal to VK_IMAGE_TILING_OPTIMAL." |
| 927 | if(tiling == VK_IMAGE_TILING_LINEAR) |
| 928 | { |
| 929 | pImageFormatProperties->maxMipLevels = 1; |
| 930 | pImageFormatProperties->maxArrayLayers = 1; |
| 931 | pImageFormatProperties->sampleCounts = VK_SAMPLE_COUNT_1_BIT; |
| 932 | } |
| 933 | |
Chris Forbes | 61f2a46 | 2019-06-26 10:31:18 -0700 | [diff] [blame] | 934 | // "Images created with a format from one of those listed in Formats requiring sampler Y'CbCr conversion for VK_IMAGE_ASPECT_COLOR_BIT image views |
Nicolas Capens | 7e01e4e | 2019-05-18 08:19:07 -0400 | [diff] [blame] | 935 | // have further restrictions on their limits and capabilities compared to images created with other formats." |
| 936 | if(format.isYcbcrFormat()) |
| 937 | { |
Nicolas Capens | 77b43d6 | 2020-03-12 00:20:00 -0400 | [diff] [blame] | 938 | pImageFormatProperties->maxMipLevels = 1; // TODO(b/151263485): This is relied on by the sampler to disable mipmapping for Y'CbCr image sampling. |
Nicolas Capens | 7e01e4e | 2019-05-18 08:19:07 -0400 | [diff] [blame] | 939 | pImageFormatProperties->maxArrayLayers = 1; |
| 940 | pImageFormatProperties->sampleCounts = VK_SAMPLE_COUNT_1_BIT; |
| 941 | } |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | uint32_t PhysicalDevice::getQueueFamilyPropertyCount() const |
| 945 | { |
| 946 | return 1; |
| 947 | } |
| 948 | |
| 949 | void PhysicalDevice::getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount, |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 950 | VkQueueFamilyProperties *pQueueFamilyProperties) const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 951 | { |
| 952 | for(uint32_t i = 0; i < pQueueFamilyPropertyCount; i++) |
| 953 | { |
| 954 | pQueueFamilyProperties[i].minImageTransferGranularity.width = 1; |
| 955 | pQueueFamilyProperties[i].minImageTransferGranularity.height = 1; |
| 956 | pQueueFamilyProperties[i].minImageTransferGranularity.depth = 1; |
| 957 | pQueueFamilyProperties[i].queueCount = 1; |
| 958 | pQueueFamilyProperties[i].queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT; |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 959 | pQueueFamilyProperties[i].timestampValidBits = 0; // No support for time stamps |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 960 | } |
| 961 | } |
| 962 | |
Alexis Hetu | 4100b73 | 2019-10-11 17:01:48 -0400 | [diff] [blame] | 963 | void PhysicalDevice::getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount, |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 964 | VkQueueFamilyProperties2 *pQueueFamilyProperties) const |
Alexis Hetu | 4100b73 | 2019-10-11 17:01:48 -0400 | [diff] [blame] | 965 | { |
| 966 | for(uint32_t i = 0; i < pQueueFamilyPropertyCount; i++) |
| 967 | { |
| 968 | pQueueFamilyProperties[i].queueFamilyProperties.minImageTransferGranularity.width = 1; |
| 969 | pQueueFamilyProperties[i].queueFamilyProperties.minImageTransferGranularity.height = 1; |
| 970 | pQueueFamilyProperties[i].queueFamilyProperties.minImageTransferGranularity.depth = 1; |
| 971 | pQueueFamilyProperties[i].queueFamilyProperties.queueCount = 1; |
| 972 | pQueueFamilyProperties[i].queueFamilyProperties.queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT; |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 973 | pQueueFamilyProperties[i].queueFamilyProperties.timestampValidBits = 0; // No support for time stamps |
Alexis Hetu | 4100b73 | 2019-10-11 17:01:48 -0400 | [diff] [blame] | 974 | } |
| 975 | } |
| 976 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 977 | const VkPhysicalDeviceMemoryProperties &PhysicalDevice::getMemoryProperties() const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 978 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 979 | static const VkPhysicalDeviceMemoryProperties properties{ |
| 980 | 1, // memoryTypeCount |
Nicolas Capens | c3f7960 | 2018-11-13 14:06:37 -0500 | [diff] [blame] | 981 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 982 | // vk::MEMORY_TYPE_GENERIC_BIT |
| 983 | { |
| 984 | (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | |
| 985 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | |
| 986 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | |
| 987 | VK_MEMORY_PROPERTY_HOST_CACHED_BIT), // propertyFlags |
| 988 | 0 // heapIndex |
| 989 | }, |
Nicolas Capens | c3f7960 | 2018-11-13 14:06:37 -0500 | [diff] [blame] | 990 | }, |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 991 | 1, // memoryHeapCount |
Nicolas Capens | c3f7960 | 2018-11-13 14:06:37 -0500 | [diff] [blame] | 992 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 993 | { |
| 994 | 1ull << 31, // size, FIXME(sugoi): This should be configurable based on available RAM |
| 995 | VK_MEMORY_HEAP_DEVICE_LOCAL_BIT // flags |
| 996 | }, |
Nicolas Capens | c3f7960 | 2018-11-13 14:06:37 -0500 | [diff] [blame] | 997 | } |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 998 | }; |
| 999 | |
| 1000 | return properties; |
| 1001 | } |
| 1002 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 1003 | } // namespace vk |