forked from walbourn/directx-sdk-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TessellatorCS40_NumVerticesIndicesCS.hlsl
55 lines (47 loc) · 2 KB
/
TessellatorCS40_NumVerticesIndicesCS.hlsl
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
//--------------------------------------------------------------------------------------
// File: TessellatorCS40_NumVerticesIndicesCS.hlsl
//
// The CS to compute number of vertices and triangles to be generated from edge tessellation factor
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License (MIT).
//--------------------------------------------------------------------------------------
#include "TessellatorCS40_common.hlsl"
StructuredBuffer<float4> InputEdgeFactor : register(t0);
RWStructuredBuffer<uint2> NumVerticesIndicesOut : register(u0);
cbuffer cbCS : register(b1)
{
uint4 g_param;
}
[numthreads(128, 1, 1)]
void CSNumVerticesIndices( uint3 DTid : SV_DispatchThreadID )
{
if (DTid.x < g_param.x)
{
float4 edge_factor = InputEdgeFactor[DTid.x];
PROCESSED_TESS_FACTORS_TRI processedTessFactors;
int num_points = TriProcessTessFactors(edge_factor, processedTessFactors, g_partitioning);
int num_index;
if (0 == num_points)
{
num_index = 0;
}
else if (3 == num_points)
{
num_index = 4;
}
else
{
int numRings = ((processedTessFactors.numPointsForOutsideInside.w + 1) / 2); // +1 is so even tess includes the center point, which we want to now
int4 outsideInsideHalfTessFactor = int4(ceil(processedTessFactors.outsideInsideHalfTessFactor));
uint3 n = NumStitchTransition(outsideInsideHalfTessFactor, processedTessFactors.outsideInsideTessFactorParity);
num_index = n.x + n.y + n.z;
num_index += TotalNumStitchRegular(true, DIAGONALS_MIRRORED, processedTessFactors.numPointsForOutsideInside.w, numRings - 1) * 3;
if( processedTessFactors.outsideInsideTessFactorParity.w == TESSELLATOR_PARITY_ODD )
{
num_index += 4;
}
}
NumVerticesIndicesOut[DTid.x] = uint2(num_points, num_index);
}
}