Remove `error` from TextGenerator.

This CL removes the `error()` method from the TextGenerator in favour of
using `Diagnostics().str()`.

Change-Id: If20261ac839d11f6d29890cb17f95f2d4df5db2d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126923
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair 2023-04-12 11:59:24 +00:00 committed by Dawn LUCI CQ
parent 24e68d9506
commit 8a435a2a4b
124 changed files with 1013 additions and 1014 deletions

View File

@ -36,7 +36,7 @@ ParserImplWrapperForTest::~ParserImplWrapperForTest() {
std::string ToString(const Program& program) {
writer::wgsl::GeneratorImpl writer(&program);
if (!writer.Generate()) {
return "WGSL writer error: " + writer.error();
return "WGSL writer error: " + writer.Diagnostics().str();
}
return writer.result();
}
@ -45,7 +45,7 @@ std::string ToString(const Program& program, utils::VectorRef<const ast::Stateme
writer::wgsl::GeneratorImpl writer(&program);
for (const auto* stmt : stmts) {
if (!writer.EmitStatement(stmt)) {
return "WGSL writer error: " + writer.error();
return "WGSL writer error: " + writer.Diagnostics().str();
}
}
return writer.result();
@ -58,13 +58,13 @@ std::string ToString(const Program& program, const ast::Node* node) {
[&](const ast::Expression* expr) {
utils::StringStream out;
if (!writer.EmitExpression(out, expr)) {
return "WGSL writer error: " + writer.error();
return "WGSL writer error: " + writer.Diagnostics().str();
}
return out.str();
},
[&](const ast::Statement* stmt) {
if (!writer.EmitStatement(stmt)) {
return "WGSL writer error: " + writer.error();
return "WGSL writer error: " + writer.Diagnostics().str();
}
return writer.result();
},

View File

@ -46,7 +46,7 @@ Result Generate(const Program* program, const Options& options, const std::strin
// Generate the GLSL code.
auto impl = std::make_unique<GeneratorImpl>(&sanitized_result.program, options.version);
result.success = impl->Generate();
result.error = impl->error();
result.error = impl->Diagnostics().str();
result.glsl = impl->result();
// Collect the list of entry points in the sanitized program.

View File

@ -31,7 +31,7 @@ TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "ary[5]");
}

View File

@ -29,7 +29,7 @@ TEST_F(GlslGeneratorImplTest_Assign, Emit_Assign) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(assign)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(assign)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " lhs = rhs;\n");
}

View File

@ -59,7 +59,7 @@ TEST_P(GlslBinaryTest, Emit_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
TEST_P(GlslBinaryTest, Emit_f16) {
@ -87,7 +87,7 @@ TEST_P(GlslBinaryTest, Emit_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
TEST_P(GlslBinaryTest, Emit_u32) {
@ -106,7 +106,7 @@ TEST_P(GlslBinaryTest, Emit_u32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
TEST_P(GlslBinaryTest, Emit_i32) {
@ -130,7 +130,7 @@ TEST_P(GlslBinaryTest, Emit_i32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(
@ -165,7 +165,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(a * 1.0f)");
}
@ -183,7 +183,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(a * 1.0hf)");
}
@ -199,7 +199,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(1.0f * a)");
}
@ -217,7 +217,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(1.0hf * a)");
}
@ -232,7 +232,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(mat * 1.0f)");
}
@ -249,7 +249,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(mat * 1.0hf)");
}
@ -264,7 +264,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(1.0f * mat)");
}
@ -281,7 +281,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(1.0hf * mat)");
}
@ -296,7 +296,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(mat * vec3(1.0f))");
}
@ -313,7 +313,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(mat * f16vec3(1.0hf))");
}
@ -328,7 +328,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(vec3(1.0f) * mat)");
}
@ -345,7 +345,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(f16vec3(1.0hf) * mat)");
}
@ -359,7 +359,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(lhs * rhs)");
}
@ -375,7 +375,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(lhs * rhs)");
}
@ -389,7 +389,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModF32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -405,7 +405,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModF16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -419,7 +419,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -435,7 +435,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -449,7 +449,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32ScalarF32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -465,7 +465,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16ScalarF16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -479,7 +479,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModScalarF32Vec3F32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -495,7 +495,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModScalarF16Vec3F16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
@ -513,7 +513,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec3 tint_float_modulo(vec3 lhs, vec3 rhs) {
@ -557,7 +557,7 @@ TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -596,7 +596,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Logical_And) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(tint_tmp)");
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (tint_tmp) {
@ -621,7 +621,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Logical_Multi) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(tint_tmp)");
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = a;
if (tint_tmp_1) {
@ -648,7 +648,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Logical_Or) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(tint_tmp)");
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (!tint_tmp) {
@ -679,7 +679,7 @@ TEST_F(GlslGeneratorImplTest_Binary, If_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (tint_tmp) {
tint_tmp = b;
@ -715,7 +715,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Return_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = a;
if (tint_tmp_1) {
tint_tmp_1 = b;
@ -746,7 +746,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Assign_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = b;
if (!tint_tmp_1) {
tint_tmp_1 = c;
@ -778,7 +778,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Decl_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(decl)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(decl)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = b;
if (tint_tmp_1) {
tint_tmp_1 = c;
@ -820,7 +820,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Call_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (tint_tmp) {
tint_tmp = b;

View File

@ -31,7 +31,7 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "intBitsToFloat(a)");
}
@ -43,7 +43,7 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "int(a)");
}
@ -55,7 +55,7 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "uint(a)");
}

View File

@ -27,7 +27,7 @@ TEST_F(GlslGeneratorImplTest_Block, Emit_Block) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
return;
}

View File

@ -27,7 +27,7 @@ TEST_F(GlslGeneratorImplTest_Break, Emit_Break) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " break;\n");
}

View File

@ -351,7 +351,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Builtin_Call) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "dot(param1, param2)");
}
@ -364,7 +364,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(true ? b : a)");
}
@ -377,7 +377,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_select(a, b, bvec2(true, false))");
}
@ -394,7 +394,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, FMA_f32) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "((a) * (b) + (c))");
}
@ -412,7 +412,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, FMA_f16) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "((a) * (b) + (c))");
}
@ -422,7 +422,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct modf_result_f32 {
@ -458,7 +458,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -493,7 +493,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct modf_result_vec3_f32 {
@ -529,7 +529,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -563,7 +563,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct modf_result_f32 {
@ -591,7 +591,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -618,7 +618,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct modf_result_vec3_f32 {
@ -646,7 +646,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -674,7 +674,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct frexp_result_f32 {
@ -710,7 +710,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -745,7 +745,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct frexp_result_vec3_f32 {
@ -781,7 +781,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -815,7 +815,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct frexp_result_f32 {
@ -843,7 +843,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -870,7 +870,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct frexp_result_vec3_f32 {
@ -898,7 +898,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -927,7 +927,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
float tint_degrees(float param_0) {
@ -955,7 +955,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec3 tint_degrees(vec3 param_0) {
@ -985,7 +985,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -1016,7 +1016,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -1045,7 +1045,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
float tint_radians(float param_0) {
@ -1073,7 +1073,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec3 tint_radians(vec3 param_0) {
@ -1103,7 +1103,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -1134,7 +1134,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -1165,7 +1165,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, ExtractBits) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uvec3 tint_extract_bits(uvec3 v, uint offset, uint count) {
@ -1199,7 +1199,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, InsertBits) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uvec3 tint_insert_bits(uvec3 v, uvec3 n, uint offset, uint count) {
@ -1230,7 +1230,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec4 p1 = vec4(0.0f, 0.0f, 0.0f, 0.0f);
@ -1248,7 +1248,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec4 p1 = vec4(0.0f, 0.0f, 0.0f, 0.0f);
@ -1266,7 +1266,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec2 p1 = vec2(0.0f, 0.0f);
@ -1284,7 +1284,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec2 p1 = vec2(0.0f, 0.0f);
@ -1302,7 +1302,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Float) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec2 p1 = vec2(0.0f, 0.0f);
@ -1320,7 +1320,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uint p1 = 0u;
@ -1338,7 +1338,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uint p1 = 0u;
@ -1356,7 +1356,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uint p1 = 0u;
@ -1374,7 +1374,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uint p1 = 0u;
@ -1392,7 +1392,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Float) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uint p1 = 0u;
@ -1416,7 +1416,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, StorageBarrier) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
@ -1439,7 +1439,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, WorkgroupBarrier) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
@ -1456,7 +1456,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, DotI32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
int tint_int_dot(ivec3 a, ivec3 b) {
@ -1482,7 +1482,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, DotU32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
uint tint_int_dot(uvec3 a, uvec3 b) {
@ -1508,7 +1508,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Scalar) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
float tint_quantizeToF16(float param_0) {
@ -1535,7 +1535,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec2) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec2 tint_quantizeToF16(vec2 param_0) {
@ -1562,7 +1562,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec3) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec3 tint_quantizeToF16(vec3 param_0) {
@ -1591,7 +1591,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec4) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
vec4 tint_quantizeToF16(vec4 param_0) {

View File

@ -289,7 +289,7 @@ TEST_P(GlslGeneratorBuiltinTextureTest, Call) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto expected = expected_texture_overload(param.overload);

View File

@ -32,7 +32,7 @@ TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_func()");
}
@ -52,7 +52,7 @@ TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_func(param1, param2)");
}
@ -72,7 +72,7 @@ TEST_F(GlslGeneratorImplTest_Call, EmitStatement_Call) {
GeneratorImpl& gen = Build();
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(call)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(call)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " my_func(param1, param2);\n");
}

View File

@ -30,7 +30,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5: {
break;
}
@ -45,7 +45,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5: {
break;
}
@ -67,7 +67,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5:
case 6: {
break;
@ -83,7 +83,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_Default) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( default: {
break;
}

View File

@ -29,7 +29,7 @@ TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "1.0f");
}
@ -40,7 +40,7 @@ TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "vec3(1.0f, 2.0f, 3.0f)");
}

View File

@ -29,7 +29,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("false"));
}
@ -38,7 +38,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
}
@ -47,7 +47,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, UInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("56779u"));
}
@ -57,7 +57,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Float) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f"));
}
@ -69,7 +69,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("32752.0hf"));
}
@ -78,7 +78,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Float) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-0.00001200000042445026f"));
}
@ -89,7 +89,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-0.0011997222900390625hf"));
}
@ -98,7 +98,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("true"));
}
@ -107,7 +107,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
}
@ -116,7 +116,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Uint) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("12345u"));
}
@ -125,7 +125,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("vec3(1.0f, 2.0f, 3.0f)"));
}
@ -136,7 +136,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("f16vec3(1.0hf, 2.0hf, 3.0hf)"));
}
@ -145,7 +145,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("vec3(0.0f)"));
}
@ -156,7 +156,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("f16vec3(0.0hf)"));
}
@ -165,7 +165,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("vec3(2.0f)"));
}
@ -176,7 +176,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("f16vec3(2.0hf)"));
}
@ -187,7 +187,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(float v = 2.0f;
vec3 tint_symbol = vec3(v);)"));
}
@ -201,7 +201,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(float16_t v = 2.0hf;
f16vec3 tint_symbol = f16vec3(v);)"));
}
@ -211,7 +211,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("bvec3(true)"));
}
@ -220,7 +220,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("ivec3(2)"));
}
@ -229,7 +229,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("uvec3(2u)"));
}
@ -238,7 +238,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("mat2x3(vec3(1.0f, 2.0f, 3.0f), vec3(3.0f, 4.0f, 5.0f))"));
}
@ -250,7 +250,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("f16mat2x3(f16vec3(1.0hf, 2.0hf, 3.0hf), f16vec3(3.0hf, 4.0hf, 5.0hf))"));
@ -277,7 +277,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("mat4(vec4(2.0f, 3.0f, 4.0f, 8.0f), vec4(0.0f), "
"vec4(7.0f), vec4(42.0f, 21.0f, 6.0f, -5.0f))"));
@ -306,7 +306,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("f16mat4(f16vec4(2.0hf, 3.0hf, 4.0hf, 8.0hf), f16vec4(0.0hf), "
@ -318,7 +318,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("mat2x3 tint_symbol = mat2x3(vec3(0.0f), vec3(0.0f))"));
}
@ -330,7 +330,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("f16mat2x3 tint_symbol = f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))"));
@ -349,7 +349,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("mat4 m_2 = mat4(m_1);"));
}
@ -369,7 +369,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("f16mat4 m_2 = f16mat4(m_1);"));
}
@ -380,7 +380,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Array) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("vec3[3](vec3(1.0f, 2.0f, 3.0f), "
"vec3(4.0f, 5.0f, 6.0f), "
"vec3(7.0f, 8.0f, 9.0f))"));
@ -391,7 +391,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Array_Empty) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("vec3[3](vec3(0.0f), vec3(0.0f), vec3(0.0f))"));
}
@ -406,7 +406,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("S(1, 2.0f, ivec3(3, 4, 5))"));
}
@ -421,7 +421,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct_Empty) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("S(0"));
}

View File

@ -27,7 +27,7 @@ TEST_F(GlslGeneratorImplTest_Continue, Emit_Continue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
if (false) {
break;

View File

@ -29,7 +29,7 @@ TEST_F(GlslGeneratorImplTest_Discard, Emit_Discard) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " discard;\n");
}

View File

@ -37,7 +37,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( #version 310 es
void my_func() {
@ -57,7 +57,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"( void tint_symbol() {
return;
})"));
@ -78,7 +78,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithParams) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( #version 310 es
void my_func(float a, int b) {
@ -96,7 +96,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_NoReturn_Void)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -115,7 +115,7 @@ TEST_F(GlslGeneratorImplTest_Function, PtrParameter) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(float f(inout float foo) {
return foo;
}
@ -143,7 +143,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOutVars)
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -184,7 +184,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOut_Built
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -237,7 +237,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_Di
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -316,7 +316,7 @@ TEST_F(GlslGeneratorImplTest_Function,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct VertexOutput {
float4 pos;
};
@ -376,7 +376,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -417,7 +417,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -458,7 +458,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -505,7 +505,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(#version 310 es
precision highp float;
@ -551,7 +551,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -596,7 +596,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -643,7 +643,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -689,7 +689,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(#version 310 es
precision highp float;
@ -726,7 +726,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithNameCollisi
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
precision highp float;
@ -752,7 +752,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
@ -771,7 +771,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWor
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
layout(local_size_x = 2, local_size_y = 4, local_size_z = 6) in;
@ -793,7 +793,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWor
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in;
@ -816,9 +816,9 @@ TEST_F(GlslGeneratorImplTest_Function,
GeneratorImpl& gen = Build();
EXPECT_FALSE(gen.Generate()) << gen.error();
EXPECT_FALSE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(
gen.error(),
gen.Diagnostics().str(),
R"(error: override-expressions should have been removed with the SubstituteOverride transform)");
}
@ -830,7 +830,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
void my_func(float a[5]) {
@ -848,7 +848,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayReturn) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
float[5] my_func() {
@ -912,7 +912,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct Data {

View File

@ -29,7 +29,7 @@ TEST_F(GlslGeneratorImplTest_Identifier, EmitIdentifierExpression) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, i)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, i)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "foo");
}

View File

@ -30,7 +30,7 @@ TEST_F(GlslGeneratorImplTest_If, Emit_If) {
GeneratorImpl& gen = Build();
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
}
@ -53,7 +53,7 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElseIf) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {
@ -78,7 +78,7 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElse) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {
@ -106,7 +106,7 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithMultiple) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {

View File

@ -41,7 +41,7 @@ TEST_P(GlslImportData_SingleParamTest, FloatScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f)");
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
@ -80,7 +80,7 @@ TEST_P(GlslImportData_SingleIntParamTest, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1)");
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
@ -97,7 +97,7 @@ TEST_P(GlslImportData_SingleVectorParamTest, FloatVector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(
out.str(),
std::string(param.glsl_name) +
@ -140,7 +140,7 @@ TEST_P(GlslImportData_DualParam_ScalarTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f, 2.0f)");
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
@ -162,7 +162,7 @@ TEST_P(GlslImportData_DualParam_VectorTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(),
std::string(param.glsl_name) + "(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f))");
}
@ -187,7 +187,7 @@ TEST_P(GlslImportData_DualParam_Int_Test, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1, 2)");
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
@ -205,7 +205,7 @@ TEST_P(GlslImportData_TripleParam_ScalarTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f, 2.0f, 3.0f)");
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
@ -225,7 +225,7 @@ TEST_P(GlslImportData_TripleParam_VectorTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(),
std::string(param.glsl_name) +
R"((vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f)))");
@ -246,7 +246,7 @@ TEST_P(GlslImportData_TripleParam_Int_Test, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1, 2, 3)");
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
@ -262,7 +262,7 @@ TEST_F(GlslGeneratorImplTest_Import, GlslImportData_Determinant) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string("determinant(var)"));
}

View File

@ -34,7 +34,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_Loop) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
}
@ -55,7 +55,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
{
@ -79,7 +79,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing_BreakIf) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
{
@ -116,7 +116,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
while (true) {
break;
@ -155,7 +155,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
float lhs = 2.5f;
float other = 0.0f;
@ -180,7 +180,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoop) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(; ; ) {
return;
@ -202,7 +202,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(int i = 0; ; ) {
return;
@ -226,7 +226,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = t;
if (tint_tmp) {
@ -254,7 +254,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(; true; ) {
a_statement();
@ -279,7 +279,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
while (true) {
bool tint_tmp = t;
@ -307,7 +307,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(; ; i = (i + 1)) {
return;
@ -333,7 +333,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
while (true) {
return;
@ -359,7 +359,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(int i = 0; true; i = (i + 1)) {
return;
@ -387,7 +387,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = t;
if (tint_tmp) {
@ -423,7 +423,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_While) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while(true) {
return;
}
@ -442,7 +442,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_While_WithContinue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while(true) {
continue;
}
@ -466,7 +466,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
bool tint_tmp = t;
if (tint_tmp) {

View File

@ -119,7 +119,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct Data {
@ -170,7 +170,7 @@ TEST_P(GlslGeneratorImplTest_MemberAccessor_StorageBufferLoad, Test) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
}
@ -222,7 +222,7 @@ TEST_P(GlslGeneratorImplTest_MemberAccessor_StorageBufferStore, Test) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
}
@ -278,7 +278,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Matrix_Empty) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -331,7 +331,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_Single_El
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -379,7 +379,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -427,7 +427,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -474,7 +474,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -527,7 +527,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -588,7 +588,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizz
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -650,7 +650,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -711,7 +711,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -771,7 +771,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -832,7 +832,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(#version 310 es
precision highp float;
@ -870,7 +870,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
WrapInFunction(var, expr);
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("my_vec.xyz"));
}
@ -880,7 +880,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
WrapInFunction(var, expr);
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("my_vec.gbr"));
}

View File

@ -28,7 +28,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalLet) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitProgramConstVariable(var)) << gen.error();
ASSERT_TRUE(gen.EmitProgramConstVariable(var)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), "const float pos[3] = float[3](1.0f, 2.0f, 3.0f);\n");
}
@ -41,7 +41,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -61,7 +61,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -81,7 +81,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_i32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -101,7 +101,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_u32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -121,7 +121,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -143,7 +143,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -164,7 +164,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -184,7 +184,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -204,7 +204,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -226,7 +226,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -247,7 +247,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -267,7 +267,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -289,7 +289,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -310,7 +310,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -333,7 +333,7 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_vec2_bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es

View File

@ -29,7 +29,7 @@ TEST_F(GlslGeneratorImplTest_Return, Emit_Return) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " return;\n");
}
@ -41,7 +41,7 @@ TEST_F(GlslGeneratorImplTest_Return, Emit_ReturnWithValue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " return 123;\n");
}

View File

@ -39,7 +39,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#version 310 es
@ -79,7 +79,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#version 310 es
@ -123,7 +123,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#version 310 es
@ -160,7 +160,7 @@ TEST_F(GlslSanitizerTest, PromoteArrayInitializerToConstVar) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#version 310 es
@ -202,7 +202,7 @@ TEST_F(GlslSanitizerTest, PromoteStructInitializerToConstVar) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#version 310 es
@ -248,7 +248,7 @@ TEST_F(GlslSanitizerTest, InlinePtrLetsBasic) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#version 310 es
@ -297,7 +297,7 @@ TEST_F(GlslSanitizerTest, InlinePtrLetsComplexChain) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#version 310 es

View File

@ -48,7 +48,7 @@ TEST_F(GlslGeneratorImplTest_StorageBuffer, Align) {
// TODO(crbug.com/tint/1421) offsets do not currently work on GLSL ES.
// They will likely require manual padding.
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct Nephews {
@ -71,7 +71,7 @@ TEST_F(GlslGeneratorImplTest_StorageBuffer, Align_Desktop) {
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 440
struct Nephews {

View File

@ -38,7 +38,7 @@ TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( switch(cond) {
case 5: {
break;
@ -65,7 +65,7 @@ TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch_MixedDefault) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( switch(cond) {
case 5:
default: {

View File

@ -33,7 +33,7 @@ TEST_F(GlslGeneratorImplTest, Generate) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
void my_func() {
@ -47,7 +47,7 @@ TEST_F(GlslGeneratorImplTest, GenerateDesktop) {
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 440
void my_func() {
@ -70,7 +70,7 @@ TEST_F(GlslGeneratorImplTest, GenerateSampleIndexES) {
GeneratorImpl& gen = Build(Version(Version::Standard::kES, 3, 1));
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_OES_sample_variables : require
@ -95,7 +95,7 @@ TEST_F(GlslGeneratorImplTest, GenerateSampleIndexDesktop) {
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 440
int my_func() {

View File

@ -42,7 +42,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, "ary"))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool ary[4]");
}
@ -55,7 +55,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, "ary"))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool ary[5][4]");
}
@ -68,7 +68,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, "ary"))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool ary[6][5][4]");
}
@ -81,7 +81,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool[4]");
}
@ -93,7 +93,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, bool_, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool");
}
@ -105,7 +105,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, f32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "float");
}
@ -119,7 +119,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, f16, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "float16_t");
}
@ -131,7 +131,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, i32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "int");
}
@ -145,7 +145,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "mat2x3");
}
@ -161,7 +161,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "f16mat2x3");
}
@ -176,7 +176,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_StructDecl) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
EXPECT_EQ(buf.String(), R"(struct S {
int a;
float b;
@ -198,7 +198,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, sem_s, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "S");
}
@ -211,7 +211,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(struct S {
int tint_symbol;
float tint_symbol_1;
@ -230,7 +230,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
EXPECT_EQ(buf.String(), R"(struct S {
int a;
float b;
@ -247,7 +247,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, u32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "uint");
}
@ -260,7 +260,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "vec3");
}
@ -275,7 +275,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "f16vec3");
}
@ -287,7 +287,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, void_, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "void");
}
@ -299,7 +299,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSampler) {
utils::StringStream out;
ASSERT_FALSE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
}
TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) {
@ -310,7 +310,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) {
utils::StringStream out;
ASSERT_FALSE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
}
struct GlslDepthTextureData {
@ -341,7 +341,7 @@ TEST_P(GlslDepthTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(
@ -369,7 +369,7 @@ TEST_F(GlslDepthMultisampledTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("sampler2DMS tex;"));
}
@ -415,7 +415,7 @@ TEST_P(GlslSampledTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type,
@ -521,7 +521,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "highp sampler2DMS");
}
@ -553,7 +553,7 @@ TEST_P(GlslStorageTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(

View File

@ -28,7 +28,7 @@ TEST_F(GlslUnaryOpTest, AddressOf) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "expr");
}
@ -40,7 +40,7 @@ TEST_F(GlslUnaryOpTest, Complement) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "~(expr)");
}
@ -53,7 +53,7 @@ TEST_F(GlslUnaryOpTest, Indirection) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "expr");
}
@ -65,7 +65,7 @@ TEST_F(GlslUnaryOpTest, Not) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "!(expr)");
}
@ -77,7 +77,7 @@ TEST_F(GlslUnaryOpTest, Negation) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "-(expr)");
}
@ -88,7 +88,7 @@ TEST_F(GlslUnaryOpTest, IntMin) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(-2147483647 - 1)");
}

View File

@ -30,7 +30,7 @@ TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
struct Simple {
@ -50,7 +50,7 @@ TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple_Desktop) {
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 440
struct Simple {

View File

@ -34,7 +34,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " float a = 0.0f;\n");
}
@ -47,7 +47,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Let) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " float a = 0.0f;\n");
}
@ -60,7 +60,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), ""); // Not a mistake - 'const' is inlined
}
@ -74,7 +74,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AInt
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -95,7 +95,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AFlo
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -116,7 +116,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_i32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -137,7 +137,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_u32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -158,7 +158,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -181,7 +181,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f16)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -203,7 +203,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -224,7 +224,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -245,7 +245,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -268,7 +268,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -290,7 +290,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -311,7 +311,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -334,7 +334,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
@ -356,7 +356,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -377,7 +377,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -398,7 +398,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -420,7 +420,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -449,7 +449,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#version 310 es
@ -469,7 +469,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr(" float a[5] = float[5](0.0f, 0.0f, 0.0f, 0.0f, 0.0f);\n"));
}
@ -483,7 +483,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(" float a = 0.0f;\n"));
}
@ -495,7 +495,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(vec3 a = vec3(0.0f);
)");
}
@ -510,7 +510,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(f16vec3 a = f16vec3(0.0hf);
)");
}
@ -523,7 +523,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(mat2x3 a = mat2x3(vec3(0.0f), vec3(0.0f));
)");
@ -539,7 +539,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(f16mat2x3 a = f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf));
)");

View File

@ -36,7 +36,7 @@ TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
});
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("shared float wg;\n"));
}
@ -52,7 +52,7 @@ TEST_F(GlslGeneratorImplTest_WorkgroupVar, Aliased) {
});
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("shared float wg;\n"));
}

View File

@ -45,7 +45,7 @@ Result Generate(const Program* program, const Options& options) {
// Generate the HLSL code.
auto impl = std::make_unique<GeneratorImpl>(&sanitized_result.program);
result.success = impl->Generate();
result.error = impl->error();
result.error = impl->Diagnostics().str();
result.hlsl = impl->result();
// Collect the list of entry points in the sanitized program.

View File

@ -30,7 +30,7 @@ TEST_F(HlslGeneratorImplTest_Expression, IndexAccessor) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "ary[5]");
}

View File

@ -66,7 +66,7 @@ TEST_P(HlslBinaryTest, Emit_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
TEST_P(HlslBinaryTest, Emit_f16) {
@ -98,7 +98,7 @@ TEST_P(HlslBinaryTest, Emit_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
TEST_P(HlslBinaryTest, Emit_u32) {
@ -121,7 +121,7 @@ TEST_P(HlslBinaryTest, Emit_u32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
TEST_P(HlslBinaryTest, Emit_i32) {
@ -149,7 +149,7 @@ TEST_P(HlslBinaryTest, Emit_i32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(
@ -186,7 +186,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(1.0f).xxx");
}
@ -203,7 +203,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(float16_t(1.0h)).xxx");
}
@ -218,7 +218,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(1.0f).xxx");
}
@ -235,7 +235,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(float16_t(1.0h)).xxx");
}
@ -250,7 +250,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(mat * 1.0f)");
}
@ -267,7 +267,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(mat * float16_t(1.0h))");
}
@ -282,7 +282,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(1.0f * mat)");
}
@ -299,7 +299,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(float16_t(1.0h) * mat)");
}
@ -314,7 +314,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "mul((1.0f).xxx, mat)");
}
@ -331,7 +331,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "mul((float16_t(1.0h)).xxx, mat)");
}
@ -346,7 +346,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "mul(mat, (1.0f).xxx)");
}
@ -363,7 +363,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "mul(mat, (float16_t(1.0h)).xxx)");
}
@ -377,7 +377,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "mul(rhs, lhs)");
}
@ -393,7 +393,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "mul(rhs, lhs)");
}
@ -407,7 +407,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Logical_And) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(tint_tmp)");
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (tint_tmp) {
@ -432,7 +432,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Logical_Multi) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(tint_tmp)");
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = a;
if (tint_tmp_1) {
@ -459,7 +459,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Logical_Or) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(tint_tmp)");
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (!tint_tmp) {
@ -490,7 +490,7 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (tint_tmp) {
tint_tmp = b;
@ -526,7 +526,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Return_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = a;
if (tint_tmp_1) {
tint_tmp_1 = b;
@ -557,7 +557,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Assign_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = b;
if (!tint_tmp_1) {
tint_tmp_1 = c;
@ -589,7 +589,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(decl)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(decl)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = b;
if (tint_tmp_1) {
tint_tmp_1 = c;
@ -631,7 +631,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
if (tint_tmp) {
tint_tmp = b;

View File

@ -30,7 +30,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "asfloat(a)");
}
@ -42,7 +42,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "asint(a)");
}
@ -54,7 +54,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "asuint(a)");
}

View File

@ -27,7 +27,7 @@ TEST_F(HlslGeneratorImplTest_Block, Emit_Block) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
return;
}

View File

@ -27,7 +27,7 @@ TEST_F(HlslGeneratorImplTest_Break, Emit_Break) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " break;\n");
}

View File

@ -350,7 +350,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Builtin_Call) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "dot(param1, param2)");
}
@ -363,7 +363,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Select_Scalar) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(true ? b : a)");
}
@ -376,7 +376,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Select_Vector) {
gen.increment_indent();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(bool2(true, false) ? b : a)");
}
@ -386,7 +386,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_f32 {
float fract;
float whole;
@ -414,7 +414,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_f16 {
float16_t fract;
float16_t whole;
@ -440,7 +440,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_vec3_f32 {
float3 fract;
float3 whole;
@ -468,7 +468,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_vec3_f16 {
vector<float16_t, 3> fract;
vector<float16_t, 3> whole;
@ -493,7 +493,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_f32 {
float fract;
float whole;
@ -513,7 +513,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_f16 {
float16_t fract;
float16_t whole;
@ -531,7 +531,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Modf_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_vec3_f32 {
float3 fract;
float3 whole;
@ -551,7 +551,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Modf_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_vec3_f16 {
vector<float16_t, 3> fract;
vector<float16_t, 3> whole;
@ -575,7 +575,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, NonInitializer_Modf_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct modf_result_vec3_f32 {
float3 fract;
float3 whole;
@ -596,7 +596,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_f32 {
float fract;
int exp;
@ -625,7 +625,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_f16 {
float16_t fract;
int exp;
@ -652,7 +652,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3_f32 {
float3 fract;
int3 exp;
@ -681,7 +681,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3_f16 {
vector<float16_t, 3> fract;
int3 exp;
@ -707,7 +707,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_f32 {
float fract;
int exp;
@ -727,7 +727,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_f16 {
float16_t fract;
int exp;
@ -745,7 +745,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3_f32 {
float3 fract;
int3 exp;
@ -765,7 +765,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3_f16 {
vector<float16_t, 3> fract;
int3 exp;
@ -789,7 +789,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, NonInitializer_Frexp_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct frexp_result_vec3_f32 {
float3 fract;
int3 exp;
@ -811,7 +811,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Degrees_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float tint_degrees(float param_0) {
return param_0 * 57.29577951308232286465;
}
@ -832,7 +832,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Degrees_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float3 tint_degrees(float3 param_0) {
return param_0 * 57.29577951308232286465;
}
@ -855,7 +855,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Degrees_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float16_t tint_degrees(float16_t param_0) {
return param_0 * 57.29577951308232286465;
}
@ -878,7 +878,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Degrees_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(vector<float16_t, 3> tint_degrees(vector<float16_t, 3> param_0) {
return param_0 * 57.29577951308232286465;
}
@ -899,7 +899,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Radians_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float tint_radians(float param_0) {
return param_0 * 0.01745329251994329547;
}
@ -920,7 +920,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Radians_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float3 tint_radians(float3 param_0) {
return param_0 * 0.01745329251994329547;
}
@ -943,7 +943,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Radians_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float16_t tint_radians(float16_t param_0) {
return param_0 * 0.01745329251994329547;
}
@ -966,7 +966,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Radians_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(vector<float16_t, 3> tint_radians(vector<float16_t, 3> param_0) {
return param_0 * 0.01745329251994329547;
}
@ -987,7 +987,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Sign_Scalar_i32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
int val = 0;
@ -1004,7 +1004,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Sign_Vector_i32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
int3 val = int3(0, 0, 0);
@ -1021,7 +1021,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Sign_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
float val = 0.0f;
@ -1038,7 +1038,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Sign_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
float3 val = float3(0.0f, 0.0f, 0.0f);
@ -1057,7 +1057,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Sign_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
float16_t val = float16_t(0.0h);
@ -1076,7 +1076,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Sign_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
vector<float16_t, 3> val = vector<float16_t, 3>(float16_t(0.0h), float16_t(0.0h), float16_t(0.0h));
@ -1093,7 +1093,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float tint_trunc(float param_0) {
return param_0 < 0 ? ceil(param_0) : floor(param_0);
}
@ -1114,7 +1114,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float3 tint_trunc(float3 param_0) {
return param_0 < 0 ? ceil(param_0) : floor(param_0);
}
@ -1137,7 +1137,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float16_t tint_trunc(float16_t param_0) {
return param_0 < 0 ? ceil(param_0) : floor(param_0);
}
@ -1160,7 +1160,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(vector<float16_t, 3> tint_trunc(vector<float16_t, 3> param_0) {
return param_0 < 0 ? ceil(param_0) : floor(param_0);
}
@ -1180,7 +1180,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(uint tint_pack4x8snorm(float4 param_0) {
int4 i = int4(round(clamp(param_0, -1.0, 1.0) * 127.0)) & 0xff;
return asuint(i.x | i.y << 8 | i.z << 16 | i.w << 24);
@ -1202,7 +1202,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(uint tint_pack4x8unorm(float4 param_0) {
uint4 i = uint4(round(clamp(param_0, 0.0, 1.0) * 255.0));
return (i.x | i.y << 8 | i.z << 16 | i.w << 24);
@ -1224,7 +1224,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(uint tint_pack2x16snorm(float2 param_0) {
int2 i = int2(round(clamp(param_0, -1.0, 1.0) * 32767.0)) & 0xffff;
return asuint(i.x | i.y << 16);
@ -1246,7 +1246,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(uint tint_pack2x16unorm(float2 param_0) {
uint2 i = uint2(round(clamp(param_0, 0.0, 1.0) * 65535.0));
return (i.x | i.y << 16);
@ -1268,7 +1268,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Float) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(uint tint_pack2x16float(float2 param_0) {
uint2 i = f32tof16(param_0);
return i.x | (i.y << 16);
@ -1290,7 +1290,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Unpack4x8Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float4 tint_unpack4x8snorm(uint param_0) {
int j = int(param_0);
int4 i = int4(j << 24, j << 16, j << 8, j) >> 24;
@ -1313,7 +1313,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Unpack4x8Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float4 tint_unpack4x8unorm(uint param_0) {
uint j = param_0;
uint4 i = uint4(j & 0xff, (j >> 8) & 0xff, (j >> 16) & 0xff, j >> 24);
@ -1336,7 +1336,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Snorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float2 tint_unpack2x16snorm(uint param_0) {
int j = int(param_0);
int2 i = int2(j << 16, j) >> 16;
@ -1359,7 +1359,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Unorm) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float2 tint_unpack2x16unorm(uint param_0) {
uint j = param_0;
uint2 i = uint2(j & 0xffff, j >> 16);
@ -1382,7 +1382,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Float) {
WrapInFunction(Decl(Var("r", call)));
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float2 tint_unpack2x16float(uint param_0) {
uint i = param_0;
return f16tof32(uint2(i & 0xffff, i >> 16));
@ -1410,7 +1410,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, StorageBarrier) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void main() {
DeviceMemoryBarrierWithGroupSync();
@ -1431,7 +1431,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, WorkgroupBarrier) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void main() {
GroupMemoryBarrierWithGroupSync();
@ -1450,7 +1450,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Dot4I8Packed) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(int tint_dot4I8Packed(uint param_0, uint param_1) {
int accumulator = 0;
return dot4add_i8packed(param_0, param_1, accumulator);
@ -1476,7 +1476,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, Dot4U8Packed) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(uint tint_dot4U8Packed(uint param_0, uint param_1) {
uint accumulator = 0u;
return dot4add_u8packed(param_0, param_1, accumulator);
@ -1499,7 +1499,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, CountOneBits) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
int val1 = 0;
@ -1516,7 +1516,7 @@ TEST_F(HlslGeneratorImplTest_Builtin, ReverseBits) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void test_function() {
int val1 = 0;

View File

@ -381,7 +381,7 @@ TEST_P(HlslGeneratorBuiltinTextureTest, Call) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto expected = expected_texture_overload(param.overload);

View File

@ -32,7 +32,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_func()");
}
@ -52,7 +52,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_func(param1, param2)");
}
@ -72,7 +72,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) {
GeneratorImpl& gen = Build();
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(call)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(call)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " my_func(param1, param2);\n");
}

View File

@ -30,7 +30,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5: {
break;
}
@ -45,7 +45,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5: {
break;
}
@ -63,7 +63,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5:
case 6: {
break;
@ -79,7 +79,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_Default) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s, 0u)) << gen.error();
ASSERT_TRUE(gen.EmitCase(s, 0u)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( default: {
break;
}

View File

@ -29,7 +29,7 @@ TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "1.0f");
}
@ -40,7 +40,7 @@ TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float3(1.0f, 2.0f, 3.0f)");
}

View File

@ -26,7 +26,7 @@ TEST_F(HlslGeneratorImplTest, Emit_GlobalConstAssert) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
// const asserts are not emitted
EXPECT_EQ(gen.result(), "");
}
@ -36,7 +36,7 @@ TEST_F(HlslGeneratorImplTest, Emit_FunctionConstAssert) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
// const asserts are not emitted
EXPECT_EQ(gen.result(), R"(void f() {
}

View File

@ -29,7 +29,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("false"));
}
@ -38,7 +38,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
}
@ -47,7 +47,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, UInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("56779u"));
}
@ -57,7 +57,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Float) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f"));
}
@ -69,7 +69,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float16_t(32752.0h)"));
}
@ -78,7 +78,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Float) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-0.00001200000042445026f"));
}
@ -89,7 +89,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float16_t(-0.0011997222900390625h)"));
}
@ -98,7 +98,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("true"));
}
@ -107,7 +107,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
}
@ -116,7 +116,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Uint) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("12345u"));
}
@ -125,7 +125,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float3(1.0f, 2.0f, 3.0f)"));
}
@ -136,7 +136,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(
gen.result(),
HasSubstr("vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h))"));
@ -147,7 +147,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("0.0f).xxx"));
}
@ -158,7 +158,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("(float16_t(0.0h)).xxx"));
}
@ -167,7 +167,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("2.0f).xxx"));
}
@ -178,7 +178,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("(float16_t(2.0h)).xxx"));
}
@ -189,7 +189,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(float v = 2.0f;
const float3 tint_symbol = float3((v).xxx);)"));
}
@ -203,7 +203,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(float16_t v = float16_t(2.0h);
const vector<float16_t, 3> tint_symbol = vector<float16_t, 3>((v).xxx);)"));
}
@ -213,7 +213,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool_Literal) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("(true).xxx"));
}
@ -224,7 +224,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool_Var) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(bool v = true;
const bool3 tint_symbol = bool3((v).xxx);)"));
}
@ -234,7 +234,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("2).xxx"));
}
@ -243,7 +243,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("2u).xxx"));
}
@ -252,7 +252,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("float2x3(float3(1.0f, 2.0f, 3.0f), float3(3.0f, 4.0f, 5.0f))"));
@ -265,7 +265,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), "
@ -294,7 +294,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float4x4(float4(2.0f, 3.0f, 4.0f, 8.0f), (0.0f).xxxx, "
"(7.0f).xxxx, float4(42.0f, 21.0f, 6.0f, -5.0f))"));
@ -323,7 +323,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("matrix<float16_t, 4, 4>("
"vector<float16_t, 4>(float16_t(2.0h), float16_t(3.0h), "
@ -338,7 +338,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float2x3 tint_symbol = float2x3((0.0f).xxx, (0.0f).xxx)"));
}
@ -350,7 +350,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("matrix<float16_t, 2, 3>((float16_t(0.0h)).xxx, (float16_t(0.0h)).xxx)"));
@ -369,7 +369,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float4x4 m_2 = float4x4(m_1);"));
}
@ -389,7 +389,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("matrix<float16_t, 4, 4> m_2 = matrix<float16_t, 4, 4>(m_1);"));
@ -401,7 +401,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Array) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(
gen.result(),
HasSubstr(
@ -413,7 +413,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Array_Empty) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("(float3[3])0"));
}
@ -428,7 +428,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Struct) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("{1, 2.0f, int3(3, 4, 5)}"));
}
@ -443,7 +443,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, Type_Struct_Empty) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("(S)0"));
}

View File

@ -28,7 +28,7 @@ TEST_F(HlslGeneratorImplTest_Continue, Emit_Continue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
if (false) {
break;

View File

@ -29,7 +29,7 @@ TEST_F(HlslGeneratorImplTest_Discard, Emit_Discard) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " discard;\n");
}

View File

@ -37,7 +37,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( void my_func() {
return;
}
@ -54,7 +54,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"( void tint_symbol() {
return;
})"));
@ -75,7 +75,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( void my_func(float a, int b) {
return;
}
@ -90,7 +90,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_NoReturn_Void)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void main() {
return;
}
@ -106,7 +106,7 @@ TEST_F(HlslGeneratorImplTest_Function, PtrParameter) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(float f(inout float foo) {
return foo;
}
@ -131,7 +131,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOutVars)
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct tint_symbol_1 {
float foo : TEXCOORD0;
};
@ -171,7 +171,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOut_Built
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct tint_symbol_1 {
float4 coord : SV_Position;
};
@ -230,7 +230,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_Di
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct Interface {
float4 pos;
float col1;
@ -315,7 +315,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_He
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct VertexOutput {
float4 pos;
};
@ -384,7 +384,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(cbuffer cbuffer_ubo : register(b0, space1) {
uint4 ubo[1];
};
@ -418,7 +418,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(cbuffer cbuffer_uniforms : register(b0, space1) {
uint4 uniforms[1];
};
@ -452,7 +452,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(RWByteAddressBuffer coord : register(u0, space1);
@ -485,7 +485,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(ByteAddressBuffer coord : register(t0, space1);
@ -516,7 +516,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(RWByteAddressBuffer coord : register(u0, space1);
@ -547,7 +547,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(RWByteAddressBuffer coord : register(u0, space1);
@ -584,7 +584,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(cbuffer cbuffer_coord : register(b0, space1) {
uint4 coord[1];
};
@ -627,7 +627,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(RWByteAddressBuffer coord : register(u0, space1);
@ -650,7 +650,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithNameCollisi
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void tint_symbol() {
return;
}
@ -666,7 +666,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)]
void main() {
return;
@ -683,7 +683,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWor
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(2, 4, 6)]
void main() {
return;
@ -703,7 +703,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWor
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"([numthreads(2, 3, 4)]
void main() {
return;
@ -724,9 +724,9 @@ TEST_F(HlslGeneratorImplTest_Function,
GeneratorImpl& gen = Build();
EXPECT_FALSE(gen.Generate()) << gen.error();
EXPECT_FALSE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(
gen.error(),
gen.Diagnostics().str(),
R"(error: override-expressions should have been removed with the SubstituteOverride transform)");
}
@ -742,7 +742,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void my_func(float a[5]) {
return;
}
@ -757,7 +757,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayReturn) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(typedef float my_func_ret[5];
my_func_ret my_func() {
return (float[5])0;
@ -775,7 +775,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithDiscardAndVoidReturn) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void my_func(int a) {
if ((a == 0)) {
discard;
@ -795,7 +795,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithDiscardAndNonVoidReturn
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(int my_func(int a) {
if (true) {
if ((a == 0)) {
@ -863,7 +863,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(RWByteAddressBuffer data : register(u0);
[numthreads(1, 1, 1)]

View File

@ -29,7 +29,7 @@ TEST_F(HlslGeneratorImplTest_Identifier, EmitIdentifierExpression) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, i)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, i)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "foo");
}

View File

@ -30,7 +30,7 @@ TEST_F(HlslGeneratorImplTest_If, Emit_If) {
GeneratorImpl& gen = Build();
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
}
@ -53,7 +53,7 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {
@ -78,7 +78,7 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {
@ -106,7 +106,7 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {

View File

@ -41,7 +41,7 @@ TEST_P(HlslImportData_SingleParamTest, FloatScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.hlsl_name) + "(1.0f)");
}
INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
@ -78,7 +78,7 @@ TEST_P(HlslImportData_SingleIntParamTest, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.hlsl_name) + "(1)");
}
INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
@ -95,7 +95,7 @@ TEST_P(HlslImportData_SingleVectorParamTest, FloatVector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(
out.str(),
std::string(param.hlsl_name) +
@ -136,7 +136,7 @@ TEST_P(HlslImportData_DualParam_ScalarTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.hlsl_name) + "(1.0f, 2.0f)");
}
INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
@ -158,7 +158,7 @@ TEST_P(HlslImportData_DualParam_VectorTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.hlsl_name) +
"(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f))");
}
@ -183,7 +183,7 @@ TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.hlsl_name) + "(1, 2)");
}
INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
@ -201,7 +201,7 @@ TEST_P(HlslImportData_TripleParam_ScalarTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.hlsl_name) + "(1.0f, 2.0f, 3.0f)");
}
INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
@ -222,7 +222,7 @@ TEST_P(HlslImportData_TripleParam_VectorTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(
out.str(),
std::string(param.hlsl_name) +
@ -245,7 +245,7 @@ TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.hlsl_name) + "(1, 2, 3)");
}
INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
@ -261,7 +261,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string("determinant(var)"));
}
@ -274,7 +274,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Scalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string("f16tof32(f32tof16(v))"));
}
@ -287,7 +287,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Vector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string("f16tof32(f32tof16(v))"));
}

View File

@ -34,7 +34,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
}
@ -55,7 +55,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
{
@ -79,7 +79,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing_BreakIf) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
{
@ -116,7 +116,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
while (true) {
break;
@ -156,7 +156,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
float lhs = 2.5f;
float other = 0.0f;
@ -180,7 +180,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoop) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(; ; ) {
return;
@ -201,7 +201,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(int i = 0; ; ) {
return;
@ -225,7 +225,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = t;
if (tint_tmp) {
@ -251,7 +251,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(; true; ) {
return;
@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
while (true) {
bool tint_tmp = t;
@ -303,7 +303,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(; ; i = (i + 1)) {
return;
@ -329,7 +329,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
while (true) {
return;
@ -355,7 +355,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
for(int i = 0; true; i = (i + 1)) {
return;
@ -383,7 +383,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = t;
if (tint_tmp) {
@ -419,7 +419,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_While) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while(true) {
return;
}
@ -438,7 +438,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_While_WithContinue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while(true) {
continue;
}
@ -462,7 +462,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
bool tint_tmp = t;
if (tint_tmp) {

View File

@ -129,7 +129,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct Data {
float mem;
};
@ -178,7 +178,7 @@ TEST_P(HlslGeneratorImplTest_MemberAccessor_StorageBufferLoad_ConstantOffset, Te
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
}
@ -321,7 +321,7 @@ TEST_P(HlslGeneratorImplTest_MemberAccessor_StorageBufferLoad_DynamicOffset, Tes
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
}
@ -452,7 +452,7 @@ TEST_P(HlslGeneratorImplTest_MemberAccessor_UniformBufferLoad_ConstantOffset, Te
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
}
@ -728,7 +728,7 @@ TEST_P(HlslGeneratorImplTest_MemberAccessor_UniformBufferLoad_DynamicOffset, Tes
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
}
@ -1003,7 +1003,7 @@ TEST_P(HlslGeneratorImplTest_MemberAccessor_StorageBufferStore, Test) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
}
@ -1138,7 +1138,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Matrix_Empty) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1174,7 +1174,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_F32_Singl
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1207,7 +1207,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_F16_Singl
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1238,7 +1238,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, UniformBuffer_Load_Matrix_F32_Singl
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[5];
@ -1273,7 +1273,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, UniformBuffer_Load_Matrix_F16_Singl
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[3];
@ -1307,7 +1307,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1339,7 +1339,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[6];
@ -1382,7 +1382,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(struct Inner {
int v;
@ -1432,7 +1432,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(struct Inner {
int v;
@ -1479,7 +1479,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1517,7 +1517,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[6];
@ -1553,7 +1553,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1592,7 +1592,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1631,7 +1631,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, UniformBuffer_Load_MultiLevel) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[8];
@ -1674,7 +1674,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizz
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1715,7 +1715,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, UniformBuffer_Load_MultiLevel_Swizz
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[8];
@ -1759,7 +1759,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1801,7 +1801,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[8];
@ -1844,7 +1844,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1885,7 +1885,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, UniformBuffer_Load_MultiLevel_Index
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(cbuffer cbuffer_data : register(b1, space1) {
uint4 data[8];
@ -1927,7 +1927,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1968,7 +1968,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto* expected =
R"(RWByteAddressBuffer data : register(u0, space1);
@ -1986,7 +1986,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
WrapInFunction(var, expr);
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("my_vec.xyz"));
}
@ -1996,7 +1996,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
WrapInFunction(var, expr);
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("my_vec.gbr"));
}

View File

@ -28,7 +28,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const int l = 1;
@ -42,7 +42,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float l = 1.0f;
@ -56,7 +56,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_i32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const int l = 1;
@ -70,7 +70,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_u32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const uint l = 1u;
@ -84,7 +84,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float l = 1.0f;
@ -100,7 +100,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float16_t l = float16_t(1.0h);
@ -114,7 +114,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const int3 l = int3(1, 2, 3);
@ -128,7 +128,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float3 l = float3(1.0f, 2.0f, 3.0f);
@ -142,7 +142,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float3 l = float3(1.0f, 2.0f, 3.0f);
@ -158,7 +158,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const vector<float16_t, 3> l = vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h));
@ -172,7 +172,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float2x3 l = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
@ -186,7 +186,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float2x3 l = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
@ -202,7 +202,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const matrix<float16_t, 2, 3> l = matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));
@ -216,7 +216,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float l[3] = {1.0f, 2.0f, 3.0f};
@ -233,7 +233,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_vec2_bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const bool2 l[3] = {bool2(true, false), bool2(false, true), (true).xx};

View File

@ -29,7 +29,7 @@ TEST_F(HlslGeneratorImplTest_Return, Emit_Return) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " return;\n");
}
@ -41,7 +41,7 @@ TEST_F(HlslGeneratorImplTest_Return, Emit_ReturnWithValue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " return 123;\n");
}

View File

@ -39,7 +39,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(ByteAddressBuffer b : register(t1, space2);
@ -73,7 +73,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(ByteAddressBuffer b : register(t1, space2);
@ -110,7 +110,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(ByteAddressBuffer b : register(t1, space2);
@ -149,7 +149,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
options.array_length_from_uniform.bindpoint_to_size_index.emplace(sem::BindingPoint{2, 2}, 7u);
GeneratorImpl& gen = SanitizeAndBuild(options);
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(cbuffer cbuffer_tint_symbol_1 : register(b4, space3) {
@ -183,7 +183,7 @@ TEST_F(HlslSanitizerTest, PromoteArrayInitializerToConstVar) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(void main() {
@ -218,7 +218,7 @@ TEST_F(HlslSanitizerTest, PromoteStructInitializerToConstVar) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(struct S {
@ -257,7 +257,7 @@ TEST_F(HlslSanitizerTest, InlinePtrLetsBasic) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(void main() {
@ -299,7 +299,7 @@ TEST_F(HlslSanitizerTest, InlinePtrLetsComplexChain) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(void main() {

View File

@ -33,7 +33,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( switch(cond) {
case 5: {
break;
@ -56,7 +56,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch_MixedDefault) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( switch(cond) {
case 5:
default: {
@ -87,7 +87,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch_OnlyDefaultCase_NoSideEffectsCo
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( do {
a = 42;
} while (false);
@ -125,7 +125,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch_OnlyDefaultCase_SideEffectsCond
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( bar();
do {
a = 42;

View File

@ -34,7 +34,8 @@ TEST_F(HlslGeneratorImplTest, UnsupportedExtension) {
GeneratorImpl& gen = Build();
ASSERT_FALSE(gen.Generate());
EXPECT_EQ(gen.error(), R"(12:34 error: HLSL backend does not support extension 'undefined')");
EXPECT_EQ(gen.Diagnostics().str(),
R"(12:34 error: HLSL backend does not support extension 'undefined')");
}
TEST_F(HlslGeneratorImplTest, Generate) {
@ -42,7 +43,7 @@ TEST_F(HlslGeneratorImplTest, Generate) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void my_func() {
}
)");

View File

@ -42,7 +42,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, "ary"))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool ary[4]");
}
@ -55,7 +55,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, "ary"))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool ary[5][4]");
}
@ -68,7 +68,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, "ary"))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool ary[6][5][4]");
}
@ -81,7 +81,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool[4]");
}
@ -93,7 +93,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, bool_, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "bool");
}
@ -105,7 +105,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, f16, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "float16_t");
}
@ -117,7 +117,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, f32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "float");
}
@ -129,7 +129,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, i32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "int");
}
@ -143,7 +143,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "matrix<float16_t, 2, 3>");
}
@ -157,7 +157,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "float2x3");
}
@ -172,7 +172,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
EXPECT_EQ(buf.String(), R"(struct S {
int a;
float b;
@ -190,7 +190,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), "RWByteAddressBuffer g : register(u0);\n");
}
@ -207,7 +207,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, sem_s, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "S");
}
@ -220,7 +220,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(struct S {
int tint_symbol;
float tint_symbol_1;
@ -239,7 +239,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
EXPECT_EQ(buf.String(), R"(struct S {
int a;
float b;
@ -255,7 +255,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, u32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "uint");
}
@ -268,7 +268,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "float3");
}
@ -280,7 +280,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, void_, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "void");
}
@ -292,7 +292,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "SamplerState");
}
@ -304,7 +304,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined,
builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "SamplerComparisonState");
}
@ -336,7 +336,7 @@ TEST_P(HlslDepthTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(
@ -367,7 +367,7 @@ TEST_F(HlslDepthMultisampledTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("Texture2DMS<float4> tex : register(t1, space2);"));
}
@ -413,7 +413,7 @@ TEST_P(HlslSampledTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Type,
@ -519,7 +519,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
utils::StringStream out;
ASSERT_TRUE(
gen.EmitType(out, s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
<< gen.error();
<< gen.Diagnostics();
EXPECT_EQ(out.str(), "Texture2DMS<float4>");
}
@ -556,7 +556,7 @@ TEST_P(HlslStorageTexturesTest, Emit) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(

View File

@ -28,7 +28,7 @@ TEST_F(HlslUnaryOpTest, AddressOf) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "expr");
}
@ -40,7 +40,7 @@ TEST_F(HlslUnaryOpTest, Complement) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "~(expr)");
}
@ -53,7 +53,7 @@ TEST_F(HlslUnaryOpTest, Indirection) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "expr");
}
@ -65,7 +65,7 @@ TEST_F(HlslUnaryOpTest, Not) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "!(expr)");
}
@ -77,7 +77,7 @@ TEST_F(HlslUnaryOpTest, Negation) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "-(expr)");
}
} // namespace

View File

@ -34,7 +34,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " float a = 0.0f;\n");
}
@ -47,7 +47,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Let) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " const float a = 0.0f;\n");
}
@ -60,7 +60,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), ""); // Not a mistake - 'const' is inlined
}
@ -74,7 +74,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AInt
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const int l = 1;
@ -92,7 +92,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AFlo
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float l = 1.0f;
@ -110,7 +110,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_i32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const int l = 1;
@ -128,7 +128,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_u32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const uint l = 1u;
@ -146,7 +146,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float l = 1.0f;
@ -166,7 +166,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f16)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float16_t l = float16_t(1.0h);
@ -184,7 +184,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const int3 l = int3(1, 2, 3);
@ -202,7 +202,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float3 l = float3(1.0f, 2.0f, 3.0f);
@ -220,7 +220,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float3 l = float3(1.0f, 2.0f, 3.0f);
@ -240,7 +240,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const vector<float16_t, 3> l = vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h));
@ -258,7 +258,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float2x3 l = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float2x3 l = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
@ -296,7 +296,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const matrix<float16_t, 2, 3> l = matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));
@ -314,7 +314,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const float l[3] = {1.0f, 2.0f, 3.0f};
@ -335,7 +335,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(void f() {
const bool2 l[3] = {bool2(true, false), bool2(false, true), (true).xx};
@ -352,7 +352,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(" float a[5] = (float[5])0;\n"));
}
@ -365,7 +365,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(" static float a = 0.0f;\n"));
}
@ -377,7 +377,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float3 a = (0.0f).xxx;
)");
}
@ -392,7 +392,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(vector<float16_t, 3> a = (float16_t(0.0h)).xxx;
)");
}
@ -405,7 +405,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(float2x3 a = float2x3((0.0f).xxx, (0.0f).xxx);
)");
@ -421,7 +421,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(
gen.result(),
R"(matrix<float16_t, 2, 3> a = matrix<float16_t, 2, 3>((float16_t(0.0h)).xxx, (float16_t(0.0h)).xxx);

View File

@ -36,7 +36,7 @@ TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) {
});
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("groupshared float wg;\n"));
}
@ -52,7 +52,7 @@ TEST_F(HlslGeneratorImplTest_WorkgroupVar, Aliased) {
});
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("groupshared float wg;\n"));
}

View File

@ -50,7 +50,7 @@ Result Generate(const Program* program, const Options& options) {
// Generate the MSL code.
auto impl = std::make_unique<GeneratorImpl>(&sanitized_result.program);
result.success = impl->Generate();
result.error = impl->error();
result.error = impl->Diagnostics().str();
result.msl = impl->result();
result.has_invariant_attribute = impl->HasInvariant();
result.workgroup_allocations = impl->DynamicWorkgroupAllocations();

View File

@ -30,7 +30,7 @@ TEST_F(MslGeneratorImplTest, IndexAccessor) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "ary[5]");
}
@ -44,7 +44,7 @@ TEST_F(MslGeneratorImplTest, IndexAccessor_OfDref) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(*(p))[5]");
}

View File

@ -29,7 +29,7 @@ TEST_F(MslGeneratorImplTest, Emit_Assign) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(assign)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(assign)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " lhs = rhs;\n");
}

View File

@ -48,7 +48,7 @@ TEST_P(MslBinaryTest, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(
@ -92,7 +92,7 @@ TEST_P(MslBinaryTest_SignedOverflowDefinedBehaviour, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
using Op = ast::BinaryOp;
@ -126,7 +126,7 @@ TEST_P(MslBinaryTest_SignedOverflowDefinedBehaviour_Chained, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr2)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr2)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
using Op = ast::BinaryOp;
@ -153,7 +153,7 @@ TEST_F(MslBinaryTest, ModF32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "fmod(left, right)");
}
@ -168,7 +168,7 @@ TEST_F(MslBinaryTest, ModF16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "fmod(left, right)");
}
@ -181,7 +181,7 @@ TEST_F(MslBinaryTest, ModVec3F32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "fmod(left, right)");
}
@ -196,7 +196,7 @@ TEST_F(MslBinaryTest, ModVec3F16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "fmod(left, right)");
}
@ -209,7 +209,7 @@ TEST_F(MslBinaryTest, BoolAnd) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "bool(left & right)");
}
@ -222,7 +222,7 @@ TEST_F(MslBinaryTest, BoolOr) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "bool(left | right)");
}

View File

@ -30,7 +30,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Bitcast) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "as_type<float>(a)");
}

View File

@ -27,7 +27,7 @@ TEST_F(MslGeneratorImplTest, Emit_Block) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
return;
}
@ -42,7 +42,7 @@ TEST_F(MslGeneratorImplTest, Emit_Block_WithoutNewline) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitBlock(b)) << gen.error();
ASSERT_TRUE(gen.EmitBlock(b)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
return;
}

View File

@ -27,7 +27,7 @@ TEST_F(MslGeneratorImplTest, Emit_Break) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " break;\n");
}

View File

@ -384,7 +384,7 @@ TEST_F(MslGeneratorImplTest, Builtin_Call) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "dot(param1, param2)");
}
@ -395,7 +395,7 @@ TEST_F(MslGeneratorImplTest, StorageBarrier) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "threadgroup_barrier(mem_flags::mem_device)");
}
@ -406,7 +406,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupBarrier) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "threadgroup_barrier(mem_flags::mem_threadgroup)");
}
@ -416,7 +416,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Modf_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -448,7 +448,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Modf_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -478,7 +478,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Modf_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -510,7 +510,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Modf_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -539,7 +539,7 @@ TEST_F(MslGeneratorImplTest, Const_Modf_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -563,7 +563,7 @@ TEST_F(MslGeneratorImplTest, Const_Modf_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -585,7 +585,7 @@ TEST_F(MslGeneratorImplTest, Const_Modf_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -609,7 +609,7 @@ TEST_F(MslGeneratorImplTest, Const_Modf_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -632,7 +632,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Frexp_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -664,7 +664,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Frexp_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -694,7 +694,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Frexp_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -726,7 +726,7 @@ TEST_F(MslGeneratorImplTest, Runtime_Frexp_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -755,7 +755,7 @@ TEST_F(MslGeneratorImplTest, Const_Frexp_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -779,7 +779,7 @@ TEST_F(MslGeneratorImplTest, Const_Frexp_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -801,7 +801,7 @@ TEST_F(MslGeneratorImplTest, Const_Frexp_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -825,7 +825,7 @@ TEST_F(MslGeneratorImplTest, Const_Frexp_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -849,7 +849,7 @@ TEST_F(MslGeneratorImplTest, Degrees_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -874,7 +874,7 @@ TEST_F(MslGeneratorImplTest, Degrees_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -901,7 +901,7 @@ TEST_F(MslGeneratorImplTest, Degrees_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -928,7 +928,7 @@ TEST_F(MslGeneratorImplTest, Degrees_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -953,7 +953,7 @@ TEST_F(MslGeneratorImplTest, Radians_Scalar_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -978,7 +978,7 @@ TEST_F(MslGeneratorImplTest, Radians_Vector_f32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -1005,7 +1005,7 @@ TEST_F(MslGeneratorImplTest, Radians_Scalar_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -1032,7 +1032,7 @@ TEST_F(MslGeneratorImplTest, Radians_Vector_f16) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -1058,7 +1058,7 @@ TEST_F(MslGeneratorImplTest, Pack2x16Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "as_type<uint>(half2(p1))");
}
@ -1070,7 +1070,7 @@ TEST_F(MslGeneratorImplTest, Unpack2x16Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float2(as_type<half2>(p1))");
}
@ -1080,7 +1080,7 @@ TEST_F(MslGeneratorImplTest, DotI32) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -1114,7 +1114,7 @@ TEST_F(MslGeneratorImplTest, Ignore) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;

View File

@ -287,7 +287,7 @@ TEST_P(MslGeneratorBuiltinTextureTest, Call) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
auto expected = expected_texture_overload(param.overload);
EXPECT_EQ(expected, out.str());

View File

@ -32,7 +32,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_func()");
}
@ -55,7 +55,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_func(param1, param2)");
}
@ -76,7 +76,7 @@ TEST_F(MslGeneratorImplTest, EmitStatement_Call) {
GeneratorImpl& gen = Build();
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " my_func(param1, param2);\n");
}

View File

@ -30,7 +30,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5: {
break;
}
@ -45,7 +45,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5: {
break;
}
@ -67,7 +67,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( case 5:
case 6: {
break;
@ -83,7 +83,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_Default) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.error();
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( default: {
break;
}

View File

@ -29,7 +29,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Scalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "1.0f");
}
@ -40,7 +40,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Vector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float3(1.0f, 2.0f, 3.0f)");
}
@ -51,7 +51,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Cast_IntMin) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "2147483648u");
}

View File

@ -26,7 +26,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConstAssert) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
// const asserts are not emitted
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -39,7 +39,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionConstAssert) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
// const asserts are not emitted
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>

View File

@ -29,7 +29,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("false"));
}
@ -38,7 +38,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
}
@ -47,7 +47,7 @@ TEST_F(MslGeneratorImplTest_Constructor, UInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("56779u"));
}
@ -57,7 +57,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Float) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f"));
}
@ -69,7 +69,7 @@ TEST_F(MslGeneratorImplTest_Constructor, F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("32752.0h"));
}
@ -78,7 +78,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Float) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-0.00001200000042445026f"));
}
@ -89,7 +89,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-0.0011997222900390625h"));
}
@ -98,7 +98,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("true"));
}
@ -107,7 +107,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
}
@ -116,7 +116,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Uint) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("12345u"));
}
@ -125,7 +125,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float3(1.0f, 2.0f, 3.0f)"));
}
@ -136,7 +136,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("half3(1.0h, 2.0h, 3.0h)"));
}
@ -145,7 +145,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float3(0.0f)"));
}
@ -156,7 +156,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("half3(0.0h)"));
}
@ -165,7 +165,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float3(2.0f)"));
}
@ -176,7 +176,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("half3(2.0h)"));
}
@ -187,7 +187,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(float v = 2.0f;
float3 const tint_symbol = float3(v);)"));
}
@ -201,7 +201,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(half v = 2.0h;
half3 const tint_symbol = half3(v);)"));
}
@ -211,7 +211,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("bool3(true)"));
}
@ -220,7 +220,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("int3(2)"));
}
@ -229,7 +229,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("uint3(2u)"));
}
@ -238,7 +238,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("float2x3(float3(1.0f, 2.0f, 3.0f), float3(3.0f, 4.0f, 5.0f))"));
@ -251,7 +251,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("half2x3(half3(1.0h, 2.0h, 3.0h), half3(3.0h, 4.0h, 5.0h))"));
@ -278,7 +278,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float4x4(float4(2.0f, 3.0f, 4.0f, 8.0f), float4(0.0f), "
"float4(7.0f), float4(42.0f, 21.0f, 6.0f, -5.0f))"));
@ -307,7 +307,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("half4x4(half4(2.0h, 3.0h, 4.0h, 8.0h), half4(0.0h), "
"half4(7.0h), half4(42.0h, 21.0h, 6.0h, -5.0h))"));
@ -318,7 +318,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("float2x3 const tint_symbol = float2x3(float3(0.0f), float3(0.0f))"));
@ -331,7 +331,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(),
HasSubstr("half2x3 const tint_symbol = half2x3(half3(0.0h), half3(0.0h))"));
@ -350,7 +350,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("float4x4 m_2 = float4x4(m_1);"));
}
@ -370,7 +370,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("half4x4 m_2 = half4x4(m_1);"));
}
@ -381,7 +381,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Array) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("{float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), "
"float3(7.0f, 8.0f, 9.0f)}"));
}
@ -397,7 +397,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Struct) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("{.a=1, .b=2.0f, .c=int3(3, 4, 5)}"));
}
@ -412,7 +412,7 @@ TEST_F(MslGeneratorImplTest_Constructor, Type_Struct_Empty) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("{}"));
EXPECT_THAT(gen.result(), testing::Not(HasSubstr("{{}}")));
}

View File

@ -28,7 +28,7 @@ TEST_F(MslGeneratorImplTest, Emit_Continue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
if (false) {
break;

View File

@ -29,7 +29,7 @@ TEST_F(MslGeneratorImplTest, Emit_Discard) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " discard_fragment();\n");
}

View File

@ -33,7 +33,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( #include <metal_stdlib>
using namespace metal;
@ -59,7 +59,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( #include <metal_stdlib>
using namespace metal;
@ -76,7 +76,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_EntryPoint_NoReturn_Void) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -105,7 +105,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_EntryPoint_WithInOutVars) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -150,7 +150,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_EntryPoint_WithInOut_Builtins) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -206,7 +206,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_EntryPoint_SharedStruct_DifferentSta
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -289,7 +289,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_EntryPoint_SharedStruct_HelperFuncti
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -357,7 +357,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -396,7 +396,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -440,7 +440,7 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -491,7 +491,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -543,7 +543,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -578,7 +578,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( #include <metal_stdlib>
using namespace metal;
@ -612,7 +612,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayReturn) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( #include <metal_stdlib>
using namespace metal;
@ -689,7 +689,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_ModuleV
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;

View File

@ -29,7 +29,7 @@ TEST_F(MslGeneratorImplTest, EmitIdentifierExpression) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, i)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, i)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "foo");
}

View File

@ -28,7 +28,7 @@ TEST_F(MslGeneratorImplTest, Emit_If) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
}
@ -45,7 +45,7 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithElseIf) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {
@ -65,7 +65,7 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithElse) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {
@ -85,7 +85,7 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithMultiple) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( if (cond) {
return;
} else {

View File

@ -83,7 +83,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), R"(abs(1))");
}
@ -94,7 +94,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_ScalarLength) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), R"(fabs(2.0f))");
}
@ -108,7 +108,7 @@ TEST_P(MslImportData_DualParam_ScalarTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.msl_name) + "(1.0f, 2.0f)");
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@ -126,7 +126,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_DualParam_ScalarDistance) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), R"(fabs(2.0f - 3.0f))");
}
@ -140,7 +140,7 @@ TEST_P(MslImportData_DualParam_VectorTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.msl_name) +
R"((float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f)))");
}
@ -165,7 +165,7 @@ TEST_P(MslImportData_DualParam_Int_Test, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.msl_name) + "(1, 2)");
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@ -182,7 +182,7 @@ TEST_P(MslImportData_TripleParam_ScalarTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.msl_name) + "(1.0f, 2.0f, 3.0f)");
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@ -203,7 +203,7 @@ TEST_P(MslImportData_TripleParam_VectorTest, Float) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(
out.str(),
std::string(param.msl_name) +
@ -226,7 +226,7 @@ TEST_P(MslImportData_TripleParam_Int_Test, IntScalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string(param.msl_name) + "(1, 2, 3)");
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@ -244,7 +244,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_Determinant) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), std::string("determinant(var)"));
}
@ -257,7 +257,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_QuantizeToF16_Scalar) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float(half(v))");
}
@ -270,7 +270,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_QuantizeToF16_Vector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float3(half3(v))");
}

View File

@ -34,7 +34,7 @@ TEST_F(MslGeneratorImplTest, Emit_Loop) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
}
@ -55,7 +55,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
{
@ -79,7 +79,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing_BreakIf) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
break;
{
@ -113,7 +113,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
while (true) {
break;
@ -153,7 +153,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
float lhs = 2.5f;
float other = 0.0f;
@ -178,7 +178,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoop) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( for(; ; ) {
return;
}
@ -198,7 +198,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleInit) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( for(int i = 0; ; ) {
return;
}
@ -226,7 +226,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
{
f(1);
@ -252,7 +252,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( for(; true; ) {
return;
}
@ -273,7 +273,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"( for(; ; i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
return;
@ -302,7 +302,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while (true) {
return;
{
@ -328,7 +328,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleInitCondCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"( for(int i = 0; true; i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
a_statement();
@ -358,7 +358,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( {
{
f(1);
@ -388,7 +388,7 @@ TEST_F(MslGeneratorImplTest, Emit_While) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while(true) {
return;
}
@ -407,7 +407,7 @@ TEST_F(MslGeneratorImplTest, Emit_While_WithContinue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while(true) {
continue;
}
@ -429,7 +429,7 @@ TEST_F(MslGeneratorImplTest, Emit_WhileWithMultiCond) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( while((t && false)) {
return;
}

View File

@ -29,7 +29,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "str.mem");
}
@ -41,7 +41,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_xyz) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_vec.xyz");
}
@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_gbr) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "my_vec.gbr");
}

View File

@ -28,7 +28,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -46,7 +46,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -64,7 +64,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_i32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -82,7 +82,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_u32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -100,7 +100,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -120,7 +120,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -138,7 +138,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_vec3_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -156,7 +156,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_vec3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -174,7 +174,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_vec3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -194,7 +194,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_vec3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -212,7 +212,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_mat2x3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -230,7 +230,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_mat2x3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -250,7 +250,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_mat2x3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -268,7 +268,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_arr_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -302,7 +302,7 @@ TEST_F(MslGeneratorImplTest, Emit_GlobalConst_arr_vec2_bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>

View File

@ -29,7 +29,7 @@ TEST_F(MslGeneratorImplTest, Emit_Return) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " return;\n");
}
@ -41,7 +41,7 @@ TEST_F(MslGeneratorImplTest, Emit_ReturnWithValue) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " return 123;\n");
}

View File

@ -44,7 +44,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength) {
opts.array_length_from_uniform.bindpoint_to_size_index.emplace(sem::BindingPoint{2, 1}, 1);
GeneratorImpl& gen = SanitizeAndBuild(opts);
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#include <metal_stdlib>
@ -101,7 +101,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
opts.array_length_from_uniform.bindpoint_to_size_index.emplace(sem::BindingPoint{2, 1}, 1);
GeneratorImpl& gen = SanitizeAndBuild(opts);
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#include <metal_stdlib>
@ -162,7 +162,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) {
opts.array_length_from_uniform.bindpoint_to_size_index.emplace(sem::BindingPoint{2, 1}, 1);
GeneratorImpl& gen = SanitizeAndBuild(opts);
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#include <metal_stdlib>
@ -222,7 +222,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
options.array_length_from_uniform.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 2}, 2u);
GeneratorImpl& gen = SanitizeAndBuild(options);
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
auto got = gen.result();
auto* expect = R"(#include <metal_stdlib>
@ -281,7 +281,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniformMissingBinding)
GeneratorImpl& gen = SanitizeAndBuild(options);
ASSERT_FALSE(gen.Generate());
EXPECT_THAT(gen.error(), HasSubstr("Unable to translate builtin: arrayLength"));
EXPECT_THAT(gen.Diagnostics().str(), HasSubstr("Unable to translate builtin: arrayLength"));
}
} // namespace

View File

@ -37,7 +37,7 @@ TEST_F(MslGeneratorImplTest, Emit_Switch) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( switch(cond) {
case 5: {
break;
@ -61,7 +61,7 @@ TEST_F(MslGeneratorImplTest, Emit_Switch_MixedDefault) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( switch(cond) {
case 5:
default: {

View File

@ -37,7 +37,8 @@ TEST_F(MslGeneratorImplTest, UnsupportedExtension) {
GeneratorImpl& gen = Build();
ASSERT_FALSE(gen.Generate());
EXPECT_EQ(gen.error(), R"(12:34 error: MSL backend does not support extension 'undefined')");
EXPECT_EQ(gen.Diagnostics().str(),
R"(12:34 error: MSL backend does not support extension 'undefined')");
}
TEST_F(MslGeneratorImplTest, Generate) {
@ -49,7 +50,7 @@ TEST_F(MslGeneratorImplTest, Generate) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -111,7 +112,7 @@ TEST_F(MslGeneratorImplTest, HasInvariantAttribute_True) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_TRUE(gen.HasInvariant());
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -148,7 +149,7 @@ TEST_F(MslGeneratorImplTest, HasInvariantAttribute_False) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_FALSE(gen.HasInvariant());
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -174,7 +175,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrix) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -214,7 +215,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrixInArray) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -275,7 +276,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrixInStruct) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;
@ -363,7 +364,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrix_Multiples) {
GeneratorImpl& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
using namespace metal;

View File

@ -96,7 +96,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_array<bool, 4>");
}
@ -108,7 +108,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_array<tint_array<bool, 4>, 5>");
}
@ -121,7 +121,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_array<tint_array<tint_array<bool, 4>, 5>, 6>");
}
@ -132,7 +132,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_array<bool, 4>");
}
@ -143,7 +143,7 @@ TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "ary")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_array<bool, 1>");
}
@ -153,7 +153,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Bool) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, bool_, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, bool_, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "bool");
}
@ -163,7 +163,7 @@ TEST_F(MslGeneratorImplTest, EmitType_F32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, f32, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, f32, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float");
}
@ -173,7 +173,7 @@ TEST_F(MslGeneratorImplTest, EmitType_F16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, f16, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, f16, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "half");
}
@ -183,7 +183,7 @@ TEST_F(MslGeneratorImplTest, EmitType_I32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, i32, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, i32, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "int");
}
@ -195,7 +195,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, mat2x3, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, mat2x3, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float2x3");
}
@ -207,7 +207,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, mat2x3, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, mat2x3, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "half2x3");
}
@ -219,7 +219,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Pointer) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, p, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, p, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "threadgroup float* ");
}
@ -232,7 +232,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(s), "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(s), "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "S");
}
@ -246,7 +246,7 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
EXPECT_EQ(buf.String(), R"(struct S {
int a;
float b;
@ -293,7 +293,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(type)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
// ALL_FIELDS() calls the macro FIELD(ADDR, TYPE, ARRAY_COUNT, NAME)
// for each field of the structure s.
@ -402,7 +402,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(type)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
// ALL_FIELDS() calls the macro FIELD(ADDR, TYPE, ARRAY_COUNT, NAME)
// for each field of the structure s.
@ -494,7 +494,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(type)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
// ALL_FIELDS() calls the macro FIELD(ADDR, TYPE, ARRAY_COUNT, NAME)
// for each field of the structure s.
@ -578,7 +578,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(type)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
// ALL_FIELDS() calls the macro FIELD(ADDR, TYPE, ARRAY_COUNT, NAME)
// for each field of the structure s.
@ -640,7 +640,7 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(type)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
EXPECT_EQ(buf.String(), R"(struct S {
/* 0x0000 */ int tint_pad_2;
/* 0x0004 */ tint_array<int8_t, 124> tint_pad_10;
@ -699,7 +699,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) {
TextGenerator::TextBuffer buf;
auto* sem_s = program->TypeOf(type)->As<sem::Struct>();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.error();
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
EXPECT_EQ(buf.String(), R"(struct S {
/* 0x0000 */ int a;
/* 0x0004 */ float b;
@ -713,7 +713,7 @@ TEST_F(MslGeneratorImplTest, EmitType_U32) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, u32, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, u32, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "uint");
}
@ -724,7 +724,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Vector) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, vec3, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, vec3, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "float3");
}
@ -734,7 +734,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Void) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, void_, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, void_, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "void");
}
@ -744,7 +744,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, sampler, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, sampler, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "sampler");
}
@ -754,7 +754,7 @@ TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, sampler, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, sampler, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "sampler");
}
@ -777,7 +777,7 @@ TEST_P(MslDepthTexturesTest, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(
@ -798,7 +798,7 @@ TEST_F(MslDepthMultisampledTexturesTest, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "depth2d_ms<float, access::read>");
}
@ -822,7 +822,7 @@ TEST_P(MslSampledtexturesTest, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, s, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, s, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(
@ -844,7 +844,7 @@ TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, ms, "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, ms, "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), "texture2d_ms<uint, access::read>");
}
@ -868,7 +868,7 @@ TEST_P(MslStorageTexturesTest, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "")) << gen.error();
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(type), "")) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(

View File

@ -28,7 +28,7 @@ TEST_F(MslUnaryOpTest, AddressOf) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "&(expr)");
}
@ -40,7 +40,7 @@ TEST_F(MslUnaryOpTest, Complement) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "~(expr)");
}
@ -53,7 +53,7 @@ TEST_F(MslUnaryOpTest, Indirection) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "*(expr)");
}
@ -65,7 +65,7 @@ TEST_F(MslUnaryOpTest, Not) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "!(expr)");
}
@ -77,7 +77,7 @@ TEST_F(MslUnaryOpTest, Negation) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "tint_unary_minus(expr)");
}
@ -88,7 +88,7 @@ TEST_F(MslUnaryOpTest, IntMin) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(-2147483647 - 1)");
}

View File

@ -34,7 +34,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " float a = 0.0f;\n");
}
@ -47,7 +47,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Let) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " float const a = 0.0f;\n");
}
@ -60,7 +60,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), ""); // Not a mistake - 'const' is inlined
}
@ -70,7 +70,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -88,7 +88,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -106,7 +106,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_i32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -124,7 +124,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_u32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -142,7 +142,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -162,7 +162,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -180,7 +180,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_vec3_AInt) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -198,7 +198,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_vec3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -216,7 +216,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_vec3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -236,7 +236,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_vec3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -254,7 +254,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_mat2x3_AFloat) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -272,7 +272,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_mat2x3_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -292,7 +292,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_mat2x3_f16) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -310,7 +310,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_arr_f32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -344,7 +344,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const_arr_vec2_bool) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(#include <metal_stdlib>
@ -378,7 +378,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " tint_array<float, 5> a = {};\n");
}
@ -396,7 +396,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"( S a = {};
)");
}
@ -410,7 +410,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector_f32) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " float2 a = 0.0f;\n");
}
@ -425,7 +425,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector_f16) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " half2 a = 0.0h;\n");
}
@ -439,7 +439,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix_f32) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " float3x2 a = float3x2(0.0f);\n");
}
@ -455,7 +455,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix_f16) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " half3x2 a = half3x2(0.0h);\n");
}
@ -467,7 +467,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec_f32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(float3 a = float3(0.0f);
)");
}
@ -482,7 +482,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec_f16)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(half3 a = half3(0.0h);
)");
}
@ -495,7 +495,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroMat_f32)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(float2x3 a = float2x3(float3(0.0f), float3(0.0f));
)");
@ -511,7 +511,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroMat_f16)
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
EXPECT_EQ(gen.result(),
R"(half2x3 a = half2x3(half3(0.0h), half3(0.0h));
)");
@ -526,7 +526,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr(R"(thread tint_private_vars_struct tint_private_vars = {};
float const tint_symbol = tint_private_vars.a;
return;
@ -542,7 +542,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Workgroup) {
gen.increment_indent();
ASSERT_TRUE(gen.Generate()) << gen.error();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_THAT(gen.result(), HasSubstr("threadgroup float tint_symbol_2;\n"));
}

View File

@ -27,7 +27,7 @@ Result Generate(const Program* program, const Options&) {
// Generate the AST dump.
auto impl = std::make_unique<GeneratorImpl>(program);
result.success = impl->Generate();
result.error = impl->error();
result.error = impl->Diagnostics().str();
result.ast = impl->result();
return result;

View File

@ -102,9 +102,6 @@ class TextGenerator {
/// @returns the list of diagnostics raised by the generator.
const diag::List& Diagnostics() const { return diagnostics_; }
/// @returns the error
std::string error() const { return diagnostics_.str(); }
/// @return a new, unique identifier with the given prefix.
/// @param prefix optional prefix to apply to the generated identifier. If
/// empty "tint_symbol" will be used.

View File

@ -27,7 +27,7 @@ Result Generate(const Program* program, const Options&) {
// Generate the WGSL code.
auto impl = std::make_unique<GeneratorImpl>(program);
result.success = impl->Generate();
result.error = impl->error();
result.error = impl->Diagnostics().str();
result.wgsl = impl->result();
return result;

View File

@ -24,7 +24,7 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_F32) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.error();
ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(alias a = f32;
)");
}
@ -39,8 +39,8 @@ TEST_F(WgslGeneratorImplTest, EmitTypeDecl_Struct) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitTypeDecl(s)) << gen.error();
ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.error();
ASSERT_TRUE(gen.EmitTypeDecl(s)) << gen.Diagnostics();
ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(struct A {
a : f32,
b : i32,
@ -59,7 +59,7 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.error();
ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), R"(alias B = A;
)");
}

View File

@ -30,7 +30,7 @@ TEST_F(WgslGeneratorImplTest, IndexAccessor) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "ary[5i]");
}
@ -44,7 +44,7 @@ TEST_F(WgslGeneratorImplTest, IndexAccessor_OfDref) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), "(*(p))[5i]");
}

View File

@ -29,7 +29,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Assign) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(assign)) << gen.error();
ASSERT_TRUE(gen.EmitStatement(assign)) << gen.Diagnostics();
EXPECT_EQ(gen.result(), " lhs = rhs;\n");
}

View File

@ -51,7 +51,7 @@ TEST_P(WgslBinaryTest, Emit) {
GeneratorImpl& gen = Build();
utils::StringStream out;
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.error();
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(

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