From 10f55a11eb729edf13ae6dc5dd5b36dcff0dbf3a Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Wed, 2 Nov 2022 11:52:02 +0100 Subject: HLSL: Add missing reference for mesh shader test. --- .../mesh-shader-basic-lines.spv14.vk.nocompat.mesh | 89 ++++++++++++++++++++++ ...sh-shader-basic-triangle.spv14.vk.nocompat.mesh | 89 ++++++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh create mode 100644 reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh diff --git a/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh b/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh new file mode 100644 index 00000000..9b9b3fa0 --- /dev/null +++ b/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh @@ -0,0 +1,89 @@ +struct BlockOut +{ + float4 a; + float4 b; +}; + +struct BlockOutPrim +{ + float4 a; + float4 b; +}; + +struct TaskPayload +{ + float a; + float b; + int c; +}; + +static const uint3 gl_WorkGroupSize = uint3(2u, 3u, 4u); + +static uint3 gl_WorkGroupID; +static uint3 gl_GlobalInvocationID; +static uint gl_LocalInvocationIndex; +struct SPIRV_Cross_Input +{ + uint3 gl_WorkGroupID : SV_GroupID; + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; + uint gl_LocalInvocationIndex : SV_GroupIndex; +}; + +struct gl_MeshPerVertexEXT +{ + float4 vOut : TEXCOORD0; + BlockOut outputs : TEXCOORD2; + float4 gl_Position : SV_Position; + float4 gl_ClipDistance[1] : SV_ClipDistance; + float4 gl_CullDistance[1] : SV_CullDistance; +}; + +struct gl_MeshPerPrimitiveEXT +{ + float4 vPrim : TEXCOORD1; + BlockOutPrim prim_outputs : TEXCOORD4; + uint gl_PrimitiveID : SV_PrimitiveID; + uint gl_Layer : SV_RenderTargetArrayIndex; + uint gl_ViewportIndex : SV_ViewportArrayIndex; + uint gl_PrimitiveShadingRateEXT : SV_ShadingRate; + bool gl_CullPrimitiveEXT : SV_CullPrimitive; +}; + +groupshared float shared_float[16]; + +void mesh_main(out gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], out gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[22], TaskPayload _payload, out uint2 gl_PrimitiveLineIndicesEXT[22]) +{ + SetMeshOutputCounts(24u, 22u); + float3 _29 = float3(gl_GlobalInvocationID); + float _31 = _29.x; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = float4(_31, _29.yz, 1.0f); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[0 / 4][0 % 4] = 4.0f; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_CullDistance[1 / 4][1 % 4] = 5.0f; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].vOut = float4(_31, _29.yz, 2.0f); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].outputs.a = 5.0f.xxxx; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].outputs.b = 6.0f.xxxx; + GroupMemoryBarrierWithGroupSync(); + if (gl_LocalInvocationIndex < 22u) + { + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].vPrim = float4(float3(gl_WorkGroupID), 3.0f); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].prim_outputs.a = _payload.a.xxxx; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].prim_outputs.b = _payload.b.xxxx; + gl_PrimitiveLineIndicesEXT[gl_LocalInvocationIndex] = uint2(0u, 1u) + gl_LocalInvocationIndex.xx; + int _126 = int(gl_GlobalInvocationID.x); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveID = _126; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_Layer = _126 + 1; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_ViewportIndex = _126 + 2; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_CullPrimitiveEXT = (gl_GlobalInvocationID.x & 1u) != 0u; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveShadingRateEXT = _126 + 3; + } +} + +[outputtopology("line")] +[numthreads(2, 3, 4)] +void main(SPIRV_Cross_Input stage_input, out vertices gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], out primitives gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[22], in payload TaskPayload _payload, out indices uint2 gl_PrimitiveLineIndicesEXT[22]) +{ + gl_WorkGroupID = stage_input.gl_WorkGroupID; + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; + mesh_main(gl_MeshVerticesEXT, gl_MeshPrimitivesEXT, _payload, gl_PrimitiveLineIndicesEXT); +} diff --git a/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh b/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh new file mode 100644 index 00000000..4d589bc9 --- /dev/null +++ b/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh @@ -0,0 +1,89 @@ +struct BlockOut +{ + float4 a; + float4 b; +}; + +struct BlockOutPrim +{ + float4 a; + float4 b; +}; + +struct TaskPayload +{ + float a; + float b; + int c; +}; + +static const uint3 gl_WorkGroupSize = uint3(2u, 3u, 4u); + +static uint3 gl_WorkGroupID; +static uint3 gl_GlobalInvocationID; +static uint gl_LocalInvocationIndex; +struct SPIRV_Cross_Input +{ + uint3 gl_WorkGroupID : SV_GroupID; + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; + uint gl_LocalInvocationIndex : SV_GroupIndex; +}; + +struct gl_MeshPerVertexEXT +{ + float4 vOut : TEXCOORD0; + BlockOut outputs : TEXCOORD2; + float4 gl_Position : SV_Position; + float4 gl_ClipDistance[1] : SV_ClipDistance; + float4 gl_CullDistance[1] : SV_CullDistance; +}; + +struct gl_MeshPerPrimitiveEXT +{ + float4 vPrim : TEXCOORD1; + BlockOutPrim prim_outputs : TEXCOORD4; + uint gl_PrimitiveID : SV_PrimitiveID; + uint gl_Layer : SV_RenderTargetArrayIndex; + uint gl_ViewportIndex : SV_ViewportArrayIndex; + uint gl_PrimitiveShadingRateEXT : SV_ShadingRate; + bool gl_CullPrimitiveEXT : SV_CullPrimitive; +}; + +groupshared float shared_float[16]; + +void mesh_main(out gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], out gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[22], TaskPayload _payload, out uint3 gl_PrimitiveTriangleIndicesEXT[22]) +{ + SetMeshOutputCounts(24u, 22u); + float3 _29 = float3(gl_GlobalInvocationID); + float _31 = _29.x; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = float4(_31, _29.yz, 1.0f); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[0 / 4][0 % 4] = 4.0f; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_CullDistance[1 / 4][1 % 4] = 5.0f; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].vOut = float4(_31, _29.yz, 2.0f); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].outputs.a = 5.0f.xxxx; + gl_MeshVerticesEXT[gl_LocalInvocationIndex].outputs.b = 6.0f.xxxx; + GroupMemoryBarrierWithGroupSync(); + if (gl_LocalInvocationIndex < 22u) + { + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].vPrim = float4(float3(gl_WorkGroupID), 3.0f); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].prim_outputs.a = _payload.a.xxxx; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].prim_outputs.b = _payload.b.xxxx; + gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uint3(0u, 1u, 2u) + gl_LocalInvocationIndex.xxx; + int _125 = int(gl_GlobalInvocationID.x); + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveID = _125; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_Layer = _125 + 1; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_ViewportIndex = _125 + 2; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_CullPrimitiveEXT = (gl_GlobalInvocationID.x & 1u) != 0u; + gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveShadingRateEXT = _125 + 3; + } +} + +[outputtopology("triangle")] +[numthreads(2, 3, 4)] +void main(SPIRV_Cross_Input stage_input, out vertices gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], out primitives gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[22], in payload TaskPayload _payload, out indices uint3 gl_PrimitiveTriangleIndicesEXT[22]) +{ + gl_WorkGroupID = stage_input.gl_WorkGroupID; + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex; + mesh_main(gl_MeshVerticesEXT, gl_MeshPrimitivesEXT, _payload, gl_PrimitiveTriangleIndicesEXT); +} -- cgit v1.2.3