1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2017 The Khronos Group Inc.
6 * Copyright (c) 2017 Codeplay Software Ltd.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief Subgroups Tests
23 */ /*--------------------------------------------------------------------*/
25 #include "vktSubgroupsShuffleTests.hpp"
26 #include "vktSubgroupsTestsUtils.hpp"
47 static bool checkVertexPipelineStages(std::vector<const void*> datas,
48 deUint32 width, deUint32)
50 const deUint32* data =
51 reinterpret_cast<const deUint32*>(datas[0]);
52 for (deUint32 x = 0; x < width; ++x)
54 deUint32 val = data[x];
65 static bool checkFragment(std::vector<const void*> datas,
66 deUint32 width, deUint32 height, deUint32)
68 const deUint32* data =
69 reinterpret_cast<const deUint32*>(datas[0]);
70 for (deUint32 x = 0; x < width; ++x)
72 for (deUint32 y = 0; y < height; ++y)
74 deUint32 val = data[x * height + y];
86 static bool checkCompute(std::vector<const void*> datas,
87 const deUint32 numWorkgroups[3], const deUint32 localSize[3],
90 const deUint32* data =
91 reinterpret_cast<const deUint32*>(datas[0]);
93 for (deUint32 nX = 0; nX < numWorkgroups[0]; ++nX)
95 for (deUint32 nY = 0; nY < numWorkgroups[1]; ++nY)
97 for (deUint32 nZ = 0; nZ < numWorkgroups[2]; ++nZ)
99 for (deUint32 lX = 0; lX < localSize[0]; ++lX)
101 for (deUint32 lY = 0; lY < localSize[1]; ++lY)
103 for (deUint32 lZ = 0; lZ < localSize[2];
106 const deUint32 globalInvocationX =
107 nX * localSize[0] + lX;
108 const deUint32 globalInvocationY =
109 nY * localSize[1] + lY;
110 const deUint32 globalInvocationZ =
111 nZ * localSize[2] + lZ;
113 const deUint32 globalSizeX =
114 numWorkgroups[0] * localSize[0];
115 const deUint32 globalSizeY =
116 numWorkgroups[1] * localSize[1];
118 const deUint32 offset =
125 if (0x1 != data[offset])
139 std::string getOpTypeName(int opType)
144 DE_FATAL("Unsupported op type");
146 return "subgroupShuffle";
147 case OPTYPE_SHUFFLE_XOR:
148 return "subgroupShuffleXor";
149 case OPTYPE_SHUFFLE_UP:
150 return "subgroupShuffleUp";
151 case OPTYPE_SHUFFLE_DOWN:
152 return "subgroupShuffleDown";
156 struct CaseDefinition
159 VkShaderStageFlags shaderStage;
164 void initFrameBufferPrograms (SourceCollections& programCollection, CaseDefinition caseDef)
166 std::string idTable[OPTYPE_LAST];
167 idTable[OPTYPE_SHUFFLE] = "data2[gl_SubgroupInvocationID]";
168 idTable[OPTYPE_SHUFFLE_XOR] = "gl_SubgroupInvocationID ^ data2[gl_SubgroupInvocationID]";
169 idTable[OPTYPE_SHUFFLE_UP] = "gl_SubgroupInvocationID - data2[gl_SubgroupInvocationID]";
170 idTable[OPTYPE_SHUFFLE_DOWN] = "gl_SubgroupInvocationID + data2[gl_SubgroupInvocationID]";
172 if (VK_SHADER_STAGE_VERTEX_BIT == caseDef.shaderStage)
174 std::ostringstream src;
175 std::ostringstream fragmentSrc;
177 src << "#version 450\n"
178 << "layout(location = 0) in highp vec4 in_position;\n"
179 << "layout(location = 0) out float result;\n";
181 switch (caseDef.opType)
184 case OPTYPE_SHUFFLE_XOR:
185 src << "#extension GL_KHR_shader_subgroup_shuffle: enable\n";
188 src << "#extension GL_KHR_shader_subgroup_shuffle_relative: enable\n";
192 src << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
193 << "layout(set = 0, binding = 0) uniform Buffer1\n"
195 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " data1[" << subgroups::maxSupportedSubgroupSize() << "];\n"
197 << "layout(set = 0, binding = 1) uniform Buffer2\n"
199 << " uint data2[" << subgroups::maxSupportedSubgroupSize() << "];\n"
202 << "void main (void)\n"
204 << " uvec4 mask = subgroupBallot(true);\n"
205 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " op = "
206 << getOpTypeName(caseDef.opType) << "(data1[gl_SubgroupInvocationID], data2[gl_SubgroupInvocationID]);\n"
207 << " uint id = " << idTable[caseDef.opType] << ";\n"
208 << " if ((0 <= id) && (id < gl_SubgroupSize) && subgroupBallotBitExtract(mask, id))\n"
210 << " result = (op == data1[id]) ? 1.0f : 0.0f;\n"
214 << " result = 1.0f; // Invocation we read from was inactive, so we can't verify results!\n"
216 << " gl_Position = in_position;\n"
217 << " gl_PointSize = 1.0f;\n"
220 programCollection.glslSources.add("vert") << glu::VertexSource(src.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
222 fragmentSrc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450)<<"\n"
223 << "layout(location = 0) in float result;\n"
224 << "layout(location = 0) out uint out_color;\n"
227 << " out_color = uint(result);\n"
229 programCollection.glslSources.add("fragment") << glu::FragmentSource(fragmentSrc.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
233 DE_FATAL("Unsupported shader stage");
237 void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
239 std::string idTable[OPTYPE_LAST];
240 idTable[OPTYPE_SHUFFLE] = "data2[gl_SubgroupInvocationID]";
241 idTable[OPTYPE_SHUFFLE_XOR] = "gl_SubgroupInvocationID ^ data2[gl_SubgroupInvocationID]";
242 idTable[OPTYPE_SHUFFLE_UP] = "gl_SubgroupInvocationID - data2[gl_SubgroupInvocationID]";
243 idTable[OPTYPE_SHUFFLE_DOWN] = "gl_SubgroupInvocationID + data2[gl_SubgroupInvocationID]";
245 if (VK_SHADER_STAGE_COMPUTE_BIT == caseDef.shaderStage)
247 std::ostringstream src;
249 src << "#version 450\n";
251 switch (caseDef.opType)
254 case OPTYPE_SHUFFLE_XOR:
255 src << "#extension GL_KHR_shader_subgroup_shuffle: enable\n";
258 src << "#extension GL_KHR_shader_subgroup_shuffle_relative: enable\n";
262 src << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
263 << "layout (local_size_x_id = 0, local_size_y_id = 1, "
264 "local_size_z_id = 2) in;\n"
265 << "layout(set = 0, binding = 0, std430) buffer Buffer1\n"
267 << " uint result[];\n"
269 << "layout(set = 0, binding = 1, std430) buffer Buffer2\n"
271 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " data1[];\n"
273 << "layout(set = 0, binding = 2, std430) buffer Buffer3\n"
275 << " uint data2[];\n"
278 << "void main (void)\n"
280 << " uvec3 globalSize = gl_NumWorkGroups * gl_WorkGroupSize;\n"
281 << " highp uint offset = globalSize.x * ((globalSize.y * "
282 "gl_GlobalInvocationID.z) + gl_GlobalInvocationID.y) + "
283 "gl_GlobalInvocationID.x;\n"
284 << " uvec4 mask = subgroupBallot(true);\n"
285 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " op = "
286 << getOpTypeName(caseDef.opType) << "(data1[gl_SubgroupInvocationID], data2[gl_SubgroupInvocationID]);\n"
287 << " uint id = " << idTable[caseDef.opType] << ";\n"
288 << " if ((0 <= id) && (id < gl_SubgroupSize) && subgroupBallotBitExtract(mask, id))\n"
290 << " result[offset] = (op == data1[id]) ? 1 : 0;\n"
294 << " result[offset] = 1; // Invocation we read from was inactive, so we can't verify results!\n"
298 programCollection.glslSources.add("comp")
299 << glu::ComputeSource(src.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
301 else if (VK_SHADER_STAGE_FRAGMENT_BIT == caseDef.shaderStage)
303 programCollection.glslSources.add("vert")
304 << glu::VertexSource(subgroups::getVertShaderForStage(caseDef.shaderStage)) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
306 std::ostringstream frag;
308 frag << "#version 450\n";
310 switch (caseDef.opType)
313 case OPTYPE_SHUFFLE_XOR:
314 frag << "#extension GL_KHR_shader_subgroup_shuffle: enable\n";
317 frag << "#extension GL_KHR_shader_subgroup_shuffle_relative: enable\n";
321 frag << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
322 << "layout(location = 0) out uint result;\n"
323 << "layout(set = 0, binding = 0, std430) readonly buffer Buffer1\n"
325 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " data1[];\n"
327 << "layout(set = 0, binding = 1, std430) readonly buffer Buffer2\n"
329 << " uint data2[];\n"
331 << "void main (void)\n"
333 << " uvec4 mask = subgroupBallot(true);\n"
334 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " op = "
335 << getOpTypeName(caseDef.opType) << "(data1[gl_SubgroupInvocationID], data2[gl_SubgroupInvocationID]);\n"
336 << " uint id = " << idTable[caseDef.opType] << ";\n"
337 << " if ((0 <= id) && (id < gl_SubgroupSize) && subgroupBallotBitExtract(mask, id))\n"
339 << " result = (op == data1[id]) ? 1 : 0;\n"
343 << " result = 1; // Invocation we read from was inactive, so we can't verify results!\n"
347 programCollection.glslSources.add("frag")
348 << glu::FragmentSource(frag.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
350 else if (VK_SHADER_STAGE_VERTEX_BIT == caseDef.shaderStage)
352 std::ostringstream src;
354 src << "#version 450\n";
356 switch (caseDef.opType)
359 case OPTYPE_SHUFFLE_XOR:
360 src << "#extension GL_KHR_shader_subgroup_shuffle: enable\n";
363 src << "#extension GL_KHR_shader_subgroup_shuffle_relative: enable\n";
367 src << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
368 << "layout(set = 0, binding = 0, std430) buffer Buffer1\n"
370 << " uint result[];\n"
372 << "layout(set = 0, binding = 1, std430) buffer Buffer2\n"
374 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " data1[];\n"
376 << "layout(set = 0, binding = 2, std430) buffer Buffer3\n"
378 << " uint data2[];\n"
381 << "void main (void)\n"
383 << " uvec4 mask = subgroupBallot(true);\n"
384 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " op = "
385 << getOpTypeName(caseDef.opType) << "(data1[gl_SubgroupInvocationID], data2[gl_SubgroupInvocationID]);\n"
386 << " uint id = " << idTable[caseDef.opType] << ";\n"
387 << " if ((0 <= id) && (id < gl_SubgroupSize) && subgroupBallotBitExtract(mask, id))\n"
389 << " result[gl_VertexIndex] = (op == data1[id]) ? 1 : 0;\n"
393 << " result[gl_VertexIndex] = 1; // Invocation we read from was inactive, so we can't verify results!\n"
397 programCollection.glslSources.add("vert")
398 << glu::VertexSource(src.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
400 else if (VK_SHADER_STAGE_GEOMETRY_BIT == caseDef.shaderStage)
402 programCollection.glslSources.add("vert")
403 << glu::VertexSource(subgroups::getVertShaderForStage(caseDef.shaderStage)) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
405 std::ostringstream src;
407 src << "#version 450\n";
409 switch (caseDef.opType)
412 case OPTYPE_SHUFFLE_XOR:
413 src << "#extension GL_KHR_shader_subgroup_shuffle: enable\n";
416 src << "#extension GL_KHR_shader_subgroup_shuffle_relative: enable\n";
420 src << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
421 << "layout(points) in;\n"
422 << "layout(points, max_vertices = 1) out;\n"
423 << "layout(set = 0, binding = 0, std430) buffer Buffer1\n"
425 << " uint result[];\n"
427 << "layout(set = 0, binding = 1, std430) buffer Buffer2\n"
429 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " data1[];\n"
431 << "layout(set = 0, binding = 2, std430) buffer Buffer3\n"
433 << " uint data2[];\n"
436 << "void main (void)\n"
438 << " uvec4 mask = subgroupBallot(true);\n"
439 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " op = "
440 << getOpTypeName(caseDef.opType) << "(data1[gl_SubgroupInvocationID], data2[gl_SubgroupInvocationID]);\n"
441 << " uint id = " << idTable[caseDef.opType] << ";\n"
442 << " if ((0 <= id) && (id < gl_SubgroupSize) && subgroupBallotBitExtract(mask, id))\n"
444 << " result[gl_PrimitiveIDIn] = (op == data1[id]) ? 1 : 0;\n"
448 << " result[gl_PrimitiveIDIn] = 1; // Invocation we read from was inactive, so we can't verify results!\n"
452 programCollection.glslSources.add("geom")
453 << glu::GeometrySource(src.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
455 else if (VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT == caseDef.shaderStage)
457 programCollection.glslSources.add("vert")
458 << glu::VertexSource(subgroups::getVertShaderForStage(caseDef.shaderStage)) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
460 programCollection.glslSources.add("tese")
461 << glu::TessellationEvaluationSource("#version 450\nlayout(isolines) in;\nvoid main (void) {}\n");
463 std::ostringstream src;
465 src << "#version 450\n";
467 switch (caseDef.opType)
470 case OPTYPE_SHUFFLE_XOR:
471 src << "#extension GL_KHR_shader_subgroup_shuffle: enable\n";
474 src << "#extension GL_KHR_shader_subgroup_shuffle_relative: enable\n";
478 src << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
479 << "layout(vertices=1) out;\n"
480 << "layout(set = 0, binding = 0, std430) buffer Buffer1\n"
482 << " uint result[];\n"
484 << "layout(set = 0, binding = 1, std430) buffer Buffer2\n"
486 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " data1[];\n"
488 << "layout(set = 0, binding = 2, std430) buffer Buffer3\n"
490 << " uint data2[];\n"
493 << "void main (void)\n"
495 << " uvec4 mask = subgroupBallot(true);\n"
496 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " op = "
497 << getOpTypeName(caseDef.opType) << "(data1[gl_SubgroupInvocationID], data2[gl_SubgroupInvocationID]);\n"
498 << " uint id = " << idTable[caseDef.opType] << ";\n"
499 << " if ((0 <= id) && (id < gl_SubgroupSize) && subgroupBallotBitExtract(mask, id))\n"
501 << " result[gl_PrimitiveID] = (op == data1[id]) ? 1 : 0;\n"
505 << " result[gl_PrimitiveID] = 1; // Invocation we read from was inactive, so we can't verify results!\n"
509 programCollection.glslSources.add("tesc")
510 << glu::TessellationControlSource(src.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
512 else if (VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT == caseDef.shaderStage)
514 programCollection.glslSources.add("vert")
515 << glu::VertexSource(subgroups::getVertShaderForStage(caseDef.shaderStage)) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
517 programCollection.glslSources.add("tesc")
518 << glu::TessellationControlSource("#version 450\nlayout(vertices=1) out;\nvoid main (void) { for(uint i = 0; i < 4; i++) { gl_TessLevelOuter[i] = 1.0f; } }\n");
520 std::ostringstream src;
522 src << "#version 450\n";
524 switch (caseDef.opType)
527 case OPTYPE_SHUFFLE_XOR:
528 src << "#extension GL_KHR_shader_subgroup_shuffle: enable\n";
531 src << "#extension GL_KHR_shader_subgroup_shuffle_relative: enable\n";
535 src << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
536 << "layout(isolines) in;\n"
537 << "layout(set = 0, binding = 0, std430) buffer Buffer1\n"
539 << " uint result[];\n"
541 << "layout(set = 0, binding = 1, std430) buffer Buffer2\n"
543 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " data1[];\n"
545 << "layout(set = 0, binding = 2, std430) buffer Buffer3\n"
547 << " uint data2[];\n"
550 << "void main (void)\n"
552 << " uvec4 mask = subgroupBallot(true);\n"
553 << " " << subgroups::getFormatNameForGLSL(caseDef.format) << " op = "
554 << getOpTypeName(caseDef.opType) << "(data1[gl_SubgroupInvocationID], data2[gl_SubgroupInvocationID]);\n"
555 << " uint id = " << idTable[caseDef.opType] << ";\n"
556 << " if ((0 <= id) && (id < gl_SubgroupSize) && subgroupBallotBitExtract(mask, id))\n"
558 << " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = (op == data1[id]) ? 1 : 0;\n"
562 << " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = 1; // Invocation we read from was inactive, so we can't verify results!\n"
566 programCollection.glslSources.add("tese")
567 << glu::TessellationEvaluationSource(src.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u);
571 DE_FATAL("Unsupported shader stage");
575 tcu::TestStatus test(Context& context, const CaseDefinition caseDef)
577 if (!subgroups::isSubgroupSupported(context))
578 TCU_THROW(NotSupportedError, "Subgroup operations are not supported");
580 if (!subgroups::areSubgroupOperationsSupportedForStage(
581 context, caseDef.shaderStage))
583 if (subgroups::areSubgroupOperationsRequiredForStage(
584 caseDef.shaderStage))
586 return tcu::TestStatus::fail(
588 subgroups::getShaderStageName(caseDef.shaderStage) +
589 " is required to support subgroup operations!");
593 TCU_THROW(NotSupportedError, "Device does not support subgroup operations for this stage");
597 switch (caseDef.opType)
600 case OPTYPE_SHUFFLE_XOR:
601 if (!subgroups::isSubgroupFeatureSupportedForDevice(context, VK_SUBGROUP_FEATURE_SHUFFLE_BIT))
603 TCU_THROW(NotSupportedError, "Device does not support subgroup shuffle operations");
607 if (!subgroups::isSubgroupFeatureSupportedForDevice(context, VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT))
609 TCU_THROW(NotSupportedError, "Device does not support subgroup shuffle relative operations");
614 if (subgroups::isDoubleFormat(caseDef.format) &&
615 !subgroups::isDoubleSupportedForDevice(context))
617 TCU_THROW(NotSupportedError, "Device does not support subgroup double operations");
620 //Tests which don't use the SSBO
621 if (caseDef.noSSBO && VK_SHADER_STAGE_VERTEX_BIT == caseDef.shaderStage)
623 subgroups::SSBOData inputData[2];
624 inputData[0].format = caseDef.format;
625 inputData[0].numElements = subgroups::maxSupportedSubgroupSize();
626 inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero;
628 inputData[1].format = VK_FORMAT_R32_UINT;
629 inputData[1].numElements = inputData[0].numElements;
630 inputData[1].initializeType = subgroups::SSBOData::InitializeNonZero;
632 return subgroups::makeVertexFrameBufferTest(context, VK_FORMAT_R32_UINT, inputData, 2, checkVertexPipelineStages);
635 if ((VK_SHADER_STAGE_FRAGMENT_BIT != caseDef.shaderStage) &&
636 (VK_SHADER_STAGE_COMPUTE_BIT != caseDef.shaderStage))
638 if (!subgroups::isVertexSSBOSupportedForDevice(context))
640 TCU_THROW(NotSupportedError, "Device does not support vertex stage SSBO writes");
644 subgroups::SSBOData inputData[2];
645 inputData[0].format = caseDef.format;
646 inputData[0].numElements = subgroups::maxSupportedSubgroupSize();
647 inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero;
649 inputData[1].format = VK_FORMAT_R32_UINT;
650 inputData[1].numElements = inputData[0].numElements;
651 inputData[1].initializeType = subgroups::SSBOData::InitializeNonZero;
653 if (VK_SHADER_STAGE_FRAGMENT_BIT == caseDef.shaderStage)
655 return subgroups::makeFragmentTest(context, VK_FORMAT_R32_UINT,
656 inputData, 2, checkFragment);
658 else if (VK_SHADER_STAGE_COMPUTE_BIT == caseDef.shaderStage)
660 return subgroups::makeComputeTest(context, VK_FORMAT_R32_UINT,
661 inputData, 2, checkCompute);
663 else if (VK_SHADER_STAGE_VERTEX_BIT == caseDef.shaderStage)
665 return subgroups::makeVertexTest(context, VK_FORMAT_R32_UINT,
666 inputData, 2, checkVertexPipelineStages);
668 else if (VK_SHADER_STAGE_GEOMETRY_BIT == caseDef.shaderStage)
670 return subgroups::makeGeometryTest(context, VK_FORMAT_R32_UINT,
671 inputData, 2, checkVertexPipelineStages);
673 else if (VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT == caseDef.shaderStage)
675 return subgroups::makeTessellationControlTest(context, VK_FORMAT_R32_UINT,
676 inputData, 2, checkVertexPipelineStages);
678 else if (VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT == caseDef.shaderStage)
680 return subgroups::makeTessellationEvaluationTest(context, VK_FORMAT_R32_UINT,
681 inputData, 2, checkVertexPipelineStages);
685 TCU_THROW(InternalError, "Unhandled shader stage");
694 tcu::TestCaseGroup* createSubgroupsShuffleTests(tcu::TestContext& testCtx)
696 de::MovePtr<tcu::TestCaseGroup> group(new tcu::TestCaseGroup(
697 testCtx, "shuffle", "Subgroup shuffle category tests"));
699 const VkShaderStageFlags stages[] =
701 VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
702 VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
703 VK_SHADER_STAGE_GEOMETRY_BIT,
704 VK_SHADER_STAGE_VERTEX_BIT,
705 VK_SHADER_STAGE_FRAGMENT_BIT,
706 VK_SHADER_STAGE_COMPUTE_BIT
709 const VkFormat formats[] =
711 VK_FORMAT_R32_SINT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32B32_SINT,
712 VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32_UINT, VK_FORMAT_R32G32_UINT,
713 VK_FORMAT_R32G32B32_UINT, VK_FORMAT_R32G32B32A32_UINT,
714 VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_SFLOAT,
715 VK_FORMAT_R32G32B32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
716 VK_FORMAT_R64_SFLOAT, VK_FORMAT_R64G64_SFLOAT,
717 VK_FORMAT_R64G64B64_SFLOAT, VK_FORMAT_R64G64B64A64_SFLOAT,
718 VK_FORMAT_R8_USCALED, VK_FORMAT_R8G8_USCALED,
719 VK_FORMAT_R8G8B8_USCALED, VK_FORMAT_R8G8B8A8_USCALED,
722 for (int stageIndex = 0; stageIndex < DE_LENGTH_OF_ARRAY(stages); ++stageIndex)
724 const VkShaderStageFlags stage = stages[stageIndex];
726 for (int formatIndex = 0; formatIndex < DE_LENGTH_OF_ARRAY(formats); ++formatIndex)
728 const VkFormat format = formats[formatIndex];
730 for (int opTypeIndex = 0; opTypeIndex < OPTYPE_LAST; ++opTypeIndex)
732 CaseDefinition caseDef = {opTypeIndex, stage, format, false};
734 std::ostringstream name;
736 std::string op = getOpTypeName(opTypeIndex);
738 name << de::toLower(op)
739 << "_" << subgroups::getFormatNameForGLSL(format)
740 << "_" << getShaderStageName(stage);
742 addFunctionCaseWithPrograms(group.get(), name.str(),
743 "", initPrograms, test, caseDef);
745 if (VK_SHADER_STAGE_VERTEX_BIT == stage )
747 caseDef.noSSBO = true;
748 addFunctionCaseWithPrograms(group.get(), name.str()+"_framebuffer", "",
749 initFrameBufferPrograms, test, caseDef);
755 return group.release();