tint: Remove single scalar matrix constructors.

These were never part of the spec, and they were not correctly
implemented for all backends.

Fixed: tint:1597
Change-Id: If1a23f1619c61c53baae277f1cf37aee4460ab7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95952
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2022-07-15 15:25:30 +00:00
committed by Dawn LUCI CQ
parent 65c5c9d92b
commit f19cb029b8
11 changed files with 4320 additions and 4984 deletions

View File

@@ -31,108 +31,6 @@ TEST_F(VectorizeScalarMatrixConstructorsTest, ShouldRunEmptyModule) {
EXPECT_FALSE(ShouldRun<VectorizeScalarMatrixConstructors>(src));
}
TEST_P(VectorizeScalarMatrixConstructorsTest, SingleScalars) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;
std::string matrix_no_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows);
std::string matrix = matrix_no_type + "<f32>";
std::string vector = "vec" + std::to_string(rows) + "<f32>";
std::string values;
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
values += ", ";
}
values += vector + "(";
for (uint32_t r = 0; r < rows; r++) {
if (r > 0) {
values += ", ";
}
values += "value";
}
values += ")";
}
std::string src = R"(
@fragment
fn main() {
let m = ${matrix}(42.0);
}
)";
std::string expect = R"(
fn build_${matrix_no_type}(value : f32) -> ${matrix} {
return ${matrix}(${values});
}
@fragment
fn main() {
let m = build_${matrix_no_type}(42.0);
}
)";
src = utils::ReplaceAll(src, "${matrix}", matrix);
expect = utils::ReplaceAll(expect, "${matrix}", matrix);
expect = utils::ReplaceAll(expect, "${matrix_no_type}", matrix_no_type);
expect = utils::ReplaceAll(expect, "${values}", values);
EXPECT_TRUE(ShouldRun<VectorizeScalarMatrixConstructors>(src));
auto got = Run<VectorizeScalarMatrixConstructors>(src);
EXPECT_EQ(expect, str(got));
}
TEST_P(VectorizeScalarMatrixConstructorsTest, SingleScalarsReference) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;
std::string matrix_no_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows);
std::string matrix = matrix_no_type + "<f32>";
std::string vector = "vec" + std::to_string(rows) + "<f32>";
std::string values;
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
values += ", ";
}
values += vector + "(";
for (uint32_t r = 0; r < rows; r++) {
if (r > 0) {
values += ", ";
}
values += "value";
}
values += ")";
}
std::string src = R"(
@fragment
fn main() {
let v = vec4<f32>(42.0);
let m = ${matrix}(v[2]);
}
)";
std::string expect = R"(
fn build_${matrix_no_type}(value : f32) -> ${matrix} {
return ${matrix}(${values});
}
@fragment
fn main() {
let v = vec4<f32>(42.0);
let m = build_${matrix_no_type}(v[2]);
}
)";
src = utils::ReplaceAll(src, "${matrix}", matrix);
expect = utils::ReplaceAll(expect, "${matrix}", matrix);
expect = utils::ReplaceAll(expect, "${matrix_no_type}", matrix_no_type);
expect = utils::ReplaceAll(expect, "${values}", values);
EXPECT_TRUE(ShouldRun<VectorizeScalarMatrixConstructors>(src));
auto got = Run<VectorizeScalarMatrixConstructors>(src);
EXPECT_EQ(expect, str(got));
}
TEST_P(VectorizeScalarMatrixConstructorsTest, MultipleScalars) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;