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