Environment:
- OS: Ubuntu 24.04
- GPU and driver version: RTX 3090 , Driver: 595.84
- SDK or header version if building from repo: 1.4.350
- Options enabled (synchronization, best practices, etc.):
Describe the Issue
Shader:
groupshared uint s_min[3];
groupshared uint s_max[3];
[ForceInline]
uint float_to_sortable_uint(float val) {
uint temp = asuint(val);
uint mask = uint(-int(temp >> 31)) | 0x80000000;
return temp ^ mask;
}
[ForceInline]
float sortable_uint_to_float(uint val) {
uint mask = ((val >> 31) - 1) | 0x80000000;
return asfloat(val ^ mask);
}
[shader("compute")]
[numthreads(256, 1, 1)]
void compute_float3_minmax(float *points, uniform uint num_points,
uniform uint start_point_idx, uint *out_minmax,
uint gid: SV_DispatchThreadID,
uint tid: SV_GroupThreadID) {
const uint global_idx = start_point_idx + gid;
if (global_idx >= num_points)
return;
if (tid < 3) {
s_min[tid] = 0xFFFFFFFFu;
s_max[tid] = 0u;
}
GroupMemoryBarrierWithGroupSync();
for (int d = 0; d < 3; ++d) {
uint val = float_to_sortable_uint(points[global_idx * 3 + d]);
// Wave min/max
uint wave_min = WaveActiveMin(val);
uint wave_max = WaveActiveMax(val);
// Atomic min/max on shared memory
if (WaveIsFirstLane()) {
InterlockedMin(s_min[d], wave_min);
InterlockedMax(s_max[d], wave_max);
}
GroupMemoryBarrierWithGroupSync();
// Atomic min/max on global memory
if (tid == 0) {
InterlockedMin(out_minmax[d], s_min[d]);
InterlockedMax(out_minmax[3 + d], s_max[d]);
}
}
}
Throws a validation error:
Validation Error: [ SharedMemoryDataRace-RaceOnLoadStoreVsAtomic ] | MessageID = 0x7600531a
vkCmdDispatch(): A data race was detected on the shared memory variable "s_max" in local invocation index 0 while performing a load or store operation. (Likely against unknown invocation)
The other access in this race was at:
Shader validation error occurred at gpu/seed_morton_sort.slang:53:13
53: InterlockedMax(s_max[d], wave_max);
^
Stage = Compute. Global invocation ID (x, y, z) = (0, 0, 0)
Command buffer (0xc0)
Compute Dispatch Index 0
Shader Module (gpu/seed_morton_sort.spv)(0x55cc943a3cd0) (internal ID 22)
Shader validation error occurred at gpu/seed_morton_sort.slang:59:13
59: InterlockedMax(out_minmax[3 + d], s_max[d]);
^
Objects: 3
[0] VkQueue 0x55cc90229b30
[1] VkCommandBuffer 0x55cc906dcbb0[stream_0]
[2] VkPipeline 0x55cc93ba3ea0[compute_float3_minmax]
2026-07-30 12:56:04.566 [Error] (Vulkan) vkCmdDispatch(): A data race was detected on the shared memory variable "s_max" in local invocation index 0 while performing a load or store operation. (Likely against unknown invocation)
The other access in this race was at:
Shader validation error occurred at gpu/seed_morton_sort.slang:53:13
53: InterlockedMax(s_max[d], wave_max);
^
Stage = Compute. Global invocation ID (x, y, z) = (0, 0, 0)
Command buffer (0xc0)
Compute Dispatch Index 0
Shader Module (gpu/seed_morton_sort.spv)(0x55cc943a3cd0) (internal ID 22)
Shader validation error occurred at gpu/seed_morton_sort.slang:59:13
59: InterlockedMax(out_minmax[3 + d], s_max[d]);
^
But I can't see any data-race there. Could anyone explain? Is this validation error correct?
Expected behavior
No validation error...
Valid Usage ID
Additional context
Environment:
Describe the Issue
Shader:
Throws a validation error:
But I can't see any data-race there. Could anyone explain? Is this validation error correct?
Expected behavior
No validation error...
Valid Usage ID
Additional context