1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2017 Google Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Utilities for Vulkan SPIR-V assembly tests
22 *//*--------------------------------------------------------------------*/
24 #include "vktSpvAsmUtils.hpp"
27 #include "deSTLUtil.hpp"
28 #include "vkQueryUtil.hpp"
29 #include "vkRefUtil.hpp"
33 namespace SpirVAssembly
38 bool is8BitStorageFeaturesSupported (const Context& context, Extension8BitStorageFeatures toCheck)
40 VkPhysicalDevice8BitStorageFeaturesKHR extensionFeatures = context.get8BitStorageFeatures();
42 if ((toCheck & EXT8BITSTORAGEFEATURES_STORAGE_BUFFER) != 0 && extensionFeatures.storageBuffer8BitAccess == VK_FALSE)
43 TCU_FAIL("storageBuffer8BitAccess has to be supported");
45 if ((toCheck & EXT8BITSTORAGEFEATURES_UNIFORM_STORAGE_BUFFER) != 0 && extensionFeatures.uniformAndStorageBuffer8BitAccess == VK_FALSE)
48 if ((toCheck & EXT8BITSTORAGEFEATURES_PUSH_CONSTANT) != 0 && extensionFeatures.storagePushConstant8 == VK_FALSE)
54 #define IS_CORE_FEATURE_AVAILABLE(CHECKED, AVAILABLE, FEATURE) \
55 if ((CHECKED.FEATURE != DE_FALSE) && (AVAILABLE.FEATURE == DE_FALSE)) { *missingFeature = #FEATURE; return false; }
57 bool isCoreFeaturesSupported (const Context& context,
58 const vk::VkPhysicalDeviceFeatures& toCheck,
59 const char** missingFeature)
61 const VkPhysicalDeviceFeatures& availableFeatures = context.getDeviceFeatures();
63 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, robustBufferAccess);
64 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, fullDrawIndexUint32);
65 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, imageCubeArray);
66 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, independentBlend);
67 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, geometryShader);
68 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, tessellationShader);
69 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sampleRateShading);
70 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, dualSrcBlend);
71 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, logicOp);
72 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, multiDrawIndirect);
73 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, drawIndirectFirstInstance);
74 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, depthClamp);
75 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, depthBiasClamp);
76 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, fillModeNonSolid);
77 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, depthBounds);
78 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, wideLines);
79 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, largePoints);
80 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, alphaToOne);
81 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, multiViewport);
82 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, samplerAnisotropy);
83 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, textureCompressionETC2);
84 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, textureCompressionASTC_LDR);
85 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, textureCompressionBC);
86 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, occlusionQueryPrecise);
87 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, pipelineStatisticsQuery);
88 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, vertexPipelineStoresAndAtomics);
89 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, fragmentStoresAndAtomics);
90 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderTessellationAndGeometryPointSize);
91 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderImageGatherExtended);
92 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderStorageImageExtendedFormats);
93 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderStorageImageMultisample);
94 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderStorageImageReadWithoutFormat);
95 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderStorageImageWriteWithoutFormat);
96 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderUniformBufferArrayDynamicIndexing);
97 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderSampledImageArrayDynamicIndexing);
98 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderStorageBufferArrayDynamicIndexing);
99 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderStorageImageArrayDynamicIndexing);
100 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderClipDistance);
101 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderCullDistance);
102 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderFloat64);
103 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderInt64);
104 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderInt16);
105 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderResourceResidency);
106 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, shaderResourceMinLod);
107 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseBinding);
108 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidencyBuffer);
109 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidencyImage2D);
110 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidencyImage3D);
111 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidency2Samples);
112 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidency4Samples);
113 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidency8Samples);
114 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidency16Samples);
115 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, sparseResidencyAliased);
116 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, variableMultisampleRate);
117 IS_CORE_FEATURE_AVAILABLE(toCheck, availableFeatures, inheritedQueries);
122 bool is16BitStorageFeaturesSupported (const Context& context, Extension16BitStorageFeatures toCheck)
124 const VkPhysicalDevice16BitStorageFeatures& extensionFeatures = context.get16BitStorageFeatures();
126 if ((toCheck & EXT16BITSTORAGEFEATURES_UNIFORM_BUFFER_BLOCK) != 0 && extensionFeatures.storageBuffer16BitAccess == VK_FALSE)
129 if ((toCheck & EXT16BITSTORAGEFEATURES_UNIFORM) != 0 && extensionFeatures.uniformAndStorageBuffer16BitAccess == VK_FALSE)
132 if ((toCheck & EXT16BITSTORAGEFEATURES_PUSH_CONSTANT) != 0 && extensionFeatures.storagePushConstant16 == VK_FALSE)
135 if ((toCheck & EXT16BITSTORAGEFEATURES_INPUT_OUTPUT) != 0 && extensionFeatures.storageInputOutput16 == VK_FALSE)
141 bool isVariablePointersFeaturesSupported (const Context& context, ExtensionVariablePointersFeatures toCheck)
143 const VkPhysicalDeviceVariablePointerFeatures& extensionFeatures = context.getVariablePointerFeatures();
145 if ((toCheck & EXTVARIABLEPOINTERSFEATURES_VARIABLE_POINTERS_STORAGEBUFFER) != 0 && extensionFeatures.variablePointersStorageBuffer == VK_FALSE)
148 if ((toCheck & EXTVARIABLEPOINTERSFEATURES_VARIABLE_POINTERS) != 0 && extensionFeatures.variablePointers == VK_FALSE)
154 deUint32 getMinRequiredVulkanVersion (const SpirvVersion version)
158 case SPIRV_VERSION_1_0:
159 return VK_API_VERSION_1_0;
160 case SPIRV_VERSION_1_1:
161 case SPIRV_VERSION_1_2:
162 case SPIRV_VERSION_1_3:
163 return VK_API_VERSION_1_1;
170 std::string getVulkanName (const deUint32 version)
172 return std::string(version == VK_API_VERSION_1_1 ? "1.1" : "1.0");