hello partypeople,
i’m giving myself some exercises to learn hlsl. Yesterday I was thinking about a ConnectAll ComputeShader.
While the CPU approach is quite straight forward iterating…
FOutput.SliceCount = SpreadMax * (SpreadMax-1);
int k = 0;
for (int i = 0; i < SpreadMax; i++){
for(int j = 1 + i; j < SpreadMax; j++){
FOutput[k](k) = FInput[i](i);
k++;
FOutput[k](k) = FInput[j](j);
k++;
}
}
… I wonder how it is done when everything is threaded and gets calculated at the same time.
Is it even possible to access the other vertices that are running on the other threads? Thats the moment where the dog on the gpu bites his own tail I guess?
- include "particle_struct.fxh"
StructuredBuffer<particle> particles; // particle input
AppendStructuredBuffer<particle> Output : BACKBUFFER; // particle output
[numthreads(128,1,1)](numthreads(128,1,1))
void CSConnectAll(uint3 index : SV_DispatchThreadID)
{
uint size, stride;
particles.GetDimensions(size, stride);
//getting other particle positions and append them
Output.Append(particles[index.x](index.x));
}
technique10 Connect
{
pass P0
{
SetComputeShader( CompileShader( cs_5_0, CSConnectAll() ) );
}
}
(I’m trying this with particles, and yes, I’m aware that the result amount of particles would be n*(n-1) :-).)
But there are also some even more basic questions.
Maybe thats just not a task for the GPU?
Maybe it’s better to create the vertices (and lines) directly in GeometryShader?
And maybe its so simple that I just don’t see it…
Thanks for your help!
jungle!