diff options
| author | Yong He <yonghe@outlook.com> | 2024-03-20 15:47:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 15:47:36 -0700 |
| commit | 45c7d33fe87e1628de7991f46ca68f8ddd2f7e4c (patch) | |
| tree | b493c79d4ef42b32ccd197112befd1c47995cbd6 /tests | |
| parent | c371cceaab3f08e134b3cb005b46e5ee95f6df54 (diff) | |
Fix spirv generation for using output stream in a function. (#3806)
* Fix spirv generation for using output stream in a function.
* polish.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/spirv/geometry-shader-sub-func.slang | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/spirv/geometry-shader-sub-func.slang b/tests/spirv/geometry-shader-sub-func.slang new file mode 100644 index 000000000..6c6944f31 --- /dev/null +++ b/tests/spirv/geometry-shader-sub-func.slang @@ -0,0 +1,44 @@ +// geometry-shader-sub-func.slang + +//TEST:SIMPLE(filecheck=SPIRV): -target spirv -emit-spirv-directly -O0 + +struct CoarseVertex +{ + float4 position : POSITION; + float3 color : COLOR; + uint id : ID; +} + +struct RasterVertex +{ + float4 position : POSITION; + float3 color : COLOR; + uint id : SV_RenderTargetArrayIndex; +} + +// SPIRV: OpEntryPoint +// SPIRV: OpStore %outputStream_position +// SPIRV: OpEmitVertex +void appendVertex(TriangleStream<RasterVertex> outputStream, RasterVertex vert) +{ + outputStream.Append(vert); +} + +[shader("geometry")] +[maxvertexcount(3)] +void main( + triangle CoarseVertex coarseVertices[3], + inout TriangleStream<RasterVertex> outputStream, + uint primitiveID : SV_PrimitiveID) +{ + [ForceUnroll] + for(int ii = 0; ii < 3; ++ii) + { + CoarseVertex coarseVertex = coarseVertices[ii]; + RasterVertex rasterVertex; + rasterVertex.position = coarseVertex.position; + rasterVertex.color = coarseVertex.color; + rasterVertex.id = coarseVertex.id + primitiveID; + appendVertex(outputStream, rasterVertex); + } +} |
