forked from microsoft/Xbox-GDK-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleTriangleMS.hlsl
More file actions
60 lines (52 loc) · 1.73 KB
/
Copy pathSimpleTriangleMS.hlsl
File metadata and controls
60 lines (52 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//--------------------------------------------------------------------------------------
// SimpleTriangleMS.hlsl
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#include "Common.hlsli"
// Hardcoded screen-space triangle positions, colors, & indices
static const float4 s_Positions[3] =
{
float4(-0.5f, -0.5f, 0.5f, 1.0f),
float4( 0.0f, 0.5f, 0.5f, 1.0f),
float4( 0.5f, -0.5f, 0.5f, 1.0f),
};
static const float4 s_Color[3] =
{
float4(1.0, 0.0, 0.0, 1.0f),
float4(0.0, 1.0, 0.0, 1.0f),
float4(0.0, 0.0, 1.0, 1.0f),
};
static const uint3 s_Triangle = uint3(0, 1, 2);
[RootSignature("")]
[NumThreads(32, 1, 1)]
[OutputTopology("triangle")]
void main(
uint gtid : SV_GroupThreadID,
out indices uint3 tris[1],
out vertices VertexOut verts[3]
)
{
// SetMeshOutputCounts(numVerts, numPrims)
// - Mandatory intrinsics function call in Mesh Shaders
// - Must be called from non-divergent codepath
// - Assumes threadgroup constant values (reads from lane 0)
// - Must be <= length of indices & vertices arrays.
SetMeshOutputCounts(3, 1); // Set the correct counts for a triangle: 3 verts & 1 primitive
// Only 3 verts so use first 3 threads to process & export.
if (gtid < 3)
{
VertexOut vout;
vout.Position = s_Positions[gtid];
vout.Color = s_Color[gtid];
// Write out vertex data to the 'vertices' array.
verts[gtid] = vout;
}
// Only 1 prim so use first thread to process & export.
if (gtid < 1)
{
// Write out index data to the 'indices' array.
tris[gtid] = s_Triangle;
}
}