diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 8e3f82a8a4..5317cfbd63 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -22,6 +22,7 @@ #include "src/ast/fallthrough_statement.h" #include "src/ast/override_decoration.h" #include "src/sem/array.h" +#include "src/sem/atomic_type.h" #include "src/sem/call.h" #include "src/sem/depth_texture_type.h" #include "src/sem/function.h" @@ -2188,6 +2189,14 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call, return result_id; } + if (intrinsic->IsAtomic()) { + if (!GenerateAtomicIntrinsic(call, intrinsic, Operand::Int(result_type_id), + result)) { + return 0; + } + return result_id; + } + // Generates the SPIR-V ID for the expression for the indexed call parameter, // and loads it if necessary. Returns 0 on error. auto get_param_as_value_id = [&](size_t i) -> uint32_t { @@ -2915,6 +2924,236 @@ bool Builder::GenerateControlBarrierIntrinsic(const sem::Intrinsic* intrinsic) { }); } +bool Builder::GenerateAtomicIntrinsic(ast::CallExpression* call, + const sem::Intrinsic* intrinsic, + Operand result_type, + Operand result_id) { + auto is_value_signed = [&] { + return intrinsic->Parameters()[1].type->Is(); + }; + + auto storage_class = + intrinsic->Parameters()[0].type->As()->StorageClass(); + + uint32_t memory_id = 0; + switch (intrinsic->Parameters()[0].type->As()->StorageClass()) { + case ast::StorageClass::kWorkgroup: + memory_id = GenerateConstantIfNeeded( + ScalarConstant::U32(static_cast(spv::Scope::Workgroup))); + break; + case ast::StorageClass::kStorage: + memory_id = GenerateConstantIfNeeded( + ScalarConstant::U32(static_cast(spv::Scope::Device))); + break; + default: + TINT_UNREACHABLE(builder_.Diagnostics()) + << "unhandled atomic storage class " << storage_class; + return false; + } + if (memory_id == 0) { + return false; + } + + uint32_t semantics_id = GenerateConstantIfNeeded(ScalarConstant::U32( + static_cast(spv::MemorySemanticsMask::MaskNone))); + if (semantics_id == 0) { + return false; + } + + uint32_t pointer_id = GenerateExpression(call->params()[0]); + if (pointer_id == 0) { + return false; + } + + uint32_t value_id = 0; + if (call->params().size() > 1) { + value_id = GenerateExpression(call->params().back()); + if (value_id == 0) { + return false; + } + } + + Operand pointer = Operand::Int(pointer_id); + Operand value = Operand::Int(value_id); + Operand memory = Operand::Int(memory_id); + Operand semantics = Operand::Int(semantics_id); + + switch (intrinsic->Type()) { + case sem::IntrinsicType::kAtomicLoad: + return push_function_inst(spv::Op::OpAtomicLoad, { + result_type, + result_id, + pointer, + memory, + semantics, + }); + case sem::IntrinsicType::kAtomicStore: + return push_function_inst(spv::Op::OpAtomicStore, { + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicAdd: + return push_function_inst(spv::Op::OpAtomicIAdd, { + result_type, + result_id, + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicMax: + return push_function_inst( + is_value_signed() ? spv::Op::OpAtomicSMax : spv::Op::OpAtomicUMax, + { + result_type, + result_id, + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicMin: + return push_function_inst( + is_value_signed() ? spv::Op::OpAtomicSMin : spv::Op::OpAtomicUMin, + { + result_type, + result_id, + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicAnd: + return push_function_inst(spv::Op::OpAtomicAnd, { + result_type, + result_id, + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicOr: + return push_function_inst(spv::Op::OpAtomicOr, { + result_type, + result_id, + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicXor: + return push_function_inst(spv::Op::OpAtomicXor, { + result_type, + result_id, + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicExchange: + return push_function_inst(spv::Op::OpAtomicExchange, { + result_type, + result_id, + pointer, + memory, + semantics, + value, + }); + case sem::IntrinsicType::kAtomicCompareExchangeWeak: { + auto comparator = GenerateExpression(call->params()[1]); + if (comparator == 0) { + return false; + } + + auto* value_sem_type = TypeOf(call->params()[2]); + + auto value_type = GenerateTypeIfNeeded(value_sem_type); + if (value_type == 0) { + return false; + } + + sem::Bool bool_sem_type; + auto bool_type = GenerateTypeIfNeeded(&bool_sem_type); + if (bool_type == 0) { + return false; + } + + // original_value := OpAtomicCompareExchange(pointer, memory, semantics, + // semantics, value, comparator) + auto original_value = result_op(); + if (!push_function_inst(spv::Op::OpAtomicCompareExchange, + { + Operand::Int(value_type), + original_value, + pointer, + memory, + semantics, + semantics, + value, + Operand::Int(comparator), + })) { + return false; + } + + // values_equal := original_value == value + auto values_equal = result_op(); + if (!push_function_inst(spv::Op::OpIEqual, { + Operand::Int(bool_type), + values_equal, + original_value, + value, + })) { + return false; + } + + // zero := T(0) + // one := T(1) + uint32_t zero = 0; + uint32_t one = 0; + if (value_sem_type->Is()) { + zero = GenerateConstantIfNeeded(ScalarConstant::I32(0u)); + one = GenerateConstantIfNeeded(ScalarConstant::I32(1u)); + } else if (value_sem_type->Is()) { + zero = GenerateConstantIfNeeded(ScalarConstant::U32(0u)); + one = GenerateConstantIfNeeded(ScalarConstant::U32(1u)); + } else { + TINT_UNREACHABLE(builder_.Diagnostics()) + << "unsupported atomic type " << value_sem_type->TypeInfo().name; + } + if (zero == 0 || one == 0) { + return false; + } + + // xchg_success := values_equal ? one : zero + auto xchg_success = result_op(); + if (!push_function_inst(spv::Op::OpSelect, { + Operand::Int(value_type), + xchg_success, + values_equal, + Operand::Int(one), + Operand::Int(zero), + })) { + return false; + } + + // result := vec2(original_value, xchg_success) + return push_function_inst(spv::Op::OpCompositeConstruct, + { + result_type, + result_id, + original_value, + xchg_success, + }); + } + default: + TINT_UNREACHABLE(builder_.Diagnostics()) + << "unhandled atomic intrinsic " << intrinsic->Type(); + return false; + } +} + uint32_t Builder::GenerateSampledImage(const sem::Type* texture_type, Operand texture_operand, Operand sampler_operand) { @@ -3313,6 +3552,12 @@ uint32_t Builder::GenerateTypeIfNeeded(const sem::Type* type) { return 0; } + // Atomics are a type in WGSL, but aren't a distinct type in SPIR-V. + // Just emit the type inside the atomic. + if (auto* atomic = type->As()) { + return GenerateTypeIfNeeded(atomic->Type()); + } + // Pointers and references with differing accesses should not result in a // different SPIR-V types, so we explicitly ignore the access. // Pointers and References both map to a SPIR-V pointer type. diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h index c752ef4589..79932c33ea 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -365,10 +365,19 @@ class Builder { spirv::Operand result_type, spirv::Operand result_id); /// Generates a control barrier statement. - /// @param intrinsic the semantic information for the barrier intrinsic - /// parameters + /// @param intrinsic the semantic information for the barrier intrinsic call /// @returns true on success bool GenerateControlBarrierIntrinsic(const sem::Intrinsic* intrinsic); + /// Generates an atomic intrinsic call. + /// @param call the call expression + /// @param intrinsic the semantic information for the atomic intrinsic call + /// @param result_type result type operand of the texture instruction + /// @param result_id result identifier operand of the texture instruction + /// @returns true on success + bool GenerateAtomicIntrinsic(ast::CallExpression* call, + const sem::Intrinsic* intrinsic, + Operand result_type, + Operand result_id); /// Generates a sampled image /// @param texture_type the texture type /// @param texture_operand the texture operand diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc index 8bc1f10440..ae74a217ff 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -1572,7 +1572,7 @@ OpFunctionEnd // TODO(crbug.com/tint/806): Remove TEST_F(IntrinsicBuilderTest, Call_ArrayLength_DEPRECATED) { - auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}, + auto* s = Structure("my_struct", {Member("a", ty.array(4))}, {create()}); Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::DecorationList{ @@ -1620,7 +1620,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_DEPRECATED) { TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct_DEPRECATED) { auto* s = Structure("my_struct", { - Member(0, "z", ty.f32()), + Member("z", ty.f32()), Member(4, "a", ty.array(4)), }, {create()}); @@ -1667,7 +1667,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct_DEPRECATED) { } TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { - auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}, + auto* s = Structure("my_struct", {Member("a", ty.array(4))}, {create()}); Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::DecorationList{ @@ -1714,7 +1714,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { auto* s = Structure("my_struct", { - Member(0, "z", ty.f32()), + Member("z", ty.f32()), Member(4, "a", ty.array(4)), }, {create()}); @@ -1761,7 +1761,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { } TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets) { - auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}, + auto* s = Structure("my_struct", {Member("a", ty.array(4))}, {create()}); Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::DecorationList{ @@ -1810,9 +1810,10 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets) { } TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { - // struct my_struct { + // [[block]] struct my_struct { // a : [[stride(4)]] array; - // } + // }; + // [[binding(1), group(2)]] var b : my_struct; // // fn a_func() { // let p = &*&b; @@ -1820,7 +1821,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { // let p3 = &((*p).a); // arrayLength(&*p3); // } - auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}, + auto* s = Structure("my_struct", {Member("a", ty.array(4))}, {create()}); Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::DecorationList{ @@ -1870,6 +1871,427 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { Validate(b); } +TEST_F(IntrinsicBuilderTest, Call_AtomicLoad) { + // [[block]] struct S { + // u : atomic; + // i : atomic; + // } + // + // [[binding(1), group(2)]] var b : S; + // + // fn a_func() { + // let u : u32 = atomicLoad(&b.u); + // let i : i32 = atomicLoad(&b.i); + // } + auto* s = Structure("S", + { + Member("u", ty.atomic()), + Member("i", ty.atomic()), + }, + {create()}); + Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::DecorationList{ + create(1), + create(2), + }); + + Func("a_func", ast::VariableList{}, ty.void_(), + ast::StatementList{ + Decl(Const("u", ty.u32(), + Call("atomicLoad", AddressOf(MemberAccessor("b", "u"))))), + Decl(Const("i", ty.i32(), + Call("atomicLoad", AddressOf(MemberAccessor("b", "i"))))), + }, + ast::DecorationList{Stage(ast::PipelineStage::kFragment)}); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + + ASSERT_EQ(b.functions().size(), 1u); + + auto* expected_types = R"(%4 = OpTypeInt 32 0 +%5 = OpTypeInt 32 1 +%3 = OpTypeStruct %4 %5 +%2 = OpTypePointer StorageBuffer %3 +%1 = OpVariable %2 StorageBuffer +%7 = OpTypeVoid +%6 = OpTypeFunction %7 +%11 = OpConstant %4 1 +%12 = OpConstant %4 0 +%14 = OpTypePointer StorageBuffer %4 +%18 = OpTypePointer StorageBuffer %5 +)"; + auto got_types = DumpInstructions(b.types()); + EXPECT_EQ(expected_types, got_types); + + auto* expected_instructions = R"(%15 = OpAccessChain %14 %1 %12 +%10 = OpAtomicLoad %4 %15 %11 %12 +%19 = OpAccessChain %18 %1 %11 +%16 = OpAtomicLoad %5 %19 %11 %12 +)"; + auto got_instructions = DumpInstructions(b.functions()[0].instructions()); + EXPECT_EQ(expected_instructions, got_instructions); + + Validate(b); +} + +TEST_F(IntrinsicBuilderTest, Call_AtomicStore) { + // [[block]] struct S { + // u : atomic; + // i : atomic; + // } + // + // [[binding(1), group(2)]] var b : S; + // + // fn a_func() { + // let u : u32 = atomicStore(&b.u, 1u); + // let i : i32 = atomicStore(&b.i, 2); + // } + auto* s = Structure("S", + { + Member("u", ty.atomic()), + Member("i", ty.atomic()), + }, + {create()}); + Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::DecorationList{ + create(1), + create(2), + }); + + Func("a_func", ast::VariableList{}, ty.void_(), + ast::StatementList{ + create( + Call("atomicStore", AddressOf(MemberAccessor("b", "u")), 1u)), + create( + Call("atomicStore", AddressOf(MemberAccessor("b", "i")), 2)), + }, + ast::DecorationList{Stage(ast::PipelineStage::kFragment)}); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + + ASSERT_EQ(b.functions().size(), 1u); + + auto* expected_types = R"(%4 = OpTypeInt 32 0 +%5 = OpTypeInt 32 1 +%3 = OpTypeStruct %4 %5 +%2 = OpTypePointer StorageBuffer %3 +%1 = OpVariable %2 StorageBuffer +%7 = OpTypeVoid +%6 = OpTypeFunction %7 +%11 = OpConstant %4 1 +%12 = OpConstant %4 0 +%14 = OpTypePointer StorageBuffer %4 +%18 = OpTypePointer StorageBuffer %5 +%20 = OpConstant %5 2 +)"; + auto got_types = DumpInstructions(b.types()); + EXPECT_EQ(expected_types, got_types); + + auto* expected_instructions = R"(%15 = OpAccessChain %14 %1 %12 +OpAtomicStore %15 %11 %12 %11 +%19 = OpAccessChain %18 %1 %11 +OpAtomicStore %19 %11 %12 %20 +)"; + auto got_instructions = DumpInstructions(b.functions()[0].instructions()); + EXPECT_EQ(expected_instructions, got_instructions); + + Validate(b); +} + +using Intrinsic_Builtin_AtomicRMW_i32 = + IntrinsicBuilderTestWithParam; +TEST_P(Intrinsic_Builtin_AtomicRMW_i32, Test) { + // [[block]] struct S { + // v : atomic; + // } + // + // [[binding(1), group(2)]] var b : S; + // + // fn a_func() { + // let x : i32 = atomicOP(&b.v); + // } + auto* s = Structure("S", + { + Member("v", ty.atomic()), + }, + {create()}); + Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::DecorationList{ + create(1), + create(2), + }); + + Func("a_func", ast::VariableList{}, ty.void_(), + ast::StatementList{ + Decl(Const( + "x", ty.i32(), + Call(GetParam().name, AddressOf(MemberAccessor("b", "v")), 10))), + }, + ast::DecorationList{Stage(ast::PipelineStage::kFragment)}); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + + ASSERT_EQ(b.functions().size(), 1u); + + std::string expected_types = R"(%4 = OpTypeInt 32 1 +%3 = OpTypeStruct %4 +%2 = OpTypePointer StorageBuffer %3 +%1 = OpVariable %2 StorageBuffer +%6 = OpTypeVoid +%5 = OpTypeFunction %6 +%10 = OpTypeInt 32 0 +%11 = OpConstant %10 1 +%12 = OpConstant %10 0 +%14 = OpTypePointer StorageBuffer %4 +%16 = OpConstant %4 10 +)"; + auto got_types = DumpInstructions(b.types()); + EXPECT_EQ(expected_types, got_types); + + std::string expected_instructions = "%15 = OpAccessChain %14 %1 %12\n"; + expected_instructions += "%9 = " + GetParam().op + " %4 %15 %11 %12 %16\n"; + + auto got_instructions = DumpInstructions(b.functions()[0].instructions()); + EXPECT_EQ(expected_instructions, got_instructions); + + Validate(b); +} +INSTANTIATE_TEST_SUITE_P( + IntrinsicBuilderTest, + Intrinsic_Builtin_AtomicRMW_i32, + testing::Values(IntrinsicData{"atomicAdd", "OpAtomicIAdd"}, + IntrinsicData{"atomicMax", "OpAtomicSMax"}, + IntrinsicData{"atomicMin", "OpAtomicSMin"}, + IntrinsicData{"atomicAnd", "OpAtomicAnd"}, + IntrinsicData{"atomicOr", "OpAtomicOr"}, + IntrinsicData{"atomicXor", "OpAtomicXor"})); + +using Intrinsic_Builtin_AtomicRMW_u32 = + IntrinsicBuilderTestWithParam; +TEST_P(Intrinsic_Builtin_AtomicRMW_u32, Test) { + // [[block]] struct S { + // v : atomic; + // } + // + // [[binding(1), group(2)]] var b : S; + // + // fn a_func() { + // let x : u32 = atomicOP(&b.v); + // } + auto* s = Structure("S", + { + Member("v", ty.atomic()), + }, + {create()}); + Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::DecorationList{ + create(1), + create(2), + }); + + Func("a_func", ast::VariableList{}, ty.void_(), + ast::StatementList{ + Decl(Const("x", ty.u32(), + Call(GetParam().name, AddressOf(MemberAccessor("b", "v")), + 10u))), + }, + ast::DecorationList{Stage(ast::PipelineStage::kFragment)}); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + + ASSERT_EQ(b.functions().size(), 1u); + + std::string expected_types = R"(%4 = OpTypeInt 32 0 +%3 = OpTypeStruct %4 +%2 = OpTypePointer StorageBuffer %3 +%1 = OpVariable %2 StorageBuffer +%6 = OpTypeVoid +%5 = OpTypeFunction %6 +%10 = OpConstant %4 1 +%11 = OpConstant %4 0 +%13 = OpTypePointer StorageBuffer %4 +%15 = OpConstant %4 10 +)"; + auto got_types = DumpInstructions(b.types()); + EXPECT_EQ(expected_types, got_types); + + std::string expected_instructions = "%14 = OpAccessChain %13 %1 %11\n"; + expected_instructions += "%9 = " + GetParam().op + " %4 %14 %10 %11 %15\n"; + + auto got_instructions = DumpInstructions(b.functions()[0].instructions()); + EXPECT_EQ(expected_instructions, got_instructions); + + Validate(b); +} +INSTANTIATE_TEST_SUITE_P( + IntrinsicBuilderTest, + Intrinsic_Builtin_AtomicRMW_u32, + testing::Values(IntrinsicData{"atomicAdd", "OpAtomicIAdd"}, + IntrinsicData{"atomicMax", "OpAtomicUMax"}, + IntrinsicData{"atomicMin", "OpAtomicUMin"}, + IntrinsicData{"atomicAnd", "OpAtomicAnd"}, + IntrinsicData{"atomicOr", "OpAtomicOr"}, + IntrinsicData{"atomicXor", "OpAtomicXor"})); + +TEST_F(IntrinsicBuilderTest, Call_AtomicExchange) { + // [[block]] struct S { + // u : atomic; + // i : atomic; + // } + // + // [[binding(1), group(2)]] var b : S; + // + // fn a_func() { + // let u : u32 = atomicExchange(&b.u, 10u); + // let i : i32 = atomicExchange(&b.i, 10); + // } + auto* s = Structure("S", + { + Member("u", ty.atomic()), + Member("i", ty.atomic()), + }, + {create()}); + Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::DecorationList{ + create(1), + create(2), + }); + + Func("a_func", ast::VariableList{}, ty.void_(), + ast::StatementList{ + Decl(Const("u", ty.u32(), + Call("atomicExchange", + AddressOf(MemberAccessor("b", "u")), 10u))), + Decl(Const("i", ty.i32(), + Call("atomicExchange", + AddressOf(MemberAccessor("b", "i")), 10))), + }, + ast::DecorationList{Stage(ast::PipelineStage::kFragment)}); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + + ASSERT_EQ(b.functions().size(), 1u); + + auto* expected_types = R"(%4 = OpTypeInt 32 0 +%5 = OpTypeInt 32 1 +%3 = OpTypeStruct %4 %5 +%2 = OpTypePointer StorageBuffer %3 +%1 = OpVariable %2 StorageBuffer +%7 = OpTypeVoid +%6 = OpTypeFunction %7 +%11 = OpConstant %4 1 +%12 = OpConstant %4 0 +%14 = OpTypePointer StorageBuffer %4 +%16 = OpConstant %4 10 +%19 = OpTypePointer StorageBuffer %5 +%21 = OpConstant %5 10 +)"; + auto got_types = DumpInstructions(b.types()); + EXPECT_EQ(expected_types, got_types); + + auto* expected_instructions = R"(%15 = OpAccessChain %14 %1 %12 +%10 = OpAtomicExchange %4 %15 %11 %12 %16 +%20 = OpAccessChain %19 %1 %11 +%17 = OpAtomicExchange %5 %20 %11 %12 %21 +)"; + auto got_instructions = DumpInstructions(b.functions()[0].instructions()); + EXPECT_EQ(expected_instructions, got_instructions); + + Validate(b); +} + +TEST_F(IntrinsicBuilderTest, Call_AtomicCompareExchangeWeak) { + // [[block]] struct S { + // u : atomic; + // i : atomic; + // } + // + // [[binding(1), group(2)]] var b : S; + // + // fn a_func() { + // let u : vec2 = atomicCompareExchangeWeak(&b.u, 10u); + // let i : vec2 = atomicCompareExchangeWeak(&b.i, 10); + // } + auto* s = Structure("S", + { + Member("u", ty.atomic()), + Member("i", ty.atomic()), + }, + {create()}); + Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::DecorationList{ + create(1), + create(2), + }); + + Func("a_func", ast::VariableList{}, ty.void_(), + ast::StatementList{ + Decl(Const("u", ty.vec2(), + Call("atomicCompareExchangeWeak", + AddressOf(MemberAccessor("b", "u")), 10u, 20u))), + Decl(Const("i", ty.vec2(), + Call("atomicCompareExchangeWeak", + AddressOf(MemberAccessor("b", "i")), 10, 20))), + }, + ast::DecorationList{Stage(ast::PipelineStage::kFragment)}); + + spirv::Builder& b = Build(); + + ASSERT_TRUE(b.Build()) << b.error(); + + ASSERT_EQ(b.functions().size(), 1u); + + auto* expected_types = R"(%4 = OpTypeInt 32 0 +%5 = OpTypeInt 32 1 +%3 = OpTypeStruct %4 %5 +%2 = OpTypePointer StorageBuffer %3 +%1 = OpVariable %2 StorageBuffer +%7 = OpTypeVoid +%6 = OpTypeFunction %7 +%11 = OpTypeVector %4 2 +%12 = OpConstant %4 1 +%13 = OpConstant %4 0 +%15 = OpTypePointer StorageBuffer %4 +%17 = OpConstant %4 20 +%18 = OpConstant %4 10 +%19 = OpTypeBool +%24 = OpTypeVector %5 2 +%26 = OpTypePointer StorageBuffer %5 +%28 = OpConstant %5 20 +%29 = OpConstant %5 10 +%32 = OpConstant %5 0 +%33 = OpConstant %5 1 +)"; + auto got_types = DumpInstructions(b.types()); + EXPECT_EQ(expected_types, got_types); + + auto* expected_instructions = R"(%16 = OpAccessChain %15 %1 %13 +%20 = OpAtomicCompareExchange %4 %16 %12 %13 %13 %17 %18 +%21 = OpIEqual %19 %20 %17 +%22 = OpSelect %4 %21 %12 %13 +%10 = OpCompositeConstruct %11 %20 %22 +%27 = OpAccessChain %26 %1 %12 +%30 = OpAtomicCompareExchange %5 %27 %12 %13 %13 %28 %29 +%31 = OpIEqual %19 %30 %28 +%34 = OpSelect %5 %31 %33 %32 +%23 = OpCompositeConstruct %24 %30 %34 +)"; + auto got_instructions = DumpInstructions(b.functions()[0].instructions()); + EXPECT_EQ(expected_instructions, got_instructions); + + Validate(b); +} + using Intrinsic_Builtin_DataPacking_Test = IntrinsicBuilderTestWithParam; TEST_P(Intrinsic_Builtin_DataPacking_Test, Binary) { diff --git a/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.spvasm index 03bf81e6be..e2b9026b7d 100644 --- a/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.spvasm @@ -1,15 +1,36 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicAdd_794055() { - var res : i32 = atomicAdd(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicAdd_794055(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicAdd_794055 "atomicAdd_794055" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %16 = OpConstantNull %int +%atomicAdd_794055 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %16 + %8 = OpAtomicIAdd %int %arg_0 %uint_2 %uint_0 %int_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicAdd_794055 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.spvasm index 0aef1b3487..399663595f 100644 --- a/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAdd/8a199a.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicAdd_8a199a() { - var res : u32 = atomicAdd(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicAdd_8a199a(); -} - -[[stage(compute)]] -fn compute_main() { - atomicAdd_8a199a(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicAdd_8a199a "atomicAdd_8a199a" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicAdd_8a199a = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicIAdd %uint %14 %uint_1 %uint_0 %uint_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicAdd_8a199a + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicAdd_8a199a + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.spvasm index 9240e6e475..11672382dd 100644 --- a/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAdd/d32fe4.wgsl.expected.spvasm @@ -1,25 +1,53 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicAdd_d32fe4() { - var res : i32 = atomicAdd(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicAdd_d32fe4(); -} - -[[stage(compute)]] -fn compute_main() { - atomicAdd_d32fe4(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicAdd_d32fe4 "atomicAdd_d32fe4" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %19 = OpConstantNull %int +%atomicAdd_d32fe4 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %19 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicIAdd %int %15 %uint_1 %uint_0 %int_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicAdd_d32fe4 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicAdd_d32fe4 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.spvasm index e5ca410e73..33ae4883d8 100644 --- a/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicAdd_d5db1d() { - var res : u32 = atomicAdd(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicAdd_d5db1d(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicAdd_d5db1d "atomicAdd_d5db1d" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%_ptr_Function_uint = OpTypePointer Function %uint + %15 = OpConstantNull %uint +%atomicAdd_d5db1d = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %15 + %8 = OpAtomicIAdd %uint %arg_0 %uint_2 %uint_0 %uint_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicAdd_d5db1d + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.spvasm index ab01640088..ee4f5dc18f 100644 --- a/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAnd/152966.wgsl.expected.spvasm @@ -1,25 +1,53 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicAnd_152966() { - var res : i32 = atomicAnd(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicAnd_152966(); -} - -[[stage(compute)]] -fn compute_main() { - atomicAnd_152966(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicAnd_152966 "atomicAnd_152966" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %19 = OpConstantNull %int +%atomicAnd_152966 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %19 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicAnd %int %15 %uint_1 %uint_0 %int_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicAnd_152966 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicAnd_152966 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.spvasm index d123701d2f..9ddb9cdc1f 100644 --- a/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicAnd_34edd3() { - var res : u32 = atomicAnd(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicAnd_34edd3(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicAnd_34edd3 "atomicAnd_34edd3" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%_ptr_Function_uint = OpTypePointer Function %uint + %15 = OpConstantNull %uint +%atomicAnd_34edd3 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %15 + %8 = OpAtomicAnd %uint %arg_0 %uint_2 %uint_0 %uint_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicAnd_34edd3 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.spvasm index e163a7fa4c..5f56565b58 100644 --- a/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.spvasm @@ -1,15 +1,36 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicAnd_45a819() { - var res : i32 = atomicAnd(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicAnd_45a819(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicAnd_45a819 "atomicAnd_45a819" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %16 = OpConstantNull %int +%atomicAnd_45a819 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %16 + %8 = OpAtomicAnd %int %arg_0 %uint_2 %uint_0 %int_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicAnd_45a819 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.spvasm b/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.spvasm index db2169636b..e45402c051 100644 --- a/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicAnd/85a8d9.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicAnd_85a8d9() { - var res : u32 = atomicAnd(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicAnd_85a8d9(); -} - -[[stage(compute)]] -fn compute_main() { - atomicAnd_85a8d9(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicAnd_85a8d9 "atomicAnd_85a8d9" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicAnd_85a8d9 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicAnd %uint %14 %uint_1 %uint_0 %uint_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicAnd_85a8d9 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicAnd_85a8d9 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicCompareExchangeWeak/12871c.wgsl.expected.spvasm b/test/intrinsics/gen/atomicCompareExchangeWeak/12871c.wgsl.expected.spvasm index 420060e8d6..f4b46af60c 100644 --- a/test/intrinsics/gen/atomicCompareExchangeWeak/12871c.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicCompareExchangeWeak/12871c.wgsl.expected.spvasm @@ -1,25 +1,59 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicCompareExchangeWeak_12871c() { - var res : vec2 = atomicCompareExchangeWeak(&(sb_rw.arg_0), 1, 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicCompareExchangeWeak_12871c(); -} - -[[stage(compute)]] -fn compute_main() { - atomicCompareExchangeWeak_12871c(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicCompareExchangeWeak_12871c "atomicCompareExchangeWeak_12871c" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %v2int = OpTypeVector %int 2 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 + %bool = OpTypeBool + %int_0 = OpConstant %int 0 +%_ptr_Function_v2int = OpTypePointer Function %v2int + %25 = OpConstantNull %v2int +%atomicCompareExchangeWeak_12871c = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_v2int Function %25 + %16 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %19 = OpAtomicCompareExchange %int %16 %uint_1 %uint_0 %uint_0 %int_1 %int_1 + %20 = OpIEqual %bool %19 %int_1 + %22 = OpSelect %int %20 %int_1 %int_0 + %9 = OpCompositeConstruct %v2int %19 %22 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %27 = OpLabel + %28 = OpFunctionCall %void %atomicCompareExchangeWeak_12871c + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %30 = OpLabel + %31 = OpFunctionCall %void %atomicCompareExchangeWeak_12871c + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicCompareExchangeWeak/6673da.wgsl.expected.spvasm b/test/intrinsics/gen/atomicCompareExchangeWeak/6673da.wgsl.expected.spvasm index d0a4f3a926..7edaed7b1f 100644 --- a/test/intrinsics/gen/atomicCompareExchangeWeak/6673da.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicCompareExchangeWeak/6673da.wgsl.expected.spvasm @@ -1,25 +1,56 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicCompareExchangeWeak_6673da() { - var res : vec2 = atomicCompareExchangeWeak(&(sb_rw.arg_0), 1u, 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicCompareExchangeWeak_6673da(); -} - -[[stage(compute)]] -fn compute_main() { - atomicCompareExchangeWeak_6673da(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 29 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicCompareExchangeWeak_6673da "atomicCompareExchangeWeak_6673da" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %v2uint = OpTypeVector %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %22 = OpConstantNull %v2uint +%atomicCompareExchangeWeak_6673da = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_v2uint Function %22 + %15 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %17 = OpAtomicCompareExchange %uint %15 %uint_1 %uint_0 %uint_0 %uint_1 %uint_1 + %18 = OpIEqual %bool %17 %uint_1 + %19 = OpSelect %uint %18 %uint_1 %uint_0 + %9 = OpCompositeConstruct %v2uint %17 %19 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicCompareExchangeWeak_6673da + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %27 = OpLabel + %28 = OpFunctionCall %void %atomicCompareExchangeWeak_6673da + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.spvasm b/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.spvasm index 04788e8d02..537dbb6aba 100644 --- a/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.spvasm @@ -1,15 +1,42 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicCompareExchangeWeak_89ea3b() { - var res : vec2 = atomicCompareExchangeWeak(&(arg_0), 1, 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicCompareExchangeWeak_89ea3b(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicCompareExchangeWeak_89ea3b "atomicCompareExchangeWeak_89ea3b" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %v2int = OpTypeVector %int 2 + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 + %bool = OpTypeBool + %int_0 = OpConstant %int 0 +%_ptr_Function_v2int = OpTypePointer Function %v2int + %22 = OpConstantNull %v2int +%atomicCompareExchangeWeak_89ea3b = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_v2int Function %22 + %16 = OpAtomicCompareExchange %int %arg_0 %uint_2 %uint_0 %uint_0 %int_1 %int_1 + %17 = OpIEqual %bool %16 %int_1 + %19 = OpSelect %int %17 %int_1 %int_0 + %8 = OpCompositeConstruct %v2int %16 %19 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicCompareExchangeWeak_89ea3b + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.spvasm b/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.spvasm index 819ff506c0..9492ec65e6 100644 --- a/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.spvasm @@ -1,15 +1,40 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicCompareExchangeWeak_b2ab2c() { - var res : vec2 = atomicCompareExchangeWeak(&(arg_0), 1u, 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicCompareExchangeWeak_b2ab2c(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicCompareExchangeWeak_b2ab2c "atomicCompareExchangeWeak_b2ab2c" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %v2uint = OpTypeVector %uint 2 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %bool = OpTypeBool +%_ptr_Function_v2uint = OpTypePointer Function %v2uint + %20 = OpConstantNull %v2uint +%atomicCompareExchangeWeak_b2ab2c = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_v2uint Function %20 + %15 = OpAtomicCompareExchange %uint %arg_0 %uint_2 %uint_0 %uint_0 %uint_1 %uint_1 + %16 = OpIEqual %bool %15 %uint_1 + %17 = OpSelect %uint %16 %uint_1 %uint_0 + %8 = OpCompositeConstruct %v2uint %15 %17 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicCompareExchangeWeak_b2ab2c + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.spvasm b/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.spvasm index 828611fb4e..680a4a879a 100644 --- a/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicExchange_0a5dca() { - var res : u32 = atomicExchange(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicExchange_0a5dca(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicExchange_0a5dca "atomicExchange_0a5dca" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%_ptr_Function_uint = OpTypePointer Function %uint + %15 = OpConstantNull %uint +%atomicExchange_0a5dca = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %15 + %8 = OpAtomicExchange %uint %arg_0 %uint_2 %uint_0 %uint_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicExchange_0a5dca + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.spvasm b/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.spvasm index f320864c38..bdd9e1de57 100644 --- a/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicExchange/d59712.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicExchange_d59712() { - var res : u32 = atomicExchange(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicExchange_d59712(); -} - -[[stage(compute)]] -fn compute_main() { - atomicExchange_d59712(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicExchange_d59712 "atomicExchange_d59712" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicExchange_d59712 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicExchange %uint %14 %uint_1 %uint_0 %uint_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicExchange_d59712 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicExchange_d59712 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.spvasm b/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.spvasm index 5107f95e6f..9232da2002 100644 --- a/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.spvasm @@ -1,15 +1,36 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicExchange_e114ba() { - var res : i32 = atomicExchange(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicExchange_e114ba(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicExchange_e114ba "atomicExchange_e114ba" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %16 = OpConstantNull %int +%atomicExchange_e114ba = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %16 + %8 = OpAtomicExchange %int %arg_0 %uint_2 %uint_0 %int_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicExchange_e114ba + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.spvasm b/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.spvasm index 2819c2943c..c4f71e9285 100644 --- a/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicExchange/f2e22f.wgsl.expected.spvasm @@ -1,25 +1,53 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicExchange_f2e22f() { - var res : i32 = atomicExchange(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicExchange_f2e22f(); -} - -[[stage(compute)]] -fn compute_main() { - atomicExchange_f2e22f(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicExchange_f2e22f "atomicExchange_f2e22f" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %19 = OpConstantNull %int +%atomicExchange_f2e22f = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %19 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicExchange %int %15 %uint_1 %uint_0 %int_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicExchange_f2e22f + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicExchange_f2e22f + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicLoad/0806ad.wgsl.expected.spvasm b/test/intrinsics/gen/atomicLoad/0806ad.wgsl.expected.spvasm index acf39ec161..d961ea5c86 100644 --- a/test/intrinsics/gen/atomicLoad/0806ad.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicLoad/0806ad.wgsl.expected.spvasm @@ -1,25 +1,52 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicLoad_0806ad() { - var res : i32 = atomicLoad(&(sb_rw.arg_0)); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicLoad_0806ad(); -} - -[[stage(compute)]] -fn compute_main() { - atomicLoad_0806ad(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 25 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicLoad_0806ad "atomicLoad_0806ad" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int +%_ptr_Function_int = OpTypePointer Function %int + %18 = OpConstantNull %int +%atomicLoad_0806ad = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %18 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicLoad %int %15 %uint_1 %uint_0 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %20 = OpLabel + %21 = OpFunctionCall %void %atomicLoad_0806ad + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %23 = OpLabel + %24 = OpFunctionCall %void %atomicLoad_0806ad + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.spvasm b/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.spvasm index f524442f9a..583063ae2e 100644 --- a/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.spvasm @@ -1,15 +1,34 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicLoad_361bf1() { - var res : u32 = atomicLoad(&(arg_0)); -} - -[[stage(compute)]] -fn compute_main() { - atomicLoad_361bf1(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 18 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicLoad_361bf1 "atomicLoad_361bf1" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_uint = OpTypePointer Function %uint + %14 = OpConstantNull %uint +%atomicLoad_361bf1 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %14 + %8 = OpAtomicLoad %uint %arg_0 %uint_2 %uint_0 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %16 = OpLabel + %17 = OpFunctionCall %void %atomicLoad_361bf1 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.spvasm b/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.spvasm index b41da50a18..1b599d0966 100644 --- a/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicLoad_afcc03() { - var res : i32 = atomicLoad(&(arg_0)); -} - -[[stage(compute)]] -fn compute_main() { - atomicLoad_afcc03(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicLoad_afcc03 "atomicLoad_afcc03" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_int = OpTypePointer Function %int + %15 = OpConstantNull %int +%atomicLoad_afcc03 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %15 + %8 = OpAtomicLoad %int %arg_0 %uint_2 %uint_0 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicLoad_afcc03 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicLoad/fe6cc3.wgsl.expected.spvasm b/test/intrinsics/gen/atomicLoad/fe6cc3.wgsl.expected.spvasm index 623a8ad5de..776c62c09f 100644 --- a/test/intrinsics/gen/atomicLoad/fe6cc3.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicLoad/fe6cc3.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicLoad_fe6cc3() { - var res : u32 = atomicLoad(&(sb_rw.arg_0)); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicLoad_fe6cc3(); -} - -[[stage(compute)]] -fn compute_main() { - atomicLoad_fe6cc3(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicLoad_fe6cc3 "atomicLoad_fe6cc3" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicLoad_fe6cc3 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicLoad %uint %14 %uint_1 %uint_0 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicLoad_fe6cc3 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicLoad_fe6cc3 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.spvasm index c5f1a7804a..7fb135e806 100644 --- a/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMax/51b9be.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicMax_51b9be() { - var res : u32 = atomicMax(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicMax_51b9be(); -} - -[[stage(compute)]] -fn compute_main() { - atomicMax_51b9be(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicMax_51b9be "atomicMax_51b9be" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicMax_51b9be = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicUMax %uint %14 %uint_1 %uint_0 %uint_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicMax_51b9be + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicMax_51b9be + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.spvasm index f1c5712c1f..82be997072 100644 --- a/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMax/92aa72.wgsl.expected.spvasm @@ -1,25 +1,53 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicMax_92aa72() { - var res : i32 = atomicMax(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicMax_92aa72(); -} - -[[stage(compute)]] -fn compute_main() { - atomicMax_92aa72(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicMax_92aa72 "atomicMax_92aa72" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %19 = OpConstantNull %int +%atomicMax_92aa72 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %19 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicSMax %int %15 %uint_1 %uint_0 %int_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicMax_92aa72 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicMax_92aa72 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.spvasm index ac851993b0..810c250c3e 100644 --- a/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.spvasm @@ -1,15 +1,36 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicMax_a89cc3() { - var res : i32 = atomicMax(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicMax_a89cc3(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicMax_a89cc3 "atomicMax_a89cc3" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %16 = OpConstantNull %int +%atomicMax_a89cc3 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %16 + %8 = OpAtomicSMax %int %arg_0 %uint_2 %uint_0 %int_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicMax_a89cc3 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.spvasm index 031d7ef1ce..a2dce6b3cd 100644 --- a/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicMax_beccfc() { - var res : u32 = atomicMax(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicMax_beccfc(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicMax_beccfc "atomicMax_beccfc" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%_ptr_Function_uint = OpTypePointer Function %uint + %15 = OpConstantNull %uint +%atomicMax_beccfc = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %15 + %8 = OpAtomicUMax %uint %arg_0 %uint_2 %uint_0 %uint_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicMax_beccfc + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMin/278235.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMin/278235.wgsl.expected.spvasm index 4e939fd60a..3eaaf73083 100644 --- a/test/intrinsics/gen/atomicMin/278235.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMin/278235.wgsl.expected.spvasm @@ -1,15 +1,36 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicMin_278235() { - var res : i32 = atomicMin(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicMin_278235(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicMin_278235 "atomicMin_278235" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %16 = OpConstantNull %int +%atomicMin_278235 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %16 + %8 = OpAtomicSMin %int %arg_0 %uint_2 %uint_0 %int_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicMin_278235 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.spvasm index dfce4dd80b..590c53253b 100644 --- a/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicMin_69d383() { - var res : u32 = atomicMin(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicMin_69d383(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicMin_69d383 "atomicMin_69d383" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%_ptr_Function_uint = OpTypePointer Function %uint + %15 = OpConstantNull %uint +%atomicMin_69d383 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %15 + %8 = OpAtomicUMin %uint %arg_0 %uint_2 %uint_0 %uint_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicMin_69d383 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.spvasm index 40fc25c731..660547b5d5 100644 --- a/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMin/8e38dc.wgsl.expected.spvasm @@ -1,25 +1,53 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicMin_8e38dc() { - var res : i32 = atomicMin(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicMin_8e38dc(); -} - -[[stage(compute)]] -fn compute_main() { - atomicMin_8e38dc(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicMin_8e38dc "atomicMin_8e38dc" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %19 = OpConstantNull %int +%atomicMin_8e38dc = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %19 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicSMin %int %15 %uint_1 %uint_0 %int_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicMin_8e38dc + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicMin_8e38dc + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.spvasm b/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.spvasm index cafcb6e14e..0ed9315fd9 100644 --- a/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicMin/c67a74.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicMin_c67a74() { - var res : u32 = atomicMin(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicMin_c67a74(); -} - -[[stage(compute)]] -fn compute_main() { - atomicMin_c67a74(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicMin_c67a74 "atomicMin_c67a74" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicMin_c67a74 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicUMin %uint %14 %uint_1 %uint_0 %uint_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicMin_c67a74 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicMin_c67a74 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.spvasm b/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.spvasm index 1a6828ab60..4376949538 100644 --- a/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicOr_5e3d61() { - var res : u32 = atomicOr(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicOr_5e3d61(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicOr_5e3d61 "atomicOr_5e3d61" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%_ptr_Function_uint = OpTypePointer Function %uint + %15 = OpConstantNull %uint +%atomicOr_5e3d61 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %15 + %8 = OpAtomicOr %uint %arg_0 %uint_2 %uint_0 %uint_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicOr_5e3d61 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.spvasm b/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.spvasm index c95c957b07..4778bc871a 100644 --- a/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicOr/5e95d4.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicOr_5e95d4() { - var res : u32 = atomicOr(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicOr_5e95d4(); -} - -[[stage(compute)]] -fn compute_main() { - atomicOr_5e95d4(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicOr_5e95d4 "atomicOr_5e95d4" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicOr_5e95d4 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicOr %uint %14 %uint_1 %uint_0 %uint_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicOr_5e95d4 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicOr_5e95d4 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.spvasm b/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.spvasm index febe758806..1bf00f2122 100644 --- a/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicOr/8d96a0.wgsl.expected.spvasm @@ -1,25 +1,53 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicOr_8d96a0() { - var res : i32 = atomicOr(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicOr_8d96a0(); -} - -[[stage(compute)]] -fn compute_main() { - atomicOr_8d96a0(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicOr_8d96a0 "atomicOr_8d96a0" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %19 = OpConstantNull %int +%atomicOr_8d96a0 = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %19 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicOr %int %15 %uint_1 %uint_0 %int_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicOr_8d96a0 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicOr_8d96a0 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.spvasm b/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.spvasm index 2022c38028..46fbd2b16e 100644 --- a/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.spvasm @@ -1,15 +1,36 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicOr_d09248() { - var res : i32 = atomicOr(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicOr_d09248(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicOr_d09248 "atomicOr_d09248" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %16 = OpConstantNull %int +%atomicOr_d09248 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %16 + %8 = OpAtomicOr %int %arg_0 %uint_2 %uint_0 %int_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicOr_d09248 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicStore/726882.wgsl.expected.spvasm b/test/intrinsics/gen/atomicStore/726882.wgsl.expected.spvasm index 67d3a77bbc..58aa6c6e8b 100644 --- a/test/intrinsics/gen/atomicStore/726882.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicStore/726882.wgsl.expected.spvasm @@ -1,15 +1,30 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicStore_726882() { - atomicStore(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicStore_726882(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 16 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicStore_726882 "atomicStore_726882" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%atomicStore_726882 = OpFunction %void None %4 + %7 = OpLabel + OpAtomicStore %arg_0 %uint_2 %uint_0 %uint_1 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %14 = OpLabel + %15 = OpFunctionCall %void %atomicStore_726882 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.spvasm b/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.spvasm index a97e60e97c..c8a60c0c2c 100644 --- a/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.spvasm @@ -1,15 +1,31 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicStore_8bea94() { - atomicStore(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicStore_8bea94(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 17 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicStore_8bea94 "atomicStore_8bea94" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%atomicStore_8bea94 = OpFunction %void None %4 + %7 = OpLabel + OpAtomicStore %arg_0 %uint_2 %uint_0 %int_1 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %15 = OpLabel + %16 = OpFunctionCall %void %atomicStore_8bea94 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicStore/cdc29e.wgsl.expected.spvasm b/test/intrinsics/gen/atomicStore/cdc29e.wgsl.expected.spvasm index 2fdd3d29f4..97adea0c19 100644 --- a/test/intrinsics/gen/atomicStore/cdc29e.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicStore/cdc29e.wgsl.expected.spvasm @@ -1,25 +1,46 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicStore_cdc29e() { - atomicStore(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicStore_cdc29e(); -} - -[[stage(compute)]] -fn compute_main() { - atomicStore_cdc29e(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicStore_cdc29e "atomicStore_cdc29e" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%atomicStore_cdc29e = OpFunction %void None %5 + %8 = OpLabel + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + OpAtomicStore %14 %uint_1 %uint_0 %uint_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %16 = OpLabel + %17 = OpFunctionCall %void %atomicStore_cdc29e + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicStore_cdc29e + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicStore/d1e9a6.wgsl.expected.spvasm b/test/intrinsics/gen/atomicStore/d1e9a6.wgsl.expected.spvasm index 21df960d6c..a4714333c3 100644 --- a/test/intrinsics/gen/atomicStore/d1e9a6.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicStore/d1e9a6.wgsl.expected.spvasm @@ -1,25 +1,48 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicStore_d1e9a6() { - atomicStore(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicStore_d1e9a6(); -} - -[[stage(compute)]] -fn compute_main() { - atomicStore_d1e9a6(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicStore_d1e9a6 "atomicStore_d1e9a6" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%atomicStore_d1e9a6 = OpFunction %void None %5 + %8 = OpLabel + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + OpAtomicStore %15 %uint_1 %uint_0 %int_1 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicStore_d1e9a6 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicStore_d1e9a6 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.spvasm b/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.spvasm index 7b2d9ec858..8b4ef2178f 100644 --- a/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicXor/54510e.wgsl.expected.spvasm @@ -1,25 +1,51 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicXor_54510e() { - var res : u32 = atomicXor(&(sb_rw.arg_0), 1u); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicXor_54510e(); -} - -[[stage(compute)]] -fn compute_main() { - atomicXor_54510e(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicXor_54510e "atomicXor_54510e" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %uint = OpTypeInt 32 0 + %SB_RW = OpTypeStruct %uint +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %17 = OpConstantNull %uint +%atomicXor_54510e = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %17 + %14 = OpAccessChain %_ptr_StorageBuffer_uint %sb_rw %uint_0 + %9 = OpAtomicXor %uint %14 %uint_1 %uint_0 %uint_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %19 = OpLabel + %20 = OpFunctionCall %void %atomicXor_54510e + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %22 = OpLabel + %23 = OpFunctionCall %void %atomicXor_54510e + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.spvasm b/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.spvasm index 1e57ceefd3..110db2b13e 100644 --- a/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.spvasm @@ -1,15 +1,36 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicXor_75dc95() { - var res : i32 = atomicXor(&(arg_0), 1); -} - -[[stage(compute)]] -fn compute_main() { - atomicXor_75dc95(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicXor_75dc95 "atomicXor_75dc95" + OpName %res "res" + OpName %compute_main "compute_main" + %int = OpTypeInt 32 1 +%_ptr_Workgroup_int = OpTypePointer Workgroup %int + %arg_0 = OpVariable %_ptr_Workgroup_int Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %16 = OpConstantNull %int +%atomicXor_75dc95 = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_int Function %16 + %8 = OpAtomicXor %int %arg_0 %uint_2 %uint_0 %int_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %18 = OpLabel + %19 = OpFunctionCall %void %atomicXor_75dc95 + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.spvasm b/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.spvasm index 3e68a72363..98ac9c2b98 100644 --- a/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicXor/c1b78c.wgsl.expected.spvasm @@ -1,25 +1,53 @@ -SKIP: FAILED - - -[[block]] -struct SB_RW { - arg_0 : atomic; -}; - -[[group(0), binding(0)]] var sb_rw : SB_RW; - -fn atomicXor_c1b78c() { - var res : i32 = atomicXor(&(sb_rw.arg_0), 1); -} - -[[stage(fragment)]] -fn fragment_main() { - atomicXor_c1b78c(); -} - -[[stage(compute)]] -fn compute_main() { - atomicXor_c1b78c(); -} - -Failed to generate: unable to convert type: __atomic__i32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %fragment_main "fragment_main" + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %fragment_main OriginUpperLeft + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %SB_RW "SB_RW" + OpMemberName %SB_RW 0 "arg_0" + OpName %sb_rw "sb_rw" + OpName %atomicXor_c1b78c "atomicXor_c1b78c" + OpName %res "res" + OpName %fragment_main "fragment_main" + OpName %compute_main "compute_main" + OpDecorate %SB_RW Block + OpMemberDecorate %SB_RW 0 Offset 0 + OpDecorate %sb_rw DescriptorSet 0 + OpDecorate %sb_rw Binding 0 + %int = OpTypeInt 32 1 + %SB_RW = OpTypeStruct %int +%_ptr_StorageBuffer_SB_RW = OpTypePointer StorageBuffer %SB_RW + %sb_rw = OpVariable %_ptr_StorageBuffer_SB_RW StorageBuffer + %void = OpTypeVoid + %5 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int + %int_1 = OpConstant %int 1 +%_ptr_Function_int = OpTypePointer Function %int + %19 = OpConstantNull %int +%atomicXor_c1b78c = OpFunction %void None %5 + %8 = OpLabel + %res = OpVariable %_ptr_Function_int Function %19 + %15 = OpAccessChain %_ptr_StorageBuffer_int %sb_rw %uint_0 + %9 = OpAtomicXor %int %15 %uint_1 %uint_0 %int_1 + OpStore %res %9 + OpReturn + OpFunctionEnd +%fragment_main = OpFunction %void None %5 + %21 = OpLabel + %22 = OpFunctionCall %void %atomicXor_c1b78c + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %5 + %24 = OpLabel + %25 = OpFunctionCall %void %atomicXor_c1b78c + OpReturn + OpFunctionEnd diff --git a/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.spvasm b/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.spvasm index d4a0179c00..cfd20e6cc1 100644 --- a/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.spvasm +++ b/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.spvasm @@ -1,15 +1,35 @@ -SKIP: FAILED - - -var arg_0 : atomic; - -fn atomicXor_c8e6be() { - var res : u32 = atomicXor(&(arg_0), 1u); -} - -[[stage(compute)]] -fn compute_main() { - atomicXor_c8e6be(); -} - -Failed to generate: unable to convert type: __atomic__u32 +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 19 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %compute_main "compute_main" + OpExecutionMode %compute_main LocalSize 1 1 1 + OpName %arg_0 "arg_0" + OpName %atomicXor_c8e6be "atomicXor_c8e6be" + OpName %res "res" + OpName %compute_main "compute_main" + %uint = OpTypeInt 32 0 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %arg_0 = OpVariable %_ptr_Workgroup_uint Workgroup + %void = OpTypeVoid + %4 = OpTypeFunction %void + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 +%_ptr_Function_uint = OpTypePointer Function %uint + %15 = OpConstantNull %uint +%atomicXor_c8e6be = OpFunction %void None %4 + %7 = OpLabel + %res = OpVariable %_ptr_Function_uint Function %15 + %8 = OpAtomicXor %uint %arg_0 %uint_2 %uint_0 %uint_1 + OpStore %res %8 + OpReturn + OpFunctionEnd +%compute_main = OpFunction %void None %4 + %17 = OpLabel + %18 = OpFunctionCall %void %atomicXor_c8e6be + OpReturn + OpFunctionEnd