Permalink
Browse files

GPU buffer oriented: append global splats in parallel too; 638 -> 644…

… Mray/s
  • Loading branch information...
aras-p committed Apr 25, 2018
1 parent 88e3e9f commit 9fcb42d968e1b3d585b801da144943af9124e630
Showing with 16 additions and 8 deletions.
  1. +16 −8 Cpp/Windows/ComputeShaderBounce.hlsl
@@ -22,6 +22,7 @@ SplatData MakeSplatData(float3 color, uint pixelIndex)
}
groupshared uint s_GroupSplatCounter;
groupshared uint s_GroupSplatGlobalStart;
groupshared SplatData s_GroupSplats[kCSRayBatchSize];
void PushSplat(float3 col, uint pixelIndex)
@@ -33,6 +34,18 @@ void PushSplat(float3 col, uint pixelIndex)
RWStructuredBuffer<SplatData> g_SplatBufferDst : register(u3);
void GetGlobalSlatDataOffset()
{
g_OutCounts.InterlockedAdd(8, s_GroupSplatCounter, s_GroupSplatGlobalStart);
}
void PushGlobalSplatData(uint threadID)
{
if (threadID < s_GroupSplatCounter)
g_SplatBufferDst[s_GroupSplatGlobalStart + threadID] = s_GroupSplats[threadID];
}
[numthreads(kCSRayBatchSize, 1, 1)]
void main(uint3 gid : SV_DispatchThreadID, uint3 tid : SV_GroupThreadID)
@@ -99,15 +112,10 @@ void main(uint3 gid : SV_DispatchThreadID, uint3 tid : SV_GroupThreadID)
g_OutCounts.InterlockedAdd(0, kCSRayBatchSize);
GetGlobalRayDataOffset(rayCount);
// append new splats into global buffer
uint splatBufferStart;
g_OutCounts.InterlockedAdd(8, s_GroupSplatCounter, splatBufferStart);
for (uint is = 0; is < s_GroupSplatCounter; ++is)
{
g_SplatBufferDst[splatBufferStart + is] = s_GroupSplats[is];
}
GetGlobalSlatDataOffset();
}
GroupMemoryBarrierWithGroupSync();
PushGlobalRayData(threadID, rayCount, kCSRayBatchSize);
PushGlobalSplatData(threadID);
}

0 comments on commit 9fcb42d

Please sign in to comment.