[spirv-reader] Use type inference for var and let

When an initializer is present, use type inference instead of
explicitly typing `var` and `let` declarations. This reduces the size
of the generated WGSL and improves readability.

Change-Id: I241ee2108279b550735945940f2b62bbbd493708
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132142
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
James Price 2023-05-23 18:28:44 +00:00 committed by Dawn LUCI CQ
parent 858ccc8a0c
commit 506b4f05d0
167 changed files with 1074 additions and 1123 deletions

View File

@ -2844,7 +2844,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) {
const std::string guard_name = block_info.flow_guard_name;
if (!guard_name.empty()) {
// Declare the guard variable just before the "if", initialized to true.
auto* guard_var = builder_.Var(guard_name, builder_.ty.bool_(), MakeTrue(Source{}));
auto* guard_var = builder_.Var(guard_name, MakeTrue(Source{}));
auto* guard_decl = create<ast::VariableDeclStatement>(Source{}, guard_var);
AddStatement(guard_decl);
}
@ -3448,7 +3448,7 @@ bool FunctionEmitter::EmitConstDefinition(const spvtools::opt::Instruction& inst
expr = AddressOfIfNeeded(expr, &inst);
expr.type = RemapPointerProperties(expr.type, inst.result_id());
auto* let = parser_impl_.MakeLet(inst.result_id(), expr.type, expr.expr);
auto* let = parser_impl_.MakeLet(inst.result_id(), expr.expr);
if (!let) {
return false;
}
@ -6212,7 +6212,7 @@ bool FunctionEmitter::MakeVectorInsertDynamic(const spvtools::opt::Instruction&
// variable with the %src_vector contents, then write the component,
// and then make a let-declaration that reads the value out:
//
// var temp : type = src_vector;
// var temp = src_vector;
// temp[index] = component;
// let result : type = temp;
//
@ -6238,8 +6238,7 @@ bool FunctionEmitter::MakeVectorInsertDynamic(const spvtools::opt::Instruction&
// API in parser_impl_.
var_name = namer_.MakeDerivedName(original_value_name);
auto* temp_var = builder_.Var(var_name, type->Build(builder_),
builtin::AddressSpace::kUndefined, src_vector.expr);
auto* temp_var = builder_.Var(var_name, builtin::AddressSpace::kUndefined, src_vector.expr);
AddStatement(builder_.Decl({}, temp_var));
}
@ -6278,7 +6277,7 @@ bool FunctionEmitter::MakeCompositeInsert(const spvtools::opt::Instruction& inst
// variable with the %composite contents, then write the component,
// and then make a let-declaration that reads the value out:
//
// var temp : type = composite;
// var temp = composite;
// temp[index].x = object;
// let result : type = temp;
//
@ -6308,8 +6307,8 @@ bool FunctionEmitter::MakeCompositeInsert(const spvtools::opt::Instruction& inst
// It doesn't correspond to a SPIR-V ID, so we don't use the ordinary
// API in parser_impl_.
var_name = namer_.MakeDerivedName(original_value_name);
auto* temp_var = builder_.Var(var_name, type->Build(builder_),
builtin::AddressSpace::kUndefined, src_composite.expr);
auto* temp_var =
builder_.Var(var_name, builtin::AddressSpace::kUndefined, src_composite.expr);
AddStatement(builder_.Decl({}, temp_var));
}

View File

@ -122,7 +122,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : i32 = -(30i);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = -(30i);"));
}
TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
@ -139,7 +139,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : i32 = -(bitcast<i32>(10u));"));
HasSubstr("let x_1 = -(bitcast<i32>(10u));"));
}
TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
@ -156,7 +156,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : u32 = bitcast<u32>(-(30i));"));
HasSubstr("let x_1 = bitcast<u32>(-(30i));"));
}
TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
@ -173,7 +173,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : u32 = bitcast<u32>(-(bitcast<i32>(10u)));"));
HasSubstr("let x_1 = bitcast<u32>(-(bitcast<i32>(10u)));"));
}
TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
@ -189,8 +189,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2i = -(vec2i(30i, 40i));"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = -(vec2i(30i, 40i));"));
}
TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
@ -207,7 +206,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2i = -(bitcast<vec2i>(vec2u(10u, 20u)));"));
HasSubstr("let x_1 = -(bitcast<vec2i>(vec2u(10u, 20u)));"));
}
TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
@ -224,7 +223,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2u = bitcast<vec2u>(-(vec2i(30i, 40i)));"));
HasSubstr("let x_1 = bitcast<vec2u>(-(vec2i(30i, 40i)));"));
}
TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
@ -240,9 +239,8 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 : vec2u = bitcast<vec2u>(-(bitcast<vec2i>(vec2u(10u, 20u))));)"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 = bitcast<vec2u>(-(bitcast<vec2i>(vec2u(10u, 20u))));)"));
}
TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
@ -258,7 +256,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : f32 = -(50.0f);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = -(50.0f);"));
}
TEST_F(SpvUnaryArithTest, FNegate_Vector) {
@ -274,8 +272,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2f = -(v2float_50_60);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = -(v2float_50_60);"));
}
struct BinaryData {
@ -313,8 +310,8 @@ TEST_P(SpvBinaryArithTest, EmitExpression) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
utils::StringStream ss;
ss << "let x_1 : " << GetParam().ast_type << " = (" << GetParam().ast_lhs << " "
<< GetParam().ast_op << " " << GetParam().ast_rhs << ");";
ss << "let x_1 = (" << GetParam().ast_lhs << " " << GetParam().ast_op << " "
<< GetParam().ast_rhs << ");";
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(ss.str())) << "got:\n" << got << assembly;
@ -352,7 +349,7 @@ TEST_P(SpvBinaryArithGeneralTest, EmitExpression) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
utils::StringStream ss;
ss << "let x_1 : " << GetParam().wgsl_type << " = " << GetParam().expected << ";";
ss << "let x_1 = " << GetParam().expected << ";";
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(ss.str())) << "got:\n" << got << assembly;
@ -547,7 +544,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Scalar_UnsignedResult) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : u32 = bitcast<u32>((30i / 40i));"));
HasSubstr("let x_1 = bitcast<u32>((30i / 40i));"));
}
TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) {
@ -567,9 +564,8 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 : vec2u = bitcast<vec2u>((vec2i(30i, 40i) / vec2i(40i, 30i)));)"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 = bitcast<vec2u>((vec2i(30i, 40i) / vec2i(40i, 30i)));)"));
}
INSTANTIATE_TEST_SUITE_P(SpvParserTest_FDiv,
@ -636,7 +632,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Scalar_UnsignedResult) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : u32 = bitcast<u32>((30i % 40i));"));
HasSubstr("let x_1 = bitcast<u32>((30i % 40i));"));
}
TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) {
@ -656,9 +652,8 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 : vec2u = bitcast<vec2u>((vec2i(30i, 40i) % vec2i(40i, 30i)));)"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 = bitcast<vec2u>((vec2i(30i, 40i) % vec2i(40i, 30i)));)"));
}
INSTANTIATE_TEST_SUITE_P(SpvParserTest_FRem,
@ -685,7 +680,7 @@ TEST_F(SpvBinaryArithTestBasic, FMod_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : f32 = (50.0f - (60.0f * floor((50.0f / 60.0f))));"));
HasSubstr("let x_1 = (50.0f - (60.0f * floor((50.0f / 60.0f))));"));
}
TEST_F(SpvBinaryArithTestBasic, FMod_Vector) {
@ -702,7 +697,7 @@ TEST_F(SpvBinaryArithTestBasic, FMod_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2f = (v2float_50_60 - (v2float_60_50 * "
HasSubstr("let x_1 = (v2float_50_60 - (v2float_60_50 * "
"floor((v2float_50_60 / v2float_60_50))));"));
}
@ -721,8 +716,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : vec2f = (x_1 * x_2);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 = (x_1 * x_2);"));
}
TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
@ -740,8 +734,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : mat2x2f = (x_1 * x_2);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 = (x_1 * x_2);"));
}
TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
@ -759,8 +752,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : vec2f = (x_1 * x_2);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 = (x_1 * x_2);"));
}
TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
@ -778,8 +770,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : vec2f = (x_1 * x_2);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 = (x_1 * x_2);"));
}
TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
@ -797,8 +788,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : mat2x2f = (x_1 * x_2);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 = (x_1 * x_2);"));
}
TEST_F(SpvBinaryArithTestBasic, Dot) {
@ -816,8 +806,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_3 : f32 = dot(x_1, x_2);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_3 = dot(x_1, x_2);"));
}
TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
@ -838,7 +827,7 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr("let x_3 : mat2x3f = mat2x3f("
EXPECT_THAT(got, HasSubstr("let x_3 = mat2x3f("
"vec3f((x_2.x * x_1.x), (x_2.x * x_1.y), (x_2.x * x_1.z)), "
"vec3f((x_2.y * x_1.x), (x_2.y * x_1.y), (x_2.y * x_1.z)));"))
<< got;
@ -888,7 +877,7 @@ TEST_P(SpvBinaryDerivativeTest, Derivatives) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_2 : " + arg.ast_type + " = " + builtin.wgsl + "(x_1);"));
HasSubstr("let x_2 = " + builtin.wgsl + "(x_1);"));
}
INSTANTIATE_TEST_SUITE_P(
@ -920,7 +909,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x2) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly;
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
const auto* expected = "let x_2 : mat2x2f = transpose(x_1);";
const auto* expected = "let x_2 = transpose(x_1);";
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(expected)) << got;
@ -942,7 +931,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x3) {
// Note, in the AST dump mat_2_3 means 2 rows and 3 columns.
// So the column vectors have 2 elements.
// That is, %m3v2float is __mat_2_3f32.
const auto* expected = "let x_2 : mat3x2f = transpose(x_1);";
const auto* expected = "let x_2 = transpose(x_1);";
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(expected)) << got;
@ -961,7 +950,7 @@ TEST_F(SpvUnaryArithTest, Transpose_3x2) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly;
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
const auto* expected = "let x_2 : mat2x3f = transpose(x_1);";
const auto* expected = "let x_2 = transpose(x_1);";
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(expected)) << got;

View File

@ -129,8 +129,8 @@ TEST_P(SpvBinaryBitTest, EmitExpression) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
utils::StringStream ss;
ss << "let x_1 : " << GetParam().ast_type << " = (" << GetParam().ast_lhs << " "
<< GetParam().ast_op << " " << GetParam().ast_rhs << ");";
ss << "let x_1 = (" << GetParam().ast_lhs << " " << GetParam().ast_op << " "
<< GetParam().ast_rhs << ");";
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(ss.str())) << assembly;
}
@ -167,7 +167,7 @@ TEST_P(SpvBinaryBitGeneralTest, EmitExpression) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error() << assembly;
utils::StringStream ss;
ss << "let x_1 : " << GetParam().wgsl_type << " = " << GetParam().expected << ";\nreturn;\n";
ss << "let x_1 = " << GetParam().expected << ";\nreturn;\n";
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(ss.str())) << "got:\n" << got << assembly;
@ -445,7 +445,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = ~(30i);"));
EXPECT_THAT(body, HasSubstr("let x_1 = ~(30i);"));
}
TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
@ -462,7 +462,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = bitcast<i32>(~(10u));"));
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<i32>(~(10u));"));
}
TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
@ -479,7 +479,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = bitcast<u32>(~(30i));"));
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<u32>(~(30i));"));
}
TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
@ -496,7 +496,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = ~(10u);"));
EXPECT_THAT(body, HasSubstr("let x_1 = ~(10u);"));
}
TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
@ -513,7 +513,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = ~(vec2i(30i, 40i));"));
EXPECT_THAT(body, HasSubstr("let x_1 = ~(vec2i(30i, 40i));"));
}
TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
@ -530,7 +530,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = bitcast<vec2i>(~(vec2u(10u, 20u)));"));
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<vec2i>(~(vec2u(10u, 20u)));"));
}
TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
@ -547,7 +547,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = bitcast<vec2u>(~(vec2i(30i, 40i)));"));
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<vec2u>(~(vec2i(30i, 40i)));"));
}
TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
const auto assembly = SimplePreamble() + R"(
@ -563,7 +563,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = ~(vec2u(10u, 20u));"));
EXPECT_THAT(body, HasSubstr("let x_1 = ~(vec2u(10u, 20u));"));
}
std::string BitTestPreamble() {
@ -604,7 +604,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = countOneBits(u1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = countOneBits(u1);")) << body;
}
TEST_F(SpvUnaryBitTest, BitCount_Uint_Int) {
@ -619,7 +619,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = bitcast<u32>(countOneBits(i1));")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<u32>(countOneBits(i1));")) << body;
}
TEST_F(SpvUnaryBitTest, BitCount_Int_Uint) {
@ -634,7 +634,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = bitcast<i32>(countOneBits(u1));")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<i32>(countOneBits(u1));")) << body;
}
TEST_F(SpvUnaryBitTest, BitCount_Int_Int) {
@ -649,7 +649,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = countOneBits(i1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = countOneBits(i1);")) << body;
}
TEST_F(SpvUnaryBitTest, BitCount_UintVector_UintVector) {
@ -664,7 +664,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_UintVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = countOneBits(v2u1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = countOneBits(v2u1);")) << body;
}
TEST_F(SpvUnaryBitTest, BitCount_UintVector_IntVector) {
@ -679,7 +679,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_IntVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = bitcast<vec2u>(countOneBits(v2i1));")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<vec2u>(countOneBits(v2i1));")) << body;
}
TEST_F(SpvUnaryBitTest, BitCount_IntVector_UintVector) {
@ -694,7 +694,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_UintVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = bitcast<vec2i>(countOneBits(v2u1));")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<vec2i>(countOneBits(v2u1));")) << body;
}
TEST_F(SpvUnaryBitTest, BitCount_IntVector_IntVector) {
@ -709,7 +709,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_IntVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = countOneBits(v2i1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = countOneBits(v2i1);")) << body;
}
TEST_F(SpvUnaryBitTest, BitReverse_Uint_Uint) {
@ -724,7 +724,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = reverseBits(u1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = reverseBits(u1);")) << body;
}
TEST_F(SpvUnaryBitTest, BitReverse_Uint_Int) {
@ -763,7 +763,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = reverseBits(i1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = reverseBits(i1);")) << body;
}
TEST_F(SpvUnaryBitTest, BitReverse_UintVector_UintVector) {
@ -778,7 +778,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_UintVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = reverseBits(v2u1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = reverseBits(v2u1);")) << body;
}
TEST_F(SpvUnaryBitTest, BitReverse_UintVector_IntVector) {
@ -817,7 +817,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_IntVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = reverseBits(v2i1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = reverseBits(v2i1);")) << body;
}
TEST_F(SpvUnaryBitTest, InsertBits_Int) {
@ -832,7 +832,7 @@ TEST_F(SpvUnaryBitTest, InsertBits_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = insertBits(30i, 40i, 10u, 20u);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = insertBits(30i, 40i, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, InsertBits_Int_SignedOffsetAndCount) {
@ -847,8 +847,7 @@ TEST_F(SpvUnaryBitTest, InsertBits_Int_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = insertBits(30i, 40i, u32(10i), u32(20i));"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = insertBits(30i, 40i, u32(10i), u32(20i));")) << body;
}
TEST_F(SpvUnaryBitTest, InsertBits_IntVector) {
@ -863,8 +862,7 @@ TEST_F(SpvUnaryBitTest, InsertBits_IntVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr(R"(let x_1 : vec2i = insertBits(x_28, vec2i(40i, 30i), 10u, 20u);)"))
EXPECT_THAT(body, HasSubstr(R"(let x_1 = insertBits(x_28, vec2i(40i, 30i), 10u, 20u);)"))
<< body;
}
@ -880,9 +878,8 @@ TEST_F(SpvUnaryBitTest, InsertBits_IntVector_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(R"(let x_1 : vec2i = insertBits(x_28, vec2i(40i, 30i), u32(10i), u32(20i));)"))
EXPECT_THAT(body,
HasSubstr(R"(let x_1 = insertBits(x_28, vec2i(40i, 30i), u32(10i), u32(20i));)"))
<< body;
}
@ -898,7 +895,7 @@ TEST_F(SpvUnaryBitTest, InsertBits_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = insertBits(20u, 10u, 10u, 20u);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = insertBits(20u, 10u, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, InsertBits_Uint_SignedOffsetAndCount) {
@ -913,8 +910,7 @@ TEST_F(SpvUnaryBitTest, InsertBits_Uint_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = insertBits(20u, 10u, u32(10i), u32(20i));"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = insertBits(20u, 10u, u32(10i), u32(20i));")) << body;
}
TEST_F(SpvUnaryBitTest, InsertBits_UintVector) {
@ -929,8 +925,7 @@ TEST_F(SpvUnaryBitTest, InsertBits_UintVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr(R"(let x_1 : vec2u = insertBits(x_26, vec2u(20u, 10u), 10u, 20u);)"))
EXPECT_THAT(body, HasSubstr(R"(let x_1 = insertBits(x_26, vec2u(20u, 10u), 10u, 20u);)"))
<< body;
}
@ -946,9 +941,8 @@ TEST_F(SpvUnaryBitTest, InsertBits_UintVector_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(R"(let x_1 : vec2u = insertBits(x_26, vec2u(20u, 10u), u32(10i), u32(20i));)"))
EXPECT_THAT(body,
HasSubstr(R"(let x_1 = insertBits(x_26, vec2u(20u, 10u), u32(10i), u32(20i));)"))
<< body;
}
@ -964,7 +958,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_Int) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = extractBits(30i, 10u, 20u);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(30i, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_Int_SignedOffsetAndCount) {
@ -979,7 +973,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_Int_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = extractBits(30i, u32(10i), u32(20i));")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(30i, u32(10i), u32(20i));")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_IntVector) {
@ -994,7 +988,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_IntVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = extractBits(x_28, 10u, 20u);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(x_28, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_IntVector_SignedOffsetAndCount) {
@ -1009,8 +1003,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_IntVector_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = extractBits(x_28, u32(10i), u32(20i));"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(x_28, u32(10i), u32(20i));")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_Uint) {
@ -1025,7 +1018,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = extractBits(20u, 10u, 20u);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(20u, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_Uint_SignedOffsetAndCount) {
@ -1040,7 +1033,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_Uint_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = extractBits(20u, u32(10i), u32(20i));")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(20u, u32(10i), u32(20i));")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_UintVector) {
@ -1055,7 +1048,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_UintVector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = extractBits(x_26, 10u, 20u);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(x_26, 10u, 20u);")) << body;
}
TEST_F(SpvUnaryBitTest, ExtractBits_UintVector_SignedOffsetAndCount) {
@ -1070,8 +1063,7 @@ TEST_F(SpvUnaryBitTest, ExtractBits_UintVector_SignedOffsetAndCount) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = extractBits(x_26, u32(10i), u32(20i));"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = extractBits(x_26, u32(10i), u32(20i));")) << body;
}
} // namespace

View File

@ -136,7 +136,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
f50 = fe.ast_body();
}
auto program = p->program();
EXPECT_THAT(test::ToString(program, f100), HasSubstr("let x_1 : u32 = x_50();\nreturn;"));
EXPECT_THAT(test::ToString(program, f100), HasSubstr("let x_1 = x_50();\nreturn;"));
EXPECT_THAT(test::ToString(program, f50), HasSubstr("return 42u;"));
}
@ -178,7 +178,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParamsUsedTwice) {
}
auto program = p->program();
EXPECT_EQ(test::ToString(program, f100), R"(var x_10 : u32;
let x_1 : u32 = x_50();
let x_1 = x_50();
x_10 = x_1;
x_10 = x_1;
return;
@ -217,7 +217,7 @@ TEST_F(SpvParserTest, EmitStatement_CallWithParams) {
}
fn x_100_1() {
let x_1 : u32 = x_50(42u, 84u);
let x_1 = x_50(42u, 84u);
return;
}

View File

@ -7192,7 +7192,7 @@ TEST_F(SpvParserCFGTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) {
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var_1 = 1u;
var guard10 : bool = true;
var guard10 = true;
if (false) {
var_1 = 2u;
if (true) {
@ -7249,7 +7249,7 @@ TEST_F(SpvParserCFGTest, EmitBody_IfBreak_FromElse_ForwardWithinElse) {
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var_1 = 1u;
var guard10 : bool = true;
var guard10 = true;
if (false) {
var_1 = 2u;
guard10 = false;
@ -7320,7 +7320,7 @@ TEST_F(SpvParserCFGTest, EmitBody_IfBreak_FromThenWithForward_FromElseWithForwar
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var_1 = 1u;
var guard10 : bool = true;
var guard10 = true;
if (false) {
var_1 = 2u;
if (true) {

View File

@ -95,10 +95,9 @@ TEST_F(SpvParserTest_Composite_Construct, Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 : vec2u = vec2u(10u, 20u);
let x_2 : vec2i = vec2i(30i, 40i);
let x_3 : vec2f = vec2f(50.0f, 60.0f);
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_1 = vec2u(10u, 20u);
let x_2 = vec2i(30i, 40i);
let x_3 = vec2f(50.0f, 60.0f);
)"));
}
@ -115,7 +114,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : mat3x2f = mat3x2f("
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = mat3x2f("
"vec2f(50.0f, 60.0f), "
"vec2f(60.0f, 50.0f), "
"vec2f(70.0f, 70.0f));"));
@ -135,7 +134,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : array<u32, 5u> = array<u32, 5u>(10u, 20u, 3u, 4u, 5u);"));
HasSubstr("let x_1 = array<u32, 5u>(10u, 20u, 3u, 4u, 5u);"));
}
TEST_F(SpvParserTest_Composite_Construct, Struct) {
@ -152,7 +151,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : S = S(vec2f(50.0f, 60.0f), 5u, 30i);"));
HasSubstr("let x_1 = S(vec2f(50.0f, 60.0f), 5u, 30i);"));
}
TEST_F(SpvParserTest_Composite_Construct, ConstantComposite_Struct_NoDeduplication) {
@ -177,8 +176,8 @@ TEST_F(SpvParserTest_Composite_Construct, ConstantComposite_Struct_NoDeduplicati
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
const auto expected = std::string(
R"(let x_2 : S_1 = S_1(10u);
let x_3 : S_2 = S_2(10u);
R"(let x_2 = S_1(10u);
let x_3 = S_2(10u);
return;
)");
EXPECT_EQ(got, expected) << got;
@ -200,7 +199,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : f32 = vec2f(50.0f, 60.0f).y;"));
HasSubstr("let x_1 = vec2f(50.0f, 60.0f).y;"));
}
TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
@ -237,7 +236,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 : vec2f = x_1[2u];"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 = x_1[2u];"));
}
TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) {
@ -278,7 +277,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 : f32 = x_1[2u].y;"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 = x_1[2u].y;"));
}
TEST_F(SpvParserTest_CompositeExtract, Array) {
@ -298,7 +297,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 : u32 = x_1[3u];"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 = x_1[3u];"));
}
TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) {
@ -338,7 +337,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 : i32 = x_1.field2;"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 = x_1.field2;"));
}
TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
@ -378,9 +377,9 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto got = fe.ast_body();
auto program = p->program();
EXPECT_THAT(test::ToString(program, got), HasSubstr("let x_2 : u32 = x_1.algo;"))
EXPECT_THAT(test::ToString(program, got), HasSubstr("let x_2 = x_1.algo;"))
<< test::ToString(program, got);
EXPECT_THAT(test::ToString(program, got), HasSubstr("let x_4 : u32 = x_3.rithm;"))
EXPECT_THAT(test::ToString(program, got), HasSubstr("let x_4 = x_3.rithm;"))
<< test::ToString(program, got);
p->SkipDumpingPending("crbug.com/tint/863");
}
@ -426,7 +425,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_2 : f32 = x_1.field1[2u][0u].y;"));
HasSubstr("let x_2 = x_1.field1[2u][0u].y;"));
}
using SpvParserTest_CompositeInsert = SpvParserTest;
@ -446,9 +445,9 @@ TEST_F(SpvParserTest_CompositeInsert, Vector) {
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
const auto* expected =
R"(var x_1_1 : vec2f = vec2f(50.0f, 60.0f);
R"(var x_1_1 = vec2f(50.0f, 60.0f);
x_1_1.y = 70.0f;
let x_1 : vec2f = x_1_1;
let x_1 = x_1_1;
return;
)";
EXPECT_EQ(got, expected);
@ -489,9 +488,9 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 : mat3x2f = x_1;
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 = x_1;
x_2_1[2u] = vec2f(50.0f, 60.0f);
let x_2 : mat3x2f = x_2_1;
let x_2 = x_2_1;
)")) << body_str;
}
@ -534,9 +533,9 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 : mat3x2f = x_1;
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 = x_1;
x_2_1[2u] = vec2f(50.0f, 60.0f);
let x_2 : mat3x2f = x_2_1;
let x_2 = x_2_1;
return;
)")) << body_str;
}
@ -559,9 +558,9 @@ TEST_F(SpvParserTest_CompositeInsert, Array) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 : array<u32, 5u> = x_1;
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 = x_1;
x_2_1[3u] = 20u;
let x_2 : array<u32, 5u> = x_2_1;
let x_2 = x_2_1;
)")) << body_str;
}
@ -604,10 +603,10 @@ TEST_F(SpvParserTest_CompositeInsert, Struct) {
auto ast_body = fe.ast_body();
auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(var x_36 : S;
let x_1 : S = x_36;
var x_2_1 : S = x_1;
let x_1 = x_36;
var x_2_1 = x_1;
x_2_1.field2 = 30i;
let x_2 : S = x_2_1;
let x_2 = x_2_1;
)")) << body_str;
}
@ -654,14 +653,14 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_DifferOnlyInMemberName) {
const auto got = test::ToString(p->program(), ast_body);
const std::string expected = R"(var var0 : S;
var var1 : S_1;
let x_1 : S = var0;
var x_2_1 : S = x_1;
let x_1 = var0;
var x_2_1 = x_1;
x_2_1.algo = 10u;
let x_2 : S = x_2_1;
let x_3 : S_1 = var1;
var x_4_1 : S_1 = x_3;
let x_2 = x_2_1;
let x_3 = var1;
var x_4_1 = x_3;
x_4_1.rithm = 11u;
let x_4 : S_1 = x_4_1;
let x_4 = x_4_1;
return;
)";
EXPECT_EQ(got, expected) << got;
@ -709,10 +708,10 @@ TEST_F(SpvParserTest_CompositeInsert, Struct_Array_Matrix_Vector) {
auto ast_body = fe.ast_body();
auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(var x_38 : S_1;
let x_1 : S_1 = x_38;
var x_2_1 : S_1 = x_1;
let x_1 = x_38;
var x_2_1 = x_1;
x_2_1.field1[2u][0u].y = 70.0f;
let x_2 : S_1 = x_2_1;
let x_2 = x_2_1;
)")) << body_str;
}
@ -732,8 +731,8 @@ TEST_F(SpvParserTest_CopyObject, Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_1 : u32 = 3u;
let x_2 : u32 = x_1;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_1 = 3u;
let x_2 = x_1;
)"));
}
@ -754,9 +753,9 @@ TEST_F(SpvParserTest_CopyObject, Pointer) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_1 : ptr<function, u32> = &(x_10);
let x_2 : ptr<function, u32> = x_1;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"( x_10 : u32;
let x_1 = &(x_10);
let x_2 = x_1;
)"));
}
@ -780,7 +779,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : vec4u = vec4u(x_2.y, x_2.x, x_1.y, x_1.x);"));
HasSubstr("let x_10 = vec4u(x_2.y, x_2.x, x_1.y, x_1.x);"));
}
TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
@ -797,7 +796,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 : vec4u = vec4u("
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 = vec4u("
"vec2u(4u, 3u).y, "
"vec2u(4u, 3u).x, "
"vec2u(3u, 4u).y, "
@ -819,8 +818,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : vec2u = vec2u(0u, x_1.y);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_10 = vec2u(0u, x_1.y);"));
}
TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_MixedInputOperandSizes) {
@ -842,7 +840,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_MixedInputOperandSizes
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : vec2u = vec2u(x_1.y, x_3.z);"));
HasSubstr("let x_10 = vec2u(x_1.y, x_3.z);"));
}
TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) {
@ -880,7 +878,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, SignedIndex) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr("let x_10 : u32 = x_1[x_2];")) << got;
EXPECT_THAT(got, HasSubstr("let x_10 = x_1[x_2];")) << got;
}
TEST_F(SpvParserTest_VectorExtractDynamic, UnsignedIndex) {
@ -900,7 +898,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, UnsignedIndex) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr("let x_10 : u32 = x_1[x_2];")) << got;
EXPECT_THAT(got, HasSubstr("let x_10 = x_1[x_2];")) << got;
}
using SpvParserTest_VectorInsertDynamic = SpvParserTest;
@ -923,9 +921,9 @@ TEST_F(SpvParserTest_VectorInsertDynamic, Sample) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(R"(var x_10_1 : vec2u = x_1;
EXPECT_THAT(got, HasSubstr(R"(var x_10_1 = x_1;
x_10_1[x_3] = x_2;
let x_10 : vec2u = x_10_1;
let x_10 = x_10_1;
)")) << got
<< assembly;
}

View File

@ -83,7 +83,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : u32 = bitcast<u32>(50.0f);"));
HasSubstr("let x_1 = bitcast<u32>(50.0f);"));
}
TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
@ -100,7 +100,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2f = bitcast<vec2f>(vec2u(10u, 20u));"));
HasSubstr("let x_1 = bitcast<vec2f>(vec2u(10u, 20u));"));
}
TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) {
@ -209,7 +209,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : f32 = f32(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = f32(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
@ -227,7 +227,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : f32 = f32(bitcast<i32>(x_30));"));
HasSubstr("let x_1 = f32(bitcast<i32>(x_30));"));
}
TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
@ -244,8 +244,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2f = vec2f(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = vec2f(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
@ -263,7 +262,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2f = vec2f(bitcast<vec2i>(x_30));"));
HasSubstr("let x_1 = vec2f(bitcast<vec2i>(x_30));"));
}
TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) {
@ -313,7 +312,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : f32 = f32(bitcast<u32>(x_30));"));
HasSubstr("let x_1 = f32(bitcast<u32>(x_30));"));
}
TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
@ -330,7 +329,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : f32 = f32(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = f32(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
@ -348,7 +347,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2f = vec2f(bitcast<vec2u>(x_30));"));
HasSubstr("let x_1 = vec2f(bitcast<vec2u>(x_30));"));
}
TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
@ -365,8 +364,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2f = vec2f(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = vec2f(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) {
@ -415,7 +413,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : i32 = i32(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = i32(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
@ -433,7 +431,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : u32 = bitcast<u32>(i32(x_30));"));
HasSubstr("let x_1 = bitcast<u32>(i32(x_30));"));
}
TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
@ -450,8 +448,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2i = vec2i(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = vec2i(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
@ -469,7 +466,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2u = bitcast<vec2u>(vec2i(x_30));"));
HasSubstr("let x_1 = bitcast<vec2u>(vec2i(x_30));"));
}
TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) {
@ -534,7 +531,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : u32 = u32(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = u32(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned_IsError) {
@ -567,8 +564,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2u = vec2u(x_30);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = vec2u(x_30);"));
}
TEST_F(SpvUnaryConversionTest, ConvertFToU_HoistedValue) {
@ -609,7 +605,7 @@ OpFunctionEnd
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_82 : u32 = u32(x_600);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_82 = u32(x_600);"));
}
// TODO(dneto): OpSConvert // only if multiple widths

View File

@ -186,7 +186,7 @@ TEST_F(SpvParserTest, Emit_FunctionDecl_ParamPtrTexture_ParamPtrSampler) {
auto got = test::ToString(p->program());
std::string expect = R"(fn x_200(x_14 : texture_2d<f32>, x_15 : sampler) {
let x_20 : vec4f = textureSample(x_14, x_15, vec2f());
let x_20 = textureSample(x_14, x_15, vec2f());
return;
}
)";
@ -216,7 +216,7 @@ TEST_F(SpvParserTest, Emit_FunctionDecl_ParamTexture_ParamSampler) {
auto got = test::ToString(p->program());
std::string expect = R"(fn x_200(x_14 : texture_2d<f32>, x_15 : sampler) {
let x_20 : vec4f = textureSample(x_14, x_15, vec2f());
let x_20 = textureSample(x_14, x_15, vec2f());
return;
}
)";

View File

@ -201,7 +201,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(f1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(f1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
@ -217,7 +217,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(v2f1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2f1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
@ -233,7 +233,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(f1, f2);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(f1, f2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
@ -249,8 +249,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(v2f1, v2f2);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2f1, v2f2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
@ -266,7 +265,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(f1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(f1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
@ -282,7 +281,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2f = " + GetParam().wgsl_func + "(v2f1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2f1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
@ -298,7 +297,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(f1, f2);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(f1, f2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
@ -314,8 +313,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2f = " + GetParam().wgsl_func + "(v2f1, v2f2);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2f1, v2f2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
@ -331,8 +329,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(f1, f2, f3);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(f1, f2, f3);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
@ -349,8 +346,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr("let x_1 : vec2f = " + GetParam().wgsl_func + "(v2f1, v2f2, v2f3);"))
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2f1, v2f2, v2f3);"))
<< body;
}
@ -367,7 +363,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = " + GetParam().wgsl_func + "(f1, i1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(f1, i1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
@ -384,8 +380,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2f = " + GetParam().wgsl_func + "(v2f1, v2i1);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2f1, v2i1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
@ -402,8 +397,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec3f = " + GetParam().wgsl_func + "(v3f1, v3f2);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v3f1, v3f2);")) << body;
}
INSTANTIATE_TEST_SUITE_P(Samples,
@ -488,7 +482,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = " + GetParam().wgsl_func + "(i1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(i1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Inting_Inting_SignednessCoercing, Scalar_UnsignedArg) {
@ -505,7 +499,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting_SignednessCoercing, Scalar_Unsigne
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = " + GetParam().wgsl_func + "(bitcast<i32>(u1));"))
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(bitcast<i32>(u1));"))
<< body;
}
@ -523,7 +517,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting_SignednessCoercing, Scalar_Unsigne
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = bitcast<u32>(" + GetParam().wgsl_func + "(i1));"))
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<u32>(" + GetParam().wgsl_func + "(i1));"))
<< body;
}
@ -541,7 +535,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = " + GetParam().wgsl_func + "(v2i1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2i1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Inting_Inting_SignednessCoercing, Vector_UnsignedArg) {
@ -558,8 +552,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting_SignednessCoercing, Vector_Unsigne
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr("let x_1 : vec2i = " + GetParam().wgsl_func + "(bitcast<vec2i>(v2u1));"))
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(bitcast<vec2i>(v2u1));"))
<< body;
}
@ -577,8 +570,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting_SignednessCoercing, Vector_Unsigne
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr("let x_1 : vec2u = bitcast<vec2u>(" + GetParam().wgsl_func + "(v2i1));"))
EXPECT_THAT(body, HasSubstr("let x_1 = bitcast<vec2u>(" + GetParam().wgsl_func + "(v2i1));"))
<< body;
}
@ -596,7 +588,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = " + GetParam().wgsl_func + "(i1, i2);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(i1, i2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
@ -613,8 +605,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2i = " + GetParam().wgsl_func + "(v2i1, v2i2);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2i1, v2i2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
@ -631,8 +622,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : i32 = " + GetParam().wgsl_func + "(i1, i2, i3);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(i1, i2, i3);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
@ -649,8 +639,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr("let x_1 : vec2i = " + GetParam().wgsl_func + "(v2i1, v2i2, v2i3);"))
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2i1, v2i2, v2i3);"))
<< body;
}
@ -688,7 +677,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_Uinting, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = " + GetParam().wgsl_func + "(u1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(u1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Uinting_Uinting, Vector) {
@ -705,7 +694,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_Uinting, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = " + GetParam().wgsl_func + "(v2u1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2u1);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) {
@ -721,7 +710,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = " + GetParam().wgsl_func + "(u1, u2);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(u1, u2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
@ -738,8 +727,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2u = " + GetParam().wgsl_func + "(v2u1, v2u2);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2u1, v2u2);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
@ -755,8 +743,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = " + GetParam().wgsl_func + "(u1, u2, u3);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(u1, u2, u3);")) << body;
}
TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
@ -773,8 +760,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr("let x_1 : vec2u = " + GetParam().wgsl_func + "(v2u1, v2u2, v2u3);"))
EXPECT_THAT(body, HasSubstr("let x_1 = " + GetParam().wgsl_func + "(v2u1, v2u2, v2u3);"))
<< body;
}
@ -809,7 +795,7 @@ TEST_F(SpvParserTest, Normalize_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : f32 = 1.0f;")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = 1.0f;")) << body;
}
TEST_F(SpvParserTest, Normalize_Vector2) {
@ -825,7 +811,7 @@ TEST_F(SpvParserTest, Normalize_Vector2) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec2f = normalize(v2f1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = normalize(v2f1);")) << body;
}
TEST_F(SpvParserTest, Normalize_Vector3) {
@ -841,7 +827,7 @@ TEST_F(SpvParserTest, Normalize_Vector3) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec3f = normalize(v3f1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = normalize(v3f1);")) << body;
}
TEST_F(SpvParserTest, Normalize_Vector4) {
@ -857,7 +843,7 @@ TEST_F(SpvParserTest, Normalize_Vector4) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : vec4f = normalize(v4f1);")) << body;
EXPECT_THAT(body, HasSubstr("let x_1 = normalize(v4f1);")) << body;
}
// Check that we convert signedness of operands and result type.
@ -876,9 +862,8 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SAbs) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr(R"(let x_1 : u32 = bitcast<u32>(abs(bitcast<i32>(u1)));)")) << body;
EXPECT_THAT(body, HasSubstr(R"(let x_2 : vec2u = bitcast<vec2u>(abs(bitcast<vec2i>(v2u1)));)"))
<< body;
EXPECT_THAT(body, HasSubstr(R"(let x_1 = bitcast<u32>(abs(bitcast<i32>(u1)));)")) << body;
EXPECT_THAT(body, HasSubstr(R"(let x_2 = bitcast<vec2u>(abs(bitcast<vec2i>(v2u1)));)")) << body;
}
TEST_F(SpvParserTest, RectifyOperandsAndResult_SMax) {
@ -894,14 +879,12 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMax) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(R"(let x_1 : u32 = bitcast<u32>(max(bitcast<i32>(u1), bitcast<i32>(u2)));)"))
EXPECT_THAT(body,
HasSubstr(R"(let x_1 = bitcast<u32>(max(bitcast<i32>(u1), bitcast<i32>(u2)));)"))
<< body;
EXPECT_THAT(
body,
HasSubstr(
R"(let x_2 : vec2u = bitcast<vec2u>(max(bitcast<vec2i>(v2u1), bitcast<vec2i>(v2u2)));)"))
HasSubstr(R"(let x_2 = bitcast<vec2u>(max(bitcast<vec2i>(v2u1), bitcast<vec2i>(v2u2)));)"))
<< body;
}
@ -918,14 +901,12 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMin) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(R"(let x_1 : u32 = bitcast<u32>(min(bitcast<i32>(u1), bitcast<i32>(u2)));)"))
EXPECT_THAT(body,
HasSubstr(R"(let x_1 = bitcast<u32>(min(bitcast<i32>(u1), bitcast<i32>(u2)));)"))
<< body;
EXPECT_THAT(
body,
HasSubstr(
R"(let x_2 : vec2u = bitcast<vec2u>(min(bitcast<vec2i>(v2u1), bitcast<vec2i>(v2u2)));)"))
HasSubstr(R"(let x_2 = bitcast<vec2u>(min(bitcast<vec2i>(v2u1), bitcast<vec2i>(v2u2)));)"))
<< body;
}
@ -944,13 +925,12 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SClamp) {
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(
R"(let x_1 : u32 = bitcast<u32>(clamp(bitcast<i32>(u1), i2, bitcast<i32>(u3)));)"))
HasSubstr(R"(let x_1 = bitcast<u32>(clamp(bitcast<i32>(u1), i2, bitcast<i32>(u3)));)"))
<< body;
EXPECT_THAT(
body,
HasSubstr(
R"(let x_2 : vec2u = bitcast<vec2u>(clamp(bitcast<vec2i>(v2u1), v2i2, bitcast<vec2i>(v2u3)));)"))
R"(let x_2 = bitcast<vec2u>(clamp(bitcast<vec2i>(v2u1), v2i2, bitcast<vec2i>(v2u3)));)"))
<< body;
}
@ -967,14 +947,12 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMax) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(R"(let x_1 : i32 = bitcast<i32>(max(bitcast<u32>(i1), bitcast<u32>(i2)));)"))
EXPECT_THAT(body,
HasSubstr(R"(let x_1 = bitcast<i32>(max(bitcast<u32>(i1), bitcast<u32>(i2)));)"))
<< body;
EXPECT_THAT(
body,
HasSubstr(
R"(let x_2 : vec2i = bitcast<vec2i>(max(bitcast<vec2u>(v2i1), bitcast<vec2u>(v2i2)));)"))
HasSubstr(R"(let x_2 = bitcast<vec2i>(max(bitcast<vec2u>(v2i1), bitcast<vec2u>(v2i2)));)"))
<< body;
}
@ -991,14 +969,12 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMin) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(R"(let x_1 : i32 = bitcast<i32>(min(bitcast<u32>(i1), bitcast<u32>(i2)));)"))
EXPECT_THAT(body,
HasSubstr(R"(let x_1 = bitcast<i32>(min(bitcast<u32>(i1), bitcast<u32>(i2)));)"))
<< body;
EXPECT_THAT(
body,
HasSubstr(
R"(let x_2 : vec2i = bitcast<vec2i>(min(bitcast<vec2u>(v2i1), bitcast<vec2u>(v2i2)));)"))
HasSubstr(R"(let x_2 = bitcast<vec2i>(min(bitcast<vec2u>(v2i1), bitcast<vec2u>(v2i2)));)"))
<< body;
}
@ -1017,13 +993,12 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UClamp) {
auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(
body,
HasSubstr(
R"(let x_1 : i32 = bitcast<i32>(clamp(bitcast<u32>(i1), u2, bitcast<u32>(i3)));)"))
HasSubstr(R"(let x_1 = bitcast<i32>(clamp(bitcast<u32>(i1), u2, bitcast<u32>(i3)));)"))
<< body;
EXPECT_THAT(
body,
HasSubstr(
R"(let x_2 : vec2i = bitcast<vec2i>(clamp(bitcast<vec2u>(v2i1), v2u2, bitcast<vec2u>(v2i3)));)"))
R"(let x_2 = bitcast<vec2i>(clamp(bitcast<vec2u>(v2i1), v2u2, bitcast<vec2u>(v2i3)));)"))
<< body;
}
@ -1048,10 +1023,10 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_FindILsb) {
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr(R"(
let x_1 : u32 = bitcast<u32>(firstTrailingBit(i1));
let x_2 : vec2u = bitcast<vec2u>(firstTrailingBit(v2i1));
let x_3 : i32 = bitcast<i32>(firstTrailingBit(u1));
let x_4 : vec2i = bitcast<vec2i>(firstTrailingBit(v2u1));)"))
let x_1 = bitcast<u32>(firstTrailingBit(i1));
let x_2 = bitcast<vec2u>(firstTrailingBit(v2i1));
let x_3 = bitcast<i32>(firstTrailingBit(u1));
let x_4 = bitcast<vec2i>(firstTrailingBit(v2u1));)"))
<< body;
}
@ -1094,14 +1069,14 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_FindSMsb) {
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr(R"(
let x_1 : i32 = firstLeadingBit(i1);
let x_2 : vec2i = firstLeadingBit(v2i1);
let x_3 : u32 = bitcast<u32>(firstLeadingBit(i1));
let x_4 : vec2u = bitcast<vec2u>(firstLeadingBit(v2i1));
let x_5 : i32 = firstLeadingBit(bitcast<i32>(u1));
let x_6 : vec2i = firstLeadingBit(bitcast<vec2i>(v2u1));
let x_7 : u32 = bitcast<u32>(firstLeadingBit(bitcast<i32>(u1)));
let x_8 : vec2u = bitcast<vec2u>(firstLeadingBit(bitcast<vec2i>(v2u1)));
let x_1 = firstLeadingBit(i1);
let x_2 = firstLeadingBit(v2i1);
let x_3 = bitcast<u32>(firstLeadingBit(i1));
let x_4 = bitcast<vec2u>(firstLeadingBit(v2i1));
let x_5 = firstLeadingBit(bitcast<i32>(u1));
let x_6 = firstLeadingBit(bitcast<vec2i>(v2u1));
let x_7 = bitcast<u32>(firstLeadingBit(bitcast<i32>(u1)));
let x_8 = bitcast<vec2u>(firstLeadingBit(bitcast<vec2i>(v2u1)));
)")) << body;
}
@ -1144,14 +1119,14 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_FindUMsb) {
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr(R"(
let x_1 : i32 = bitcast<i32>(firstLeadingBit(bitcast<u32>(i1)));
let x_2 : vec2i = bitcast<vec2i>(firstLeadingBit(bitcast<vec2u>(v2i1)));
let x_3 : u32 = firstLeadingBit(bitcast<u32>(i1));
let x_4 : vec2u = firstLeadingBit(bitcast<vec2u>(v2i1));
let x_5 : i32 = bitcast<i32>(firstLeadingBit(u1));
let x_6 : vec2i = bitcast<vec2i>(firstLeadingBit(v2u1));
let x_7 : u32 = firstLeadingBit(u1);
let x_8 : vec2u = firstLeadingBit(v2u1);
let x_1 = bitcast<i32>(firstLeadingBit(bitcast<u32>(i1)));
let x_2 = bitcast<vec2i>(firstLeadingBit(bitcast<vec2u>(v2i1)));
let x_3 = firstLeadingBit(bitcast<u32>(i1));
let x_4 = firstLeadingBit(bitcast<vec2u>(v2i1));
let x_5 = bitcast<i32>(firstLeadingBit(u1));
let x_6 = bitcast<vec2i>(firstLeadingBit(v2u1));
let x_7 = firstLeadingBit(u1);
let x_8 = firstLeadingBit(v2u1);
)")) << body;
}
@ -1183,7 +1158,7 @@ TEST_P(SpvParserTest_GlslStd450_DataPacking, Valid) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body, HasSubstr("let x_1 : u32 = " + param.wgsl_func + "(v" +
EXPECT_THAT(body, HasSubstr("let x_1 = " + param.wgsl_func + "(v" +
std::to_string(param.vec_size) + "f1);"))
<< body;
}
@ -1214,11 +1189,7 @@ TEST_P(SpvParserTest_GlslStd450_DataUnpacking, Valid) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
EXPECT_THAT(body,
HasSubstr("let x_1 : " + std::string(param.vec_size == 2 ? "vec2f" : "vec4f") +
+" = " + param.wgsl_func + "(u1);"))
<< body;
EXPECT_THAT(body, HasSubstr("let x_1 = " + param.wgsl_func + "(u1);")) << body;
}
INSTANTIATE_TEST_SUITE_P(Samples,
@ -1242,7 +1213,7 @@ TEST_F(SpvParserTest, GlslStd450_Refract_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
const auto* expected = R"(let x_1 : f32 = refract(vec2f(f1, 0.0f), vec2f(f2, 0.0f), f3).x;)";
const auto* expected = R"(let x_1 = refract(vec2f(f1, 0.0f), vec2f(f2, 0.0f), f3).x;)";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1259,7 +1230,7 @@ TEST_F(SpvParserTest, GlslStd450_Refract_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
const auto* expected = R"(let x_1 : vec2f = refract(v2f1, v2f2, f3);)";
const auto* expected = R"(let x_1 = refract(v2f1, v2f2, f3);)";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1280,7 +1251,7 @@ TEST_F(SpvParserTest, GlslStd450_FaceForward_Scalar) {
// The %99 sum only has one use. Ensure it is evaluated only once by
// making a let-declaration for it, since it is the normal operand to
// the builtin function, and code generation uses it twice.
const auto* expected = R"(let x_1 : f32 = select(-(x_99), x_99, ((f2 * f3) < 0.0f));)";
const auto* expected = R"(let x_1 = select(-(x_99), x_99, ((f2 * f3) < 0.0f));)";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1298,7 +1269,7 @@ TEST_F(SpvParserTest, GlslStd450_FaceForward_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
const auto* expected = R"(let x_1 : vec2f = faceForward(v2f1, v2f2, v2f3);)";
const auto* expected = R"(let x_1 = faceForward(v2f1, v2f2, v2f3);)";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1320,7 +1291,7 @@ TEST_F(SpvParserTest, GlslStd450_Reflect_Scalar) {
// The %99 sum only has one use. Ensure it is evaluated only once by
// making a let-declaration for it, since it is the normal operand to
// the builtin function, and code generation uses it twice.
const auto* expected = R"(let x_1 : f32 = (x_98 - (2.0f * (x_99 * (x_99 * x_98))));)";
const auto* expected = R"(let x_1 = (x_98 - (2.0f * (x_99 * (x_99 * x_98))));)";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1340,9 +1311,9 @@ TEST_F(SpvParserTest, GlslStd450_Reflect_Vector) {
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
const auto* expected = R"(
let x_98 : vec2f = (v2f1 + v2f1);
let x_99 : vec2f = (v2f2 + v2f2);
let x_1 : vec2f = reflect(x_98, x_99);
let x_98 = (v2f1 + v2f1);
let x_99 = (v2f2 + v2f2);
let x_1 = reflect(x_98, x_99);
)";
EXPECT_THAT(body, HasSubstr(expected)) << body;
@ -1361,7 +1332,7 @@ TEST_F(SpvParserTest, GlslStd450_Ldexp_Scalar_Float_Uint) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
const auto* expected = "let x_1 : f32 = ldexp(f1, i32(u1));";
const auto* expected = "let x_1 = ldexp(f1, i32(u1));";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1378,7 +1349,7 @@ TEST_F(SpvParserTest, GlslStd450_Ldexp_Vector_Floatvec_Uintvec) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
const auto* expected = "let x_1 : vec2f = ldexp(v2f1, vec2i(v2u1));";
const auto* expected = "let x_1 = ldexp(v2f1, vec2i(v2u1));";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1397,7 +1368,7 @@ TEST_P(GlslStd450_Determinant, Test) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body = test::ToString(p->program(), ast_body);
std::string expected = "let x_1 : f32 = determinant(" + GetParam() + ");";
std::string expected = "let x_1 = determinant(" + GetParam() + ");";
EXPECT_THAT(body, HasSubstr(expected)) << body;
}
@ -1420,7 +1391,7 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_mat2x2) {
std::string expected =
"let s = (1.0f / determinant(m2x2f1));\n"
"let x_1 : mat2x2f = mat2x2f(vec2f((s * m2x2f1[1u][1u]), (-(s) * "
"let x_1 = mat2x2f(vec2f((s * m2x2f1[1u][1u]), (-(s) * "
"m2x2f1[0u][1u])), vec2f((-(s) * m2x2f1[1u][0u]), (s * m2x2f1[0u][0u])));";
EXPECT_THAT(body, HasSubstr(expected)) << body;
@ -1441,7 +1412,7 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_mat3x3) {
std::string expected =
"let s = (1.0f / determinant(m3x3f1));\n"
"let x_1 : mat3x3f = (s * mat3x3f(vec3f(((m3x3f1[1u][1u] * m3x3f1[2u][2u]) - "
"let x_1 = (s * mat3x3f(vec3f(((m3x3f1[1u][1u] * m3x3f1[2u][2u]) - "
"(m3x3f1[1u][2u] * m3x3f1[2u][1u])), ((m3x3f1[0u][2u] * m3x3f1[2u][1u]) - (m3x3f1[0u][1u] "
"* m3x3f1[2u][2u])), ((m3x3f1[0u][1u] * m3x3f1[1u][2u]) - (m3x3f1[0u][2u] * "
"m3x3f1[1u][1u]))), vec3f(((m3x3f1[1u][2u] * m3x3f1[2u][0u]) - (m3x3f1[1u][0u] * "
@ -1470,7 +1441,7 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_mat4x4) {
std::string expected =
"let s = (1.0f / determinant(m4x4f1));\n"
"let x_1 : mat4x4f = (s * mat4x4f(vec4f((((m4x4f1[1u][1u] * ((m4x4f1[2u][2u] * "
"let x_1 = (s * mat4x4f(vec4f((((m4x4f1[1u][1u] * ((m4x4f1[2u][2u] * "
"m4x4f1[3u][3u]) - (m4x4f1[2u][3u] * m4x4f1[3u][2u]))) - (m4x4f1[1u][2u] * "
"((m4x4f1[2u][1u] * m4x4f1[3u][3u]) - (m4x4f1[2u][3u] * m4x4f1[3u][1u])))) + "
"(m4x4f1[1u][3u] * ((m4x4f1[2u][1u] * m4x4f1[3u][2u]) - (m4x4f1[2u][2u] * "
@ -1551,10 +1522,10 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_MultipleInScope) {
std::string expected =
"let s = (1.0f / determinant(m2x2f1));\n"
"let x_1 : mat2x2f = mat2x2f(vec2f((s * m2x2f1[1u][1u]), (-(s) * "
"let x_1 = mat2x2f(vec2f((s * m2x2f1[1u][1u]), (-(s) * "
"m2x2f1[0u][1u])), vec2f((-(s) * m2x2f1[1u][0u]), (s * m2x2f1[0u][0u])));\n"
"let s_1 = (1.0f / determinant(m2x2f1));\n"
"let x_2 : mat2x2f = mat2x2f(vec2f((s_1 * m2x2f1[1u][1u]), (-(s_1) * "
"let x_2 = mat2x2f(vec2f((s_1 * m2x2f1[1u][1u]), (-(s_1) * "
"m2x2f1[0u][1u])), vec2f((-(s_1) * m2x2f1[1u][0u]), (s_1 * m2x2f1[0u][0u])));";
EXPECT_THAT(body, HasSubstr(expected)) << body;

View File

@ -136,7 +136,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : bool = !(true);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = !(true);"));
}
TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
@ -153,7 +153,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = !(vec2<bool>(true, false));"));
HasSubstr("let x_1 = !(vec2<bool>(true, false));"));
}
struct BinaryData {
@ -190,8 +190,8 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
utils::StringStream ss;
ss << "let x_1 : " << GetParam().ast_type << " = (" << GetParam().ast_lhs << " "
<< GetParam().ast_op << " " << GetParam().ast_rhs << ");";
ss << "let x_1 = (" << GetParam().ast_lhs << " " << GetParam().ast_op << " "
<< GetParam().ast_rhs << ");";
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(ss.str())) << assembly;
}
@ -516,7 +516,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = !((50.0f != 60.0f));"));
HasSubstr("let x_1 = !((50.0f != 60.0f));"));
}
TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
@ -532,9 +532,8 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = !((vec2f(50.0f, 60.0f) != vec2f(60.0f, 50.0f)));"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 = !((vec2f(50.0f, 60.0f) != vec2f(60.0f, 50.0f)));"));
}
TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
@ -551,7 +550,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = !((50.0f == 60.0f));"));
HasSubstr("let x_1 = !((50.0f == 60.0f));"));
}
TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
@ -567,9 +566,8 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = !((vec2f(50.0f, 60.0f) == vec2f(60.0f, 50.0f)));"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 = !((vec2f(50.0f, 60.0f) == vec2f(60.0f, 50.0f)));"));
}
TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
@ -586,7 +584,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = !((50.0f >= 60.0f));"));
HasSubstr("let x_1 = !((50.0f >= 60.0f));"));
}
TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
@ -602,9 +600,8 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = !((vec2f(50.0f, 60.0f) >= vec2f(60.0f, 50.0f)));"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 = !((vec2f(50.0f, 60.0f) >= vec2f(60.0f, 50.0f)));"));
}
TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
@ -620,8 +617,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = !((50.0f > 60.0f));"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = !((50.0f > 60.0f));"));
}
TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
@ -637,9 +633,8 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = !((vec2f(50.0f, 60.0f) > vec2f(60.0f, 50.0f)));"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 = !((vec2f(50.0f, 60.0f) > vec2f(60.0f, 50.0f)));"));
}
TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
@ -656,7 +651,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = !((50.0f <= 60.0f));"));
HasSubstr("let x_1 = !((50.0f <= 60.0f));"));
}
TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
@ -672,9 +667,8 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = !((vec2f(50.0f, 60.0f) <= vec2f(60.0f, 50.0f)));"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 = !((vec2f(50.0f, 60.0f) <= vec2f(60.0f, 50.0f)));"));
}
TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
@ -690,8 +684,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = !((50.0f < 60.0f));"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = !((50.0f < 60.0f));"));
}
TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
@ -707,9 +700,8 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(
test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = !((vec2f(50.0f, 60.0f) < vec2f(60.0f, 50.0f)));"));
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 = !((vec2f(50.0f, 60.0f) < vec2f(60.0f, 50.0f)));"));
}
using SpvLogicalTest = SpvParserTestBase<::testing::Test>;
@ -728,7 +720,7 @@ TEST_F(SpvLogicalTest, Select_BoolCond_BoolParams) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = select(false, true, true);"));
HasSubstr("let x_1 = select(false, true, true);"));
}
TEST_F(SpvLogicalTest, Select_BoolCond_IntScalarParams) {
@ -745,7 +737,7 @@ TEST_F(SpvLogicalTest, Select_BoolCond_IntScalarParams) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : u32 = select(20u, 10u, true);"));
HasSubstr("let x_1 = select(20u, 10u, true);"));
}
TEST_F(SpvLogicalTest, Select_BoolCond_FloatScalarParams) {
@ -762,7 +754,7 @@ TEST_F(SpvLogicalTest, Select_BoolCond_FloatScalarParams) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : f32 = select(60.0f, 50.0f, true);"));
HasSubstr("let x_1 = select(60.0f, 50.0f, true);"));
}
TEST_F(SpvLogicalTest, Select_BoolCond_VectorParams) {
@ -781,7 +773,7 @@ TEST_F(SpvLogicalTest, Select_BoolCond_VectorParams) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : vec2u = select("
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = select("
"vec2u(20u, 10u), "
"vec2u(10u, 20u), "
"true);"));
@ -806,7 +798,7 @@ TEST_F(SpvLogicalTest, Select_VecBoolCond_VectorParams) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : vec2u = select("
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = select("
"vec2u(20u, 10u), "
"vec2u(10u, 20u), "
"vec2<bool>(true, false));"));
@ -826,7 +818,7 @@ TEST_F(SpvLogicalTest, Any) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = any(vec2<bool>(true, false));"));
HasSubstr("let x_1 = any(vec2<bool>(true, false));"));
}
TEST_F(SpvLogicalTest, All) {
@ -843,7 +835,7 @@ TEST_F(SpvLogicalTest, All) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = all(vec2<bool>(true, false));"));
HasSubstr("let x_1 = all(vec2<bool>(true, false));"));
}
TEST_F(SpvLogicalTest, IsNan_Scalar) {
@ -859,8 +851,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = isNan(50.0f);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = isNan(50.0f);"));
}
TEST_F(SpvLogicalTest, IsNan_Vector) {
@ -877,7 +868,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = isNan(vec2f(50.0f, 60.0f));"));
HasSubstr("let x_1 = isNan(vec2f(50.0f, 60.0f));"));
}
TEST_F(SpvLogicalTest, IsInf_Scalar) {
@ -893,8 +884,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : bool = isInf(50.0f);"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 = isInf(50.0f);"));
}
TEST_F(SpvLogicalTest, IsInf_Vector) {
@ -911,7 +901,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_1 : vec2<bool> = isInf(vec2f(50.0f, 60.0f));"));
HasSubstr("let x_1 = isInf(vec2f(50.0f, 60.0f));"));
}
// TODO(dneto): Kernel-guarded instructions.

View File

@ -159,7 +159,7 @@ TEST_F(SpvParserMemoryTest, EmitStatement_LoadBool) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 : bool = x_1;"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_2 = x_1;"));
}
TEST_F(SpvParserMemoryTest, EmitStatement_LoadScalar) {
@ -181,8 +181,9 @@ TEST_F(SpvParserMemoryTest, EmitStatement_LoadScalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_2 : u32 = x_1;
let x_3 : u32 = x_1;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"( x_1 = 42u;
let x_2 = x_1;
let x_3 = x_1;
)"));
}
@ -206,7 +207,8 @@ TEST_F(SpvParserMemoryTest, EmitStatement_UseLoadedScalarTwice) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_2 : u32 = x_1;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"( x_1 = 42u;
let x_2 = x_1;
x_1 = x_2;
x_1 = x_2;
)"));
@ -802,7 +804,7 @@ TEST_F(SpvParserMemoryTest, EmitStatement_AccessChain_DereferenceBase) {
ASSERT_TRUE(p->BuildAndParseInternalModule());
const auto got = test::ToString(p->program());
const std::string expected = R"(fn x_200(x_1 : ptr<private, vec2u>) {
let x_3 : u32 = (*(x_1)).x;
let x_3 = (*(x_1)).x;
return;
}
@ -846,7 +848,7 @@ OpExecutionMode %main OriginUpperLeft
const auto got = test::ToString(p->program());
const std::string expected = R"(fn main_1() {
var x_1 : u32;
let x_2 : ptr<function, u32> = &(x_1);
let x_2 = &(x_1);
return;
}
@ -1018,11 +1020,11 @@ TEST_F(SpvParserMemoryTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded_Us
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(R"(let x_1 : ptr<storage, u32, read_write> = &(myvar.field0);
EXPECT_THAT(got, HasSubstr(R"(let x_1 = &(myvar.field0);
*(x_1) = 0u;
*(x_1) = 0u;
let x_2 : ptr<storage, u32, read_write> = &(myvar.field1[1u]);
let x_3 : u32 = *(x_2);
let x_2 = &(myvar.field1[1u]);
let x_3 = *(x_2);
*(x_2) = 0u;
)"));
}
@ -1054,11 +1056,11 @@ TEST_F(SpvParserMemoryTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded_Us
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(R"(let x_1 : ptr<storage, u32, read> = &(myvar.field0);
EXPECT_THAT(got, HasSubstr(R"(let x_1 = &(myvar.field0);
*(x_1) = 0u;
*(x_1) = 0u;
let x_2 : ptr<storage, u32, read> = &(myvar.field1[1u]);
let x_3 : u32 = *(x_2);
let x_2 = &(myvar.field1[1u]);
let x_3 = *(x_2);
*(x_2) = 0u;
)")) << got
<< assembly;
@ -1093,11 +1095,11 @@ TEST_F(SpvParserMemoryTest, StorageBuffer_ThroughAccessChain_NonCascaded_UsedTwi
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(R"(let x_1 : ptr<storage, u32, read_write> = &(myvar.field0);
EXPECT_THAT(got, HasSubstr(R"(let x_1 = &(myvar.field0);
*(x_1) = 0u;
*(x_1) = 0u;
let x_2 : ptr<storage, u32, read_write> = &(myvar.field1[1u]);
let x_3 : u32 = *(x_2);
let x_2 = &(myvar.field1[1u]);
let x_3 = *(x_2);
*(x_2) = 0u;
)")) << got;
}
@ -1133,11 +1135,11 @@ TEST_F(SpvParserMemoryTest, StorageBuffer_ThroughAccessChain_NonCascaded_UsedTwi
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(R"(let x_1 : ptr<storage, u32, read> = &(myvar.field0);
EXPECT_THAT(got, HasSubstr(R"(let x_1 = &(myvar.field0);
*(x_1) = 0u;
*(x_1) = 0u;
let x_2 : ptr<storage, u32, read> = &(myvar.field1[1u]);
let x_3 : u32 = *(x_2);
let x_2 = &(myvar.field1[1u]);
let x_3 = *(x_2);
*(x_2) = 0u;
)")) << got;
}
@ -1216,8 +1218,7 @@ TEST_F(SpvParserMemoryTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_2 : ptr<storage, u32, read_write> = &(myvar.field1[1u]);
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_2 = &(myvar.field1[1u]);
*(x_2) = 0u;
)")) << p->error();
@ -1275,7 +1276,7 @@ TEST_F(SpvParserMemoryTest, ArrayLength_FromVar) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr("let x_1 : u32 = arrayLength(&(myvar.rtarr));")) << body_str;
EXPECT_THAT(body_str, HasSubstr("let x_1 = arrayLength(&(myvar.rtarr));")) << body_str;
}
TEST_F(SpvParserMemoryTest, ArrayLength_FromCopyObject) {
@ -1295,8 +1296,8 @@ TEST_F(SpvParserMemoryTest, ArrayLength_FromCopyObject) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(let x_2 : ptr<storage, S, read_write> = &(myvar);
let x_1 : u32 = arrayLength(&((*(x_2)).rtarr));
EXPECT_THAT(body_str, HasSubstr(R"(let x_2 = &(myvar);
let x_1 = arrayLength(&((*(x_2)).rtarr));
)")) << body_str;
p->SkipDumpingPending("crbug.com/tint/1041 track access mode in spirv-reader parser type");
@ -1319,7 +1320,7 @@ TEST_F(SpvParserMemoryTest, ArrayLength_FromAccessChain) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
const auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr("let x_1 : u32 = arrayLength(&(myvar.rtarr));")) << body_str;
EXPECT_THAT(body_str, HasSubstr("let x_1 = arrayLength(&(myvar.rtarr));")) << body_str;
}
std::string InvalidPointerPreamble() {

View File

@ -72,10 +72,10 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 : bool = false;
let x_12 : u32 = 0u;
let x_13 : i32 = 0i;
let x_14 : f32 = 0.0f;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 = false;
let x_12 = 0u;
let x_13 = 0i;
let x_14 = 0.0f;
return;
)"));
}
@ -102,11 +102,10 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_BeforeFunction_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr(R"(let x_14 : vec2<bool> = vec2<bool>();
let x_11 : vec2u = vec2u();
let x_12 : vec2i = vec2i();
let x_13 : vec2f = vec2f();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_14 = vec2<bool>();
let x_11 = vec2u();
let x_12 = vec2i();
let x_13 = vec2f();
)"));
}
@ -131,10 +130,10 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 : bool = false;
let x_12 : u32 = 0u;
let x_13 : i32 = 0i;
let x_14 : f32 = 0.0f;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 = false;
let x_12 = 0u;
let x_13 = 0i;
let x_14 = 0.0f;
return;
)"));
}
@ -158,9 +157,9 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 : vec2u = vec2u();
let x_12 : vec2i = vec2i();
let x_13 : vec2f = vec2f();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(let x_11 = vec2u();
let x_12 = vec2i();
let x_13 = vec2f();
)"));
}
@ -181,8 +180,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_11 : mat2x2f = mat2x2f();"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_11 = mat2x2f();"));
}
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
@ -203,8 +201,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_11 : array<u32, 2u> = array<u32, 2u>();"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_11 = array<u32, 2u>();"));
}
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
@ -225,7 +222,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_11 : S = S(false, 0u, 0i, 0.0f);"));
HasSubstr("let x_11 = S(false, 0u, 0i, 0.0f);"));
}
TEST_F(SpvParserTestMiscInstruction, OpNop) {

View File

@ -181,11 +181,11 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ScalarInitializers) {
EXPECT_TRUE(fe.EmitFunctionVariables());
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(var a : bool = true;
var b : bool = false;
var c : i32 = -1i;
var d : u32 = 1u;
var e : f32 = 1.5f;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(var a = true;
var b = false;
var c = -1i;
var d = 1u;
var e = 1.5f;
)"));
}
@ -210,10 +210,10 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ScalarNullInitializers) {
EXPECT_TRUE(fe.EmitFunctionVariables());
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(var a : bool = false;
var b : i32 = 0i;
var c : u32 = 0u;
var d : f32 = 0.0f;
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr(R"(var a = false;
var b = 0i;
var c = 0u;
var d = 0.0f;
)"));
}
@ -235,7 +235,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_VectorInitializer) {
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("var x_200 : vec2f = vec2f(1.5f, 2.0f);"));
HasSubstr("var x_200 = vec2f(1.5f, 2.0f);"));
}
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_MatrixInitializer) {
@ -260,7 +260,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_MatrixInitializer) {
EXPECT_TRUE(fe.EmitFunctionVariables());
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("var x_200 : mat3x2f = mat3x2f("
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("var x_200 = mat3x2f("
"vec2f(1.5f, 2.0f), "
"vec2f(2.0f, 3.0f), "
"vec2f(3.0f, 4.0f));"));
@ -284,7 +284,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer) {
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("var x_200 : array<u32, 2u> = array<u32, 2u>(1u, 2u);"));
HasSubstr("var x_200 = array<u32, 2u>(1u, 2u);"));
}
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer_Alias) {
@ -311,7 +311,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer_Alias) {
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
const char* expect = "var x_200 : Arr = Arr(1u, 2u);\n";
const char* expect = "var x_200 = Arr(1u, 2u);\n";
EXPECT_EQ(expect, got);
}
@ -332,8 +332,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer_Null) {
EXPECT_TRUE(fe.EmitFunctionVariables());
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("var x_200 : array<u32, 2u> = array<u32, 2u>();"));
EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("var x_200 = array<u32, 2u>();"));
}
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
@ -360,7 +359,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer_Alias_Nu
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("var x_200 : Arr = @stride(16) array<u32, 2u>();"));
HasSubstr("var x_200 = @stride(16) array<u32, 2u>();"));
}
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_StructInitializer) {
@ -382,7 +381,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_StructInitializer) {
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("var x_200 : S = S(1u, 1.5f, array<u32, 2u>(1u, 2u));"));
HasSubstr("var x_200 = S(1u, 1.5f, array<u32, 2u>(1u, 2u));"));
}
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_StructInitializer_Null) {
@ -404,7 +403,7 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_StructInitializer_Null) {
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("var x_200 : S = S(0u, 0.0f, array<u32, 2u>());"));
HasSubstr("var x_200 = S(0u, 0.0f, array<u32, 2u>());"));
}
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_Decorate_RelaxedPrecision) {
@ -556,7 +555,7 @@ TEST_F(SpvParserFunctionVarTest, EmitStatement_CombinatorialValue_Immediate_Used
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var x_25 : u32;
let x_2 : u32 = (1u + 1u);
let x_2 = (1u + 1u);
x_25 = 1u;
x_25 = x_2;
x_25 = x_2;
@ -601,7 +600,7 @@ TEST_F(SpvParserFunctionVarTest,
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var x_25 : u32;
let x_2 : u32 = (1u + 1u);
let x_2 = (1u + 1u);
x_25 = 1u;
loop {
@ -740,10 +739,10 @@ TEST_F(SpvParserFunctionVarTest,
// a const definition.
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(let x_1 : u32 = 1u;
auto* expect = R"(let x_1 = 1u;
if (true) {
}
let x_3 : u32 = x_1;
let x_3 = x_1;
x_200 = x_3;
return;
)";
@ -801,10 +800,10 @@ TEST_F(SpvParserFunctionVarTest,
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(if (true) {
let x_1 : u32 = 1u;
let x_1 = 1u;
if (true) {
}
let x_3 : u32 = x_1;
let x_3 = x_1;
x_200 = x_3;
}
return;
@ -857,14 +856,14 @@ TEST_F(SpvParserFunctionVarTest,
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(if (true) {
let x_1 : u32 = 1u;
let x_1 = 1u;
switch(1u) {
case 0u: {
}
default: {
}
}
let x_3 : u32 = x_1;
let x_3 = x_1;
x_200 = x_3;
}
return;
@ -911,8 +910,8 @@ TEST_F(SpvParserFunctionVarTest,
// a const definition.
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(let x_1 : u32 = 1u;
let x_2 : u32 = x_1;
auto* expect = R"(let x_1 = 1u;
let x_2 = x_1;
if (true) {
}
return;
@ -1015,8 +1014,8 @@ TEST_F(SpvParserFunctionVarTest, EmitStatement_Phi_SingleBlockLoopIndex) {
auto* expect = R"(loop {
var x_2 : u32;
var x_3 : u32;
let x_101 : bool = x_7;
let x_102 : bool = x_8;
let x_101 = x_7;
let x_102 = x_8;
x_2 = 0u;
x_3 = 1u;
if (x_101) {
@ -1088,8 +1087,8 @@ TEST_F(SpvParserFunctionVarTest, EmitStatement_Phi_MultiBlockLoopIndex) {
auto* expect = R"(loop {
var x_2 : u32;
var x_3 : u32;
let x_101 : bool = x_7;
let x_102 : bool = x_8;
let x_101 = x_7;
let x_102 = x_8;
x_2 = 0u;
x_3 = 1u;
if (x_101) {
@ -1164,7 +1163,7 @@ TEST_F(SpvParserFunctionVarTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuin
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(let x_101 : bool = x_17;
auto* expect = R"(let x_101 = x_17;
loop {
var x_2 : u32;
var x_5 : u32;
@ -1182,7 +1181,7 @@ loop {
continuing {
x_7 = (x_4 + x_6);
let x_8 : u32 = x_5;
let x_8 = x_5;
x_2 = x_4;
x_5 = x_7;
}
@ -1244,8 +1243,8 @@ TEST_F(SpvParserFunctionVarTest, EmitStatement_Phi_FromElseAndThen) {
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(let x_101 : bool = x_7;
let x_102 : bool = x_8;
auto* expect = R"(let x_101 = x_7;
let x_102 = x_8;
loop {
var x_2 : u32;
if (x_101) {
@ -1317,8 +1316,8 @@ TEST_F(SpvParserFunctionVarTest, EmitStatement_Phi_FromHeaderAndThen) {
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(let x_101 : bool = x_7;
let x_102 : bool = x_8;
auto* expect = R"(let x_101 = x_7;
let x_102 = x_8;
loop {
var x_2 : u32;
if (x_101) {
@ -1380,13 +1379,13 @@ TEST_F(SpvParserFunctionVarTest, EmitStatement_Phi_UseInPhiCountsAsUse) {
auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var x_101 : bool;
let x_11 : bool = (true & true);
let x_12 : bool = !(x_11);
let x_11 = (true & true);
let x_12 = !(x_11);
x_101 = x_11;
if (true) {
x_101 = x_12;
}
let x_102 : bool = x_101;
let x_102 = x_101;
return;
)";
EXPECT_EQ(expect, got);
@ -1532,7 +1531,7 @@ loop {
x_101 = x_999;
}
}
let x_1000 : bool = x_101;
let x_1000 = x_101;
return;
)";
EXPECT_EQ(expect, got);
@ -1698,7 +1697,7 @@ loop {
x_101 = x_999;
}
}
let x_1000 : bool = x_101;
let x_1000 = x_101;
return;
)";
EXPECT_EQ(expect, got);
@ -1737,7 +1736,7 @@ if (true) {
} else {
return;
}
let x_201 : vec2i = x_200;
let x_201 = x_200;
return;
)";
auto ast_body = fe.ast_body();
@ -1780,7 +1779,7 @@ if (true) {
} else {
return;
}
let x_201 : vec2i = x_200;
let x_201 = x_200;
return;
)";
EXPECT_EQ(got, expected) << got;

View File

@ -1610,16 +1610,15 @@ const ast::Var* ParserImpl::MakeVar(uint32_t id,
return nullptr;
}
// Use type inference if there is an initializer.
auto sym = builder_.Symbols().Register(namer_.Name(id));
return builder_.Var(Source{}, sym, storage_type->Build(builder_), address_space, access,
initializer, std::move(attrs.list));
return builder_.Var(Source{}, sym, initializer ? ast::Type{} : storage_type->Build(builder_),
address_space, access, initializer, std::move(attrs.list));
}
const ast::Let* ParserImpl::MakeLet(uint32_t id,
const Type* type,
const ast::Expression* initializer) {
const ast::Let* ParserImpl::MakeLet(uint32_t id, const ast::Expression* initializer) {
auto sym = builder_.Symbols().Register(namer_.Name(id));
return builder_.Let(Source{}, sym, type->Build(builder_), initializer, utils::Empty);
return builder_.Let(Source{}, sym, initializer, utils::Empty);
}
const ast::Override* ParserImpl::MakeOverride(uint32_t id,

View File

@ -446,10 +446,9 @@ class ParserImpl : Reader {
/// Creates an AST 'let' node for a SPIR-V ID, including any attached decorations,.
/// @param id the SPIR-V result ID
/// @param type the type of the variable
/// @param initializer the variable initializer
/// @returns the AST 'let' node
const ast::Let* MakeLet(uint32_t id, const Type* type, const ast::Expression* initializer);
const ast::Let* MakeLet(uint32_t id, const ast::Expression* initializer);
/// Creates an AST 'override' node for a SPIR-V ID, including any attached decorations.
/// @param id the SPIR-V result ID

View File

@ -377,12 +377,12 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) {
}
fn branch() -> u32 {
let leaf_result : u32 = leaf();
let leaf_result = leaf();
return leaf_result;
}
fn root() {
let branch_result : u32 = branch();
let branch_result = branch();
return;
}
)")) << program_ast;

View File

@ -1827,8 +1827,31 @@ INSTANTIATE_TEST_SUITE_P(
@group(0) @binding(1) var x_30 : sampler_comparison;
)",
R"(
let x_200 : vec4f = vec4f(textureSample(x_20, x_10, coords12), 0.0f, 0.0f, 0.0f);
let x_210 : f32 = textureSampleCompare(x_20, x_30, coords12, 0.20000000298023223877f);
@group(2) @binding(1) var x_20 : texture_depth_2d;
@group(0) @binding(1) var x_30 : sampler_comparison;
fn main_1() {
let f1 = 1.0f;
let vf12 = vec2f(1.0f, 2.0f);
let vf21 = vec2f(2.0f, 1.0f);
let vf123 = vec3f(1.0f, 2.0f, 3.0f);
let vf1234 = vec4f(1.0f, 2.0f, 3.0f, 4.0f);
let i1 = 1i;
let vi12 = vec2i(1i, 2i);
let vi123 = vec3i(1i, 2i, 3i);
let vi1234 = vec4i(1i, 2i, 3i, 4i);
let u1 = 1u;
let vu12 = vec2u(1u, 2u);
let vu123 = vec3u(1u, 2u, 3u);
let vu1234 = vec4u(1u, 2u, 3u, 4u);
let coords1 = 1.0f;
let coords12 = vf12;
let coords123 = vf123;
let coords1234 = vf1234;
let x_200 = vec4f(textureSample(x_20, x_10, coords12), 0.0f, 0.0f, 0.0f);
let x_210 = textureSampleCompare(x_20, x_30, coords12, 0.20000000298023223877f);
)"}));
INSTANTIATE_TEST_SUITE_P(
@ -2649,20 +2672,20 @@ INSTANTIATE_TEST_SUITE_P(
// Level of detail is injected for sampled texture
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : vec4f = textureLoad(x_20, vi12, 0i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch with explicit level, on sampled texture
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : vec4f = textureLoad(x_20, vi12, 3i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 3i);)"},
// OpImageFetch with no extra params, on depth texture
// Level of detail is injected for depth texture
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
R"(let x_99 : vec4f = vec4f(textureLoad(x_20, vi12, 0i), 0.0f, 0.0f, 0.0f);)"},
R"(let x_99 = vec4f(textureLoad(x_20, vi12, 0i), 0.0f, 0.0f, 0.0f);)"},
// OpImageFetch with extra params, on depth texture
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
R"(let x_99 : vec4f = vec4f(textureLoad(x_20, vi12, 3i), 0.0f, 0.0f, 0.0f);)"}}));
R"(let x_99 = vec4f(textureLoad(x_20, vi12, 3i), 0.0f, 0.0f, 0.0f);)"}}));
INSTANTIATE_TEST_SUITE_P(
ImageFetch_Depth,
@ -2675,7 +2698,7 @@ INSTANTIATE_TEST_SUITE_P(
// ImageFetch on depth image.
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12 ",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
R"(let x_99 : vec4f = vec4f(textureLoad(x_20, vi12, 0i), 0.0f, 0.0f, 0.0f);)"}}));
R"(let x_99 = vec4f(textureLoad(x_20, vi12, 0i), 0.0f, 0.0f, 0.0f);)"}}));
INSTANTIATE_TEST_SUITE_P(
ImageFetch_DepthMultisampled,
@ -2688,7 +2711,7 @@ INSTANTIATE_TEST_SUITE_P(
// ImageFetch on multisampled depth image.
{"%float 2D 1 0 1 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12 Sample %i1",
R"(@group(2) @binding(1) var x_20 : texture_depth_multisampled_2d;)",
R"(let x_99 : vec4f = vec4f(textureLoad(x_20, vi12, i1), 0.0f, 0.0f, 0.0f);)"}}));
R"(let x_99 = vec4f(textureLoad(x_20, vi12, i1), 0.0f, 0.0f, 0.0f);)"}}));
INSTANTIATE_TEST_SUITE_P(ImageFetch_Multisampled,
SpvParserHandleTest_ImageAccessTest,
@ -2703,7 +2726,7 @@ INSTANTIATE_TEST_SUITE_P(ImageFetch_Multisampled,
{"%float 2D 0 0 1 1 Unknown",
"%99 = OpImageFetch %v4float %im %vi12 Sample %i1",
R"(@group(2) @binding(1) var x_20 : texture_multisampled_2d<f32>;)",
R"(let x_99 : vec4f = textureLoad(x_20, vi12, i1);)"}}));
R"(let x_99 = textureLoad(x_20, vi12, i1);)"}}));
INSTANTIATE_TEST_SUITE_P(ImageFetch_Multisampled_ConvertSampleOperand,
SpvParserHandleTest_ImageAccessTest,
@ -2711,7 +2734,7 @@ INSTANTIATE_TEST_SUITE_P(ImageFetch_Multisampled_ConvertSampleOperand,
{"%float 2D 0 0 1 1 Unknown",
"%99 = OpImageFetch %v4float %im %vi12 Sample %u1",
R"(@group(2) @binding(1) var x_20 : texture_multisampled_2d<f32>;)",
R"(let x_99 : vec4f = textureLoad(x_20, vi12, i32(u1));)"}}));
R"(let x_99 = textureLoad(x_20, vi12, i32(u1));)"}}));
INSTANTIATE_TEST_SUITE_P(ConvertResultSignedness,
SpvParserHandleTest_SampledImageAccessTest,
@ -2733,11 +2756,11 @@ INSTANTIATE_TEST_SUITE_P(ConvertResultSignedness,
// OpImageFetch requires no conversion, float -> v4float
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : vec4f = textureLoad(x_20, vi12, 0i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch requires no conversion, uint -> v4uint
{"%uint 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4uint %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<u32>;)",
R"(let x_99 : vec4u = textureLoad(x_20, vi12, 0i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch requires conversion, uint -> v4int
// is invalid SPIR-V:
// "Expected Image 'Sampled Type' to be the same as Result Type
@ -2746,7 +2769,7 @@ INSTANTIATE_TEST_SUITE_P(ConvertResultSignedness,
// OpImageFetch requires no conversion, int -> v4int
{"%int 2D 0 0 0 1 Unknown", "%99 = OpImageFetch %v4int %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<i32>;)",
R"(let x_99 : vec4i = textureLoad(x_20, vi12, 0i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 0i);)"},
// OpImageFetch requires conversion, int -> v4uint
// is invalid SPIR-V:
// "Expected Image 'Sampled Type' to be the same as Result Type
@ -2759,11 +2782,11 @@ INSTANTIATE_TEST_SUITE_P(ConvertResultSignedness,
// OpImageRead requires no conversion, float -> v4float
{"%float 2D 0 0 0 2 Rgba32f", "%99 = OpImageRead %v4float %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : vec4f = textureLoad(x_20, vi12, 0i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 0i);)"},
// OpImageRead requires no conversion, uint -> v4uint
{"%uint 2D 0 0 0 2 Rgba32ui", "%99 = OpImageRead %v4uint %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<u32>;)",
R"(let x_99 : vec4u = textureLoad(x_20, vi12, 0i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 0i);)"},
// OpImageRead requires conversion, uint -> v4int
// is invalid SPIR-V:
@ -2773,7 +2796,7 @@ INSTANTIATE_TEST_SUITE_P(ConvertResultSignedness,
// OpImageRead requires no conversion, int -> v4int
{"%int 2D 0 0 0 2 Rgba32i", "%99 = OpImageRead %v4int %im %vi12",
R"(@group(2) @binding(1) var x_20 : texture_2d<i32>;)",
R"(let x_99 : vec4i = textureLoad(x_20, vi12, 0i);)"},
R"(let x_99 = textureLoad(x_20, vi12, 0i);)"},
// OpImageRead requires conversion, int -> v4uint
// is invalid SPIR-V:
@ -2792,7 +2815,7 @@ INSTANTIATE_TEST_SUITE_P(ConvertResultSignedness,
R"(@group(0) @binding(0) var x_10 : sampler;
@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : vec4f = textureSample(x_20, x_10, vf12);)"}}));
R"(let x_99 = textureSample(x_20, x_10, vf12);)"}}));
INSTANTIATE_TEST_SUITE_P(ImageQuerySize_NonArrayed_SignedResult,
// ImageQuerySize requires storage image or multisampled
@ -2806,26 +2829,26 @@ INSTANTIATE_TEST_SUITE_P(ImageQuerySize_NonArrayed_SignedResult,
"%98 = OpImageRead %v4float %im %i1\n", // Implicitly mark as
// NonWritable
R"(@group(2) @binding(1) var x_20 : texture_1d<f32>;)",
R"(let x_99 : i32 = i32(textureDimensions(x_20));)"},
R"(let x_99 = i32(textureDimensions(x_20));)"},
// 2D storage image
{"%float 2D 0 0 0 2 Rgba32f",
"%99 = OpImageQuerySize %v2int %im \n"
"%98 = OpImageRead %v4float %im %vi12\n", // Implicitly mark as
// NonWritable
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : vec2i = vec2i(textureDimensions(x_20))"},
R"(let x_99 = vec2i(textureDimensions(x_20))"},
// 3D storage image
{"%float 3D 0 0 0 2 Rgba32f",
"%99 = OpImageQuerySize %v3int %im \n"
"%98 = OpImageRead %v4float %im %vi123\n", // Implicitly mark as
// NonWritable
R"(@group(2) @binding(1) var x_20 : texture_3d<f32>;)",
R"(let x_99 : vec3i = vec3i(textureDimensions(x_20));)"},
R"(let x_99 = vec3i(textureDimensions(x_20));)"},
// Multisampled
{"%float 2D 0 0 1 1 Unknown", "%99 = OpImageQuerySize %v2int %im \n",
R"(@group(2) @binding(1) var x_20 : texture_multisampled_2d<f32>;)",
R"(let x_99 : vec2i = vec2i(textureDimensions(x_20));)"}}));
R"(let x_99 = vec2i(textureDimensions(x_20));)"}}));
INSTANTIATE_TEST_SUITE_P(
ImageQuerySize_Arrayed_SignedResult,
@ -2841,7 +2864,7 @@ INSTANTIATE_TEST_SUITE_P(
"%99 = OpImageQuerySize %v3int %im \n"
"%98 = OpImageRead %v4float %im %vi123\n",
R"(@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
R"(let x_99 : vec3i = vec3i(vec3u(textureDimensions(x_20), textureNumLayers(x_20)));)"}
R"(let x_99 = vec3i(vec3u(textureDimensions(x_20), textureNumLayers(x_20)));)"}
// 3D array storage image doesn't exist.
// Multisampled array
@ -2857,32 +2880,32 @@ INSTANTIATE_TEST_SUITE_P(
// 1D
{"%float 1D 0 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_1d<f32>;)",
R"(let x_99 : i32 = i32(textureDimensions(x_20, i1)))"},
R"(let x_99 = i32(textureDimensions(x_20, i1)))"},
// 2D
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : vec2i = vec2i(textureDimensions(x_20, i1));)"},
R"(let x_99 = vec2i(textureDimensions(x_20, i1));)"},
// 3D
{"%float 3D 0 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %v3int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_3d<f32>;)",
R"(let x_99 : vec3i = vec3i(textureDimensions(x_20, i1));)"},
R"(let x_99 = vec3i(textureDimensions(x_20, i1));)"},
// Cube
{"%float Cube 0 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_cube<f32>;)",
R"(let x_99 : vec2i = vec2i(textureDimensions(x_20, i1).xy);)"},
R"(let x_99 = vec2i(textureDimensions(x_20, i1).xy);)"},
// Depth 2D
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
R"(let x_99 : vec2i = vec2i(textureDimensions(x_20, i1));)"},
R"(let x_99 = vec2i(textureDimensions(x_20, i1));)"},
// Depth Cube
{"%float Cube 1 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_cube;)",
R"(let x_99 : vec2i = vec2i(textureDimensions(x_20, i1).xy);)"}}));
R"(let x_99 = vec2i(textureDimensions(x_20, i1).xy);)"}}));
INSTANTIATE_TEST_SUITE_P(
ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel,
@ -2897,7 +2920,7 @@ INSTANTIATE_TEST_SUITE_P(
// 2D array
{"%float 2D 0 1 0 1 Unknown", "%99 = OpImageQuerySizeLod %v3int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
R"(let x_99 : vec3i = vec3i(vec3u(textureDimensions(x_20, i1), textureNumLayers(x_20)));)"},
R"(let x_99 = vec3i(vec3u(textureDimensions(x_20, i1), textureNumLayers(x_20)));)"},
// There is no 3D array
@ -2908,12 +2931,12 @@ INSTANTIATE_TEST_SUITE_P(
// https://github.com/gpuweb/gpuweb/issues/1345
{"%float Cube 0 1 0 1 Unknown", "%99 = OpImageQuerySizeLod %v3int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_cube_array<f32>;)",
R"(let x_99 : vec3i = vec3i(vec3u(textureDimensions(x_20, i1).xy, textureNumLayers(x_20)));)"},
R"(let x_99 = vec3i(vec3u(textureDimensions(x_20, i1).xy, textureNumLayers(x_20)));)"},
// Depth 2D array
{"%float 2D 1 1 0 1 Unknown", "%99 = OpImageQuerySizeLod %v3int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d_array;)",
R"(let x_99 : vec3i = vec3i(vec3u(textureDimensions(x_20, i1), textureNumLayers(x_20)));)"},
R"(let x_99 = vec3i(vec3u(textureDimensions(x_20, i1), textureNumLayers(x_20)));)"},
// Depth Cube Array
//
@ -2922,7 +2945,7 @@ INSTANTIATE_TEST_SUITE_P(
// https://github.com/gpuweb/gpuweb/issues/1345
{"%float Cube 1 1 0 1 Unknown", "%99 = OpImageQuerySizeLod %v3int %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_cube_array;)",
R"(let x_99 : vec3i = vec3i(vec3u(textureDimensions(x_20, i1).xy, textureNumLayers(x_20)));)"}}));
R"(let x_99 = vec3i(vec3u(textureDimensions(x_20, i1).xy, textureNumLayers(x_20)));)"}}));
INSTANTIATE_TEST_SUITE_P(
// textureDimensions accepts both signed and unsigned the level-of-detail values.
@ -2932,7 +2955,7 @@ INSTANTIATE_TEST_SUITE_P(
{"%float 1D 0 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %int %im %u1\n",
R"(@group(2) @binding(1) var x_20 : texture_1d<f32>;)",
R"(let x_99 : i32 = i32(textureDimensions(x_20, u1));)"}}));
R"(let x_99 = i32(textureDimensions(x_20, u1));)"}}));
INSTANTIATE_TEST_SUITE_P(
// When SPIR-V wants the result type to be unsigned, we have to
@ -2945,7 +2968,7 @@ INSTANTIATE_TEST_SUITE_P(
{"%float 1D 0 0 0 1 Unknown", "%99 = OpImageQuerySizeLod %uint %im %i1\n",
R"(@group(2) @binding(1) var x_20 : texture_1d<f32>;)",
R"(let x_99 : i32 = i32(textureDimensions(x_20, i1));)"}}));
R"(let x_99 = i32(textureDimensions(x_20, i1));)"}}));
INSTANTIATE_TEST_SUITE_P(ImageQueryLevels_SignedResult,
SpvParserHandleTest_SampledImageAccessTest,
@ -2958,47 +2981,47 @@ INSTANTIATE_TEST_SUITE_P(ImageQueryLevels_SignedResult,
// 2D
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// 2D array
{"%float 2D 0 1 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_2d_array<f32>;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// 3D
{"%float 3D 0 0 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_3d<f32>;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// Cube
{"%float Cube 0 0 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_cube<f32>;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// Cube array
{"%float Cube 0 1 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_cube_array<f32>;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// depth 2d
{"%float 2D 1 0 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// depth 2d array
{"%float 2D 1 1 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_2d_array;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// depth cube
{"%float Cube 1 0 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_cube;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"},
R"(let x_99 = i32(textureNumLevels(x_20));)"},
// depth cube array
{"%float Cube 1 1 0 1 Unknown", "%99 = OpImageQueryLevels %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_depth_cube_array;)",
R"(let x_99 : i32 = i32(textureNumLevels(x_20));)"}}));
R"(let x_99 = i32(textureNumLevels(x_20));)"}}));
INSTANTIATE_TEST_SUITE_P(
// Spot check that a value conversion is inserted when SPIR-V asks for an unsigned int result.
@ -3007,7 +3030,7 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(std::vector<ImageAccessCase>{
{"%float 2D 0 0 0 1 Unknown", "%99 = OpImageQueryLevels %uint %im\n",
R"(@group(2) @binding(1) var x_20 : texture_2d<f32>;)",
R"(let x_99 : u32 = textureNumLevels(x_20);)"}}));
R"(let x_99 = textureNumLevels(x_20);)"}}));
INSTANTIATE_TEST_SUITE_P(ImageQuerySamples_SignedResult,
SpvParserHandleTest_SampledImageAccessTest,
@ -3015,7 +3038,7 @@ INSTANTIATE_TEST_SUITE_P(ImageQuerySamples_SignedResult,
// Multsample 2D
{"%float 2D 0 0 1 1 Unknown", "%99 = OpImageQuerySamples %int %im\n",
R"(@group(2) @binding(1) var x_20 : texture_multisampled_2d<f32>;)",
R"(let x_99 : i32 = i32(textureNumSamples(x_20));)"}
R"(let x_99 = i32(textureNumSamples(x_20));)"}
// Multisample 2D array
// Not in WebGPU
@ -3029,7 +3052,7 @@ INSTANTIATE_TEST_SUITE_P(
// Multisample 2D
{"%float 2D 0 0 1 1 Unknown", "%99 = OpImageQuerySamples %uint %im\n",
R"(@group(2) @binding(1) var x_20 : texture_multisampled_2d<f32>;)",
R"(let x_99 : u32 = textureNumSamples(x_20);)"}
R"(let x_99 = textureNumSamples(x_20);)"}
// Multisample 2D array
// Not in WebGPU
@ -3815,8 +3838,8 @@ TEST_F(SpvParserHandleTest, NeverGenerateConstDeclForHandle_UseVariableDirectly)
auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body);
auto* expect = R"(var var_1 : vec4f;
let x_22 : vec4f = textureSample(x_2, x_3, vec2f());
let x_26 : vec4f = textureSample(x_2, x_3, vec2f());
let x_22 = textureSample(x_2, x_3, vec2f());
let x_26 = textureSample(x_2, x_3, vec2f());
var_1 = (x_22 + x_26);
return;
)";
@ -3890,7 +3913,7 @@ TEST_F(SpvParserHandleTest, SamplerLoadedInEnclosingConstruct_DontGenerateVar) {
auto* expect = R"(switch(0i) {
default: {
if (true) {
let x_24 : vec4f = textureSample(var_im, var_s, vec2f());
let x_24 = textureSample(var_im, var_s, vec2f());
}
}
}
@ -3977,7 +4000,7 @@ OpFunctionEnd
x_900 = 0.0f;
if (true) {
if (true) {
let x_18 : vec4f = textureSample(x_20, x_10, x_900);
let x_18 = textureSample(x_20, x_10, x_900);
}
}
return;
@ -4064,7 +4087,7 @@ OpFunctionEnd
x_900 = vec2f();
if (true) {
if (true) {
let x_19 : vec4f = textureSample(x_20, x_10, x_900.x);
let x_19 = textureSample(x_20, x_10, x_900.x);
}
}
return;
@ -4226,7 +4249,7 @@ loop {
x_15 = x_17;
}
}
let x_21 : f32 = select(0.0f, x_14, (x_14 > 1.0f));
let x_21 = select(0.0f, x_14, (x_14 > 1.0f));
x_1 = vec4f(x_21, x_21, x_21, x_21);
return;
)";

View File

@ -881,15 +881,15 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarInitializers) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 : bool = true;
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 = true;
var<private> x_2 : bool = false;
var<private> x_2 = false;
var<private> x_3 : i32 = -1i;
var<private> x_3 = -1i;
var<private> x_4 : u32 = 1u;
var<private> x_4 = 1u;
var<private> x_5 : f32 = 1.5f;
var<private> x_5 = 1.5f;
)"));
}
@ -908,13 +908,13 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarNullInitializers) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 : bool = false;
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 = false;
var<private> x_2 : i32 = 0i;
var<private> x_2 = 0i;
var<private> x_3 : u32 = 0u;
var<private> x_3 = 0u;
var<private> x_4 : f32 = 0.0f;
var<private> x_4 = 0.0f;
)"));
}
@ -933,13 +933,13 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarUndefInitializers) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 : bool = false;
EXPECT_THAT(module_str, HasSubstr(R"(var<private> x_1 = false;
var<private> x_2 : i32 = 0i;
var<private> x_2 = 0i;
var<private> x_3 : u32 = 0u;
var<private> x_3 = 0u;
var<private> x_4 : f32 = 0.0f;
var<private> x_4 = 0.0f;
)"));
// This example module emits ok, but is not valid SPIR-V in the first place.
@ -956,7 +956,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2f = vec2f(1.5f, 2.0f);"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2f(1.5f, 2.0f);"));
}
TEST_F(SpvModuleScopeVarParserTest, VectorBoolNullInitializer) {
@ -968,7 +968,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorBoolNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2<bool> = vec2<bool>();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2<bool>();"));
}
TEST_F(SpvModuleScopeVarParserTest, VectorBoolUndefInitializer) {
@ -980,7 +980,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorBoolUndefInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2<bool> = vec2<bool>();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2<bool>();"));
// This example module emits ok, but is not valid SPIR-V in the first place.
p->DeliberatelyInvalidSpirv();
@ -995,7 +995,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorUintNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2u = vec2u();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2u();"));
}
TEST_F(SpvModuleScopeVarParserTest, VectorUintUndefInitializer) {
@ -1007,7 +1007,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorUintUndefInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2u = vec2u();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2u();"));
// This example module emits ok, but is not valid SPIR-V in the first place.
p->DeliberatelyInvalidSpirv();
@ -1022,7 +1022,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorIntNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2i = vec2i();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2i();"));
}
TEST_F(SpvModuleScopeVarParserTest, VectorIntUndefInitializer) {
@ -1034,7 +1034,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorIntUndefInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2i = vec2i();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2i();"));
// This example module emits ok, but is not valid SPIR-V in the first place.
p->DeliberatelyInvalidSpirv();
@ -1049,7 +1049,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorFloatNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2f = vec2f();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2f();"));
}
TEST_F(SpvModuleScopeVarParserTest, VectorFloatUndefInitializer) {
@ -1061,7 +1061,7 @@ TEST_F(SpvModuleScopeVarParserTest, VectorFloatUndefInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : vec2f = vec2f();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = vec2f();"));
// This example module emits ok, but is not valid SPIR-V in the first place.
p->DeliberatelyInvalidSpirv();
@ -1082,7 +1082,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2f = mat3x2f("
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = mat3x2f("
"vec2f(1.5f, 2.0f), "
"vec2f(2.0f, 3.0f), "
"vec2f(3.0f, 4.0f));"));
@ -1097,7 +1097,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2f = mat3x2f();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = mat3x2f();"));
}
TEST_F(SpvModuleScopeVarParserTest, MatrixUndefInitializer) {
@ -1109,7 +1109,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixUndefInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2f = mat3x2f();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = mat3x2f();"));
// This example module emits ok, but is not valid SPIR-V in the first place.
p->DeliberatelyInvalidSpirv();
@ -1125,8 +1125,7 @@ TEST_F(SpvModuleScopeVarParserTest, ArrayInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str,
HasSubstr("var<private> x_200 : array<u32, 2u> = array<u32, 2u>(1u, 2u);"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = array<u32, 2u>(1u, 2u);"));
}
TEST_F(SpvModuleScopeVarParserTest, ArrayNullInitializer) {
@ -1138,7 +1137,7 @@ TEST_F(SpvModuleScopeVarParserTest, ArrayNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : array<u32, 2u> = array<u32, 2u>();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = array<u32, 2u>();"));
}
TEST_F(SpvModuleScopeVarParserTest, ArrayUndefInitializer) {
@ -1150,7 +1149,7 @@ TEST_F(SpvModuleScopeVarParserTest, ArrayUndefInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : array<u32, 2u> = array<u32, 2u>();"));
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = array<u32, 2u>();"));
// This example module emits ok, but is not valid SPIR-V in the first place.
p->DeliberatelyInvalidSpirv();
@ -1167,8 +1166,7 @@ TEST_F(SpvModuleScopeVarParserTest, StructInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str,
HasSubstr("var<private> x_200 : S = S(1u, 1.5f, array<u32, 2u>(1u, 2u));"))
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = S(1u, 1.5f, array<u32, 2u>(1u, 2u));"))
<< module_str;
}
@ -1181,7 +1179,7 @@ TEST_F(SpvModuleScopeVarParserTest, StructNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : S = S(0u, 0.0f, array<u32, 2u>());"))
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = S(0u, 0.0f, array<u32, 2u>());"))
<< module_str;
}
@ -1195,7 +1193,7 @@ TEST_F(SpvModuleScopeVarParserTest, StructUndefInitializer) {
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : S = S(0u, 0.0f, array<u32, 2u>());"))
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 = S(0u, 0.0f, array<u32, 2u>());"))
<< module_str;
// This example module emits ok, but is not valid SPIR-V in the first place.
@ -1660,7 +1658,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleId_I32_Load_Direct) {
R"(var<private> x_1 : i32;
fn main_1() {
let x_2 : i32 = x_1;
let x_2 = x_1;
return;
}
@ -1773,7 +1771,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleId_I32_Load_AccessChain) {
const std::string expected = R"(var<private> x_1 : i32;
fn main_1() {
let x_2 : i32 = x_1;
let x_2 = x_1;
return;
}
@ -1826,7 +1824,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleId_U32_Load_Direct) {
const std::string expected = R"(var<private> x_1 : u32;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
return;
}
@ -1855,8 +1853,8 @@ TEST_F(SpvModuleScopeVarParserTest, SampleId_U32_Load_CopyObject) {
const std::string expected = R"(var<private> x_1 : u32;
fn main_1() {
let x_11 : ptr<private, u32> = &(x_1);
let x_2 : u32 = *(x_11);
let x_11 = &(x_1);
let x_2 = *(x_11);
return;
}
@ -1885,7 +1883,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleId_U32_Load_AccessChain) {
const std::string expected = R"(var<private> x_1 : u32;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
return;
}
@ -1999,7 +1997,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleMask_In_U32_Direct) {
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
let x_3 : u32 = x_1[0i];
let x_3 = x_1[0i];
return;
}
@ -2031,7 +2029,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleMask_In_U32_CopyObject) {
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
let x_4 : u32 = x_1[0i];
let x_4 = x_1[0i];
return;
}
@ -2063,7 +2061,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleMask_In_U32_AccessChain) {
const std::string expected = R"(var<private> x_1 : array<u32, 1u>;
fn main_1() {
let x_4 : u32 = x_1[0i];
let x_4 = x_1[0i];
return;
}
@ -2094,7 +2092,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleMask_In_I32_Direct) {
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
let x_3 : i32 = x_1[0i];
let x_3 = x_1[0i];
return;
}
@ -2126,7 +2124,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleMask_In_I32_CopyObject) {
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
let x_4 : i32 = x_1[0i];
let x_4 = x_1[0i];
return;
}
@ -2158,7 +2156,7 @@ TEST_F(SpvModuleScopeVarParserTest, SampleMask_In_I32_AccessChain) {
const std::string expected = R"(var<private> x_1 : array<i32, 1u>;
fn main_1() {
let x_4 : i32 = x_1[0i];
let x_4 = x_1[0i];
return;
}
@ -2435,7 +2433,7 @@ alias Arr_3 = @stride(4) array<i32, 2u>;
var<private> x_1 : Arr;
fn main_1() {
let x_3 : u32 = x_1[0i];
let x_3 = x_1[0i];
return;
}
@ -2532,7 +2530,7 @@ TEST_F(SpvModuleScopeVarParserTest, VertexIndex_I32_Load_Direct) {
var<private> x_4 : vec4f;
fn main_1() {
let x_2 : i32 = x_1;
let x_2 = x_1;
return;
}
@ -2589,9 +2587,9 @@ TEST_F(SpvModuleScopeVarParserTest, VertexIndex_UsedTwice_DifferentConstructs) {
var<private> x_5 : vec4f;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
if (true) {
let x_3 : u32 = x_1;
let x_3 = x_1;
if (true) {
}
}
@ -2631,8 +2629,8 @@ TEST_F(SpvModuleScopeVarParserTest, VertexIndex_I32_Load_CopyObject) {
var<private> x_4 : vec4f;
fn main_1() {
let x_14 : ptr<private, i32> = &(x_1);
let x_2 : i32 = *(x_14);
let x_14 = &(x_1);
let x_2 = *(x_14);
return;
}
@ -2669,7 +2667,7 @@ TEST_F(SpvModuleScopeVarParserTest, VertexIndex_I32_Load_AccessChain) {
var<private> x_4 : vec4f;
fn main_1() {
let x_2 : i32 = x_1;
let x_2 = x_1;
return;
}
@ -2705,7 +2703,7 @@ TEST_F(SpvModuleScopeVarParserTest, VertexIndex_U32_Load_Direct) {
var<private> x_4 : vec4f;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
return;
}
@ -2742,8 +2740,8 @@ TEST_F(SpvModuleScopeVarParserTest, VertexIndex_U32_Load_CopyObject) {
var<private> x_4 : vec4f;
fn main_1() {
let x_14 : ptr<private, u32> = &(x_1);
let x_2 : u32 = *(x_14);
let x_14 = &(x_1);
let x_2 = *(x_14);
return;
}
@ -2780,7 +2778,7 @@ TEST_F(SpvModuleScopeVarParserTest, VertexIndex_U32_Load_AccessChain) {
var<private> x_4 : vec4f;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
return;
}
@ -2864,7 +2862,7 @@ TEST_F(SpvModuleScopeVarParserTest, InstanceIndex_I32_Load_Direct) {
var<private> position_1 : vec4f;
fn main_1() {
let x_2 : i32 = x_1;
let x_2 = x_1;
return;
}
@ -2901,8 +2899,8 @@ TEST_F(SpvModuleScopeVarParserTest, InstanceIndex_I32_Load_CopyObject) {
var<private> position_1 : vec4f;
fn main_1() {
let x_14 : ptr<private, i32> = &(x_1);
let x_2 : i32 = *(x_14);
let x_14 = &(x_1);
let x_2 = *(x_14);
return;
}
@ -2939,7 +2937,7 @@ TEST_F(SpvModuleScopeVarParserTest, InstanceIndex_I32_Load_AccessChain) {
var<private> position_1 : vec4f;
fn main_1() {
let x_2 : i32 = x_1;
let x_2 = x_1;
return;
}
@ -2998,7 +2996,7 @@ TEST_F(SpvModuleScopeVarParserTest, InstanceIndex_U32_Load_Direct) {
var<private> position_1 : vec4f;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
return;
}
@ -3035,8 +3033,8 @@ TEST_F(SpvModuleScopeVarParserTest, InstanceIndex_U32_Load_CopyObject) {
var<private> position_1 : vec4f;
fn main_1() {
let x_14 : ptr<private, u32> = &(x_1);
let x_2 : u32 = *(x_14);
let x_14 = &(x_1);
let x_2 = *(x_14);
return;
}
@ -3073,7 +3071,7 @@ TEST_F(SpvModuleScopeVarParserTest, InstanceIndex_U32_Load_AccessChain) {
var<private> position_1 : vec4f;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
return;
}
@ -3230,7 +3228,7 @@ TEST_P(SpvModuleScopeVarParserTest_ComputeBuiltin, Load_Direct) {
std::string expected = R"(var<private> x_1 : ${wgsl_type};
fn main_1() {
let x_2 : ${wgsl_type} = x_1;
let x_2 = x_1;
return;
}
@ -3275,8 +3273,8 @@ TEST_P(SpvModuleScopeVarParserTest_ComputeBuiltin, Load_CopyObject) {
std::string expected = R"(var<private> x_1 : ${wgsl_type};
fn main_1() {
let x_13 : ptr<private, ${wgsl_type}> = &(x_1);
let x_2 : ${wgsl_type} = *(x_13);
let x_13 = &(x_1);
let x_2 = *(x_13);
return;
}
@ -3321,7 +3319,7 @@ TEST_P(SpvModuleScopeVarParserTest_ComputeBuiltin, Load_AccessChain) {
std::string expected = R"(var<private> x_1 : ${wgsl_type};
fn main_1() {
let x_2 : ${wgsl_type} = x_1;
let x_2 = x_1;
return;
}
@ -3396,7 +3394,7 @@ TEST_P(SpvModuleScopeVarParserTest_ComputeBuiltinVector, Load_Component_Direct)
std::string expected = R"(var<private> x_1 : ${wgsl_type};
fn main_1() {
let x_2 : ${wgsl_component_type} = x_1.y;
let x_2 = x_1.y;
return;
}
@ -3582,7 +3580,7 @@ TEST_F(SpvModuleScopeVarParserTest, OutputVarsConvertedToPrivate_WithInitializer
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program());
const std::string expected = "var<private> x_1 : u32 = 1u;";
const std::string expected = "var<private> x_1 = 1u;";
EXPECT_THAT(got, HasSubstr(expected)) << got;
}
@ -3602,7 +3600,7 @@ TEST_F(SpvModuleScopeVarParserTest, Builtin_Output_Initializer_SameSignednessAsW
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program());
const std::string expected = "var<private> x_1 : array<u32, 1u> = array<u32, 1u>(2u);";
const std::string expected = "var<private> x_1 = array<u32, 1u>(2u);";
EXPECT_THAT(got, HasSubstr(expected)) << got;
}
@ -3622,7 +3620,7 @@ TEST_F(SpvModuleScopeVarParserTest, Builtin_Output_Initializer_OppositeSignednes
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program());
const std::string expected = "var<private> x_1 : array<i32, 1u> = array<i32, 1u>(14i);";
const std::string expected = "var<private> x_1 = array<i32, 1u>(14i);";
EXPECT_THAT(got, HasSubstr(expected)) << got;
}
@ -3749,7 +3747,7 @@ TEST_F(SpvModuleScopeVarParserTest, EntryPointWrapping_BuiltinVar_Input_SameSign
var<private> x_4 : vec4f;
fn main_1() {
let x_2 : u32 = x_1;
let x_2 = x_1;
return;
}
@ -3798,7 +3796,7 @@ TEST_F(SpvModuleScopeVarParserTest, EntryPointWrapping_BuiltinVar_Input_Opposite
var<private> x_4 : vec4f;
fn main_1() {
let x_2 : i32 = x_1;
let x_2 = x_1;
return;
}
@ -3920,7 +3918,7 @@ TEST_F(SpvModuleScopeVarParserTest,
EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program());
const std::string expected =
R"(var<private> x_1 : array<u32, 1u> = array<u32, 1u>();
R"(var<private> x_1 = array<u32, 1u>();
fn main_1() {
return;
@ -3966,7 +3964,7 @@ TEST_F(SpvModuleScopeVarParserTest,
EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program());
const std::string expected =
R"(var<private> x_1 : array<i32, 1u> = array<i32, 1u>();
R"(var<private> x_1 = array<i32, 1u>();
fn main_1() {
return;
@ -4009,7 +4007,7 @@ TEST_F(SpvModuleScopeVarParserTest, EntryPointWrapping_BuiltinVar_FragDepth_Out_
ASSERT_TRUE(p->Parse()) << p->error() << assembly;
EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program());
const std::string expected = R"(var<private> x_1 : f32 = 0.0f;
const std::string expected = R"(var<private> x_1 = 0.0f;
fn main_1() {
return;
@ -4112,7 +4110,7 @@ TEST_F(SpvModuleScopeVarParserTest, BuiltinPosition_BuiltIn_Position_Initializer
const auto got = test::ToString(p->program());
const std::string expected =
R"(var<private> gl_Position : vec4f = vec4f(1.0f, 2.0f, 3.0f, 4.0f);
R"(var<private> gl_Position = vec4f(1.0f, 2.0f, 3.0f, 4.0f);
fn main_1() {
return;

View File

@ -1,5 +1,5 @@
fn main_1() {
let x_24 : f32 = mat3x3f(vec3f(1.0f, 2.0f, 3.0f), vec3f(4.0f, 5.0f, 6.0f), vec3f(7.0f, 8.0f, 9.0f))[1u].y;
let x_24 = mat3x3f(vec3f(1.0f, 2.0f, 3.0f), vec3f(4.0f, 5.0f, 6.0f), vec3f(7.0f, 8.0f, 9.0f))[1u].y;
return;
}

View File

@ -1,9 +1,9 @@
const x_10 = vec3f(1.0f, 2.0f, 3.0f);
fn main_1() {
let x_11 : f32 = x_10.y;
let x_13 : vec2f = vec2f(x_10.x, x_10.z);
let x_14 : vec3f = vec3f(x_10.x, x_10.z, x_10.y);
let x_11 = x_10.y;
let x_13 = vec2f(x_10.x, x_10.z);
let x_14 = vec3f(x_10.x, x_10.z, x_10.y);
return;
}

View File

@ -1,7 +1,7 @@
fn main_1() {
var m : mat3x3f = mat3x3f();
let x_15 : vec3f = m[1i];
let x_16 : f32 = x_15.y;
var m = mat3x3f();
let x_15 = m[1i];
let x_16 = x_15.y;
return;
}

View File

@ -1,10 +1,10 @@
fn main_1() {
var v : vec3f = vec3f();
let x_14 : f32 = v.y;
let x_16 : vec3f = v;
let x_17 : vec2f = vec2f(x_16.x, x_16.z);
let x_18 : vec3f = v;
let x_19 : vec3f = vec3f(x_18.x, x_18.z, x_18.y);
var v = vec3f();
let x_14 = v.y;
let x_16 = v;
let x_17 = vec2f(x_16.x, x_16.z);
let x_18 = v;
let x_19 = vec3f(x_18.x, x_18.z, x_18.y);
return;
}

View File

@ -22,10 +22,10 @@ struct S {
@group(0) @binding(0) var<storage, read_write> s : S;
fn f_1() {
let x_19 : Arr_2 = s.a;
let x_24 : Arr_1 = s.a[3i].el;
let x_28 : Arr = s.a[3i].el[2i];
let x_32 : f32 = s.a[3i].el[2i][1i].el;
let x_19 = s.a;
let x_24 = s.a[3i].el;
let x_28 = s.a[3i].el[2i];
let x_32 = s.a[3i].el[2i][1i].el;
s.a = array<strided_arr_1, 4u>();
s.a[3i].el[2i][1i].el = 5.0f;
return;

View File

@ -34,7 +34,7 @@ const x_72 = vec4f(0.0f, 0.0f, 0.0f, 0.0f);
const x_73 = mat4x4f(x_72, x_72, x_72, x_72);
var<private> x_75 : array<mat4x4f, 58u> = array<mat4x4f, 58u>(x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73);
var<private> x_75 = array<mat4x4f, 58u>(x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73);
const x_77 = vec3f(0.0f, 0.0f, 0.0f);
@ -42,12 +42,12 @@ const x_78 = array<vec3f, 18u>(x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x
const x_80 = S_6(array<array<vec3f, 18u>, 13u>(x_78, x_78, x_78, x_78, x_78, x_78, x_78, x_78, x_78, x_78, x_78, x_78, x_78));
var<private> x_82 : array<S_6, 46u> = array<S_6, 46u>(x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80);
var<private> x_82 = array<S_6, 46u>(x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80, x_80);
var<private> x_85 : array<vec3f, 37u> = array<vec3f, 37u>(x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77);
var<private> x_85 = array<vec3f, 37u>(x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77, x_77);
fn main_1() {
let x_88 : u32 = 58u;
let x_88 = 58u;
return;
}

View File

@ -11,13 +11,13 @@ fn main_1() {
var f : f32;
var v : vec4f;
f = determinant(mat3x3f(vec3f(1.0f, 0.0f, 0.0f), vec3f(0.0f, 1.0f, 0.0f), vec3f(0.0f, 0.0f, 1.0f)));
let x_33 : f32 = f;
let x_35 : f32 = f;
let x_37 : f32 = f;
let x_39 : f32 = f;
let x_33 = f;
let x_35 = f;
let x_37 = f;
let x_39 = f;
v = vec4f(sin(x_33), cos(x_35), exp2(x_37), log(x_39));
let x_42 : vec4f = v;
let x_44 : vec4f = x_7.r;
let x_42 = v;
let x_44 = x_7.r;
if ((distance(x_42, x_44) < 0.10000000149011611938f)) {
x_GLF_color = vec4f(1.0f, 0.0f, 0.0f, 1.0f);
} else {

View File

@ -33,24 +33,24 @@ var<private> gl_Position : vec4f;
fn main_1() {
var q : vec4f;
var p : vec3f;
let x_13 : vec3f = position_1;
let x_13 = position_1;
q = vec4f(x_13.x, x_13.y, x_13.z, 1.0f);
let x_21 : vec4f = q;
let x_21 = q;
p = vec3f(x_21.x, x_21.y, x_21.z);
let x_27 : f32 = p.x;
let x_41 : f32 = x_14.test[0i].el;
let x_45 : f32 = position_1.y;
let x_49 : f32 = x_14.time;
let x_27 = p.x;
let x_41 = x_14.test[0i].el;
let x_45 = position_1.y;
let x_49 = x_14.time;
p.x = (x_27 + sin(((x_41 * x_45) + x_49)));
let x_55 : f32 = p.y;
let x_57 : f32 = x_14.time;
let x_55 = p.y;
let x_57 = x_14.time;
p.y = (x_55 + sin((x_57 + 4.0f)));
let x_69 : mat4x4f = x_14.worldViewProjection;
let x_70 : vec3f = p;
let x_69 = x_14.worldViewProjection;
let x_70 = p;
gl_Position = (x_69 * vec4f(x_70.x, x_70.y, x_70.z, 1.0f));
let x_83 : vec2f = uv;
let x_83 = uv;
vUV = x_83;
let x_87 : f32 = gl_Position.y;
let x_87 = gl_Position.y;
gl_Position.y = (x_87 * -1.0f);
return;
}

View File

@ -35,8 +35,8 @@ fn test_int_S1_c0_b() -> bool {
var x_55 : bool;
var x_65 : bool;
var x_66 : bool;
let x_26 : f32 = x_4.unknownInput_S1_c0;
let x_27 : i32 = i32(x_26);
let x_26 = x_4.unknownInput_S1_c0;
let x_27 = i32(x_26);
unknown = x_27;
ok = true;
x_41 = false;
@ -45,15 +45,15 @@ fn test_int_S1_c0_b() -> bool {
x_41 = x_40;
}
ok = x_41;
let x_44 : vec4i = vec4i(x_27, x_27, x_27, x_27);
let x_44 = vec4i(x_27, x_27, x_27, x_27);
val = x_44;
let x_47 : vec4i = (x_44 + x_46);
let x_47 = (x_44 + x_46);
val = x_47;
let x_48 : vec4i = (x_47 - x_46);
let x_48 = (x_47 - x_46);
val = x_48;
let x_49 : vec4i = (x_48 + x_46);
let x_49 = (x_48 + x_46);
val = x_49;
let x_50 : vec4i = (x_49 - x_46);
let x_50 = (x_49 - x_46);
val = x_50;
x_55 = false;
if (x_41) {
@ -61,13 +61,13 @@ fn test_int_S1_c0_b() -> bool {
x_55 = x_54;
}
ok = x_55;
let x_58 : vec4i = (x_50 * x_57);
let x_58 = (x_50 * x_57);
val = x_58;
let x_59 : vec4i = (x_58 / x_57);
let x_59 = (x_58 / x_57);
val = x_59;
let x_60 : vec4i = (x_59 * x_57);
let x_60 = (x_59 * x_57);
val = x_60;
let x_61 : vec4i = (x_60 / x_57);
let x_61 = (x_60 / x_57);
val = x_61;
x_66 = false;
if (x_55) {
@ -99,9 +99,9 @@ fn main_1() {
var x_111 : bool;
var x_114 : bool;
var x_115 : bool;
let x_72 : vec4f = vcolor_S0;
let x_72 = vcolor_S0;
outputColor_S0 = x_72;
let x_77 : f32 = x_4.unknownInput_S1_c0;
let x_77 = x_4.unknownInput_S1_c0;
x_8_unknown = x_77;
x_9_ok = true;
x_87 = false;
@ -110,15 +110,15 @@ fn main_1() {
x_87 = x_86;
}
x_9_ok = x_87;
let x_89 : vec4f = vec4f(x_77, x_77, x_77, x_77);
let x_89 = vec4f(x_77, x_77, x_77, x_77);
x_10_val = x_89;
let x_92 : vec4f = (x_89 + x_91);
let x_92 = (x_89 + x_91);
x_10_val = x_92;
let x_93 : vec4f = (x_92 - x_91);
let x_93 = (x_92 - x_91);
x_10_val = x_93;
let x_94 : vec4f = (x_93 + x_91);
let x_94 = (x_93 + x_91);
x_10_val = x_94;
let x_95 : vec4f = (x_94 - x_91);
let x_95 = (x_94 - x_91);
x_10_val = x_95;
x_100 = false;
if (x_87) {
@ -126,13 +126,13 @@ fn main_1() {
x_100 = x_99;
}
x_9_ok = x_100;
let x_103 : vec4f = (x_95 * x_102);
let x_103 = (x_95 * x_102);
x_10_val = x_103;
let x_104 : vec4f = (x_103 / x_102);
let x_104 = (x_103 / x_102);
x_10_val = x_104;
let x_105 : vec4f = (x_104 * x_102);
let x_105 = (x_104 * x_102);
x_10_val = x_105;
let x_106 : vec4f = (x_105 / x_102);
let x_106 = (x_105 / x_102);
x_10_val = x_106;
x_111 = false;
if (x_100) {
@ -146,13 +146,13 @@ fn main_1() {
x_115 = x_114;
}
if (x_115) {
let x_122 : vec4f = x_4.ucolorGreen_S1_c0;
let x_122 = x_4.ucolorGreen_S1_c0;
x_116 = x_122;
} else {
let x_124 : vec4f = x_4.ucolorRed_S1_c0;
let x_124 = x_4.ucolorRed_S1_c0;
x_116 = x_124;
}
let x_125 : vec4f = x_116;
let x_125 = x_116;
output_S1 = x_125;
sk_FragColor = x_125;
return;

View File

@ -5,13 +5,13 @@ fn main_1() {
var m3 : mat3x3f;
var m4i : mat4x4f;
var m4 : mat4x4f;
let x_12 : mat2x2f = m2;
let x_12 = m2;
let s = (1.0f / determinant(x_12));
m2i = mat2x2f(vec2f((s * x_12[1u][1u]), (-(s) * x_12[0u][1u])), vec2f((-(s) * x_12[1u][0u]), (s * x_12[0u][0u])));
let x_19 : mat3x3f = m3;
let x_19 = m3;
let s_1 = (1.0f / determinant(x_19));
m3i = (s_1 * mat3x3f(vec3f(((x_19[1u][1u] * x_19[2u][2u]) - (x_19[1u][2u] * x_19[2u][1u])), ((x_19[0u][2u] * x_19[2u][1u]) - (x_19[0u][1u] * x_19[2u][2u])), ((x_19[0u][1u] * x_19[1u][2u]) - (x_19[0u][2u] * x_19[1u][1u]))), vec3f(((x_19[1u][2u] * x_19[2u][0u]) - (x_19[1u][0u] * x_19[2u][2u])), ((x_19[0u][0u] * x_19[2u][2u]) - (x_19[0u][2u] * x_19[2u][0u])), ((x_19[0u][2u] * x_19[1u][0u]) - (x_19[0u][0u] * x_19[1u][2u]))), vec3f(((x_19[1u][0u] * x_19[2u][1u]) - (x_19[1u][1u] * x_19[2u][0u])), ((x_19[0u][1u] * x_19[2u][0u]) - (x_19[0u][0u] * x_19[2u][1u])), ((x_19[0u][0u] * x_19[1u][1u]) - (x_19[0u][1u] * x_19[1u][0u])))));
let x_26 : mat4x4f = m4;
let x_26 = m4;
let s_2 = (1.0f / determinant(x_26));
m4i = (s_2 * mat4x4f(vec4f((((x_26[1u][1u] * ((x_26[2u][2u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][2u]))) - (x_26[1u][2u] * ((x_26[2u][1u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][1u])))) + (x_26[1u][3u] * ((x_26[2u][1u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][1u])))), (((-(x_26[0u][1u]) * ((x_26[2u][2u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][2u]))) + (x_26[0u][2u] * ((x_26[2u][1u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][1u])))) - (x_26[0u][3u] * ((x_26[2u][1u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][1u])))), (((x_26[0u][1u] * ((x_26[1u][2u] * x_26[3u][3u]) - (x_26[1u][3u] * x_26[3u][2u]))) - (x_26[0u][2u] * ((x_26[1u][1u] * x_26[3u][3u]) - (x_26[1u][3u] * x_26[3u][1u])))) + (x_26[0u][3u] * ((x_26[1u][1u] * x_26[3u][2u]) - (x_26[1u][2u] * x_26[3u][1u])))), (((-(x_26[0u][1u]) * ((x_26[1u][2u] * x_26[2u][3u]) - (x_26[1u][3u] * x_26[2u][2u]))) + (x_26[0u][2u] * ((x_26[1u][1u] * x_26[2u][3u]) - (x_26[1u][3u] * x_26[2u][1u])))) - (x_26[0u][3u] * ((x_26[1u][1u] * x_26[2u][2u]) - (x_26[1u][2u] * x_26[2u][1u]))))), vec4f((((-(x_26[1u][0u]) * ((x_26[2u][2u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][2u]))) + (x_26[1u][2u] * ((x_26[2u][0u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][0u])))) - (x_26[1u][3u] * ((x_26[2u][0u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][0u])))), (((x_26[0u][0u] * ((x_26[2u][2u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][2u]))) - (x_26[0u][2u] * ((x_26[2u][0u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][0u])))) + (x_26[0u][3u] * ((x_26[2u][0u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][0u])))), (((-(x_26[0u][0u]) * ((x_26[1u][2u] * x_26[3u][3u]) - (x_26[1u][3u] * x_26[3u][2u]))) + (x_26[0u][2u] * ((x_26[1u][0u] * x_26[3u][3u]) - (x_26[1u][3u] * x_26[3u][0u])))) - (x_26[0u][3u] * ((x_26[1u][0u] * x_26[3u][2u]) - (x_26[1u][2u] * x_26[3u][0u])))), (((x_26[0u][0u] * ((x_26[1u][2u] * x_26[2u][3u]) - (x_26[1u][3u] * x_26[2u][2u]))) - (x_26[0u][2u] * ((x_26[1u][0u] * x_26[2u][3u]) - (x_26[1u][3u] * x_26[2u][0u])))) + (x_26[0u][3u] * ((x_26[1u][0u] * x_26[2u][2u]) - (x_26[1u][2u] * x_26[2u][0u]))))), vec4f((((x_26[1u][0u] * ((x_26[2u][1u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][1u]))) - (x_26[1u][1u] * ((x_26[2u][0u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][0u])))) + (x_26[1u][3u] * ((x_26[2u][0u] * x_26[3u][1u]) - (x_26[2u][1u] * x_26[3u][0u])))), (((-(x_26[0u][0u]) * ((x_26[2u][1u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][1u]))) + (x_26[0u][1u] * ((x_26[2u][0u] * x_26[3u][3u]) - (x_26[2u][3u] * x_26[3u][0u])))) - (x_26[0u][3u] * ((x_26[2u][0u] * x_26[3u][1u]) - (x_26[2u][1u] * x_26[3u][0u])))), (((x_26[0u][0u] * ((x_26[1u][1u] * x_26[3u][3u]) - (x_26[1u][3u] * x_26[3u][1u]))) - (x_26[0u][1u] * ((x_26[1u][0u] * x_26[3u][3u]) - (x_26[1u][3u] * x_26[3u][0u])))) + (x_26[0u][3u] * ((x_26[1u][0u] * x_26[3u][1u]) - (x_26[1u][1u] * x_26[3u][0u])))), (((-(x_26[0u][0u]) * ((x_26[1u][1u] * x_26[2u][3u]) - (x_26[1u][3u] * x_26[2u][1u]))) + (x_26[0u][1u] * ((x_26[1u][0u] * x_26[2u][3u]) - (x_26[1u][3u] * x_26[2u][0u])))) - (x_26[0u][3u] * ((x_26[1u][0u] * x_26[2u][1u]) - (x_26[1u][1u] * x_26[2u][0u]))))), vec4f((((-(x_26[1u][0u]) * ((x_26[2u][1u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][1u]))) + (x_26[1u][1u] * ((x_26[2u][0u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][0u])))) - (x_26[1u][2u] * ((x_26[2u][0u] * x_26[3u][1u]) - (x_26[2u][1u] * x_26[3u][0u])))), (((x_26[0u][0u] * ((x_26[2u][1u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][1u]))) - (x_26[0u][1u] * ((x_26[2u][0u] * x_26[3u][2u]) - (x_26[2u][2u] * x_26[3u][0u])))) + (x_26[0u][2u] * ((x_26[2u][0u] * x_26[3u][1u]) - (x_26[2u][1u] * x_26[3u][0u])))), (((-(x_26[0u][0u]) * ((x_26[1u][1u] * x_26[3u][2u]) - (x_26[1u][2u] * x_26[3u][1u]))) + (x_26[0u][1u] * ((x_26[1u][0u] * x_26[3u][2u]) - (x_26[1u][2u] * x_26[3u][0u])))) - (x_26[0u][2u] * ((x_26[1u][0u] * x_26[3u][1u]) - (x_26[1u][1u] * x_26[3u][0u])))), (((x_26[0u][0u] * ((x_26[1u][1u] * x_26[2u][2u]) - (x_26[1u][2u] * x_26[2u][1u]))) - (x_26[0u][1u] * ((x_26[1u][0u] * x_26[2u][2u]) - (x_26[1u][2u] * x_26[2u][0u])))) + (x_26[0u][2u] * ((x_26[1u][0u] * x_26[2u][1u]) - (x_26[1u][1u] * x_26[2u][0u])))))));
return;

View File

@ -15,7 +15,7 @@ struct sb_block {
@group(0) @binding(0) var<storage, read_write> sb : sb_block;
fn main_1() {
let x_18 : S = sb.inner[1i];
let x_18 = sb.inner[1i];
return;
}

View File

@ -1,8 +1,8 @@
const x_22 = vec2f(2.0f, 2.0f);
fn main_1() {
let distance_1 : vec2f = x_22;
let x_10 : f32 = distance(distance_1, x_22);
let distance_1 = x_22;
let x_10 = distance(distance_1, x_22);
return;
}

View File

@ -1,11 +1,11 @@
fn x_200(x_201 : ptr<function, vec2f>) -> f32 {
let x_212 : f32 = (*(x_201)).x;
let x_212 = (*(x_201)).x;
return x_212;
}
fn main_1() {
var x_11 : vec2f;
let x_12 : f32 = x_200(&(x_11));
let x_12 = x_200(&(x_11));
return;
}

View File

@ -6,11 +6,11 @@ const x_17 = vec2i(0i, 0i);
fn main_1() {
var srcValue : vec4u;
let x_18 : vec4u = textureLoad(Src, x_17, 0i);
let x_18 = textureLoad(Src, x_17, 0i);
srcValue = x_18;
let x_22 : u32 = srcValue.x;
let x_22 = srcValue.x;
srcValue.x = (x_22 + bitcast<u32>(1i));
let x_27 : vec4u = srcValue;
let x_27 = srcValue;
textureStore(Dst, x_17, x_27);
return;
}

View File

@ -20,7 +20,7 @@ struct x_B4_BuildInformation {
fn main_1() {
var orientation : array<i32, 6u>;
let x_23 : Arr = sspp962805860buildInformation.passthru.orientation;
let x_23 = sspp962805860buildInformation.passthru.orientation;
orientation[0i] = x_23[0u];
orientation[1i] = x_23[1u];
orientation[2i] = x_23[2u];

View File

@ -40,22 +40,22 @@ var<private> gl_GlobalInvocationID : vec3u;
fn binaryOperation_f1_f1_(a : ptr<function, f32>, b : ptr<function, f32>) -> f32 {
var x_26 : f32;
let x_13 : f32 = *(b);
let x_13 = *(b);
if ((x_13 == 0.0f)) {
return 1.0f;
}
let x_21 : f32 = *(b);
let x_21 = *(b);
if (!((round((x_21 - (2.0f * floor((x_21 / 2.0f))))) == 1.0f))) {
let x_29 : f32 = *(a);
let x_31 : f32 = *(b);
let x_29 = *(a);
let x_31 = *(b);
x_26 = pow(abs(x_29), x_31);
} else {
let x_34 : f32 = *(a);
let x_36 : f32 = *(a);
let x_38 : f32 = *(b);
let x_34 = *(a);
let x_36 = *(a);
let x_38 = *(b);
x_26 = (sign(x_34) * pow(abs(x_36), x_38));
}
let x_41 : f32 = x_26;
let x_41 = x_26;
return x_41;
}
@ -64,13 +64,13 @@ fn main_1() {
var a_1 : i32;
var param : f32;
var param_1 : f32;
let x_54 : u32 = gl_GlobalInvocationID.x;
let x_54 = gl_GlobalInvocationID.x;
index = bitcast<i32>(x_54);
a_1 = -10i;
let x_63 : i32 = index;
let x_63 = index;
param = -4.0f;
param_1 = -3.0f;
let x_68 : f32 = binaryOperation_f1_f1_(&(param), &(param_1));
let x_68 = binaryOperation_f1_f1_(&(param), &(param_1));
resultMatrix.numbers[x_63] = x_68;
return;
}

View File

@ -9,20 +9,20 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> wg : array<array<array<atomic<u32>, 1u>, 2u>, 3u>;
fn compute_main_inner(local_invocation_index_2 : u32) {
var idx : u32 = 0u;
var idx = 0u;
idx = local_invocation_index_2;
loop {
let x_25 : u32 = idx;
let x_25 = idx;
if (!((x_25 < 6u))) {
break;
}
let x_31 : u32 = idx;
let x_33 : u32 = idx;
let x_35 : u32 = idx;
let x_31 = idx;
let x_33 = idx;
let x_35 = idx;
atomicStore(&(wg[(x_31 / 2u)][(x_33 % 2u)][(x_35 % 1u)]), 0u);
continuing {
let x_42 : u32 = idx;
let x_42 = idx;
idx = (x_42 + 1u);
}
}
@ -32,7 +32,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_57 : u32 = local_invocation_index_1;
let x_57 = local_invocation_index_1;
compute_main_inner(x_57);
return;
}

View File

@ -5,18 +5,18 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> wg : array<atomic<u32>, 4u>;
fn compute_main_inner(local_invocation_index_2 : u32) {
var idx : u32 = 0u;
var idx = 0u;
idx = local_invocation_index_2;
loop {
let x_21 : u32 = idx;
let x_21 = idx;
if (!((x_21 < 4u))) {
break;
}
let x_26 : u32 = idx;
let x_26 = idx;
atomicStore(&(wg[x_26]), 0u);
continuing {
let x_33 : u32 = idx;
let x_33 = idx;
idx = (x_33 + 1u);
}
}
@ -26,7 +26,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_47 : u32 = local_invocation_index_1;
let x_47 = local_invocation_index_1;
compute_main_inner(x_47);
return;
}

View File

@ -9,20 +9,20 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> wg : array<array<array<atomic<u32>, 1u>, 2u>, 3u>;
fn compute_main_inner(local_invocation_index_2 : u32) {
var idx : u32 = 0u;
var idx = 0u;
idx = local_invocation_index_2;
loop {
let x_25 : u32 = idx;
let x_25 = idx;
if (!((x_25 < 6u))) {
break;
}
let x_31 : u32 = idx;
let x_33 : u32 = idx;
let x_35 : u32 = idx;
let x_31 = idx;
let x_33 = idx;
let x_35 = idx;
atomicStore(&(wg[(x_31 / 2u)][(x_33 % 2u)][(x_35 % 1u)]), 0u);
continuing {
let x_42 : u32 = idx;
let x_42 = idx;
idx = (x_42 + 1u);
}
}
@ -32,7 +32,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_57 : u32 = local_invocation_index_1;
let x_57 = local_invocation_index_1;
compute_main_inner(x_57);
return;
}

View File

@ -23,20 +23,20 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> wg : array<S_atomic, 10u>;
fn compute_main_inner(local_invocation_index_2 : u32) {
var idx : u32 = 0u;
var idx = 0u;
idx = local_invocation_index_2;
loop {
let x_23 : u32 = idx;
let x_23 = idx;
if (!((x_23 < 10u))) {
break;
}
let x_28 : u32 = idx;
let x_28 = idx;
wg[x_28].x = 0i;
atomicStore(&(wg[x_28].a), 0u);
wg[x_28].y = 0u;
continuing {
let x_41 : u32 = idx;
let x_41 = idx;
idx = (x_41 + 1u);
}
}
@ -46,7 +46,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_53 : u32 = local_invocation_index_1;
let x_53 = local_invocation_index_1;
compute_main_inner(x_53);
return;
}

View File

@ -31,7 +31,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_39 : u32 = local_invocation_index_1;
let x_39 = local_invocation_index_1;
compute_main_inner(x_39);
return;
}

View File

@ -30,7 +30,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_35 : u32 = local_invocation_index_1;
let x_35 = local_invocation_index_1;
compute_main_inner(x_35);
return;
}

View File

@ -85,7 +85,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_44 : u32 = local_invocation_index_1;
let x_44 = local_invocation_index_1;
compute_main_inner(x_44);
return;
}

View File

@ -23,20 +23,20 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> wg : S_atomic;
fn compute_main_inner(local_invocation_index_2 : u32) {
var idx : u32 = 0u;
var idx = 0u;
wg.x = 0i;
wg.y = 0u;
idx = local_invocation_index_2;
loop {
let x_30 : u32 = idx;
let x_30 = idx;
if (!((x_30 < 10u))) {
break;
}
let x_35 : u32 = idx;
let x_35 = idx;
atomicStore(&(wg.a[x_35]), 0u);
continuing {
let x_41 : u32 = idx;
let x_41 = idx;
idx = (x_41 + 1u);
}
}
@ -46,7 +46,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_53 : u32 = local_invocation_index_1;
let x_53 = local_invocation_index_1;
compute_main_inner(x_53);
return;
}

View File

@ -30,7 +30,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_35 : u32 = local_invocation_index_1;
let x_35 = local_invocation_index_1;
compute_main_inner(x_35);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_d32fe4() {
var res : i32 = 0i;
let x_9 : i32 = atomicAdd(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicAdd(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_8a199a() {
var res : u32 = 0u;
let x_9 : u32 = atomicAdd(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicAdd(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicAdd_794055() {
var res : i32 = 0i;
let x_11 : i32 = atomicAdd(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicAdd(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicAdd_d5db1d() {
var res : u32 = 0u;
let x_10 : u32 = atomicAdd(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicAdd(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAnd_152966() {
var res : i32 = 0i;
let x_9 : i32 = atomicAnd(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicAnd(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAnd_85a8d9() {
var res : u32 = 0u;
let x_9 : u32 = atomicAnd(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicAnd(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicAnd_45a819() {
var res : i32 = 0i;
let x_11 : i32 = atomicAnd(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicAnd(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicAnd_34edd3() {
var res : u32 = 0u;
let x_10 : u32 = atomicAnd(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicAnd(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -18,9 +18,9 @@ struct x__atomic_compare_exchange_resulti32 {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicCompareExchangeWeak_1bd40a() {
var res : x__atomic_compare_exchange_resulti32 = x__atomic_compare_exchange_resulti32(0i, false);
var res = x__atomic_compare_exchange_resulti32(0i, false);
let old_value_1 = atomicCompareExchangeWeak(&(sb_rw.arg_0), 1i, 1i).old_value;
let x_19 : i32 = old_value_1;
let x_19 = old_value_1;
res = x__atomic_compare_exchange_resulti32(x_19, (x_19 == 1i));
return;
}

View File

@ -18,9 +18,9 @@ struct x__atomic_compare_exchange_resultu32 {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicCompareExchangeWeak_63d8e6() {
var res : x__atomic_compare_exchange_resultu32 = x__atomic_compare_exchange_resultu32(0u, false);
var res = x__atomic_compare_exchange_resultu32(0u, false);
let old_value_1 = atomicCompareExchangeWeak(&(sb_rw.arg_0), 1u, 1u).old_value;
let x_17 : u32 = old_value_1;
let x_17 = old_value_1;
res = x__atomic_compare_exchange_resultu32(x_17, (x_17 == 1u));
return;
}

View File

@ -10,9 +10,9 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicCompareExchangeWeak_e88938() {
var res : x__atomic_compare_exchange_resulti32 = x__atomic_compare_exchange_resulti32(0i, false);
var res = x__atomic_compare_exchange_resulti32(0i, false);
let old_value_1 = atomicCompareExchangeWeak(&(arg_0), 1i, 1i).old_value;
let x_18 : i32 = old_value_1;
let x_18 = old_value_1;
res = x__atomic_compare_exchange_resulti32(x_18, (x_18 == 1i));
return;
}
@ -25,7 +25,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_36 : u32 = local_invocation_index_1;
let x_36 = local_invocation_index_1;
compute_main_inner(x_36);
return;
}

View File

@ -10,9 +10,9 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicCompareExchangeWeak_83580d() {
var res : x__atomic_compare_exchange_resultu32 = x__atomic_compare_exchange_resultu32(0u, false);
var res = x__atomic_compare_exchange_resultu32(0u, false);
let old_value_1 = atomicCompareExchangeWeak(&(arg_0), 1u, 1u).old_value;
let x_17 : u32 = old_value_1;
let x_17 = old_value_1;
res = x__atomic_compare_exchange_resultu32(x_17, (x_17 == 1u));
return;
}
@ -25,7 +25,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_35 : u32 = local_invocation_index_1;
let x_35 = local_invocation_index_1;
compute_main_inner(x_35);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicExchange_f2e22f() {
var res : i32 = 0i;
let x_9 : i32 = atomicExchange(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicExchange(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicExchange_d59712() {
var res : u32 = 0u;
let x_9 : u32 = atomicExchange(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicExchange(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicExchange_e114ba() {
var res : i32 = 0i;
let x_11 : i32 = atomicExchange(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicExchange(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicExchange_0a5dca() {
var res : u32 = 0u;
let x_10 : u32 = atomicExchange(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicExchange(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicLoad_0806ad() {
var res : i32 = 0i;
let x_9 : i32 = atomicLoad(&(sb_rw.arg_0));
var res = 0i;
let x_9 = atomicLoad(&(sb_rw.arg_0));
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicLoad_fe6cc3() {
var res : u32 = 0u;
let x_9 : u32 = atomicLoad(&(sb_rw.arg_0));
var res = 0u;
let x_9 = atomicLoad(&(sb_rw.arg_0));
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicLoad_afcc03() {
var res : i32 = 0i;
let x_11 : i32 = atomicLoad(&(arg_0));
var res = 0i;
let x_11 = atomicLoad(&(arg_0));
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicLoad_361bf1() {
var res : u32 = 0u;
let x_10 : u32 = atomicLoad(&(arg_0));
var res = 0u;
let x_10 = atomicLoad(&(arg_0));
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_29 : u32 = local_invocation_index_1;
let x_29 = local_invocation_index_1;
compute_main_inner(x_29);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicMax_92aa72() {
var res : i32 = 0i;
let x_9 : i32 = atomicMax(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicMax(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicMax_51b9be() {
var res : u32 = 0u;
let x_9 : u32 = atomicMax(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicMax(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicMax_a89cc3() {
var res : i32 = 0i;
let x_11 : i32 = atomicMax(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicMax(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicMax_beccfc() {
var res : u32 = 0u;
let x_10 : u32 = atomicMax(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicMax(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicMin_8e38dc() {
var res : i32 = 0i;
let x_9 : i32 = atomicMin(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicMin(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicMin_c67a74() {
var res : u32 = 0u;
let x_9 : u32 = atomicMin(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicMin(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicMin_278235() {
var res : i32 = 0i;
let x_11 : i32 = atomicMin(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicMin(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicMin_69d383() {
var res : u32 = 0u;
let x_10 : u32 = atomicMin(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicMin(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicOr_8d96a0() {
var res : i32 = 0i;
let x_9 : i32 = atomicOr(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicOr(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicOr_5e95d4() {
var res : u32 = 0u;
let x_9 : u32 = atomicOr(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicOr(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicOr_d09248() {
var res : i32 = 0i;
let x_11 : i32 = atomicOr(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicOr(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicOr_5e3d61() {
var res : u32 = 0u;
let x_10 : u32 = atomicOr(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicOr(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -15,7 +15,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_29 : u32 = local_invocation_index_1;
let x_29 = local_invocation_index_1;
compute_main_inner(x_29);
return;
}

View File

@ -15,7 +15,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_28 : u32 = local_invocation_index_1;
let x_28 = local_invocation_index_1;
compute_main_inner(x_28);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicSub_051100() {
var res : i32 = 0i;
let x_9 : i32 = atomicSub(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicSub(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicSub_15bfc9() {
var res : u32 = 0u;
let x_9 : u32 = atomicSub(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicSub(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicSub_77883a() {
var res : i32 = 0i;
let x_11 : i32 = atomicSub(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicSub(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicSub_0d26c2() {
var res : u32 = 0u;
let x_10 : u32 = atomicSub(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicSub(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicXor_c1b78c() {
var res : i32 = 0i;
let x_9 : i32 = atomicXor(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicXor(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicXor_54510e() {
var res : u32 = 0u;
let x_9 : u32 = atomicXor(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicXor(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicXor_75dc95() {
var res : i32 = 0i;
let x_11 : i32 = atomicXor(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicXor(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicXor_c8e6be() {
var res : u32 = 0u;
let x_10 : u32 = atomicXor(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicXor(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_d32fe4() {
var res : i32 = 0i;
let x_9 : i32 = atomicSub(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicSub(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_8a199a() {
var res : u32 = 0u;
let x_9 : u32 = atomicSub(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicSub(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicAdd_794055() {
var res : i32 = 0i;
let x_11 : i32 = atomicSub(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicSub(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicAdd_d5db1d() {
var res : u32 = 0u;
let x_10 : u32 = atomicSub(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicSub(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_d32fe4() {
var res : i32 = 0i;
let x_9 : i32 = atomicAdd(&(sb_rw.arg_0), 1i);
var res = 0i;
let x_9 = atomicAdd(&(sb_rw.arg_0), 1i);
res = x_9;
return;
}

View File

@ -11,8 +11,8 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_8a199a() {
var res : u32 = 0u;
let x_9 : u32 = atomicAdd(&(sb_rw.arg_0), 1u);
var res = 0u;
let x_9 = atomicAdd(&(sb_rw.arg_0), 1u);
res = x_9;
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicAdd_794055() {
var res : i32 = 0i;
let x_11 : i32 = atomicAdd(&(arg_0), 1i);
var res = 0i;
let x_11 = atomicAdd(&(arg_0), 1i);
res = x_11;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_31 : u32 = local_invocation_index_1;
let x_31 = local_invocation_index_1;
compute_main_inner(x_31);
return;
}

View File

@ -3,8 +3,8 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicAdd_d5db1d() {
var res : u32 = 0u;
let x_10 : u32 = atomicAdd(&(arg_0), 1u);
var res = 0u;
let x_10 = atomicAdd(&(arg_0), 1u);
res = x_10;
return;
}
@ -17,7 +17,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_30 : u32 = local_invocation_index_1;
let x_30 = local_invocation_index_1;
compute_main_inner(x_30);
return;
}

View File

@ -11,11 +11,11 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_d32fe4() {
var arg_1 : i32 = 0i;
var res : i32 = 0i;
var arg_1 = 0i;
var res = 0i;
arg_1 = 1i;
let x_20 : i32 = arg_1;
let x_13 : i32 = atomicAdd(&(sb_rw.arg_0), x_20);
let x_20 = arg_1;
let x_13 = atomicAdd(&(sb_rw.arg_0), x_20);
res = x_13;
return;
}

View File

@ -11,11 +11,11 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAdd_8a199a() {
var arg_1 : u32 = 0u;
var res : u32 = 0u;
var arg_1 = 0u;
var res = 0u;
arg_1 = 1u;
let x_18 : u32 = arg_1;
let x_13 : u32 = atomicAdd(&(sb_rw.arg_0), x_18);
let x_18 = arg_1;
let x_13 = atomicAdd(&(sb_rw.arg_0), x_18);
res = x_13;
return;
}

View File

@ -3,11 +3,11 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicAdd_794055() {
var arg_1 : i32 = 0i;
var res : i32 = 0i;
var arg_1 = 0i;
var res = 0i;
arg_1 = 1i;
let x_19 : i32 = arg_1;
let x_15 : i32 = atomicAdd(&(arg_0), x_19);
let x_19 = arg_1;
let x_15 = atomicAdd(&(arg_0), x_19);
res = x_15;
return;
}
@ -20,7 +20,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_33 : u32 = local_invocation_index_1;
let x_33 = local_invocation_index_1;
compute_main_inner(x_33);
return;
}

View File

@ -3,11 +3,11 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<u32>;
fn atomicAdd_d5db1d() {
var arg_1 : u32 = 0u;
var res : u32 = 0u;
var arg_1 = 0u;
var res = 0u;
arg_1 = 1u;
let x_18 : u32 = arg_1;
let x_14 : u32 = atomicAdd(&(arg_0), x_18);
let x_18 = arg_1;
let x_14 = atomicAdd(&(arg_0), x_18);
res = x_14;
return;
}
@ -20,7 +20,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_32 : u32 = local_invocation_index_1;
let x_32 = local_invocation_index_1;
compute_main_inner(x_32);
return;
}

View File

@ -11,11 +11,11 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAnd_152966() {
var arg_1 : i32 = 0i;
var res : i32 = 0i;
var arg_1 = 0i;
var res = 0i;
arg_1 = 1i;
let x_20 : i32 = arg_1;
let x_13 : i32 = atomicAnd(&(sb_rw.arg_0), x_20);
let x_20 = arg_1;
let x_13 = atomicAnd(&(sb_rw.arg_0), x_20);
res = x_13;
return;
}

View File

@ -11,11 +11,11 @@ struct SB_RW {
@group(0) @binding(0) var<storage, read_write> sb_rw : SB_RW_atomic;
fn atomicAnd_85a8d9() {
var arg_1 : u32 = 0u;
var res : u32 = 0u;
var arg_1 = 0u;
var res = 0u;
arg_1 = 1u;
let x_18 : u32 = arg_1;
let x_13 : u32 = atomicAnd(&(sb_rw.arg_0), x_18);
let x_18 = arg_1;
let x_13 = atomicAnd(&(sb_rw.arg_0), x_18);
res = x_13;
return;
}

View File

@ -3,11 +3,11 @@ var<private> local_invocation_index_1 : u32;
var<workgroup> arg_0 : atomic<i32>;
fn atomicAnd_45a819() {
var arg_1 : i32 = 0i;
var res : i32 = 0i;
var arg_1 = 0i;
var res = 0i;
arg_1 = 1i;
let x_19 : i32 = arg_1;
let x_15 : i32 = atomicAnd(&(arg_0), x_19);
let x_19 = arg_1;
let x_15 = atomicAnd(&(arg_0), x_19);
res = x_15;
return;
}
@ -20,7 +20,7 @@ fn compute_main_inner(local_invocation_index_2 : u32) {
}
fn compute_main_1() {
let x_33 : u32 = local_invocation_index_1;
let x_33 = local_invocation_index_1;
compute_main_inner(x_33);
return;
}

Some files were not shown because too many files have changed in this diff Show More