diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 7ab9ea5f32..4cbb6ceb47 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -880,6 +880,10 @@ bool GeneratorImpl::EmitStorageAtomicCall( auto* offset = expr->params()[1]; auto call_buffer_method = [&](const char* name) { + // First two arguments to the DecomposeMemoryAccess::Intrinsic are the + // buffer and offset. The buffer is the moved to the LHS of the '.', and the + // offset becomes the first argument. The rest of the method's arguments are + // the same. auto pre = line(); if (!EmitExpression(pre, buffer)) { return false; @@ -891,7 +895,7 @@ bool GeneratorImpl::EmitStorageAtomicCall( return false; } - for (size_t i = 1; i < expr->params().size() - 1; i++) { + for (size_t i = 2; i < expr->params().size(); i++) { auto* arg = expr->params()[i]; pre << ", "; if (!EmitExpression(pre, arg)) { diff --git a/test/bug/tint/926.wgsl.expected.hlsl b/test/bug/tint/926.wgsl.expected.hlsl index 287e01d1f1..febfdb4bae 100644 --- a/test/bug/tint/926.wgsl.expected.hlsl +++ b/test/bug/tint/926.wgsl.expected.hlsl @@ -9,7 +9,7 @@ struct tint_symbol_1 { void computeMain(tint_symbol_1 tint_symbol) { const uint3 global_id = tint_symbol.global_id; uint atomic_result = 0u; - drawOut.InterlockedAdd(0u, 0u, atomic_result); + drawOut.InterlockedAdd(0u, cubeVerts, atomic_result); const uint firstVertex = atomic_result; return; } diff --git a/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.hlsl b/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.hlsl index b13b46649e..d8bcd226c6 100644 --- a/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicAdd_8a199a() { uint atomic_result = 0u; - sb_rw.InterlockedAdd(0u, 0u, atomic_result); + sb_rw.InterlockedAdd(0u, 1u, atomic_result); uint res = atomic_result; } diff --git a/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.hlsl b/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.hlsl index a578c6e3da..392d656a11 100644 --- a/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicAdd_d32fe4() { int atomic_result = 0; - sb_rw.InterlockedAdd(0u, 0u, atomic_result); + sb_rw.InterlockedAdd(0u, 1, atomic_result); int res = atomic_result; } diff --git a/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.hlsl b/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.hlsl index 819eaf2d5e..6080eba365 100644 --- a/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicAnd_152966() { int atomic_result = 0; - sb_rw.InterlockedAnd(0u, 0u, atomic_result); + sb_rw.InterlockedAnd(0u, 1, atomic_result); int res = atomic_result; } diff --git a/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.hlsl b/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.hlsl index 434f98dc3e..c0d64fcfeb 100644 --- a/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicAnd_85a8d9() { uint atomic_result = 0u; - sb_rw.InterlockedAnd(0u, 0u, atomic_result); + sb_rw.InterlockedAnd(0u, 1u, atomic_result); uint res = atomic_result; } diff --git a/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.hlsl b/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.hlsl index 736c4f539e..a54642c4fc 100644 --- a/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicExchange_d59712() { uint atomic_result = 0u; - sb_rw.InterlockedExchange(0u, 0u, atomic_result); + sb_rw.InterlockedExchange(0u, 1u, atomic_result); uint res = atomic_result; } diff --git a/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.hlsl b/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.hlsl index ce77930d99..e361c93d2c 100644 --- a/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicExchange_f2e22f() { int atomic_result = 0; - sb_rw.InterlockedExchange(0u, 0u, atomic_result); + sb_rw.InterlockedExchange(0u, 1, atomic_result); int res = atomic_result; } diff --git a/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.hlsl b/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.hlsl index fc4250bed2..41dae87995 100644 --- a/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicMax_51b9be() { uint atomic_result = 0u; - sb_rw.InterlockedMax(0u, 0u, atomic_result); + sb_rw.InterlockedMax(0u, 1u, atomic_result); uint res = atomic_result; } diff --git a/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.hlsl b/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.hlsl index d23b3802c3..e29705ede0 100644 --- a/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicMax_92aa72() { int atomic_result = 0; - sb_rw.InterlockedMax(0u, 0u, atomic_result); + sb_rw.InterlockedMax(0u, 1, atomic_result); int res = atomic_result; } diff --git a/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.hlsl b/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.hlsl index 304bc49a9c..ab52cbdbd9 100644 --- a/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicMin_8e38dc() { int atomic_result = 0; - sb_rw.InterlockedMin(0u, 0u, atomic_result); + sb_rw.InterlockedMin(0u, 1, atomic_result); int res = atomic_result; } diff --git a/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.hlsl b/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.hlsl index 104ecf1143..ac804d0daf 100644 --- a/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicMin_c67a74() { uint atomic_result = 0u; - sb_rw.InterlockedMin(0u, 0u, atomic_result); + sb_rw.InterlockedMin(0u, 1u, atomic_result); uint res = atomic_result; } diff --git a/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.hlsl b/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.hlsl index 315eee794f..63db7ef6c4 100644 --- a/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicOr_5e95d4() { uint atomic_result = 0u; - sb_rw.InterlockedOr(0u, 0u, atomic_result); + sb_rw.InterlockedOr(0u, 1u, atomic_result); uint res = atomic_result; } diff --git a/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.hlsl b/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.hlsl index 5b68897ebe..b5de43e201 100644 --- a/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicOr_8d96a0() { int atomic_result = 0; - sb_rw.InterlockedOr(0u, 0u, atomic_result); + sb_rw.InterlockedOr(0u, 1, atomic_result); int res = atomic_result; } diff --git a/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.hlsl b/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.hlsl index d81f8e551c..401a107f4f 100644 --- a/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicXor_54510e() { uint atomic_result = 0u; - sb_rw.InterlockedXor(0u, 0u, atomic_result); + sb_rw.InterlockedXor(0u, 1u, atomic_result); uint res = atomic_result; } diff --git a/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.hlsl b/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.hlsl index 660aaf1f0a..d10eeddd0a 100644 --- a/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.hlsl +++ b/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.hlsl @@ -2,7 +2,7 @@ RWByteAddressBuffer sb_rw : register(u0, space0); void atomicXor_c1b78c() { int atomic_result = 0; - sb_rw.InterlockedXor(0u, 0u, atomic_result); + sb_rw.InterlockedXor(0u, 1, atomic_result); int res = atomic_result; }