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; out << "int" << size;
} else if (vec->type()->Is<sem::U32>() && size >= 1 && size <= 4) { } else if (vec->type()->Is<sem::U32>() && size >= 1 && size <= 4) {
out << "uint" << size; out << "uint" << size;
} else if (vec->type()->Is<sem::Bool>() && size >= 1 && size <= 4) {
out << "bool" << size;
} else { } else {
out << "vector<"; out << "vector<";
if (!EmitType(out, vec->type(), storage_class, access, "")) { if (!EmitType(out, vec->type(), storage_class, access, "")) {

View File

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

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void all_986c7b() { void all_986c7b() {
bool res = all(vector<bool, 4>(false, false, false, false)); bool res = all(bool4(false, false, false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void all_bd2dba() { void all_bd2dba() {
bool res = all(vector<bool, 3>(false, false, false)); bool res = all(bool3(false, false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void all_f46790() { void all_f46790() {
bool res = all(vector<bool, 2>(false, false)); bool res = all(bool2(false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void any_083428() { void any_083428() {
bool res = any(vector<bool, 4>(false, false, false, false)); bool res = any(bool4(false, false, false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void any_0e3e58() { void any_0e3e58() {
bool res = any(vector<bool, 2>(false, false)); bool res = any(bool2(false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void any_e755c1() { void any_e755c1() {
bool res = any(vector<bool, 3>(false, false, false)); bool res = any(bool3(false, false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void isFinite_34d32b() { void isFinite_34d32b() {
vector<bool, 2> res = isfinite(float2(0.0f, 0.0f)); bool2 res = isfinite(float2(0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void isFinite_8a23ad() { void isFinite_8a23ad() {
vector<bool, 3> res = isfinite(float3(0.0f, 0.0f, 0.0f)); bool3 res = isfinite(float3(0.0f, 0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void isFinite_f31987() { void isFinite_f31987() {
vector<bool, 4> res = isfinite(float4(0.0f, 0.0f, 0.0f, 0.0f)); bool4 res = isfinite(float4(0.0f, 0.0f, 0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void isInf_666f2a() { void isInf_666f2a() {
vector<bool, 3> res = isinf(float3(0.0f, 0.0f, 0.0f)); bool3 res = isinf(float3(0.0f, 0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void isInf_7e81b5() { void isInf_7e81b5() {
vector<bool, 4> res = isinf(float4(0.0f, 0.0f, 0.0f, 0.0f)); bool4 res = isinf(float4(0.0f, 0.0f, 0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void isInf_a46d6f() { void isInf_a46d6f() {
vector<bool, 2> res = isinf(float2(0.0f, 0.0f)); bool2 res = isinf(float2(0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_00b848() { void select_00b848() {
int2 res = (vector<bool, 2>(false, false) ? int2(0, 0) : int2(0, 0)); int2 res = (bool2(false, false) ? int2(0, 0) : int2(0, 0));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_01e2cd() { void select_01e2cd() {
int3 res = (vector<bool, 3>(false, false, false) ? int3(0, 0, 0) : int3(0, 0, 0)); int3 res = (bool3(false, false, false) ? int3(0, 0, 0) : int3(0, 0, 0));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_1e960b() { void select_1e960b() {
uint2 res = (vector<bool, 2>(false, false) ? uint2(0u, 0u) : uint2(0u, 0u)); uint2 res = (bool2(false, false) ? uint2(0u, 0u) : uint2(0u, 0u));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_266aff() { void select_266aff() {
float2 res = (vector<bool, 2>(false, false) ? float2(0.0f, 0.0f) : float2(0.0f, 0.0f)); float2 res = (bool2(false, false) ? float2(0.0f, 0.0f) : float2(0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_28a27e() { void select_28a27e() {
uint3 res = (vector<bool, 3>(false, false, false) ? uint3(0u, 0u, 0u) : uint3(0u, 0u, 0u)); uint3 res = (bool3(false, false, false) ? uint3(0u, 0u, 0u) : uint3(0u, 0u, 0u));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_80a9a9() { void select_80a9a9() {
vector<bool, 3> res = (vector<bool, 3>(false, false, false) ? vector<bool, 3>(false, false, false) : vector<bool, 3>(false, false, false)); bool3 res = (bool3(false, false, false) ? bool3(false, false, false) : bool3(false, false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_a2860e() { void select_a2860e() {
int4 res = (vector<bool, 4>(false, false, false, false) ? int4(0, 0, 0, 0) : int4(0, 0, 0, 0)); int4 res = (bool4(false, false, false, false) ? int4(0, 0, 0, 0) : int4(0, 0, 0, 0));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_bb8aae() { void select_bb8aae() {
float4 res = (vector<bool, 4>(false, false, false, false) ? float4(0.0f, 0.0f, 0.0f, 0.0f) : float4(0.0f, 0.0f, 0.0f, 0.0f)); float4 res = (bool4(false, false, false, false) ? float4(0.0f, 0.0f, 0.0f, 0.0f) : float4(0.0f, 0.0f, 0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_c4a4ef() { void select_c4a4ef() {
uint4 res = (vector<bool, 4>(false, false, false, false) ? uint4(0u, 0u, 0u, 0u) : uint4(0u, 0u, 0u, 0u)); uint4 res = (bool4(false, false, false, false) ? uint4(0u, 0u, 0u, 0u) : uint4(0u, 0u, 0u, 0u));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_cb9301() { void select_cb9301() {
vector<bool, 2> res = (vector<bool, 2>(false, false) ? vector<bool, 2>(false, false) : vector<bool, 2>(false, false)); bool2 res = (bool2(false, false) ? bool2(false, false) : bool2(false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_e3e028() { void select_e3e028() {
vector<bool, 4> res = (vector<bool, 4>(false, false, false, false) ? vector<bool, 4>(false, false, false, false) : vector<bool, 4>(false, false, false, false)); bool4 res = (bool4(false, false, false, false) ? bool4(false, false, false, false) : bool4(false, false, false, false));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {

View File

@ -3,7 +3,7 @@ struct tint_symbol {
}; };
void select_ebfea2() { void select_ebfea2() {
float3 res = (vector<bool, 3>(false, false, false) ? float3(0.0f, 0.0f, 0.0f) : float3(0.0f, 0.0f, 0.0f)); float3 res = (bool3(false, false, false) ? float3(0.0f, 0.0f, 0.0f) : float3(0.0f, 0.0f, 0.0f));
} }
tint_symbol vertex_main() { tint_symbol vertex_main() {