" 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);
"#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"
" 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);
}
{
" 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"
<< 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);
}
"{\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"
<< 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);
}
" 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"
<< 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);
}
<< " {\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);
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"
<< " 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);
}
{
" 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);
"#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"
" 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);
}
{
"{\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")
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"
" 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);
}
{
"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"
"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"
"%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"
"%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);
/*
"#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"
"%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"
"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);
}
{
" 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);
"#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"
" 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);
}
{
" {\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);
"#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"
" 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);
}
{
"{\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")
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"
" 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);
}
{
" {\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")
"#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"
" 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 =
#include "vktSubgroupsTestsUtils.hpp"
#include "deRandom.hpp"
#include "tcuCommandLine.hpp"
+#include "tcuStringTemplate.hpp"
#include "vkImageUtil.hpp"
using namespace tcu;
"\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;
}
}
-std::string vkt::subgroups::getFormatNameForGLSL(VkFormat format)
+std::string vkt::subgroups::getFormatNameForGLSL (VkFormat format)
{
switch (format)
{
}
}
+void vkt::subgroups::addGeometryShadersFromTemplate (const std::string& glslTemplate, const vk::ShaderBuildOptions& options, vk::GlslSourceCollection& collection)
+{
+ tcu::StringTemplate geometryTemplate(glslTemplate);
+
+ map<string, string> linesParams;
+ linesParams.insert(pair<string, string>("TOPOLOGY", "lines"));
+
+ map<string, string> pointsParams;
+ pointsParams.insert(pair<string, string>("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<string, string> linesParams;
+ linesParams.insert(pair<string, string>("TOPOLOGY", "InputLines"));
+
+ map<string, string> pointsParams;
+ pointsParams.insert(pair<string, string>("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;
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);
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<const void*> datas, deUint32 width, deUint32 subgroupSize),
"{\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")
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"
" 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);
}
{