@@ -1403,7 +1403,7 @@ S_atomic = struct @align(4) {
14031403 ASSERT_EQ (expect, str ());
14041404}
14051405
1406- TEST_F (SpirvReader_AtomicsTest, DISABLED_AtomicExchange ) {
1406+ TEST_F (SpirvReader_AtomicsTest, AtomicExchange ) {
14071407 auto * f = b.ComputeFunction (" main" );
14081408
14091409 auto * sb = ty.Struct (mod.symbols .New (" S" ), {
@@ -1429,11 +1429,11 @@ TEST_F(SpirvReader_AtomicsTest, DISABLED_AtomicExchange) {
14291429
14301430 auto * a1 = b.Access (ty.ptr <storage, u32 , read_write>(), sg, 1_u);
14311431 b.Call <spirv::ir::BuiltinCall>(ty.u32 (), spirv::BuiltinFn::kAtomicExchange , a1, 1_u, 0_u,
1432- 1_u );
1432+ 2_u );
14331433 b.Call <spirv::ir::BuiltinCall>(ty.i32 (), spirv::BuiltinFn::kAtomicExchange , wg_i32, 1_u,
1434- 0_u, 1_i );
1434+ 0_u, 3_i );
14351435 b.Call <spirv::ir::BuiltinCall>(ty.u32 (), spirv::BuiltinFn::kAtomicExchange , wg_u32, 1_u,
1436- 0_u, 1_u );
1436+ 0_u, 4_u );
14371437 b.Return (f);
14381438 });
14391439
@@ -1454,9 +1454,9 @@ S = struct @align(4) {
14541454 %5:ptr<storage, i32, read_write> = access %sb, 0u
14551455 %6:i32 = spirv.atomic_exchange %5, 1u, 0u, 1i
14561456 %7:ptr<storage, u32, read_write> = access %sb, 1u
1457- %8:u32 = spirv.atomic_exchange %7, 1u, 0u, 1u
1458- %9:i32 = spirv.atomic_exchange %wg_i32, 1u, 0u, 1i
1459- %10:u32 = spirv.atomic_exchange %wg_u32, 1u, 0u, 1u
1457+ %8:u32 = spirv.atomic_exchange %7, 1u, 0u, 2u
1458+ %9:i32 = spirv.atomic_exchange %wg_i32, 1u, 0u, 3i
1459+ %10:u32 = spirv.atomic_exchange %wg_u32, 1u, 0u, 4u
14601460 ret
14611461 }
14621462}
@@ -1466,7 +1466,33 @@ S = struct @align(4) {
14661466 Run (Atomics);
14671467
14681468 auto * expect = R"(
1469- UNIMPLEMENTED
1469+ S = struct @align(4) {
1470+ a:i32 @offset(0)
1471+ b:u32 @offset(4)
1472+ }
1473+
1474+ S_atomic = struct @align(4) {
1475+ a:atomic<i32> @offset(0)
1476+ b:atomic<u32> @offset(4)
1477+ }
1478+
1479+ $B1: { # root
1480+ %sb:ptr<storage, S_atomic, read_write> = var undef @binding_point(0, 0)
1481+ %wg_i32:ptr<workgroup, atomic<i32>, read_write> = var undef
1482+ %wg_u32:ptr<workgroup, atomic<u32>, read_write> = var undef
1483+ }
1484+
1485+ %main = @compute @workgroup_size(1u, 1u, 1u) func():void {
1486+ $B2: {
1487+ %5:ptr<storage, atomic<i32>, read_write> = access %sb, 0u
1488+ %6:i32 = atomicExchange %5, 1i
1489+ %7:ptr<storage, atomic<u32>, read_write> = access %sb, 1u
1490+ %8:u32 = atomicExchange %7, 2u
1491+ %9:i32 = atomicExchange %wg_i32, 3i
1492+ %10:u32 = atomicExchange %wg_u32, 4u
1493+ ret
1494+ }
1495+ }
14701496)" ;
14711497 ASSERT_EQ (expect, str ());
14721498}
0 commit comments