1 #ifndef _VKTSUBGROUPSTESTSUTILS_HPP
2 #define _VKTSUBGROUPSTESTSUTILS_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2017 The Khronos Group Inc.
8 * Copyright (c) 2017 Codeplay Software Ltd.
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * \brief Subgroups tests utility classes
25 */ /*--------------------------------------------------------------------*/
27 #include "vkBuilderUtil.hpp"
29 #include "vkDeviceUtil.hpp"
30 #include "vkMemUtil.hpp"
31 #include "vkPlatform.hpp"
32 #include "vkPrograms.hpp"
33 #include "vkQueryUtil.hpp"
35 #include "vkRefUtil.hpp"
36 #include "vkStrUtil.hpp"
37 #include "vkTypeUtil.hpp"
38 #include "vktTestCase.hpp"
39 #include "vktTestCaseUtil.hpp"
41 #include "tcuFormatUtil.hpp"
42 #include "tcuTestLog.hpp"
43 #include "tcuVectorUtil.hpp"
45 #include "gluShaderUtil.hpp"
47 #include "deSharedPtr.hpp"
48 #include "deUniquePtr.hpp"
56 // A struct to represent input data to a shader
60 initializeType (InitializeNone),
61 format (vk::VK_FORMAT_UNDEFINED),
65 stages ((vk::VkShaderStageFlagBits)0u)
68 enum InputDataInitializeType
76 vk::VkDeviceSize numElements;
79 vk::VkShaderStageFlagBits stages;
82 std::string getSharedMemoryBallotHelper();
84 deUint32 getSubgroupSize(Context& context);
86 vk::VkDeviceSize maxSupportedSubgroupSize();
88 std::string getShaderStageName(vk::VkShaderStageFlags stage);
90 std::string getSubgroupFeatureName(vk::VkSubgroupFeatureFlagBits bit);
92 void addNoSubgroupShader (vk::SourceCollections& programCollection);
94 std::string getVertShaderForStage(vk::VkShaderStageFlags stage);//TODO
96 bool isSubgroupSupported(Context& context);
98 bool areSubgroupOperationsSupportedForStage(
99 Context& context, vk::VkShaderStageFlags stage);
101 bool areSubgroupOperationsRequiredForStage(vk::VkShaderStageFlags stage);
103 bool isSubgroupFeatureSupportedForDevice(Context& context, vk::VkSubgroupFeatureFlagBits bit);
105 bool isFragmentSSBOSupportedForDevice(Context& context);
107 bool isVertexSSBOSupportedForDevice(Context& context);
109 bool isDoubleSupportedForDevice(Context& context);
111 bool isDoubleFormat(vk::VkFormat format);
113 std::string getFormatNameForGLSL(vk::VkFormat format);
115 void addGeometryShadersFromTemplate (const std::string& glslTemplate, const vk::ShaderBuildOptions& options, vk::GlslSourceCollection& collection);
116 void addGeometryShadersFromTemplate (const std::string& spirvTemplate, const vk::SpirVAsmBuildOptions& options, vk::SpirVAsmCollection& collection);
118 void setVertexShaderFrameBuffer (vk::SourceCollections& programCollection);
120 void setFragmentShaderFrameBuffer (vk::SourceCollections& programCollection);
122 void setFragmentShaderFrameBuffer (vk::SourceCollections& programCollection);
124 void setTesCtrlShaderFrameBuffer (vk::SourceCollections& programCollection);
126 void setTesEvalShaderFrameBuffer (vk::SourceCollections& programCollection);
128 bool check(std::vector<const void*> datas,
129 deUint32 width, deUint32 ref);
131 bool checkCompute(std::vector<const void*> datas,
132 const deUint32 numWorkgroups[3], const deUint32 localSize[3],
135 tcu::TestStatus makeTessellationEvaluationFrameBufferTest(Context& context, vk::VkFormat format,
136 SSBOData* extraData, deUint32 extraDataCount,
137 bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize),
138 const vk::VkShaderStageFlags shaderStage = vk::VK_SHADER_STAGE_ALL_GRAPHICS);
140 tcu::TestStatus makeGeometryFrameBufferTest(Context& context, vk::VkFormat format, SSBOData* extraData,
141 deUint32 extraDataCount,
142 bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
144 tcu::TestStatus allStages(Context& context, vk::VkFormat format,
145 SSBOData* extraData, deUint32 extraDataCount,
146 bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize),
147 const vk::VkShaderStageFlags shaderStage);
149 tcu::TestStatus makeVertexFrameBufferTest(Context& context, vk::VkFormat format,
150 SSBOData* extraData, deUint32 extraDataCount,
151 bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
153 tcu::TestStatus makeFragmentFrameBufferTest(Context& context, vk::VkFormat format,
154 SSBOData* extraData, deUint32 extraDataCount,
155 bool (*checkResult)(std::vector<const void*> datas, deUint32 width,
156 deUint32 height, deUint32 subgroupSize));
158 tcu::TestStatus makeComputeTest(
159 Context& context, vk::VkFormat format, SSBOData* inputs,
160 deUint32 inputsCount,
161 bool (*checkResult)(std::vector<const void*> datas,
162 const deUint32 numWorkgroups[3], const deUint32 localSize[3],
163 deUint32 subgroupSize));
167 #endif // _VKTSUBGROUPSTESTSUTILS_HPP