From 688580ad608c000573da24873f82c62c1afb2c70 Mon Sep 17 00:00:00 2001 From: Slawomir Cygan Date: Fri, 29 Dec 2017 18:18:20 +0100 Subject: [PATCH] Emit defined positions from tessellation shader in subgroups tests. Use only defined components of gl_in[] in tessellation evaluation shader: the tessellation control shader emits only one vertex in patch, so the value of gl_in[1] is undefined. The code is changed to use only gl_in[0]. Additionally fix geometry shader input primitive topology, when tessellation shaders are used: tessellation outputs isolines, so geometry input should be lines, not points. Affects: dEQP-VK.subgroups.*graphic Components: Vulkan VK-GL-CTS issue: 924 Change-Id: Id1984a387a32c50e0f86638bf3d6b0273a7633d8 (cherry picked from commit 36a60de573f65194c50271fc5b9d9a137fba0bb5) --- .../subgroups/vktSubgroupsArithmeticTests.cpp | 9 +- .../subgroups/vktSubgroupsBallotBroadcastTests.cpp | 9 +- .../subgroups/vktSubgroupsBallotOtherTests.cpp | 9 +- .../vulkan/subgroups/vktSubgroupsBallotTests.cpp | 9 +- .../vulkan/subgroups/vktSubgroupsBasicTests.cpp | 17 +-- .../subgroups/vktSubgroupsBuiltinMaskVarTests.cpp | 9 +- .../subgroups/vktSubgroupsBuiltinVarTests.cpp | 77 ++++++------ .../subgroups/vktSubgroupsClusteredTests.cpp | 8 +- .../vulkan/subgroups/vktSubgroupsQuadTests.cpp | 9 +- .../vulkan/subgroups/vktSubgroupsShapeTests.cpp | 9 +- .../vulkan/subgroups/vktSubgroupsShuffleTests.cpp | 9 +- .../vulkan/subgroups/vktSubgroupsTestsUtils.cpp | 130 ++++++++++++++------- .../vulkan/subgroups/vktSubgroupsTestsUtils.hpp | 3 + .../vulkan/subgroups/vktSubgroupsVoteTests.cpp | 9 +- 14 files changed, 191 insertions(+), 125 deletions(-) diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp index 7d5182e..e483d32 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp @@ -715,7 +715,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " uvec4 mask = subgroupBallot(true);\n" + bdy + " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = tempResult;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); @@ -726,7 +727,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "#version 450\n" "#extension GL_KHR_shader_subgroup_arithmetic: enable\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -746,8 +747,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EmitVertex();\n" " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp index f09c06c..0c0b9cf 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp @@ -386,13 +386,14 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " uvec4 mask = subgroupBallot(true);\n" + bdy.str() + " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = tempResult;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; const std::string geometry = "#version 450\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -436,8 +437,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) << glu::TessellationControlSource(tesc) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); programCollection.glslSources.add("fragment") << glu::FragmentSource(fragment)<< vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); } diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotOtherTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotOtherTests.cpp index 3d20c2a..7ba3a95 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotOtherTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotOtherTests.cpp @@ -544,13 +544,14 @@ void initPrograms (SourceCollections& programCollection, CaseDefinition caseDef) "{\n" + bdy.str() + " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = tempResult;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; const string geometry = "#version 450\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -584,8 +585,8 @@ void initPrograms (SourceCollections& programCollection, CaseDefinition caseDef) << glu::TessellationControlSource(tesc) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); programCollection.glslSources.add("fragment") << glu::FragmentSource(fragment)<< vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); } diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp index 15e2ed5..caa46bc 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp @@ -272,13 +272,14 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " tempResult |= !bool(uvec4(0) == subgroupBallot(bData)) ? 0x2 : 0;\n" " tempResult |= uvec4(0) == subgroupBallot(false) ? 0x4 : 0;\n" " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = tempResult;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; const string geometry = "#version 450\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -328,8 +329,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) << glu::TessellationControlSource(tesc) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); programCollection.glslSources.add("fragment") << glu::FragmentSource(fragment)<< vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); } diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp index 8675933..5936fb4 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp @@ -616,7 +616,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) << " {\n" << " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = " << UNELECTED_VALUE << ";\n" << " }\n" - << " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + << " float pixelSize = 2.0f/1024.0f;\n" + << " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" << "}\n"; programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); @@ -626,7 +627,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) std::ostringstream geometry; geometry << "#version 450\n" << "#extension GL_KHR_shader_subgroup_basic: enable\n" - << "layout(points) in;\n" + << "layout(${TOPOLOGY}) in;\n" << "layout(points, max_vertices = 1) out;\n" << "layout(set = 0, binding = 3, std430) buffer Buffer1\n" << "{\n" @@ -652,8 +653,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) << " EmitVertex();\n" << " EndPrimitive();\n" << "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry.str()) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry.str(), vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { @@ -886,7 +887,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " uint tempResult = 0;\n" + bdy.str() + " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = tempResult;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n"" gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); @@ -897,7 +898,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "#version 450\n" "#extension GL_KHR_shader_subgroup_basic: enable\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -932,8 +933,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EmitVertex();\n" " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinMaskVarTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinMaskVarTests.cpp index e4c4c0e..c7373dc 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinMaskVarTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinMaskVarTests.cpp @@ -297,7 +297,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "{\n" + bdy + " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = tempResult;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") @@ -308,7 +309,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) const string geometry = "#version 450\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Output\n" "{\n" @@ -324,8 +325,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinVarTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinVarTests.cpp index b170ad8..87fec01 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinVarTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBuiltinVarTests.cpp @@ -630,20 +630,21 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "void main (void)\n" "{\n" " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = uvec4(gl_SubgroupSize, gl_SubgroupInvocationID, 0, 0);\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; */ const string tese = - "; SPIR-V\n" + "; SPIR - V\n" "; Version: 1.3\n" - "; Generator: Khronos Glslang Reference Front End; 1\n" - "; Bound: 63\n" + "; Generator: Khronos Glslang Reference Front End; 2\n" + "; Bound: 67\n" "; Schema: 0\n" "OpCapability Tessellation\n" "OpCapability GroupNonUniform\n" "%1 = OpExtInstImport \"GLSL.std.450\"\n" "OpMemoryModel Logical GLSL450\n" - "OpEntryPoint TessellationEvaluation %4 \"main\" %15 %23 %33 %35 %45 %50\n" + "OpEntryPoint TessellationEvaluation %4 \"main\" %15 %23 %33 %35 %48 %53\n" "OpExecutionMode %4 Isolines\n" "OpExecutionMode %4 SpacingEqual\n" "OpExecutionMode %4 VertexOrderCcw\n" @@ -660,16 +661,16 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "OpDecorate %35 RelaxedPrecision\n" "OpDecorate %35 BuiltIn SubgroupLocalInvocationId\n" "OpDecorate %36 RelaxedPrecision\n" - "OpMemberDecorate %43 0 BuiltIn Position\n" - "OpMemberDecorate %43 1 BuiltIn PointSize\n" - "OpMemberDecorate %43 2 BuiltIn ClipDistance\n" - "OpMemberDecorate %43 3 BuiltIn CullDistance\n" - "OpDecorate %43 Block\n" "OpMemberDecorate %46 0 BuiltIn Position\n" "OpMemberDecorate %46 1 BuiltIn PointSize\n" "OpMemberDecorate %46 2 BuiltIn ClipDistance\n" "OpMemberDecorate %46 3 BuiltIn CullDistance\n" "OpDecorate %46 Block\n" + "OpMemberDecorate %49 0 BuiltIn Position\n" + "OpMemberDecorate %49 1 BuiltIn PointSize\n" + "OpMemberDecorate %49 2 BuiltIn ClipDistance\n" + "OpMemberDecorate %49 3 BuiltIn CullDistance\n" + "OpDecorate %49 Block\n" "%2 = OpTypeVoid\n" "%3 = OpTypeFunction %2\n" "%6 = OpTypeInt 32 0\n" @@ -694,22 +695,25 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "%33 = OpVariable %32 Input\n" "%35 = OpVariable %32 Input\n" "%38 = OpTypePointer Uniform %7\n" - "%40 = OpTypeVector %20 4\n" - "%41 = OpConstant %6 1\n" - "%42 = OpTypeArray %20 %41\n" - "%43 = OpTypeStruct %40 %20 %42 %42\n" - "%44 = OpTypePointer Output %43\n" - "%45 = OpVariable %44 Output\n" - "%46 = OpTypeStruct %40 %20 %42 %42\n" - "%47 = OpConstant %6 32\n" - "%48 = OpTypeArray %46 %47\n" - "%49 = OpTypePointer Input %48\n" - "%50 = OpVariable %49 Input\n" - "%51 = OpTypePointer Input %40\n" - "%54 = OpConstant %12 1\n" - "%61 = OpTypePointer Output %40\n" + "%40 = OpTypePointer Function %20\n" + "%42 = OpConstant %20 0.00195313\n" + "%43 = OpTypeVector %20 4\n" + "%44 = OpConstant %6 1\n" + "%45 = OpTypeArray %20 %44\n" + "%46 = OpTypeStruct %43 %20 %45 %45\n" + "%47 = OpTypePointer Output %46\n" + "%48 = OpVariable %47 Output\n" + "%49 = OpTypeStruct %43 %20 %45 %45\n" + "%50 = OpConstant %6 32\n" + "%51 = OpTypeArray %49 %50\n" + "%52 = OpTypePointer Input %51\n" + "%53 = OpVariable %52 Input\n" + "%54 = OpTypePointer Input %43\n" + "%61 = OpConstant %20 2\n" + "%65 = OpTypePointer Output %43\n" "%4 = OpFunction %2 None %3\n" "%5 = OpLabel\n" + "%41 = OpVariable %40 Function\n" "%16 = OpLoad %12 %15\n" "%18 = OpIMul %12 %16 %17\n" "%19 = OpBitcast %6 %18\n" @@ -723,16 +727,18 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "%37 = OpCompositeConstruct %7 %34 %36 %24 %24\n" "%39 = OpAccessChain %38 %11 %13 %31\n" "OpStore %39 %37\n" - "%52 = OpAccessChain %51 %50 %13 %13\n" - "%53 = OpLoad %40 %52\n" - "%55 = OpAccessChain %51 %50 %54 %13\n" - "%56 = OpLoad %40 %55\n" + "OpStore %41 %42\n" + "%55 = OpAccessChain %54 %53 %13 %13\n" + "%56 = OpLoad %43 %55\n" "%57 = OpAccessChain %25 %23 %24\n" "%58 = OpLoad %20 %57\n" - "%59 = OpCompositeConstruct %40 %58 %58 %58 %58\n" - "%60 = OpExtInst %40 %1 FMix %53 %56 %59\n" - "%62 = OpAccessChain %61 %45 %13\n" - "OpStore %62 %60\n" + "%59 = OpLoad %20 %41\n" + "%60 = OpFMul %20 %58 %59\n" + "%62 = OpFDiv %20 %60 %61\n" + "%63 = OpCompositeConstruct %43 %62 %62 %62 %62\n" + "%64 = OpFAdd %43 %56 %63\n" + "%66 = OpAccessChain %65 %48 %13\n" + "OpStore %66 %64\n" "OpReturn\n" "OpFunctionEnd\n"; programCollection.spirvAsmSources.add("tese") << tese << SpirVAsmBuildOptions(SPIRV_VERSION_1_3); @@ -742,7 +748,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) /* "#version 450\n" "#extension GL_KHR_shader_subgroup_basic: enable\n" - "layout(points) in;\n" + "// Note: ${TOPOLOGY} variable is substituted manually at SPIR-V ASM level" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Output\n" "{\n" @@ -768,7 +775,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "%1 = OpExtInstImport \"GLSL.std.450\"\n" "OpMemoryModel Logical GLSL450\n" "OpEntryPoint Geometry %4 \"main\" %15 %18 %20 %32 %36\n" - "OpExecutionMode %4 InputPoints\n" + "OpExecutionMode %4 ${TOPOLOGY}\n" "OpExecutionMode %4 Invocations 1\n" "OpExecutionMode %4 OutputPoints\n" "OpExecutionMode %4 OutputVertices 1\n" @@ -840,7 +847,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "OpEndPrimitive\n" "OpReturn\n" "OpFunctionEnd\n"; - programCollection.spirvAsmSources.add("geometry") << geometry << SpirVAsmBuildOptions(SPIRV_VERSION_1_3); + addGeometryShadersFromTemplate(geometry, SpirVAsmBuildOptions(SPIRV_VERSION_1_3), programCollection.spirvAsmSources); } { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp index 0731756..5ad0a2b 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp @@ -593,7 +593,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " uvec4 mask = subgroupBallot(true);\n" + bdy.str() + " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = tempResult ? 1 : 0;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); @@ -604,7 +605,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "#version 450\n" "#extension GL_KHR_shader_subgroup_clustered: enable\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -624,8 +625,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EmitVertex();\n" " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), programCollection.glslSources); } { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp index 20518c2..9c5bd49 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp @@ -393,7 +393,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " {\n" " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = 1; // Invocation we read from was inactive, so we can't verify results!\n" " }\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") << glu::TessellationEvaluationSource(tese) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); @@ -404,7 +405,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "#version 450\n" "#extension GL_KHR_shader_subgroup_quad: enable\n" "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -432,8 +433,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EmitVertex();\n" " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShapeTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShapeTests.cpp index 73aeec6..e85c773 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShapeTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShapeTests.cpp @@ -380,7 +380,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "{\n" + bdy.str() + " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = 1;\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") @@ -391,7 +392,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) const string geometry = "#version 450\n" + extension + - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -407,8 +408,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp index 39a5ad2..7ace300 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp @@ -404,7 +404,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " {\n" " result[gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5)] = 1; // Invocation we read from was inactive, so we can't verify results!\n" " }\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") @@ -416,7 +417,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "#version 450\n" + source + "#extension GL_KHR_shader_subgroup_ballot: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -450,8 +451,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { const string fragment = diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp index 7adf4fc..a07be0a 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp @@ -25,6 +25,7 @@ #include "vktSubgroupsTestsUtils.hpp" #include "deRandom.hpp" #include "tcuCommandLine.hpp" +#include "tcuStringTemplate.hpp" #include "vkImageUtil.hpp" using namespace tcu; @@ -960,70 +961,76 @@ void vkt::subgroups::addNoSubgroupShader (SourceCollections& programCollection) "\n" "void main (void)\n" "{\n" - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; */ const std::string teseNoSubgroup = "; SPIR-V\n" "; Version: 1.3\n" - "; Generator: Khronos Glslang Reference Front End; 1\n" - "; Bound: 38\n" + "; Generator: Khronos Glslang Reference Front End; 2\n" + "; Bound: 42\n" "; Schema: 0\n" "OpCapability Tessellation\n" "%1 = OpExtInstImport \"GLSL.std.450\"\n" "OpMemoryModel Logical GLSL450\n" - "OpEntryPoint TessellationEvaluation %4 \"main\" %13 %20 %29\n" + "OpEntryPoint TessellationEvaluation %4 \"main\" %16 %23 %29\n" "OpExecutionMode %4 Isolines\n" "OpExecutionMode %4 SpacingEqual\n" "OpExecutionMode %4 VertexOrderCcw\n" - "OpMemberDecorate %11 0 BuiltIn Position\n" - "OpMemberDecorate %11 1 BuiltIn PointSize\n" - "OpMemberDecorate %11 2 BuiltIn ClipDistance\n" - "OpMemberDecorate %11 3 BuiltIn CullDistance\n" - "OpDecorate %11 Block\n" - "OpMemberDecorate %16 0 BuiltIn Position\n" - "OpMemberDecorate %16 1 BuiltIn PointSize\n" - "OpMemberDecorate %16 2 BuiltIn ClipDistance\n" - "OpMemberDecorate %16 3 BuiltIn CullDistance\n" - "OpDecorate %16 Block\n" + "OpMemberDecorate %14 0 BuiltIn Position\n" + "OpMemberDecorate %14 1 BuiltIn PointSize\n" + "OpMemberDecorate %14 2 BuiltIn ClipDistance\n" + "OpMemberDecorate %14 3 BuiltIn CullDistance\n" + "OpDecorate %14 Block\n" + "OpMemberDecorate %19 0 BuiltIn Position\n" + "OpMemberDecorate %19 1 BuiltIn PointSize\n" + "OpMemberDecorate %19 2 BuiltIn ClipDistance\n" + "OpMemberDecorate %19 3 BuiltIn CullDistance\n" + "OpDecorate %19 Block\n" "OpDecorate %29 BuiltIn TessCoord\n" "%2 = OpTypeVoid\n" "%3 = OpTypeFunction %2\n" "%6 = OpTypeFloat 32\n" - "%7 = OpTypeVector %6 4\n" - "%8 = OpTypeInt 32 0\n" - "%9 = OpConstant %8 1\n" - "%10 = OpTypeArray %6 %9\n" - "%11 = OpTypeStruct %7 %6 %10 %10\n" - "%12 = OpTypePointer Output %11\n" - "%13 = OpVariable %12 Output\n" - "%14 = OpTypeInt 32 1\n" - "%15 = OpConstant %14 0\n" - "%16 = OpTypeStruct %7 %6 %10 %10\n" - "%17 = OpConstant %8 32\n" - "%18 = OpTypeArray %16 %17\n" - "%19 = OpTypePointer Input %18\n" - "%20 = OpVariable %19 Input\n" - "%21 = OpTypePointer Input %7\n" - "%24 = OpConstant %14 1\n" + "%7 = OpTypePointer Function %6\n" + "%9 = OpConstant %6 0.00195313\n" + "%10 = OpTypeVector %6 4\n" + "%11 = OpTypeInt 32 0\n" + "%12 = OpConstant %11 1\n" + "%13 = OpTypeArray %6 %12\n" + "%14 = OpTypeStruct %10 %6 %13 %13\n" + "%15 = OpTypePointer Output %14\n" + "%16 = OpVariable %15 Output\n" + "%17 = OpTypeInt 32 1\n" + "%18 = OpConstant %17 0\n" + "%19 = OpTypeStruct %10 %6 %13 %13\n" + "%20 = OpConstant %11 32\n" + "%21 = OpTypeArray %19 %20\n" + "%22 = OpTypePointer Input %21\n" + "%23 = OpVariable %22 Input\n" + "%24 = OpTypePointer Input %10\n" "%27 = OpTypeVector %6 3\n" "%28 = OpTypePointer Input %27\n" "%29 = OpVariable %28 Input\n" - "%30 = OpConstant %8 0\n" + "%30 = OpConstant %11 0\n" "%31 = OpTypePointer Input %6\n" - "%36 = OpTypePointer Output %7\n" + "%36 = OpConstant %6 2\n" + "%40 = OpTypePointer Output %10\n" "%4 = OpFunction %2 None %3\n" "%5 = OpLabel\n" - "%22 = OpAccessChain %21 %20 %15 %15\n" - "%23 = OpLoad %7 %22\n" - "%25 = OpAccessChain %21 %20 %24 %15\n" - "%26 = OpLoad %7 %25\n" + "%8 = OpVariable %7 Function\n" + "OpStore %8 %9\n" + "%25 = OpAccessChain %24 %23 %18 %18\n" + "%26 = OpLoad %10 %25\n" "%32 = OpAccessChain %31 %29 %30\n" "%33 = OpLoad %6 %32\n" - "%34 = OpCompositeConstruct %7 %33 %33 %33 %33\n" - "%35 = OpExtInst %7 %1 FMix %23 %26 %34\n" - "%37 = OpAccessChain %36 %13 %15\n" - "OpStore %37 %35\n" + "%34 = OpLoad %6 %8\n" + "%35 = OpFMul %6 %33 %34\n" + "%37 = OpFDiv %6 %35 %36\n" + "%38 = OpCompositeConstruct %10 %37 %37 %37 %37\n" + "%39 = OpFAdd %10 %26 %38\n" + "%41 = OpAccessChain %40 %16 %18\n" + "OpStore %41 %39\n" "OpReturn\n" "OpFunctionEnd\n"; programCollection.spirvAsmSources.add("tese_noSubgroup") << teseNoSubgroup; @@ -1147,7 +1154,7 @@ bool vkt::subgroups::isDoubleFormat(VkFormat format) } } -std::string vkt::subgroups::getFormatNameForGLSL(VkFormat format) +std::string vkt::subgroups::getFormatNameForGLSL (VkFormat format) { switch (format) { @@ -1196,6 +1203,34 @@ std::string vkt::subgroups::getFormatNameForGLSL(VkFormat format) } } +void vkt::subgroups::addGeometryShadersFromTemplate (const std::string& glslTemplate, const vk::ShaderBuildOptions& options, vk::GlslSourceCollection& collection) +{ + tcu::StringTemplate geometryTemplate(glslTemplate); + + map linesParams; + linesParams.insert(pair("TOPOLOGY", "lines")); + + map pointsParams; + pointsParams.insert(pair("TOPOLOGY", "points")); + + collection.add("geometry_lines") << glu::GeometrySource(geometryTemplate.specialize(linesParams)) << options; + collection.add("geometry_points") << glu::GeometrySource(geometryTemplate.specialize(pointsParams)) << options; +} + +void vkt::subgroups::addGeometryShadersFromTemplate (const std::string& spirvTemplate, const vk::SpirVAsmBuildOptions& options, vk::SpirVAsmCollection& collection) +{ + tcu::StringTemplate geometryTemplate(spirvTemplate); + + map linesParams; + linesParams.insert(pair("TOPOLOGY", "InputLines")); + + map pointsParams; + pointsParams.insert(pair("TOPOLOGY", "InputPoints")); + + collection.add("geometry_lines") << geometryTemplate.specialize(linesParams) << options; + collection.add("geometry_points") << geometryTemplate.specialize(pointsParams) << options; +} + void initializeMemory(Context& context, const Allocation& alloc, subgroups::SSBOData& data) { const vk::VkFormat format = data.format; @@ -1400,7 +1435,18 @@ tcu::TestStatus vkt::subgroups::allStages( teEvalShaderModule = createShaderModule(context.getDeviceInterface(), context.getDevice(), context.getBinaryCollection().get(tese), 0u); } if (shaderStageRequired & VK_SHADER_STAGE_GEOMETRY_BIT) - geometryShaderModule = createShaderModule(context.getDeviceInterface(), context.getDevice(), context.getBinaryCollection().get("geometry"), 0u); + { + if (shaderStageRequired & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) + { + // tessellation shaders output line primitives + geometryShaderModule = createShaderModule(context.getDeviceInterface(), context.getDevice(), context.getBinaryCollection().get("geometry_lines"), 0u); + } + else + { + // otherwise points are processed by geometry shader + geometryShaderModule = createShaderModule(context.getDeviceInterface(), context.getDevice(), context.getBinaryCollection().get("geometry_points"), 0u); + } + } if (shaderStageRequired & VK_SHADER_STAGE_FRAGMENT_BIT) fragmentShaderModule = createShaderModule(context.getDeviceInterface(), context.getDevice(), context.getBinaryCollection().get("fragment"), 0u); diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp index 46ca873..d7ccd2b 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp @@ -112,6 +112,9 @@ bool isDoubleFormat(vk::VkFormat format); std::string getFormatNameForGLSL(vk::VkFormat format); +void addGeometryShadersFromTemplate (const std::string& glslTemplate, const vk::ShaderBuildOptions& options, vk::GlslSourceCollection& collection); +void addGeometryShadersFromTemplate (const std::string& spirvTemplate, const vk::SpirVAsmBuildOptions& options, vk::SpirVAsmCollection& collection); + tcu::TestStatus allStages(Context& context, vk::VkFormat format, SSBOData* extraData, deUint32 extraDataCount, bool (*checkResult)(std::vector datas, deUint32 width, deUint32 subgroupSize), diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp index 3b3fb77..849bff2 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp @@ -437,7 +437,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) "{\n" " highp uint offset = gl_PrimitiveID * 2 + uint(gl_TessCoord.x + 0.5);\n" + source + - " gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x);\n" + " float pixelSize = 2.0f/1024.0f;\n" + " gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n" "}\n"; programCollection.glslSources.add("tese") @@ -448,7 +449,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) const string geometry = "#version 450\n" "#extension GL_KHR_shader_subgroup_vote: enable\n" - "layout(points) in;\n" + "layout(${TOPOLOGY}) in;\n" "layout(points, max_vertices = 1) out;\n" "layout(set = 0, binding = 3, std430) buffer Buffer1\n" "{\n" @@ -468,8 +469,8 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef) " EndPrimitive();\n" "}\n"; - programCollection.glslSources.add("geometry") - << glu::GeometrySource(geometry) << vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u); + subgroups::addGeometryShadersFromTemplate(geometry, vk::ShaderBuildOptions(vk::SPIRV_VERSION_1_3, 0u), + programCollection.glslSources); } { -- 2.7.4