https://github.com/shader-slang/slang
Raw File
Tip revision: 7f11f883d0781952f002b3aa3222a3aa0040f18a authored by Yong He on 17 March 2023, 22:57:22 UTC
Add support for emitting cuda kernel and host functions. (#2712)
Tip revision: 7f11f88
atomics.slang
// atomics.slang

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out, name outputBuffer

RWStructuredBuffer<uint> outputBuffer;

void test(uint val)
{
    uint originalValue;

	InterlockedAdd(outputBuffer[val], 		val, 		originalValue);
	InterlockedAdd(outputBuffer[val ^ 1], 	val*16, 	originalValue);
	InterlockedAdd(outputBuffer[val ^ 2], 	val*16*16, 	originalValue);
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    uint tid = dispatchThreadID.x;
    test(tid);
}
back to top