yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1// if-early-exit.slang 2 3// Test active mask synthesis for an `if` where one side 4// unconditionally exits the current function/scope, 5// and thus cannot "re-converge" after the conditional. 6 7//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute 8//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute 9//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 10//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute 11//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -capability cuda_sm_7_0 12 13//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name buffer 14RWStructuredBuffer<int> buffer; 15 16#define THREAD_COUNT 4 17#define WRITE(IDX) buffer[IDX*THREAD_COUNT + tid] = WaveGetActiveMask() 18 19void test(int tid) 20{ 21 WRITE(0); 22 if((tid & 1) != 0) 23 { 24 WRITE(1); 25 return; 26 } 27 else 28 { 29 WRITE(2); 30 } 31 WRITE(3); 32} 33 34[numthreads(THREAD_COUNT, 1, 1)] 35void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 36{ 37 test(dispatchThreadID.x); 38}