writer/hlsl: Emit vector-of-bool as boolN

Much like uintN, intN, floatN - boolN is far more common, and easier to read than vector<bool, N>

Change-Id: I51f9edc003c590266316d3eba286ca2f6882da10
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53390
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-06-07 20:01:54 +00:00
parent 7dbc4baa71
commit d7255e37f6
26 changed files with 27 additions and 26 deletions

View File

@@ -2479,6 +2479,8 @@ bool GeneratorImpl::EmitType(std::ostream& out,
out << "int" << size;
} else if (vec->type()->Is<sem::U32>() && size >= 1 && size <= 4) {
out << "uint" << size;
} else if (vec->type()->Is<sem::Bool>() && size >= 1 && size <= 4) {
out << "bool" << size;
} else {
out << "vector<";
if (!EmitType(out, vec->type(), storage_class, access, "")) {

View File

@@ -290,8 +290,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Select_Vector) {
gen.increment_indent();
ASSERT_TRUE(gen.EmitExpression(pre, out, call)) << gen.error();
EXPECT_EQ(result(),
"(vector<bool, 2>(true, false) ? int2(1, 2) : int2(3, 4))");
EXPECT_EQ(result(), "(bool2(true, false) ? int2(1, 2) : int2(3, 4))");
}
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Snorm) {