Closed Ipotrick closed 2 months ago
InterlockedAdd
for 64bit types with images looks to only have a hlsl implementation:
[ForceInline]
void InterlockedAdd(__ref int64_t dest, int64_t value)
{
__target_switch
{
case hlsl: __intrinsic_asm "InterlockedAdd";
}
}
For now the glsl syntax variant of the operation should work as a workaround if only a spir-v/glsl target is needed: imageAtomicAdd
How would i use imageAtomicAdd in the example code i have above? I dont understand.
I believe the following should work: imageAtomicAdd(tex, ivec2(0,0), uint64_t(0));
slang does not recognize imageAromicAdd nor ivec2. Do i need to import a specific module for this to work?
the compiler flag -allow-glsl
should enable GLSL syntax to work along-side HLSL syntax
slang crashes when i try to use glsl syntax 😨
That is not the expected result.
[[vk::binding(0,0)]] RWTexture2D<uint64_t> tex[];
[shader("compute")]
[numthreads(1, 1, 1)]
void main()
{
imageAtomicAdd(tex[0], int2(0,0), uint64_t(0));
}
This is a repro for the crash. It does not happen when the images are not in an array. This does not cause a crash:
[[vk::binding(0,0)]] RWTexture2D<uint64_t> tex;
[shader("compute")]
[numthreads(1, 1, 1)]
void main()
{
imageAtomicAdd(tex, int2(0,0), uint64_t(0));
}
import glsl;
is another (preferred) way to use glsl flavored intrinsics. But we should look into the crash.
This probably should be broken into 2 issues: 1 for the crash 1 for merging glsl.meta<->hlsl.meta image atomic operations
I ll make another issue for the crash
I am currently porting some code to be slang from glsl for a vulkan renderer and need 64 bit image and 64 bit buffer atomics. When i try to use interlocked ops. Example:
i get the following error: