https://github.com/shader-slang/slang
Raw File
Tip revision: b40cd149c2038b0a429e46d60ddee5610e08b0ba authored by Yong He on 19 January 2022, 19:14:38 UTC
More fixes to GFX d3d12. (#2084)
Tip revision: b40cd14
wave-prefix-product.slang
//TEST_CATEGORY(wave, compute)
//DISABLE_TEST:COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 -shaderobj -render-feature hardware-device
//TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -render-feature hardware-device
//TEST:COMPARE_COMPUTE_EX:-cuda -compute -render-features cuda_sm_7_0 -shaderobj

//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;

[numthreads(8, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    int idx = int(dispatchThreadID.x);
    
    float2 v1 = float2(1, idx + 1);
  
    int r0 = WavePrefixProduct(idx + 1);
    float2 r1 = WavePrefixProduct(v1);
    
    int r2 = int(r1.x) + int(r1.y) - 1;
    
    outputBuffer[idx] = r0 + (r2 << 16);
    
}
back to top