mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 14:46:08 +00:00
tint: Rename kInvalid to kUndefined for enums
This is a more neutral term for an unassigned enum value. Change-Id: Ic69d912472f26fd8a2c8348281b27edfcc145eab Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105480 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
78c839be97
commit
d2e0db3af2
@@ -59,7 +59,7 @@ ast::AddressSpace EnumConverter::ToAddressSpace(const SpvStorageClass sc) {
|
||||
}
|
||||
|
||||
Fail() << "unknown SPIR-V storage class: " << uint32_t(sc);
|
||||
return ast::AddressSpace::kInvalid;
|
||||
return ast::AddressSpace::kUndefined;
|
||||
}
|
||||
|
||||
ast::BuiltinValue EnumConverter::ToBuiltin(SpvBuiltIn b) {
|
||||
@@ -93,7 +93,7 @@ ast::BuiltinValue EnumConverter::ToBuiltin(SpvBuiltIn b) {
|
||||
}
|
||||
|
||||
Fail() << "unknown SPIR-V builtin: " << uint32_t(b);
|
||||
return ast::BuiltinValue::kInvalid;
|
||||
return ast::BuiltinValue::kUndefined;
|
||||
}
|
||||
|
||||
ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
||||
@@ -129,7 +129,7 @@ ast::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
||||
ast::TexelFormat EnumConverter::ToTexelFormat(SpvImageFormat fmt) {
|
||||
switch (fmt) {
|
||||
case SpvImageFormatUnknown:
|
||||
return ast::TexelFormat::kInvalid;
|
||||
return ast::TexelFormat::kUndefined;
|
||||
|
||||
// 8 bit channels
|
||||
case SpvImageFormatRgba8:
|
||||
@@ -172,7 +172,7 @@ ast::TexelFormat EnumConverter::ToTexelFormat(SpvImageFormat fmt) {
|
||||
break;
|
||||
}
|
||||
Fail() << "invalid image format: " << int(fmt);
|
||||
return ast::TexelFormat::kInvalid;
|
||||
return ast::TexelFormat::kUndefined;
|
||||
}
|
||||
|
||||
} // namespace tint::reader::spirv
|
||||
|
||||
@@ -137,7 +137,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
|
||||
SpvStorageClassTest,
|
||||
testing::Values(StorageClassCase{static_cast<SpvStorageClass>(9999), false,
|
||||
ast::AddressSpace::kInvalid}));
|
||||
ast::AddressSpace::kUndefined}));
|
||||
|
||||
// Builtin
|
||||
|
||||
@@ -202,12 +202,14 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
BuiltinCase{SpvBuiltInFragDepth, true, ast::BuiltinValue::kFragDepth},
|
||||
BuiltinCase{SpvBuiltInSampleMask, true, ast::BuiltinValue::kSampleMask}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvBuiltinTest,
|
||||
testing::Values(BuiltinCase{static_cast<SpvBuiltIn>(9999), false, ast::BuiltinValue::kInvalid},
|
||||
BuiltinCase{static_cast<SpvBuiltIn>(9999), false, ast::BuiltinValue::kInvalid},
|
||||
BuiltinCase{SpvBuiltInNumWorkgroups, false, ast::BuiltinValue::kInvalid}));
|
||||
INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
|
||||
SpvBuiltinTest,
|
||||
testing::Values(BuiltinCase{static_cast<SpvBuiltIn>(9999), false,
|
||||
ast::BuiltinValue::kUndefined},
|
||||
BuiltinCase{static_cast<SpvBuiltIn>(9999), false,
|
||||
ast::BuiltinValue::kUndefined},
|
||||
BuiltinCase{SpvBuiltInNumWorkgroups, false,
|
||||
ast::BuiltinValue::kUndefined}));
|
||||
|
||||
// Dim
|
||||
|
||||
@@ -326,7 +328,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Unknown. This is used for sampled images.
|
||||
TexelFormatCase{SpvImageFormatUnknown, true, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatUnknown, true, ast::TexelFormat::kUndefined},
|
||||
// 8 bit channels
|
||||
TexelFormatCase{SpvImageFormatRgba8, true, ast::TexelFormat::kRgba8Unorm},
|
||||
TexelFormatCase{SpvImageFormatRgba8Snorm, true, ast::TexelFormat::kRgba8Snorm},
|
||||
@@ -355,23 +357,23 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Scanning in order from the SPIR-V spec.
|
||||
TexelFormatCase{SpvImageFormatRg16f, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatR11fG11fB10f, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatR16f, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRgb10A2, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg16, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg8, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatR16, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatR8, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRgba16Snorm, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg16Snorm, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg8Snorm, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg16i, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg8i, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatR8i, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRgb10a2ui, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg16ui, false, ast::TexelFormat::kInvalid},
|
||||
TexelFormatCase{SpvImageFormatRg8ui, false, ast::TexelFormat::kInvalid}));
|
||||
TexelFormatCase{SpvImageFormatRg16f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR11fG11fB10f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR16f, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRgb10A2, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR16, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR8, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRgba16Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8Snorm, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatR8i, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRgb10a2ui, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg16ui, false, ast::TexelFormat::kUndefined},
|
||||
TexelFormatCase{SpvImageFormatRg8ui, false, ast::TexelFormat::kUndefined}));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::reader::spirv
|
||||
|
||||
@@ -4854,7 +4854,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) {
|
||||
}
|
||||
// Local variables are always Function storage class, with default
|
||||
// access mode.
|
||||
return DefInfo::Pointer{ast::AddressSpace::kFunction, ast::Access::kInvalid};
|
||||
return DefInfo::Pointer{ast::AddressSpace::kFunction, ast::Access::kUndefined};
|
||||
}
|
||||
case SpvOpFunctionParameter: {
|
||||
const auto* type = As<Pointer>(parser_impl_.ConvertType(inst.type_id()));
|
||||
@@ -4862,7 +4862,7 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) {
|
||||
// Using kUndefined is ok for now, since the only non-default access mode
|
||||
// on a pointer would be for a storage buffer, and baseline SPIR-V doesn't
|
||||
// allow passing pointers to buffers as function parameters.
|
||||
return DefInfo::Pointer{type->address_space, ast::Access::kInvalid};
|
||||
return DefInfo::Pointer{type->address_space, ast::Access::kUndefined};
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@@ -5086,7 +5086,7 @@ void FunctionEmitter::FindValuesNeedingNamedOrHoistedDefinition() {
|
||||
// Avoid moving combinatorial values across constructs. This is a
|
||||
// simple heuristic to avoid changing the cost of an operation
|
||||
// by moving it into or out of a loop, for example.
|
||||
if ((def_info->pointer.address_space == ast::AddressSpace::kInvalid) &&
|
||||
if ((def_info->pointer.address_space == ast::AddressSpace::kUndefined) &&
|
||||
local_def.used_in_another_construct) {
|
||||
should_hoist_to_let = true;
|
||||
}
|
||||
|
||||
@@ -332,10 +332,10 @@ struct DefInfo {
|
||||
/// buffer expressed in the old style (with Uniform address space)
|
||||
/// that needs to be remapped to StorageBuffer address space.
|
||||
/// This is kInvalid for non-pointers.
|
||||
ast::AddressSpace address_space = ast::AddressSpace::kInvalid;
|
||||
ast::AddressSpace address_space = ast::AddressSpace::kUndefined;
|
||||
|
||||
/// The declared access mode.
|
||||
ast::Access access = ast::Access::kInvalid;
|
||||
ast::Access access = ast::Access::kUndefined;
|
||||
};
|
||||
|
||||
/// The expression to use when sinking pointers into their use.
|
||||
|
||||
@@ -1207,7 +1207,7 @@ const Type* ParserImpl::ConvertType(uint32_t type_id,
|
||||
}
|
||||
|
||||
auto ast_address_space = enum_converter_.ToAddressSpace(storage_class);
|
||||
if (ast_address_space == ast::AddressSpace::kInvalid) {
|
||||
if (ast_address_space == ast::AddressSpace::kUndefined) {
|
||||
Fail() << "SPIR-V pointer type with ID " << type_id << " has invalid storage class "
|
||||
<< static_cast<uint32_t>(storage_class);
|
||||
return nullptr;
|
||||
@@ -1567,7 +1567,7 @@ ast::Var* ParserImpl::MakeVar(uint32_t id,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ast::Access access = ast::Access::kInvalid;
|
||||
ast::Access access = ast::Access::kUndefined;
|
||||
if (address_space == ast::AddressSpace::kStorage) {
|
||||
bool read_only = false;
|
||||
if (auto* tn = storage_type->As<Named>()) {
|
||||
@@ -1678,7 +1678,7 @@ bool ParserImpl::ConvertDecorationsForVariable(uint32_t id,
|
||||
break;
|
||||
}
|
||||
auto ast_builtin = enum_converter_.ToBuiltin(spv_builtin);
|
||||
if (ast_builtin == ast::BuiltinValue::kInvalid) {
|
||||
if (ast_builtin == ast::BuiltinValue::kUndefined) {
|
||||
// A diagnostic has already been emitted.
|
||||
return false;
|
||||
}
|
||||
@@ -1750,7 +1750,7 @@ bool ParserImpl::ConvertPipelineDecorations(const Type* store_type,
|
||||
AttributeList* attributes) {
|
||||
// Vulkan defaults to perspective-correct interpolation.
|
||||
ast::InterpolationType type = ast::InterpolationType::kPerspective;
|
||||
ast::InterpolationSampling sampling = ast::InterpolationSampling::kInvalid;
|
||||
ast::InterpolationSampling sampling = ast::InterpolationSampling::kUndefined;
|
||||
|
||||
for (const auto& deco : decorations) {
|
||||
TINT_ASSERT(Reader, deco.size() > 0);
|
||||
@@ -1805,7 +1805,7 @@ bool ParserImpl::ConvertPipelineDecorations(const Type* store_type,
|
||||
|
||||
// Apply interpolation.
|
||||
if (type == ast::InterpolationType::kPerspective &&
|
||||
sampling == ast::InterpolationSampling::kInvalid) {
|
||||
sampling == ast::InterpolationSampling::kUndefined) {
|
||||
// This is the default. Don't add a decoration.
|
||||
} else {
|
||||
attributes->Push(create<ast::InterpolateAttribute>(type, sampling));
|
||||
@@ -2477,7 +2477,7 @@ const Pointer* ParserImpl::GetTypeForHandleVar(const spvtools::opt::Instruction&
|
||||
} else {
|
||||
const auto access = ast::Access::kWrite;
|
||||
const auto format = enum_converter_.ToTexelFormat(image_type->format());
|
||||
if (format == ast::TexelFormat::kInvalid) {
|
||||
if (format == ast::TexelFormat::kUndefined) {
|
||||
return nullptr;
|
||||
}
|
||||
ast_store_type = ty_.StorageTexture(dim, format, access);
|
||||
|
||||
@@ -383,7 +383,7 @@ Maybe<Void> ParserImpl::enable_directive() {
|
||||
return add_error(t.source(), "enable directives don't take parenthesis");
|
||||
}
|
||||
|
||||
auto extension = ast::Extension::kInvalid;
|
||||
auto extension = ast::Extension::kUndefined;
|
||||
if (t.Is(Token::Type::kF16)) {
|
||||
// `f16` is a valid extension name and also a keyword
|
||||
synchronized_ = true;
|
||||
@@ -991,7 +991,7 @@ Maybe<ParserImpl::VariableQualifier> ParserImpl::variable_qualifier() {
|
||||
}
|
||||
return VariableQualifier{sc.value, ac.value};
|
||||
}
|
||||
return Expect<VariableQualifier>{VariableQualifier{sc.value, ast::Access::kInvalid},
|
||||
return Expect<VariableQualifier>{VariableQualifier{sc.value, ast::Access::kUndefined},
|
||||
source};
|
||||
});
|
||||
|
||||
@@ -1179,7 +1179,7 @@ Expect<ENUM> ParserImpl::expect_enum(std::string_view name,
|
||||
auto& t = peek();
|
||||
if (t.IsIdentifier()) {
|
||||
auto val = parse(t.to_str());
|
||||
if (val != ENUM::kInvalid) {
|
||||
if (val != ENUM::kUndefined) {
|
||||
synchronized_ = true;
|
||||
next();
|
||||
return {val, t.source()};
|
||||
@@ -1247,7 +1247,7 @@ Expect<const ast::Type*> ParserImpl::expect_type_specifier_pointer(const Source&
|
||||
const char* use = "ptr declaration";
|
||||
|
||||
auto address_space = ast::AddressSpace::kNone;
|
||||
auto access = ast::Access::kInvalid;
|
||||
auto access = ast::Access::kUndefined;
|
||||
|
||||
auto subtype = expect_lt_gt_block(use, [&]() -> Expect<const ast::Type*> {
|
||||
auto sc = expect_address_space(use);
|
||||
@@ -3512,7 +3512,7 @@ Maybe<const ast::Attribute*> ParserImpl::attribute() {
|
||||
return Failure::kErrored;
|
||||
}
|
||||
|
||||
ast::InterpolationSampling sampling = ast::InterpolationSampling::kInvalid;
|
||||
ast::InterpolationSampling sampling = ast::InterpolationSampling::kUndefined;
|
||||
if (match(Token::Type::kComma)) {
|
||||
if (!peek_is(Token::Type::kParenRight)) {
|
||||
auto sample = expect_interpolation_sample_name();
|
||||
|
||||
@@ -296,7 +296,7 @@ class ParserImpl {
|
||||
/// Variable address space
|
||||
ast::AddressSpace address_space = ast::AddressSpace::kNone;
|
||||
/// Variable access control
|
||||
ast::Access access = ast::Access::kInvalid;
|
||||
ast::Access access = ast::Access::kUndefined;
|
||||
/// Variable type
|
||||
const ast::Type* type = nullptr;
|
||||
};
|
||||
@@ -306,7 +306,7 @@ class ParserImpl {
|
||||
/// The variable's address space
|
||||
ast::AddressSpace address_space = ast::AddressSpace::kNone;
|
||||
/// The variable's access control
|
||||
ast::Access access = ast::Access::kInvalid;
|
||||
ast::Access access = ast::Access::kUndefined;
|
||||
};
|
||||
|
||||
/// MatrixDimensions contains the column and row information for a matrix
|
||||
|
||||
@@ -227,7 +227,7 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Flat) {
|
||||
|
||||
auto* interp = var_attr->As<ast::InterpolateAttribute>();
|
||||
EXPECT_EQ(interp->type, ast::InterpolationType::kFlat);
|
||||
EXPECT_EQ(interp->sampling, ast::InterpolationSampling::kInvalid);
|
||||
EXPECT_EQ(interp->sampling, ast::InterpolationSampling::kUndefined);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Attribute_Interpolate_Single_TrailingComma) {
|
||||
@@ -243,7 +243,7 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Single_TrailingComma) {
|
||||
|
||||
auto* interp = var_attr->As<ast::InterpolateAttribute>();
|
||||
EXPECT_EQ(interp->type, ast::InterpolationType::kFlat);
|
||||
EXPECT_EQ(interp->sampling, ast::InterpolationSampling::kInvalid);
|
||||
EXPECT_EQ(interp->sampling, ast::InterpolationSampling::kUndefined);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Attribute_Interpolate_Single_DoubleTrailingComma) {
|
||||
|
||||
@@ -47,11 +47,11 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
ParserImplTest,
|
||||
VariableQualifierTest,
|
||||
testing::Values(
|
||||
VariableStorageData{"uniform", ast::AddressSpace::kUniform, ast::Access::kInvalid},
|
||||
VariableStorageData{"workgroup", ast::AddressSpace::kWorkgroup, ast::Access::kInvalid},
|
||||
VariableStorageData{"storage", ast::AddressSpace::kStorage, ast::Access::kInvalid},
|
||||
VariableStorageData{"private", ast::AddressSpace::kPrivate, ast::Access::kInvalid},
|
||||
VariableStorageData{"function", ast::AddressSpace::kFunction, ast::Access::kInvalid},
|
||||
VariableStorageData{"uniform", ast::AddressSpace::kUniform, ast::Access::kUndefined},
|
||||
VariableStorageData{"workgroup", ast::AddressSpace::kWorkgroup, ast::Access::kUndefined},
|
||||
VariableStorageData{"storage", ast::AddressSpace::kStorage, ast::Access::kUndefined},
|
||||
VariableStorageData{"private", ast::AddressSpace::kPrivate, ast::Access::kUndefined},
|
||||
VariableStorageData{"function", ast::AddressSpace::kFunction, ast::Access::kUndefined},
|
||||
VariableStorageData{"storage, read", ast::AddressSpace::kStorage, ast::Access::kRead},
|
||||
VariableStorageData{"storage, write", ast::AddressSpace::kStorage, ast::Access::kWrite},
|
||||
VariableStorageData{"storage, read_write", ast::AddressSpace::kStorage,
|
||||
|
||||
Reference in New Issue
Block a user