[spirv-reader] Use builtin matrix aliases

This makes the generated WGSL more concise and readable.

Change-Id: I78a722b9a86264d3bbf219445628dc5597cbfd62
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132141
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
James Price 2023-05-09 10:40:06 +00:00 committed by Dawn LUCI CQ
parent 114bae24b0
commit f91b77dd6d
17 changed files with 128 additions and 124 deletions

View File

@ -4136,9 +4136,9 @@ TypedExpression FunctionEmitter::EmitGlslStd450MatrixInverse(
auto* d = idx(1, 1); auto* d = idx(1, 1);
// s * d, -s * b, -s * c, s * a // s * d, -s * b, -s * c, s * a
auto* r = pb.mat2x2<f32>( // auto* r = pb.Call("mat2x2f", //
pb.Call("vec2f", pb.Mul(s, d), pb.Mul(neg(s), b)), pb.Call("vec2f", pb.Mul(s, d), pb.Mul(neg(s), b)),
pb.Call("vec2f", pb.Mul(neg(s), c), pb.Mul(s, a))); pb.Call("vec2f", pb.Mul(neg(s), c), pb.Mul(s, a)));
return {mat.type, r}; return {mat.type, r};
} }
@ -4156,29 +4156,29 @@ TypedExpression FunctionEmitter::EmitGlslStd450MatrixInverse(
auto* h = idx(2, 1); auto* h = idx(2, 1);
auto* i = idx(2, 2); auto* i = idx(2, 2);
auto r = pb.Mul(s, // auto r = pb.Mul(s, //
pb.mat3x3<f32>( // pb.Call("mat3x3f", //
pb.Call("vec3f", pb.Call("vec3f",
// e * i - f * h // e * i - f * h
sub_mul2(e, i, f, h), sub_mul2(e, i, f, h),
// c * h - b * i // c * h - b * i
sub_mul2(c, h, b, i), sub_mul2(c, h, b, i),
// b * f - c * e // b * f - c * e
sub_mul2(b, f, c, e)), sub_mul2(b, f, c, e)),
pb.Call("vec3f", pb.Call("vec3f",
// f * g - d * i // f * g - d * i
sub_mul2(f, g, d, i), sub_mul2(f, g, d, i),
// a * i - c * g // a * i - c * g
sub_mul2(a, i, c, g), sub_mul2(a, i, c, g),
// c * d - a * f // c * d - a * f
sub_mul2(c, d, a, f)), sub_mul2(c, d, a, f)),
pb.Call("vec3f", pb.Call("vec3f",
// d * h - e * g // d * h - e * g
sub_mul2(d, h, e, g), sub_mul2(d, h, e, g),
// b * g - a * h // b * g - a * h
sub_mul2(b, g, a, h), sub_mul2(b, g, a, h),
// a * e - b * d // a * e - b * d
sub_mul2(a, e, b, d)))); sub_mul2(a, e, b, d))));
return {mat.type, r}; return {mat.type, r};
} }
@ -4234,44 +4234,44 @@ TypedExpression FunctionEmitter::EmitGlslStd450MatrixInverse(
auto* enfm = sub_mul2(e, n, f, m); auto* enfm = sub_mul2(e, n, f, m);
auto* ejfi = sub_mul2(e, j, f, i); auto* ejfi = sub_mul2(e, j, f, i);
auto r = pb.Mul(s, // auto r = pb.Mul(s, //
pb.mat4x4<f32>( // pb.Call("mat4x4f", //
pb.Call("vec4f", pb.Call("vec4f",
// f * kplo - g * jpln + h * jokn // f * kplo - g * jpln + h * jokn
sub_add_mul3(f, kplo, g, jpln, h, jokn), sub_add_mul3(f, kplo, g, jpln, h, jokn),
// -b * kplo + c * jpln - d * jokn // -b * kplo + c * jpln - d * jokn
add_sub_mul3(neg(b), kplo, c, jpln, d, jokn), add_sub_mul3(neg(b), kplo, c, jpln, d, jokn),
// b * gpho - c * fphn + d * fogn // b * gpho - c * fphn + d * fogn
sub_add_mul3(b, gpho, c, fphn, d, fogn), sub_add_mul3(b, gpho, c, fphn, d, fogn),
// -b * glhk + c * flhj - d * fkgj // -b * glhk + c * flhj - d * fkgj
add_sub_mul3(neg(b), glhk, c, flhj, d, fkgj)), add_sub_mul3(neg(b), glhk, c, flhj, d, fkgj)),
pb.Call("vec4f", pb.Call("vec4f",
// -e * kplo + g * iplm - h * iokm // -e * kplo + g * iplm - h * iokm
add_sub_mul3(neg(e), kplo, g, iplm, h, iokm), add_sub_mul3(neg(e), kplo, g, iplm, h, iokm),
// a * kplo - c * iplm + d * iokm // a * kplo - c * iplm + d * iokm
sub_add_mul3(a, kplo, c, iplm, d, iokm), sub_add_mul3(a, kplo, c, iplm, d, iokm),
// -a * gpho + c * ephm - d * eogm // -a * gpho + c * ephm - d * eogm
add_sub_mul3(neg(a), gpho, c, ephm, d, eogm), add_sub_mul3(neg(a), gpho, c, ephm, d, eogm),
// a * glhk - c * elhi + d * ekgi // a * glhk - c * elhi + d * ekgi
sub_add_mul3(a, glhk, c, elhi, d, ekgi)), sub_add_mul3(a, glhk, c, elhi, d, ekgi)),
pb.Call("vec4f", pb.Call("vec4f",
// e * jpln - f * iplm + h * injm // e * jpln - f * iplm + h * injm
sub_add_mul3(e, jpln, f, iplm, h, injm), sub_add_mul3(e, jpln, f, iplm, h, injm),
// -a * jpln + b * iplm - d * injm // -a * jpln + b * iplm - d * injm
add_sub_mul3(neg(a), jpln, b, iplm, d, injm), add_sub_mul3(neg(a), jpln, b, iplm, d, injm),
// a * fphn - b * ephm + d * enfm // a * fphn - b * ephm + d * enfm
sub_add_mul3(a, fphn, b, ephm, d, enfm), sub_add_mul3(a, fphn, b, ephm, d, enfm),
// -a * flhj + b * elhi - d * ejfi // -a * flhj + b * elhi - d * ejfi
add_sub_mul3(neg(a), flhj, b, elhi, d, ejfi)), add_sub_mul3(neg(a), flhj, b, elhi, d, ejfi)),
pb.Call("vec4f", pb.Call("vec4f",
// -e * jokn + f * iokm - g * injm // -e * jokn + f * iokm - g * injm
add_sub_mul3(neg(e), jokn, f, iokm, g, injm), add_sub_mul3(neg(e), jokn, f, iokm, g, injm),
// a * jokn - b * iokm + c * injm // a * jokn - b * iokm + c * injm
sub_add_mul3(a, jokn, b, iokm, c, injm), sub_add_mul3(a, jokn, b, iokm, c, injm),
// -a * fogn + b * eogm - c * enfm // -a * fogn + b * eogm - c * enfm
add_sub_mul3(neg(a), fogn, b, eogm, c, enfm), add_sub_mul3(neg(a), fogn, b, eogm, c, enfm),
// a * fkgj - b * ekgi + c * ejfi // a * fkgj - b * ekgi + c * ejfi
sub_add_mul3(a, fkgj, b, ekgi, c, ejfi)))); sub_add_mul3(a, fkgj, b, ekgi, c, ejfi))));
return {mat.type, r}; return {mat.type, r};
} }
} }

View File

@ -741,7 +741,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : mat2x2<f32> = (x_1 * x_2);")); HasSubstr("let x_10 : mat2x2f = (x_1 * x_2);"));
} }
TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
@ -798,7 +798,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : mat2x2<f32> = (x_1 * x_2);")); HasSubstr("let x_10 : mat2x2f = (x_1 * x_2);"));
} }
TEST_F(SpvBinaryArithTestBasic, Dot) { TEST_F(SpvBinaryArithTestBasic, Dot) {
@ -838,7 +838,7 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
auto got = test::ToString(p->program(), ast_body); auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr("let x_3 : mat2x3<f32> = mat2x3<f32>(" EXPECT_THAT(got, HasSubstr("let x_3 : mat2x3f = mat2x3f("
"vec3f((x_2.x * x_1.x), (x_2.x * x_1.y), (x_2.x * x_1.z)), " "vec3f((x_2.x * x_1.x), (x_2.x * x_1.y), (x_2.x * x_1.z)), "
"vec3f((x_2.y * x_1.x), (x_2.y * x_1.y), (x_2.y * x_1.z)));")) "vec3f((x_2.y * x_1.x), (x_2.y * x_1.y), (x_2.y * x_1.z)));"))
<< got; << got;
@ -920,7 +920,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x2) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly;
auto fe = p->function_emitter(100); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
const auto* expected = "let x_2 : mat2x2<f32> = transpose(x_1);"; const auto* expected = "let x_2 : mat2x2f = transpose(x_1);";
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body); const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(expected)) << got; EXPECT_THAT(got, HasSubstr(expected)) << got;
@ -942,7 +942,7 @@ TEST_F(SpvUnaryArithTest, Transpose_2x3) {
// Note, in the AST dump mat_2_3 means 2 rows and 3 columns. // Note, in the AST dump mat_2_3 means 2 rows and 3 columns.
// So the column vectors have 2 elements. // So the column vectors have 2 elements.
// That is, %m3v2float is __mat_2_3f32. // That is, %m3v2float is __mat_2_3f32.
const auto* expected = "let x_2 : mat3x2<f32> = transpose(x_1);"; const auto* expected = "let x_2 : mat3x2f = transpose(x_1);";
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body); const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(expected)) << got; EXPECT_THAT(got, HasSubstr(expected)) << got;
@ -961,7 +961,7 @@ TEST_F(SpvUnaryArithTest, Transpose_3x2) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly; ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error() << "\n" << assembly;
auto fe = p->function_emitter(100); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
const auto* expected = "let x_2 : mat2x3<f32> = transpose(x_1);"; const auto* expected = "let x_2 : mat2x3f = transpose(x_1);";
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
const auto got = test::ToString(p->program(), ast_body); const auto got = test::ToString(p->program(), ast_body);
EXPECT_THAT(got, HasSubstr(expected)) << got; EXPECT_THAT(got, HasSubstr(expected)) << got;

View File

@ -115,11 +115,10 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) {
auto fe = p->function_emitter(100); auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("let x_1 : mat3x2f = mat3x2f("
HasSubstr("let x_1 : mat3x2<f32> = mat3x2<f32>(" "vec2f(50.0f, 60.0f), "
"vec2f(50.0f, 60.0f), " "vec2f(60.0f, 50.0f), "
"vec2f(60.0f, 50.0f), " "vec2f(70.0f, 70.0f));"));
"vec2f(70.0f, 70.0f));"));
} }
TEST_F(SpvParserTest_Composite_Construct, Array) { TEST_F(SpvParserTest_Composite_Construct, Array) {
@ -490,9 +489,9 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix) {
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
auto body_str = test::ToString(p->program(), ast_body); auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 : mat3x2<f32> = x_1; EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 : mat3x2f = x_1;
x_2_1[2u] = vec2f(50.0f, 60.0f); x_2_1[2u] = vec2f(50.0f, 60.0f);
let x_2 : mat3x2<f32> = x_2_1; let x_2 : mat3x2f = x_2_1;
)")) << body_str; )")) << body_str;
} }
@ -535,9 +534,9 @@ TEST_F(SpvParserTest_CompositeInsert, Matrix_Vector) {
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
auto body_str = test::ToString(p->program(), ast_body); auto body_str = test::ToString(p->program(), ast_body);
EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 : mat3x2<f32> = x_1; EXPECT_THAT(body_str, HasSubstr(R"(var x_2_1 : mat3x2f = x_1;
x_2_1[2u] = vec2f(50.0f, 60.0f); x_2_1[2u] = vec2f(50.0f, 60.0f);
let x_2 : mat3x2<f32> = x_2_1; let x_2 : mat3x2f = x_2_1;
return; return;
)")) << body_str; )")) << body_str;
} }

View File

@ -1420,7 +1420,7 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_mat2x2) {
std::string expected = std::string expected =
"let s = (1.0f / determinant(m2x2f1));\n" "let s = (1.0f / determinant(m2x2f1));\n"
"let x_1 : mat2x2<f32> = mat2x2<f32>(vec2f((s * m2x2f1[1u][1u]), (-(s) * " "let x_1 : mat2x2f = mat2x2f(vec2f((s * m2x2f1[1u][1u]), (-(s) * "
"m2x2f1[0u][1u])), vec2f((-(s) * m2x2f1[1u][0u]), (s * m2x2f1[0u][0u])));"; "m2x2f1[0u][1u])), vec2f((-(s) * m2x2f1[1u][0u]), (s * m2x2f1[0u][0u])));";
EXPECT_THAT(body, HasSubstr(expected)) << body; EXPECT_THAT(body, HasSubstr(expected)) << body;
@ -1441,7 +1441,7 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_mat3x3) {
std::string expected = std::string expected =
"let s = (1.0f / determinant(m3x3f1));\n" "let s = (1.0f / determinant(m3x3f1));\n"
"let x_1 : mat3x3<f32> = (s * mat3x3<f32>(vec3f(((m3x3f1[1u][1u] * m3x3f1[2u][2u]) - " "let x_1 : mat3x3f = (s * mat3x3f(vec3f(((m3x3f1[1u][1u] * m3x3f1[2u][2u]) - "
"(m3x3f1[1u][2u] * m3x3f1[2u][1u])), ((m3x3f1[0u][2u] * m3x3f1[2u][1u]) - (m3x3f1[0u][1u] " "(m3x3f1[1u][2u] * m3x3f1[2u][1u])), ((m3x3f1[0u][2u] * m3x3f1[2u][1u]) - (m3x3f1[0u][1u] "
"* m3x3f1[2u][2u])), ((m3x3f1[0u][1u] * m3x3f1[1u][2u]) - (m3x3f1[0u][2u] * " "* m3x3f1[2u][2u])), ((m3x3f1[0u][1u] * m3x3f1[1u][2u]) - (m3x3f1[0u][2u] * "
"m3x3f1[1u][1u]))), vec3f(((m3x3f1[1u][2u] * m3x3f1[2u][0u]) - (m3x3f1[1u][0u] * " "m3x3f1[1u][1u]))), vec3f(((m3x3f1[1u][2u] * m3x3f1[2u][0u]) - (m3x3f1[1u][0u] * "
@ -1470,7 +1470,7 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_mat4x4) {
std::string expected = std::string expected =
"let s = (1.0f / determinant(m4x4f1));\n" "let s = (1.0f / determinant(m4x4f1));\n"
"let x_1 : mat4x4<f32> = (s * mat4x4<f32>(vec4f((((m4x4f1[1u][1u] * ((m4x4f1[2u][2u] * " "let x_1 : mat4x4f = (s * mat4x4f(vec4f((((m4x4f1[1u][1u] * ((m4x4f1[2u][2u] * "
"m4x4f1[3u][3u]) - (m4x4f1[2u][3u] * m4x4f1[3u][2u]))) - (m4x4f1[1u][2u] * " "m4x4f1[3u][3u]) - (m4x4f1[2u][3u] * m4x4f1[3u][2u]))) - (m4x4f1[1u][2u] * "
"((m4x4f1[2u][1u] * m4x4f1[3u][3u]) - (m4x4f1[2u][3u] * m4x4f1[3u][1u])))) + " "((m4x4f1[2u][1u] * m4x4f1[3u][3u]) - (m4x4f1[2u][3u] * m4x4f1[3u][1u])))) + "
"(m4x4f1[1u][3u] * ((m4x4f1[2u][1u] * m4x4f1[3u][2u]) - (m4x4f1[2u][2u] * " "(m4x4f1[1u][3u] * ((m4x4f1[2u][1u] * m4x4f1[3u][2u]) - (m4x4f1[2u][2u] * "
@ -1551,10 +1551,10 @@ TEST_F(SpvParserTest, GlslStd450_MatrixInverse_MultipleInScope) {
std::string expected = std::string expected =
"let s = (1.0f / determinant(m2x2f1));\n" "let s = (1.0f / determinant(m2x2f1));\n"
"let x_1 : mat2x2<f32> = mat2x2<f32>(vec2f((s * m2x2f1[1u][1u]), (-(s) * " "let x_1 : mat2x2f = mat2x2f(vec2f((s * m2x2f1[1u][1u]), (-(s) * "
"m2x2f1[0u][1u])), vec2f((-(s) * m2x2f1[1u][0u]), (s * m2x2f1[0u][0u])));\n" "m2x2f1[0u][1u])), vec2f((-(s) * m2x2f1[1u][0u]), (s * m2x2f1[0u][0u])));\n"
"let s_1 = (1.0f / determinant(m2x2f1));\n" "let s_1 = (1.0f / determinant(m2x2f1));\n"
"let x_2 : mat2x2<f32> = mat2x2<f32>(vec2f((s_1 * m2x2f1[1u][1u]), (-(s_1) * " "let x_2 : mat2x2f = mat2x2f(vec2f((s_1 * m2x2f1[1u][1u]), (-(s_1) * "
"m2x2f1[0u][1u])), vec2f((-(s_1) * m2x2f1[1u][0u]), (s_1 * m2x2f1[0u][0u])));"; "m2x2f1[0u][1u])), vec2f((-(s_1) * m2x2f1[1u][0u]), (s_1 * m2x2f1[0u][0u])));";
EXPECT_THAT(body, HasSubstr(expected)) << body; EXPECT_THAT(body, HasSubstr(expected)) << body;

View File

@ -182,7 +182,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_11 : mat2x2<f32> = mat2x2<f32>();")); HasSubstr("let x_11 : mat2x2f = mat2x2f();"));
} }
TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {

View File

@ -260,11 +260,10 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_MatrixInitializer) {
EXPECT_TRUE(fe.EmitFunctionVariables()); EXPECT_TRUE(fe.EmitFunctionVariables());
auto ast_body = fe.ast_body(); auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body), EXPECT_THAT(test::ToString(p->program(), ast_body), HasSubstr("var x_200 : mat3x2f = mat3x2f("
HasSubstr("var x_200 : mat3x2<f32> = mat3x2<f32>(" "vec2f(1.5f, 2.0f), "
"vec2f(1.5f, 2.0f), " "vec2f(2.0f, 3.0f), "
"vec2f(2.0f, 3.0f), " "vec2f(3.0f, 4.0f));"));
"vec2f(3.0f, 4.0f));"));
} }
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer) { TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer) {

View File

@ -1082,7 +1082,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program()); const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2<f32> = mat3x2<f32>(" EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2f = mat3x2f("
"vec2f(1.5f, 2.0f), " "vec2f(1.5f, 2.0f), "
"vec2f(2.0f, 3.0f), " "vec2f(2.0f, 3.0f), "
"vec2f(3.0f, 4.0f));")); "vec2f(3.0f, 4.0f));"));
@ -1097,7 +1097,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixNullInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program()); const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2<f32> = mat3x2<f32>();")); EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2f = mat3x2f();"));
} }
TEST_F(SpvModuleScopeVarParserTest, MatrixUndefInitializer) { TEST_F(SpvModuleScopeVarParserTest, MatrixUndefInitializer) {
@ -1109,7 +1109,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixUndefInitializer) {
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program()); const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2<f32> = mat3x2<f32>();")); EXPECT_THAT(module_str, HasSubstr("var<private> x_200 : mat3x2f = mat3x2f();"));
// This example module emits ok, but is not valid SPIR-V in the first place. // This example module emits ok, but is not valid SPIR-V in the first place.
p->DeliberatelyInvalidSpirv(); p->DeliberatelyInvalidSpirv();
@ -1290,7 +1290,7 @@ TEST_F(SpvModuleScopeVarParserTest, ColMajorDecoration_Dropped) {
const auto module_str = test::ToString(p->program()); const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S { EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */ /* @offset(0) */
field0 : mat3x2<f32>, field0 : mat3x2f,
} }
@group(0) @binding(0) var<storage, read_write> myvar : S; @group(0) @binding(0) var<storage, read_write> myvar : S;
@ -1321,7 +1321,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixStrideDecoration_Natural_Dropped) {
const auto module_str = test::ToString(p->program()); const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S { EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */ /* @offset(0) */
field0 : mat3x2<f32>, field0 : mat3x2f,
} }
@group(0) @binding(0) var<storage, read_write> myvar : S; @group(0) @binding(0) var<storage, read_write> myvar : S;
@ -1353,7 +1353,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixStrideDecoration) {
EXPECT_THAT(module_str, HasSubstr(R"(struct S { EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */ /* @offset(0) */
@stride(64) @internal(disable_validation__ignore_stride) @stride(64) @internal(disable_validation__ignore_stride)
field0 : mat3x2<f32>, field0 : mat3x2f,
} }
@group(0) @binding(0) var<storage, read_write> myvar : S; @group(0) @binding(0) var<storage, read_write> myvar : S;
@ -4254,7 +4254,7 @@ TEST_F(SpvModuleScopeVarParserTest, Input_FlattenMatrix) {
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program()); const auto got = test::ToString(p->program());
const std::string expected = R"(var<private> x_1 : mat2x4<f32>; const std::string expected = R"(var<private> x_1 : mat2x4f;
var<private> x_2 : vec4f; var<private> x_2 : vec4f;
@ -4380,7 +4380,7 @@ TEST_F(SpvModuleScopeVarParserTest, Input_FlattenNested) {
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program()); const auto got = test::ToString(p->program());
const std::string expected = R"(var<private> x_1 : array<mat2x4<f32>, 2u>; const std::string expected = R"(var<private> x_1 : array<mat2x4f, 2u>;
var<private> x_2 : vec4f; var<private> x_2 : vec4f;
@ -4502,7 +4502,7 @@ TEST_F(SpvModuleScopeVarParserTest, Output_FlattenMatrix) {
EXPECT_TRUE(p->error().empty()); EXPECT_TRUE(p->error().empty());
const auto got = test::ToString(p->program()); const auto got = test::ToString(p->program());
const std::string expected = R"(var<private> x_1 : mat2x4<f32>; const std::string expected = R"(var<private> x_1 : mat2x4f;
var<private> x_2 : vec4f; var<private> x_2 : vec4f;

View File

@ -14,6 +14,7 @@
#include "src/tint/reader/spirv/parser_type.h" #include "src/tint/reader/spirv/parser_type.h"
#include <sstream>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
@ -216,6 +217,11 @@ Matrix::Matrix(const Type* t, uint32_t c, uint32_t r) : type(t), columns(c), row
Matrix::Matrix(const Matrix&) = default; Matrix::Matrix(const Matrix&) = default;
ast::Type Matrix::Build(ProgramBuilder& b) const { ast::Type Matrix::Build(ProgramBuilder& b) const {
if (type->Is<F32>()) {
std::ostringstream ss;
ss << "mat" << columns << "x" << rows << "f";
return b.ty(ss.str());
}
return b.ty.mat(type->Build(b), columns, rows); return b.ty.mat(type->Build(b), columns, rows);
} }

View File

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

View File

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

View File

@ -1,5 +1,5 @@
struct S { struct S {
field0 : mat3x3<f32>, field0 : mat3x3f,
} }
struct S_1 { struct S_1 {
@ -32,9 +32,9 @@ struct S_7 {
const x_72 = vec4f(0.0f, 0.0f, 0.0f, 0.0f); const x_72 = vec4f(0.0f, 0.0f, 0.0f, 0.0f);
const x_73 = mat4x4<f32>(x_72, x_72, x_72, x_72); const x_73 = mat4x4f(x_72, x_72, x_72, x_72);
var<private> x_75 : array<mat4x4<f32>, 58u> = array<mat4x4<f32>, 58u>(x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73); var<private> x_75 : array<mat4x4f, 58u> = array<mat4x4f, 58u>(x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73, x_73);
const x_77 = vec3f(0.0f, 0.0f, 0.0f); const x_77 = vec3f(0.0f, 0.0f, 0.0f);

View File

@ -10,7 +10,7 @@ var<private> x_GLF_color : vec4f;
fn main_1() { fn main_1() {
var f : f32; var f : f32;
var v : vec4f; var v : vec4f;
f = determinant(mat3x3<f32>(vec3f(1.0f, 0.0f, 0.0f), vec3f(0.0f, 1.0f, 0.0f), vec3f(0.0f, 0.0f, 1.0f))); f = determinant(mat3x3f(vec3f(1.0f, 0.0f, 0.0f), vec3f(0.0f, 1.0f, 0.0f), vec3f(0.0f, 0.0f, 1.0f)));
let x_33 : f32 = f; let x_33 : f32 = f;
let x_35 : f32 = f; let x_35 : f32 = f;
let x_37 : f32 = f; let x_37 : f32 = f;

View File

@ -1,4 +1,4 @@
alias Arr = array<mat4x4<f32>, 2u>; alias Arr = array<mat4x4f, 2u>;
struct strided_arr { struct strided_arr {
@size(16) @size(16)
@ -9,7 +9,7 @@ alias Arr_1 = array<strided_arr, 4u>;
struct LeftOver { struct LeftOver {
/* @offset(0) */ /* @offset(0) */
worldViewProjection : mat4x4<f32>, worldViewProjection : mat4x4f,
/* @offset(64) */ /* @offset(64) */
time : f32, time : f32,
/* @offset(80) */ /* @offset(80) */
@ -45,7 +45,7 @@ fn main_1() {
let x_55 : f32 = p.y; let x_55 : f32 = p.y;
let x_57 : f32 = x_14.time; let x_57 : f32 = x_14.time;
p.y = (x_55 + sin((x_57 + 4.0f))); p.y = (x_55 + sin((x_57 + 4.0f)));
let x_69 : mat4x4<f32> = x_14.worldViewProjection; let x_69 : mat4x4f = x_14.worldViewProjection;
let x_70 : vec3f = p; let x_70 : vec3f = p;
gl_Position = (x_69 * vec4f(x_70.x, x_70.y, x_70.z, 1.0f)); gl_Position = (x_69 * vec4f(x_70.x, x_70.y, x_70.z, 1.0f));
let x_83 : vec2f = uv; let x_83 : vec2f = uv;

View File

@ -8,7 +8,7 @@ struct UniformBuffer {
/* @offset(48) */ /* @offset(48) */
ucolorGreen_S1_c0 : vec4f, ucolorGreen_S1_c0 : vec4f,
/* @offset(64) */ /* @offset(64) */
umatrix_S1 : mat3x3<f32>, umatrix_S1 : mat3x3f,
} }
@binding(0) @group(0) var<uniform> x_4 : UniformBuffer; @binding(0) @group(0) var<uniform> x_4 : UniformBuffer;

View File

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

View File

@ -19,7 +19,7 @@ fn mat2x2_stride_16_to_arr(m : mat2x2<f32>) -> array<strided_arr, 2u> {
} }
fn f_1() { fn f_1() {
let x_15 : mat2x2<f32> = arr_to_mat2x2_stride_16(ssbo.m); let x_15 : mat2x2f = arr_to_mat2x2_stride_16(ssbo.m);
ssbo.m = mat2x2_stride_16_to_arr(x_15); ssbo.m = mat2x2_stride_16_to_arr(x_15);
return; return;
} }

View File

@ -1,6 +1,6 @@
fn main_1() { fn main_1() {
var m : mat3x3<f32> = mat3x3<f32>(); var m : mat3x3f = mat3x3f();
m = mat3x3<f32>(vec3f(1.0f, 2.0f, 3.0f), vec3f(4.0f, 5.0f, 6.0f), vec3f(7.0f, 8.0f, 9.0f)); m = mat3x3f(vec3f(1.0f, 2.0f, 3.0f), vec3f(4.0f, 5.0f, 6.0f), vec3f(7.0f, 8.0f, 9.0f));
m[1i] = vec3f(5.0f, 5.0f, 5.0f); m[1i] = vec3f(5.0f, 5.0f, 5.0f);
return; return;
} }