tint: Use PascalCase for builtin enum names
Nicer names if we add some "_tint_*" builtins Change-Id: I7574f5cfeeeb04ec5910b20068aa0dd12a460bd5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104821 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Auto-Submit: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
76a709c760
commit
73683027a3
|
@ -2572,7 +2572,7 @@ TEST_P(ResolverBuiltinTest_DataPacking, InferType) {
|
|||
auto param = GetParam();
|
||||
|
||||
bool pack4 =
|
||||
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
||||
param.builtin == BuiltinType::kPack4X8Snorm || param.builtin == BuiltinType::kPack4X8Unorm;
|
||||
|
||||
auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f))
|
||||
: Call(param.name, vec2<f32>(1_f, 2_f));
|
||||
|
@ -2587,7 +2587,7 @@ TEST_P(ResolverBuiltinTest_DataPacking, Error_IncorrectParamType) {
|
|||
auto param = GetParam();
|
||||
|
||||
bool pack4 =
|
||||
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
||||
param.builtin == BuiltinType::kPack4X8Snorm || param.builtin == BuiltinType::kPack4X8Unorm;
|
||||
|
||||
auto* call = pack4 ? Call(param.name, vec4<i32>(1_i, 2_i, 3_i, 4_i))
|
||||
: Call(param.name, vec2<i32>(1_i, 2_i));
|
||||
|
@ -2613,7 +2613,7 @@ TEST_P(ResolverBuiltinTest_DataPacking, Error_TooManyParams) {
|
|||
auto param = GetParam();
|
||||
|
||||
bool pack4 =
|
||||
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
|
||||
param.builtin == BuiltinType::kPack4X8Snorm || param.builtin == BuiltinType::kPack4X8Unorm;
|
||||
|
||||
auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f), 1_f)
|
||||
: Call(param.name, vec2<f32>(1_f, 2_f), 1_f);
|
||||
|
@ -2626,12 +2626,12 @@ TEST_P(ResolverBuiltinTest_DataPacking, Error_TooManyParams) {
|
|||
|
||||
INSTANTIATE_TEST_SUITE_P(ResolverTest,
|
||||
ResolverBuiltinTest_DataPacking,
|
||||
testing::Values(BuiltinData{"pack4x8snorm", BuiltinType::kPack4x8snorm},
|
||||
BuiltinData{"pack4x8unorm", BuiltinType::kPack4x8unorm},
|
||||
BuiltinData{"pack2x16snorm", BuiltinType::kPack2x16snorm},
|
||||
BuiltinData{"pack2x16unorm", BuiltinType::kPack2x16unorm},
|
||||
testing::Values(BuiltinData{"pack4x8snorm", BuiltinType::kPack4X8Snorm},
|
||||
BuiltinData{"pack4x8unorm", BuiltinType::kPack4X8Unorm},
|
||||
BuiltinData{"pack2x16snorm", BuiltinType::kPack2X16Snorm},
|
||||
BuiltinData{"pack2x16unorm", BuiltinType::kPack2X16Unorm},
|
||||
BuiltinData{"pack2x16float",
|
||||
BuiltinType::kPack2x16float}));
|
||||
BuiltinType::kPack2X16Float}));
|
||||
|
||||
} // namespace data_packing_builtin_tests
|
||||
|
||||
|
@ -2642,8 +2642,8 @@ using ResolverBuiltinTest_DataUnpacking = ResolverTestWithParam<BuiltinData>;
|
|||
TEST_P(ResolverBuiltinTest_DataUnpacking, InferType) {
|
||||
auto param = GetParam();
|
||||
|
||||
bool pack4 = param.builtin == BuiltinType::kUnpack4x8snorm ||
|
||||
param.builtin == BuiltinType::kUnpack4x8unorm;
|
||||
bool pack4 = param.builtin == BuiltinType::kUnpack4X8Snorm ||
|
||||
param.builtin == BuiltinType::kUnpack4X8Unorm;
|
||||
|
||||
auto* call = Call(param.name, 1_u);
|
||||
WrapInFunction(call);
|
||||
|
@ -2661,11 +2661,11 @@ TEST_P(ResolverBuiltinTest_DataUnpacking, InferType) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
ResolverTest,
|
||||
ResolverBuiltinTest_DataUnpacking,
|
||||
testing::Values(BuiltinData{"unpack4x8snorm", BuiltinType::kUnpack4x8snorm},
|
||||
BuiltinData{"unpack4x8unorm", BuiltinType::kUnpack4x8unorm},
|
||||
BuiltinData{"unpack2x16snorm", BuiltinType::kUnpack2x16snorm},
|
||||
BuiltinData{"unpack2x16unorm", BuiltinType::kUnpack2x16unorm},
|
||||
BuiltinData{"unpack2x16float", BuiltinType::kUnpack2x16float}));
|
||||
testing::Values(BuiltinData{"unpack4x8snorm", BuiltinType::kUnpack4X8Snorm},
|
||||
BuiltinData{"unpack4x8unorm", BuiltinType::kUnpack4X8Unorm},
|
||||
BuiltinData{"unpack2x16snorm", BuiltinType::kUnpack2X16Snorm},
|
||||
BuiltinData{"unpack2x16unorm", BuiltinType::kUnpack2X16Unorm},
|
||||
BuiltinData{"unpack2x16float", BuiltinType::kUnpack2X16Float}));
|
||||
|
||||
} // namespace data_unpacking_builtin_tests
|
||||
|
||||
|
|
|
@ -75,11 +75,11 @@ TEST_F(IntrinsicTableTest, MatchU32) {
|
|||
auto* f32 = create<sem::F32>();
|
||||
auto* u32 = create<sem::U32>();
|
||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||
auto result = table->Lookup(BuiltinType::kUnpack2x16float, utils::Vector{u32},
|
||||
auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{u32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||
ASSERT_EQ(Diagnostics().str(), "");
|
||||
EXPECT_EQ(result.sem->Type(), BuiltinType::kUnpack2x16float);
|
||||
EXPECT_EQ(result.sem->Type(), BuiltinType::kUnpack2X16Float);
|
||||
EXPECT_EQ(result.sem->ReturnType(), vec2_f32);
|
||||
ASSERT_EQ(result.sem->Parameters().Length(), 1u);
|
||||
EXPECT_EQ(result.sem->Parameters()[0]->Type(), u32);
|
||||
|
@ -87,7 +87,7 @@ TEST_F(IntrinsicTableTest, MatchU32) {
|
|||
|
||||
TEST_F(IntrinsicTableTest, MismatchU32) {
|
||||
auto* f32 = create<sem::F32>();
|
||||
auto result = table->Lookup(BuiltinType::kUnpack2x16float, utils::Vector{f32},
|
||||
auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{f32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_EQ(result.sem, nullptr);
|
||||
ASSERT_THAT(Diagnostics().str(), HasSubstr("no matching call"));
|
||||
|
|
|
@ -77,15 +77,15 @@ bool IsImageQueryBuiltin(BuiltinType i) {
|
|||
}
|
||||
|
||||
bool IsDataPackingBuiltin(BuiltinType i) {
|
||||
return i == BuiltinType::kPack4x8snorm || i == BuiltinType::kPack4x8unorm ||
|
||||
i == BuiltinType::kPack2x16snorm || i == BuiltinType::kPack2x16unorm ||
|
||||
i == BuiltinType::kPack2x16float;
|
||||
return i == BuiltinType::kPack4X8Snorm || i == BuiltinType::kPack4X8Unorm ||
|
||||
i == BuiltinType::kPack2X16Snorm || i == BuiltinType::kPack2X16Unorm ||
|
||||
i == BuiltinType::kPack2X16Float;
|
||||
}
|
||||
|
||||
bool IsDataUnpackingBuiltin(BuiltinType i) {
|
||||
return i == BuiltinType::kUnpack4x8snorm || i == BuiltinType::kUnpack4x8unorm ||
|
||||
i == BuiltinType::kUnpack2x16snorm || i == BuiltinType::kUnpack2x16unorm ||
|
||||
i == BuiltinType::kUnpack2x16float;
|
||||
return i == BuiltinType::kUnpack4X8Snorm || i == BuiltinType::kUnpack4X8Unorm ||
|
||||
i == BuiltinType::kUnpack2X16Snorm || i == BuiltinType::kUnpack2X16Unorm ||
|
||||
i == BuiltinType::kUnpack2X16Float;
|
||||
}
|
||||
|
||||
bool IsBarrierBuiltin(BuiltinType i) {
|
||||
|
|
|
@ -111,11 +111,11 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
BuiltinData{"textureSampleGrad", BuiltinType::kTextureSampleGrad},
|
||||
BuiltinData{"textureSampleLevel", BuiltinType::kTextureSampleLevel},
|
||||
BuiltinData{"trunc", BuiltinType::kTrunc},
|
||||
BuiltinData{"unpack2x16float", BuiltinType::kUnpack2x16float},
|
||||
BuiltinData{"unpack2x16snorm", BuiltinType::kUnpack2x16snorm},
|
||||
BuiltinData{"unpack2x16unorm", BuiltinType::kUnpack2x16unorm},
|
||||
BuiltinData{"unpack4x8snorm", BuiltinType::kUnpack4x8snorm},
|
||||
BuiltinData{"unpack4x8unorm", BuiltinType::kUnpack4x8unorm},
|
||||
BuiltinData{"unpack2x16float", BuiltinType::kUnpack2X16Float},
|
||||
BuiltinData{"unpack2x16snorm", BuiltinType::kUnpack2X16Snorm},
|
||||
BuiltinData{"unpack2x16unorm", BuiltinType::kUnpack2X16Unorm},
|
||||
BuiltinData{"unpack4x8snorm", BuiltinType::kUnpack4X8Snorm},
|
||||
BuiltinData{"unpack4x8unorm", BuiltinType::kUnpack4X8Unorm},
|
||||
BuiltinData{"workgroupBarrier", BuiltinType::kWorkgroupBarrier}));
|
||||
|
||||
TEST_F(BuiltinTypeTest, ParseNoMatch) {
|
||||
|
|
|
@ -193,19 +193,19 @@ BuiltinType ParseBuiltinType(const std::string& name) {
|
|||
return BuiltinType::kNormalize;
|
||||
}
|
||||
if (name == "pack2x16float") {
|
||||
return BuiltinType::kPack2x16float;
|
||||
return BuiltinType::kPack2X16Float;
|
||||
}
|
||||
if (name == "pack2x16snorm") {
|
||||
return BuiltinType::kPack2x16snorm;
|
||||
return BuiltinType::kPack2X16Snorm;
|
||||
}
|
||||
if (name == "pack2x16unorm") {
|
||||
return BuiltinType::kPack2x16unorm;
|
||||
return BuiltinType::kPack2X16Unorm;
|
||||
}
|
||||
if (name == "pack4x8snorm") {
|
||||
return BuiltinType::kPack4x8snorm;
|
||||
return BuiltinType::kPack4X8Snorm;
|
||||
}
|
||||
if (name == "pack4x8unorm") {
|
||||
return BuiltinType::kPack4x8unorm;
|
||||
return BuiltinType::kPack4X8Unorm;
|
||||
}
|
||||
if (name == "pow") {
|
||||
return BuiltinType::kPow;
|
||||
|
@ -265,19 +265,19 @@ BuiltinType ParseBuiltinType(const std::string& name) {
|
|||
return BuiltinType::kTrunc;
|
||||
}
|
||||
if (name == "unpack2x16float") {
|
||||
return BuiltinType::kUnpack2x16float;
|
||||
return BuiltinType::kUnpack2X16Float;
|
||||
}
|
||||
if (name == "unpack2x16snorm") {
|
||||
return BuiltinType::kUnpack2x16snorm;
|
||||
return BuiltinType::kUnpack2X16Snorm;
|
||||
}
|
||||
if (name == "unpack2x16unorm") {
|
||||
return BuiltinType::kUnpack2x16unorm;
|
||||
return BuiltinType::kUnpack2X16Unorm;
|
||||
}
|
||||
if (name == "unpack4x8snorm") {
|
||||
return BuiltinType::kUnpack4x8snorm;
|
||||
return BuiltinType::kUnpack4X8Snorm;
|
||||
}
|
||||
if (name == "unpack4x8unorm") {
|
||||
return BuiltinType::kUnpack4x8unorm;
|
||||
return BuiltinType::kUnpack4X8Unorm;
|
||||
}
|
||||
if (name == "workgroupBarrier") {
|
||||
return BuiltinType::kWorkgroupBarrier;
|
||||
|
@ -477,15 +477,15 @@ const char* str(BuiltinType i) {
|
|||
return "modf";
|
||||
case BuiltinType::kNormalize:
|
||||
return "normalize";
|
||||
case BuiltinType::kPack2x16float:
|
||||
case BuiltinType::kPack2X16Float:
|
||||
return "pack2x16float";
|
||||
case BuiltinType::kPack2x16snorm:
|
||||
case BuiltinType::kPack2X16Snorm:
|
||||
return "pack2x16snorm";
|
||||
case BuiltinType::kPack2x16unorm:
|
||||
case BuiltinType::kPack2X16Unorm:
|
||||
return "pack2x16unorm";
|
||||
case BuiltinType::kPack4x8snorm:
|
||||
case BuiltinType::kPack4X8Snorm:
|
||||
return "pack4x8snorm";
|
||||
case BuiltinType::kPack4x8unorm:
|
||||
case BuiltinType::kPack4X8Unorm:
|
||||
return "pack4x8unorm";
|
||||
case BuiltinType::kPow:
|
||||
return "pow";
|
||||
|
@ -525,15 +525,15 @@ const char* str(BuiltinType i) {
|
|||
return "transpose";
|
||||
case BuiltinType::kTrunc:
|
||||
return "trunc";
|
||||
case BuiltinType::kUnpack2x16float:
|
||||
case BuiltinType::kUnpack2X16Float:
|
||||
return "unpack2x16float";
|
||||
case BuiltinType::kUnpack2x16snorm:
|
||||
case BuiltinType::kUnpack2X16Snorm:
|
||||
return "unpack2x16snorm";
|
||||
case BuiltinType::kUnpack2x16unorm:
|
||||
case BuiltinType::kUnpack2X16Unorm:
|
||||
return "unpack2x16unorm";
|
||||
case BuiltinType::kUnpack4x8snorm:
|
||||
case BuiltinType::kUnpack4X8Snorm:
|
||||
return "unpack4x8snorm";
|
||||
case BuiltinType::kUnpack4x8unorm:
|
||||
case BuiltinType::kUnpack4X8Unorm:
|
||||
return "unpack4x8unorm";
|
||||
case BuiltinType::kWorkgroupBarrier:
|
||||
return "workgroupBarrier";
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace tint::sem {
|
|||
BuiltinType ParseBuiltinType(const std::string& name) {
|
||||
{{- range Sem.Builtins }}
|
||||
if (name == "{{.Name}}") {
|
||||
return BuiltinType::k{{Title .Name}};
|
||||
return BuiltinType::k{{PascalCase .Name}};
|
||||
}
|
||||
{{- end }}
|
||||
return BuiltinType::kNone;
|
||||
|
@ -31,7 +31,7 @@ const char* str(BuiltinType i) {
|
|||
case BuiltinType::kNone:
|
||||
return "<none>";
|
||||
{{- range Sem.Builtins }}
|
||||
case BuiltinType::k{{Title .Name}}:
|
||||
case BuiltinType::k{{PascalCase .Name}}:
|
||||
return "{{.Name}}";
|
||||
{{- end }}
|
||||
}
|
||||
|
|
|
@ -86,11 +86,11 @@ enum class BuiltinType {
|
|||
kMix,
|
||||
kModf,
|
||||
kNormalize,
|
||||
kPack2x16float,
|
||||
kPack2x16snorm,
|
||||
kPack2x16unorm,
|
||||
kPack4x8snorm,
|
||||
kPack4x8unorm,
|
||||
kPack2X16Float,
|
||||
kPack2X16Snorm,
|
||||
kPack2X16Unorm,
|
||||
kPack4X8Snorm,
|
||||
kPack4X8Unorm,
|
||||
kPow,
|
||||
kRadians,
|
||||
kReflect,
|
||||
|
@ -110,11 +110,11 @@ enum class BuiltinType {
|
|||
kTanh,
|
||||
kTranspose,
|
||||
kTrunc,
|
||||
kUnpack2x16float,
|
||||
kUnpack2x16snorm,
|
||||
kUnpack2x16unorm,
|
||||
kUnpack4x8snorm,
|
||||
kUnpack4x8unorm,
|
||||
kUnpack2X16Float,
|
||||
kUnpack2X16Snorm,
|
||||
kUnpack2X16Unorm,
|
||||
kUnpack4X8Snorm,
|
||||
kUnpack4X8Unorm,
|
||||
kWorkgroupBarrier,
|
||||
kTextureDimensions,
|
||||
kTextureGather,
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint::sem {
|
|||
enum class BuiltinType {
|
||||
kNone = -1,
|
||||
{{- range Sem.Builtins }}
|
||||
k{{Title .Name}},
|
||||
k{{PascalCase .Name}},
|
||||
{{- end }}
|
||||
};
|
||||
|
||||
|
|
|
@ -1653,29 +1653,29 @@ std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) {
|
|||
return "inversesqrt";
|
||||
case sem::BuiltinType::kMix:
|
||||
return "mix";
|
||||
case sem::BuiltinType::kPack2x16float:
|
||||
case sem::BuiltinType::kPack2X16Float:
|
||||
return "packHalf2x16";
|
||||
case sem::BuiltinType::kPack2x16snorm:
|
||||
case sem::BuiltinType::kPack2X16Snorm:
|
||||
return "packSnorm2x16";
|
||||
case sem::BuiltinType::kPack2x16unorm:
|
||||
case sem::BuiltinType::kPack2X16Unorm:
|
||||
return "packUnorm2x16";
|
||||
case sem::BuiltinType::kPack4x8snorm:
|
||||
case sem::BuiltinType::kPack4X8Snorm:
|
||||
return "packSnorm4x8";
|
||||
case sem::BuiltinType::kPack4x8unorm:
|
||||
case sem::BuiltinType::kPack4X8Unorm:
|
||||
return "packUnorm4x8";
|
||||
case sem::BuiltinType::kReverseBits:
|
||||
return "bitfieldReverse";
|
||||
case sem::BuiltinType::kSmoothstep:
|
||||
return "smoothstep";
|
||||
case sem::BuiltinType::kUnpack2x16float:
|
||||
case sem::BuiltinType::kUnpack2X16Float:
|
||||
return "unpackHalf2x16";
|
||||
case sem::BuiltinType::kUnpack2x16snorm:
|
||||
case sem::BuiltinType::kUnpack2X16Snorm:
|
||||
return "unpackSnorm2x16";
|
||||
case sem::BuiltinType::kUnpack2x16unorm:
|
||||
case sem::BuiltinType::kUnpack2X16Unorm:
|
||||
return "unpackUnorm2x16";
|
||||
case sem::BuiltinType::kUnpack4x8snorm:
|
||||
case sem::BuiltinType::kUnpack4X8Snorm:
|
||||
return "unpackSnorm4x8";
|
||||
case sem::BuiltinType::kUnpack4x8unorm:
|
||||
case sem::BuiltinType::kUnpack4X8Unorm:
|
||||
return "unpackUnorm4x8";
|
||||
default:
|
||||
diagnostics_.add_error(diag::System::Writer,
|
||||
|
|
|
@ -1924,21 +1924,21 @@ bool GeneratorImpl::EmitDataPackingCall(std::ostream& out,
|
|||
uint32_t dims = 2;
|
||||
bool is_signed = false;
|
||||
uint32_t scale = 65535;
|
||||
if (builtin->Type() == sem::BuiltinType::kPack4x8snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kPack4x8unorm) {
|
||||
if (builtin->Type() == sem::BuiltinType::kPack4X8Snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kPack4X8Unorm) {
|
||||
dims = 4;
|
||||
scale = 255;
|
||||
}
|
||||
if (builtin->Type() == sem::BuiltinType::kPack4x8snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kPack2x16snorm) {
|
||||
if (builtin->Type() == sem::BuiltinType::kPack4X8Snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kPack2X16Snorm) {
|
||||
is_signed = true;
|
||||
scale = (scale - 1) / 2;
|
||||
}
|
||||
switch (builtin->Type()) {
|
||||
case sem::BuiltinType::kPack4x8snorm:
|
||||
case sem::BuiltinType::kPack4x8unorm:
|
||||
case sem::BuiltinType::kPack2x16snorm:
|
||||
case sem::BuiltinType::kPack2x16unorm: {
|
||||
case sem::BuiltinType::kPack4X8Snorm:
|
||||
case sem::BuiltinType::kPack4X8Unorm:
|
||||
case sem::BuiltinType::kPack2X16Snorm:
|
||||
case sem::BuiltinType::kPack2X16Unorm: {
|
||||
{
|
||||
auto l = line(b);
|
||||
l << (is_signed ? "" : "u") << "int" << dims
|
||||
|
@ -1964,7 +1964,7 @@ bool GeneratorImpl::EmitDataPackingCall(std::ostream& out,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case sem::BuiltinType::kPack2x16float: {
|
||||
case sem::BuiltinType::kPack2X16Float: {
|
||||
line(b) << "uint2 i = f32tof16(" << params[0] << ");";
|
||||
line(b) << "return i.x | (i.y << 16);";
|
||||
break;
|
||||
|
@ -1987,19 +1987,19 @@ bool GeneratorImpl::EmitDataUnpackingCall(std::ostream& out,
|
|||
uint32_t dims = 2;
|
||||
bool is_signed = false;
|
||||
uint32_t scale = 65535;
|
||||
if (builtin->Type() == sem::BuiltinType::kUnpack4x8snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kUnpack4x8unorm) {
|
||||
if (builtin->Type() == sem::BuiltinType::kUnpack4X8Snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kUnpack4X8Unorm) {
|
||||
dims = 4;
|
||||
scale = 255;
|
||||
}
|
||||
if (builtin->Type() == sem::BuiltinType::kUnpack4x8snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kUnpack2x16snorm) {
|
||||
if (builtin->Type() == sem::BuiltinType::kUnpack4X8Snorm ||
|
||||
builtin->Type() == sem::BuiltinType::kUnpack2X16Snorm) {
|
||||
is_signed = true;
|
||||
scale = (scale - 1) / 2;
|
||||
}
|
||||
switch (builtin->Type()) {
|
||||
case sem::BuiltinType::kUnpack4x8snorm:
|
||||
case sem::BuiltinType::kUnpack2x16snorm: {
|
||||
case sem::BuiltinType::kUnpack4X8Snorm:
|
||||
case sem::BuiltinType::kUnpack2X16Snorm: {
|
||||
line(b) << "int j = int(" << params[0] << ");";
|
||||
{ // Perform sign extension on the converted values.
|
||||
auto l = line(b);
|
||||
|
@ -2015,8 +2015,8 @@ bool GeneratorImpl::EmitDataUnpackingCall(std::ostream& out,
|
|||
<< (is_signed ? "-1.0" : "0.0") << ", 1.0);";
|
||||
break;
|
||||
}
|
||||
case sem::BuiltinType::kUnpack4x8unorm:
|
||||
case sem::BuiltinType::kUnpack2x16unorm: {
|
||||
case sem::BuiltinType::kUnpack4X8Unorm:
|
||||
case sem::BuiltinType::kUnpack2X16Unorm: {
|
||||
line(b) << "uint j = " << params[0] << ";";
|
||||
{
|
||||
auto l = line(b);
|
||||
|
@ -2032,7 +2032,7 @@ bool GeneratorImpl::EmitDataUnpackingCall(std::ostream& out,
|
|||
line(b) << "return float" << dims << "(i) / " << scale << ".0;";
|
||||
break;
|
||||
}
|
||||
case sem::BuiltinType::kUnpack2x16float:
|
||||
case sem::BuiltinType::kUnpack2X16Float:
|
||||
line(b) << "uint i = " << params[0] << ";";
|
||||
line(b) << "return f16tof32(uint2(i & 0xffff, i >> 16));";
|
||||
break;
|
||||
|
|
|
@ -700,9 +700,9 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out,
|
|||
case sem::BuiltinType::kRadians:
|
||||
return EmitRadiansCall(out, expr, builtin);
|
||||
|
||||
case sem::BuiltinType::kPack2x16float:
|
||||
case sem::BuiltinType::kUnpack2x16float: {
|
||||
if (builtin->Type() == sem::BuiltinType::kPack2x16float) {
|
||||
case sem::BuiltinType::kPack2X16Float:
|
||||
case sem::BuiltinType::kUnpack2X16Float: {
|
||||
if (builtin->Type() == sem::BuiltinType::kPack2X16Float) {
|
||||
out << "as_type<uint>(half2(";
|
||||
} else {
|
||||
out << "float2(as_type<half2>(";
|
||||
|
@ -1516,16 +1516,16 @@ std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) {
|
|||
case sem::BuiltinType::kFaceForward:
|
||||
out += "faceforward";
|
||||
break;
|
||||
case sem::BuiltinType::kPack4x8snorm:
|
||||
case sem::BuiltinType::kPack4X8Snorm:
|
||||
out += "pack_float_to_snorm4x8";
|
||||
break;
|
||||
case sem::BuiltinType::kPack4x8unorm:
|
||||
case sem::BuiltinType::kPack4X8Unorm:
|
||||
out += "pack_float_to_unorm4x8";
|
||||
break;
|
||||
case sem::BuiltinType::kPack2x16snorm:
|
||||
case sem::BuiltinType::kPack2X16Snorm:
|
||||
out += "pack_float_to_snorm2x16";
|
||||
break;
|
||||
case sem::BuiltinType::kPack2x16unorm:
|
||||
case sem::BuiltinType::kPack2X16Unorm:
|
||||
out += "pack_float_to_unorm2x16";
|
||||
break;
|
||||
case sem::BuiltinType::kReverseBits:
|
||||
|
@ -1540,16 +1540,16 @@ std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) {
|
|||
case sem::BuiltinType::kInverseSqrt:
|
||||
out += "rsqrt";
|
||||
break;
|
||||
case sem::BuiltinType::kUnpack4x8snorm:
|
||||
case sem::BuiltinType::kUnpack4X8Snorm:
|
||||
out += "unpack_snorm4x8_to_float";
|
||||
break;
|
||||
case sem::BuiltinType::kUnpack4x8unorm:
|
||||
case sem::BuiltinType::kUnpack4X8Unorm:
|
||||
out += "unpack_unorm4x8_to_float";
|
||||
break;
|
||||
case sem::BuiltinType::kUnpack2x16snorm:
|
||||
case sem::BuiltinType::kUnpack2X16Snorm:
|
||||
out += "unpack_snorm2x16_to_float";
|
||||
break;
|
||||
case sem::BuiltinType::kUnpack2x16unorm:
|
||||
case sem::BuiltinType::kUnpack2X16Unorm:
|
||||
out += "unpack_unorm2x16_to_float";
|
||||
break;
|
||||
case sem::BuiltinType::kArrayLength:
|
||||
|
|
|
@ -184,16 +184,16 @@ const ast::CallExpression* GenerateCall(BuiltinType builtin,
|
|||
} else {
|
||||
return builder->Call(str.str(), "m2x2");
|
||||
}
|
||||
case BuiltinType::kPack2x16snorm:
|
||||
case BuiltinType::kPack2x16unorm:
|
||||
case BuiltinType::kPack2X16Snorm:
|
||||
case BuiltinType::kPack2X16Unorm:
|
||||
return builder->Call(str.str(), "f2");
|
||||
case BuiltinType::kPack4x8snorm:
|
||||
case BuiltinType::kPack4x8unorm:
|
||||
case BuiltinType::kPack4X8Snorm:
|
||||
case BuiltinType::kPack4X8Unorm:
|
||||
return builder->Call(str.str(), "f4");
|
||||
case BuiltinType::kUnpack4x8snorm:
|
||||
case BuiltinType::kUnpack4x8unorm:
|
||||
case BuiltinType::kUnpack2x16snorm:
|
||||
case BuiltinType::kUnpack2x16unorm:
|
||||
case BuiltinType::kUnpack4X8Snorm:
|
||||
case BuiltinType::kUnpack4X8Unorm:
|
||||
case BuiltinType::kUnpack2X16Snorm:
|
||||
case BuiltinType::kUnpack2X16Unorm:
|
||||
return builder->Call(str.str(), "u1");
|
||||
case BuiltinType::kWorkgroupBarrier:
|
||||
return builder->Call(str.str());
|
||||
|
@ -357,16 +357,16 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
BuiltinData{BuiltinType::kFwidthCoarse, CallParamType::kF32, "fwidth"},
|
||||
BuiltinData{BuiltinType::kFwidthFine, CallParamType::kF32, "fwidth"},
|
||||
/* Data packing builtin */
|
||||
BuiltinData{BuiltinType::kPack4x8snorm, CallParamType::kF32, "pack_float_to_snorm4x8"},
|
||||
BuiltinData{BuiltinType::kPack4x8unorm, CallParamType::kF32, "pack_float_to_unorm4x8"},
|
||||
BuiltinData{BuiltinType::kPack2x16snorm, CallParamType::kF32, "pack_float_to_snorm2x16"},
|
||||
BuiltinData{BuiltinType::kPack2x16unorm, CallParamType::kF32, "pack_float_to_unorm2x16"},
|
||||
BuiltinData{BuiltinType::kPack4X8Snorm, CallParamType::kF32, "pack_float_to_snorm4x8"},
|
||||
BuiltinData{BuiltinType::kPack4X8Unorm, CallParamType::kF32, "pack_float_to_unorm4x8"},
|
||||
BuiltinData{BuiltinType::kPack2X16Snorm, CallParamType::kF32, "pack_float_to_snorm2x16"},
|
||||
BuiltinData{BuiltinType::kPack2X16Unorm, CallParamType::kF32, "pack_float_to_unorm2x16"},
|
||||
/* Data unpacking builtin */
|
||||
BuiltinData{BuiltinType::kUnpack4x8snorm, CallParamType::kU32, "unpack_snorm4x8_to_float"},
|
||||
BuiltinData{BuiltinType::kUnpack4x8unorm, CallParamType::kU32, "unpack_unorm4x8_to_float"},
|
||||
BuiltinData{BuiltinType::kUnpack2x16snorm, CallParamType::kU32,
|
||||
BuiltinData{BuiltinType::kUnpack4X8Snorm, CallParamType::kU32, "unpack_snorm4x8_to_float"},
|
||||
BuiltinData{BuiltinType::kUnpack4X8Unorm, CallParamType::kU32, "unpack_unorm4x8_to_float"},
|
||||
BuiltinData{BuiltinType::kUnpack2X16Snorm, CallParamType::kU32,
|
||||
"unpack_snorm2x16_to_float"},
|
||||
BuiltinData{BuiltinType::kUnpack2x16unorm, CallParamType::kU32,
|
||||
BuiltinData{BuiltinType::kUnpack2X16Unorm, CallParamType::kU32,
|
||||
"unpack_unorm2x16_to_float"}));
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Builtin_Call) {
|
||||
|
|
|
@ -183,15 +183,15 @@ uint32_t builtin_to_glsl_method(const sem::Builtin* builtin) {
|
|||
return GLSLstd450ModfStruct;
|
||||
case BuiltinType::kNormalize:
|
||||
return GLSLstd450Normalize;
|
||||
case BuiltinType::kPack4x8snorm:
|
||||
case BuiltinType::kPack4X8Snorm:
|
||||
return GLSLstd450PackSnorm4x8;
|
||||
case BuiltinType::kPack4x8unorm:
|
||||
case BuiltinType::kPack4X8Unorm:
|
||||
return GLSLstd450PackUnorm4x8;
|
||||
case BuiltinType::kPack2x16snorm:
|
||||
case BuiltinType::kPack2X16Snorm:
|
||||
return GLSLstd450PackSnorm2x16;
|
||||
case BuiltinType::kPack2x16unorm:
|
||||
case BuiltinType::kPack2X16Unorm:
|
||||
return GLSLstd450PackUnorm2x16;
|
||||
case BuiltinType::kPack2x16float:
|
||||
case BuiltinType::kPack2X16Float:
|
||||
return GLSLstd450PackHalf2x16;
|
||||
case BuiltinType::kPow:
|
||||
return GLSLstd450Pow;
|
||||
|
@ -221,15 +221,15 @@ uint32_t builtin_to_glsl_method(const sem::Builtin* builtin) {
|
|||
return GLSLstd450Tanh;
|
||||
case BuiltinType::kTrunc:
|
||||
return GLSLstd450Trunc;
|
||||
case BuiltinType::kUnpack4x8snorm:
|
||||
case BuiltinType::kUnpack4X8Snorm:
|
||||
return GLSLstd450UnpackSnorm4x8;
|
||||
case BuiltinType::kUnpack4x8unorm:
|
||||
case BuiltinType::kUnpack4X8Unorm:
|
||||
return GLSLstd450UnpackUnorm4x8;
|
||||
case BuiltinType::kUnpack2x16snorm:
|
||||
case BuiltinType::kUnpack2X16Snorm:
|
||||
return GLSLstd450UnpackSnorm2x16;
|
||||
case BuiltinType::kUnpack2x16unorm:
|
||||
case BuiltinType::kUnpack2X16Unorm:
|
||||
return GLSLstd450UnpackUnorm2x16;
|
||||
case BuiltinType::kUnpack2x16float:
|
||||
case BuiltinType::kUnpack2X16Float:
|
||||
return GLSLstd450UnpackHalf2x16;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue