mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-11 04:51:32 +11:00
33d7b25a92
This adds a prefix sum test. This patch is also trying to get a little more serious about structuring both the test runner (toward the goal of collecting proper statistics) and pipeline stages for the tests. Still WIP but giving good results.
44 lines
841 B
HLSL
44 lines
841 B
HLSL
static const uint3 gl_WorkGroupSize = uint3(1u, 1u, 1u);
|
|
|
|
RWByteAddressBuffer _53 : register(u1);
|
|
ByteAddressBuffer _59 : register(t0);
|
|
|
|
static uint3 gl_GlobalInvocationID;
|
|
struct SPIRV_Cross_Input
|
|
{
|
|
uint3 gl_GlobalInvocationID : SV_DispatchThreadID;
|
|
};
|
|
|
|
uint collatz_iterations(inout uint n)
|
|
{
|
|
uint i = 0u;
|
|
while (n != 1u)
|
|
{
|
|
if ((n % 2u) == 0u)
|
|
{
|
|
n /= 2u;
|
|
}
|
|
else
|
|
{
|
|
n = (3u * n) + 1u;
|
|
}
|
|
i++;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
void comp_main()
|
|
{
|
|
uint index = gl_GlobalInvocationID.x;
|
|
uint param = _59.Load(index * 4 + 0);
|
|
uint _65 = collatz_iterations(param);
|
|
_53.Store(index * 4 + 0, _65);
|
|
}
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void main(SPIRV_Cross_Input stage_input)
|
|
{
|
|
gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID;
|
|
comp_main();
|
|
}
|