Imported Upstream version 2.81
[platform/upstream/libbullet.git] / src / BulletMultiThreaded / GpuSoftBodySolvers / DX11 / HLSL / OutputToVertexArray.hlsl
1 MSTRINGIFY(\r
2 \r
3 cbuffer OutputToVertexArrayCB : register( b0 )\r
4 {\r
5         int startNode;\r
6         int numNodes;\r
7         int positionOffset;\r
8         int positionStride;\r
9         \r
10         int normalOffset;       \r
11         int normalStride;\r
12         int padding1;\r
13         int padding2;\r
14 };\r
15 \r
16 \r
17 StructuredBuffer<float4> g_vertexPositions : register( t0 );\r
18 StructuredBuffer<float4> g_vertexNormals : register( t1 );\r
19 \r
20 RWBuffer<float> g_vertexBuffer : register( u0 );\r
21 \r
22 \r
23 [numthreads(128, 1, 1)]\r
24 void \r
25 OutputToVertexArrayWithNormalsKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )\r
26 {\r
27         int nodeID = DTid.x;\r
28         if( nodeID < numNodes )\r
29         {                       \r
30                 float4 position = g_vertexPositions[nodeID + startNode];\r
31                 float4 normal = g_vertexNormals[nodeID + startNode];\r
32                 \r
33                 // Stride should account for the float->float4 conversion\r
34                 int positionDestination = nodeID * positionStride + positionOffset;             \r
35                 g_vertexBuffer[positionDestination] = position.x;\r
36                 g_vertexBuffer[positionDestination+1] = position.y;\r
37                 g_vertexBuffer[positionDestination+2] = position.z;\r
38                 \r
39                 int normalDestination = nodeID * normalStride + normalOffset;\r
40                 g_vertexBuffer[normalDestination] = normal.x;\r
41                 g_vertexBuffer[normalDestination+1] = normal.y;\r
42                 g_vertexBuffer[normalDestination+2] = normal.z;         \r
43         }\r
44 }\r
45 \r
46 [numthreads(128, 1, 1)]\r
47 void \r
48 OutputToVertexArrayWithoutNormalsKernel( uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex )\r
49 {\r
50         int nodeID = DTid.x;\r
51         if( nodeID < numNodes )\r
52         {                       \r
53                 float4 position = g_vertexPositions[nodeID + startNode];\r
54                 float4 normal = g_vertexNormals[nodeID + startNode];\r
55                 \r
56                 // Stride should account for the float->float4 conversion\r
57                 int positionDestination = nodeID * positionStride + positionOffset;             \r
58                 g_vertexBuffer[positionDestination] = position.x;\r
59                 g_vertexBuffer[positionDestination+1] = position.y;\r
60                 g_vertexBuffer[positionDestination+2] = position.z;             \r
61         }\r
62 }\r
63 );