tint: Remove type::AddressSpace::kNone
Just use kUndefined. Change-Id: I26eada75a31b26f83e132a9a15c8ff64f7821676 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120404 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:
parent
643f2aad43
commit
1b90f93742
|
@ -75,7 +75,9 @@ std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(GLFWwind
|
|||
return std::move(desc);
|
||||
}
|
||||
#else
|
||||
{ return nullptr; }
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
return nullptr;
|
||||
|
|
|
@ -144,7 +144,7 @@ TEST_F(ITypBitsetTest, And) {
|
|||
Bitset bits = {1 << 1 | 1 << 2 | 1 << 7};
|
||||
ExpectBits(bits, {1, 2, 7});
|
||||
|
||||
Bitset bits2 = bits & Bitset{1 << 0 | 1 << 3 | 1 << 7};
|
||||
Bitset bits2 = bits& Bitset{1 << 0 | 1 << 3 | 1 << 7};
|
||||
ExpectBits(bits2, {7});
|
||||
ExpectBits(bits, {1, 2, 7});
|
||||
|
||||
|
|
|
@ -74,7 +74,6 @@ enum extension {
|
|||
|
||||
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
|
||||
enum address_space {
|
||||
@internal none
|
||||
function
|
||||
private
|
||||
workgroup
|
||||
|
|
|
@ -225,7 +225,7 @@ class ProgramBuilder {
|
|||
~VarOptions();
|
||||
|
||||
ast::Type type;
|
||||
type::AddressSpace address_space = type::AddressSpace::kNone;
|
||||
type::AddressSpace address_space = type::AddressSpace::kUndefined;
|
||||
type::Access access = type::Access::kUndefined;
|
||||
const ast::Expression* initializer = nullptr;
|
||||
utils::Vector<const ast::Attribute*, 4> attributes;
|
||||
|
|
|
@ -49,7 +49,7 @@ type::AddressSpace EnumConverter::ToAddressSpace(const spv::StorageClass sc) {
|
|||
case spv::StorageClass::Workgroup:
|
||||
return type::AddressSpace::kWorkgroup;
|
||||
case spv::StorageClass::UniformConstant:
|
||||
return type::AddressSpace::kNone;
|
||||
return type::AddressSpace::kUndefined;
|
||||
case spv::StorageClass::StorageBuffer:
|
||||
return type::AddressSpace::kStorage;
|
||||
case spv::StorageClass::Private:
|
||||
|
|
|
@ -130,7 +130,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
StorageClassCase{spv::StorageClass::Output, true, type::AddressSpace::kOut},
|
||||
StorageClassCase{spv::StorageClass::Uniform, true, type::AddressSpace::kUniform},
|
||||
StorageClassCase{spv::StorageClass::Workgroup, true, type::AddressSpace::kWorkgroup},
|
||||
StorageClassCase{spv::StorageClass::UniformConstant, true, type::AddressSpace::kNone},
|
||||
StorageClassCase{spv::StorageClass::UniformConstant, true, type::AddressSpace::kUndefined},
|
||||
StorageClassCase{spv::StorageClass::StorageBuffer, true, type::AddressSpace::kStorage},
|
||||
StorageClassCase{spv::StorageClass::Private, true, type::AddressSpace::kPrivate},
|
||||
StorageClassCase{spv::StorageClass::Function, true, type::AddressSpace::kFunction}));
|
||||
|
|
|
@ -2521,11 +2521,11 @@ bool FunctionEmitter::EmitFunctionVariables() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
auto* var = parser_impl_.MakeVar(inst.result_id(), type::AddressSpace::kNone,
|
||||
auto* var = parser_impl_.MakeVar(inst.result_id(), type::AddressSpace::kUndefined,
|
||||
var_store_type, initializer, AttributeList{});
|
||||
auto* var_decl_stmt = create<ast::VariableDeclStatement>(Source{}, var);
|
||||
AddStatement(var_decl_stmt);
|
||||
auto* var_type = ty_.Reference(var_store_type, type::AddressSpace::kNone);
|
||||
auto* var_type = ty_.Reference(var_store_type, type::AddressSpace::kUndefined);
|
||||
identifier_types_.emplace(inst.result_id(), var_type);
|
||||
}
|
||||
return success();
|
||||
|
@ -3367,9 +3367,9 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info,
|
|||
// no need to remap pointer properties.
|
||||
auto* store_type = parser_impl_.ConvertType(def_inst->type_id());
|
||||
AddStatement(create<ast::VariableDeclStatement>(
|
||||
Source{}, parser_impl_.MakeVar(id, type::AddressSpace::kNone, store_type, nullptr,
|
||||
Source{}, parser_impl_.MakeVar(id, type::AddressSpace::kUndefined, store_type, nullptr,
|
||||
AttributeList{})));
|
||||
auto* type = ty_.Reference(store_type, type::AddressSpace::kNone);
|
||||
auto* type = ty_.Reference(store_type, type::AddressSpace::kUndefined);
|
||||
identifier_types_.emplace(id, type);
|
||||
}
|
||||
|
||||
|
@ -6190,8 +6190,8 @@ bool FunctionEmitter::MakeVectorInsertDynamic(const spvtools::opt::Instruction&
|
|||
// API in parser_impl_.
|
||||
var_name = namer_.MakeDerivedName(original_value_name);
|
||||
|
||||
auto* temp_var = builder_.Var(var_name, type->Build(builder_), type::AddressSpace::kNone,
|
||||
src_vector.expr);
|
||||
auto* temp_var = builder_.Var(var_name, type->Build(builder_),
|
||||
type::AddressSpace::kUndefined, src_vector.expr);
|
||||
|
||||
AddStatement(builder_.Decl({}, temp_var));
|
||||
}
|
||||
|
@ -6260,8 +6260,8 @@ bool FunctionEmitter::MakeCompositeInsert(const spvtools::opt::Instruction& inst
|
|||
// It doesn't correspond to a SPIR-V ID, so we don't use the ordinary
|
||||
// API in parser_impl_.
|
||||
var_name = namer_.MakeDerivedName(original_value_name);
|
||||
auto* temp_var = builder_.Var(var_name, type->Build(builder_), type::AddressSpace::kNone,
|
||||
src_composite.expr);
|
||||
auto* temp_var = builder_.Var(var_name, type->Build(builder_),
|
||||
type::AddressSpace::kUndefined, src_composite.expr);
|
||||
AddStatement(builder_.Decl({}, temp_var));
|
||||
}
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ inline std::ostream& operator<<(std::ostream& o, const DefInfo& di) {
|
|||
}
|
||||
o << " requires_named_let_def: " << (di.requires_named_let_def ? "true" : "false")
|
||||
<< " requires_hoisted_var_def: " << (di.requires_hoisted_var_def ? "true" : "false");
|
||||
if (di.pointer.address_space != type::AddressSpace::kNone) {
|
||||
if (di.pointer.address_space != type::AddressSpace::kUndefined) {
|
||||
o << " sc:" << int(di.pointer.address_space);
|
||||
}
|
||||
switch (di.skip) {
|
||||
|
|
|
@ -1222,11 +1222,6 @@ const Type* ParserImpl::ConvertType(uint32_t type_id,
|
|||
}
|
||||
|
||||
auto ast_address_space = enum_converter_.ToAddressSpace(storage_class);
|
||||
if (ast_address_space == type::AddressSpace::kUndefined) {
|
||||
Fail() << "SPIR-V pointer type with ID " << type_id << " has invalid storage class "
|
||||
<< static_cast<uint32_t>(storage_class);
|
||||
return nullptr;
|
||||
}
|
||||
if (ast_address_space == type::AddressSpace::kUniform &&
|
||||
remap_buffer_block_type_.count(pointee_type_id)) {
|
||||
ast_address_space = type::AddressSpace::kStorage;
|
||||
|
@ -1459,7 +1454,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
|||
continue;
|
||||
}
|
||||
switch (enum_converter_.ToAddressSpace(spirv_storage_class)) {
|
||||
case type::AddressSpace::kNone:
|
||||
case type::AddressSpace::kUndefined:
|
||||
case type::AddressSpace::kIn:
|
||||
case type::AddressSpace::kOut:
|
||||
case type::AddressSpace::kUniform:
|
||||
|
@ -1476,7 +1471,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
|||
return false;
|
||||
}
|
||||
const Type* ast_store_type = nullptr;
|
||||
type::AddressSpace ast_address_space = type::AddressSpace::kNone;
|
||||
type::AddressSpace ast_address_space = type::AddressSpace::kUndefined;
|
||||
if (spirv_storage_class == spv::StorageClass::UniformConstant) {
|
||||
// These are opaque handles: samplers or textures
|
||||
ast_store_type = GetHandleTypeForSpirvHandle(var);
|
||||
|
@ -1600,7 +1595,7 @@ const ast::Var* ParserImpl::MakeVar(uint32_t id,
|
|||
// Handle variables (textures and samplers) are always in the handle
|
||||
// address space, so we don't mention the address space.
|
||||
if (address_space == type::AddressSpace::kHandle) {
|
||||
address_space = type::AddressSpace::kNone;
|
||||
address_space = type::AddressSpace::kUndefined;
|
||||
}
|
||||
|
||||
if (!ConvertDecorationsForVariable(id, &storage_type, &decorations,
|
||||
|
|
|
@ -423,7 +423,7 @@ class ParserImpl : Reader {
|
|||
/// Creates an AST 'var' node for a SPIR-V ID, including any attached decorations, unless it's
|
||||
/// an ignorable builtin variable.
|
||||
/// @param id the SPIR-V result ID
|
||||
/// @param address_space the address space, which cannot be type::AddressSpace::kNone
|
||||
/// @param address_space the address space, which cannot be type::AddressSpace::kUndefined
|
||||
/// @param storage_type the storage type of the variable
|
||||
/// @param initializer the variable initializer
|
||||
/// @param decorations the variable decorations
|
||||
|
|
|
@ -783,22 +783,6 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
|
|||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer UniformConstant %float
|
||||
)" + MainBody()));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<Pointer>());
|
||||
auto* ptr_ty = type->As<Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type->Is<F32>());
|
||||
EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kNone);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%float = OpTypeFloat 32
|
||||
|
|
|
@ -29,8 +29,8 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
|
|||
EXPECT_EQ(ty.U32(), ty.U32());
|
||||
EXPECT_EQ(ty.F32(), ty.F32());
|
||||
EXPECT_EQ(ty.I32(), ty.I32());
|
||||
EXPECT_EQ(ty.Pointer(ty.I32(), type::AddressSpace::kNone),
|
||||
ty.Pointer(ty.I32(), type::AddressSpace::kNone));
|
||||
EXPECT_EQ(ty.Pointer(ty.I32(), type::AddressSpace::kUndefined),
|
||||
ty.Pointer(ty.I32(), type::AddressSpace::kUndefined));
|
||||
EXPECT_EQ(ty.Vector(ty.I32(), 3), ty.Vector(ty.I32(), 3));
|
||||
EXPECT_EQ(ty.Matrix(ty.I32(), 3, 2), ty.Matrix(ty.I32(), 3, 2));
|
||||
EXPECT_EQ(ty.Array(ty.I32(), 3, 2), ty.Array(ty.I32(), 3, 2));
|
||||
|
@ -54,9 +54,9 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
|
|||
Symbol sym_b(Symbol(2, {}));
|
||||
|
||||
TypeManager ty;
|
||||
EXPECT_NE(ty.Pointer(ty.I32(), type::AddressSpace::kNone),
|
||||
ty.Pointer(ty.U32(), type::AddressSpace::kNone));
|
||||
EXPECT_NE(ty.Pointer(ty.I32(), type::AddressSpace::kNone),
|
||||
EXPECT_NE(ty.Pointer(ty.I32(), type::AddressSpace::kUndefined),
|
||||
ty.Pointer(ty.U32(), type::AddressSpace::kUndefined));
|
||||
EXPECT_NE(ty.Pointer(ty.I32(), type::AddressSpace::kUndefined),
|
||||
ty.Pointer(ty.I32(), type::AddressSpace::kIn));
|
||||
EXPECT_NE(ty.Vector(ty.I32(), 3), ty.Vector(ty.U32(), 3));
|
||||
EXPECT_NE(ty.Vector(ty.I32(), 3), ty.Vector(ty.I32(), 2));
|
||||
|
|
|
@ -292,7 +292,7 @@ class ParserImpl {
|
|||
/// Variable name
|
||||
std::string name;
|
||||
/// Variable address space
|
||||
type::AddressSpace address_space = type::AddressSpace::kNone;
|
||||
type::AddressSpace address_space = type::AddressSpace::kUndefined;
|
||||
/// Variable access control
|
||||
type::Access access = type::Access::kUndefined;
|
||||
/// Variable type
|
||||
|
@ -302,7 +302,7 @@ class ParserImpl {
|
|||
/// VariableQualifier contains the parsed information for a variable qualifier
|
||||
struct VariableQualifier {
|
||||
/// The variable's address space
|
||||
type::AddressSpace address_space = type::AddressSpace::kNone;
|
||||
type::AddressSpace address_space = type::AddressSpace::kUndefined;
|
||||
/// The variable's access control
|
||||
type::Access access = type::Access::kUndefined;
|
||||
};
|
||||
|
@ -449,7 +449,7 @@ class ParserImpl {
|
|||
Maybe<ast::Type> type_specifier();
|
||||
/// Parses an `address_space` grammar element, erroring on parse failure.
|
||||
/// @param use a description of what was being parsed if an error was raised.
|
||||
/// @returns the address space or type::AddressSpace::kNone if none matched
|
||||
/// @returns the address space or type::AddressSpace::kUndefined if none matched
|
||||
Expect<type::AddressSpace> expect_address_space(std::string_view use);
|
||||
/// Parses a `struct_decl` grammar element.
|
||||
/// @returns the struct type or nullptr on error
|
||||
|
|
|
@ -1104,7 +1104,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
ResolverTest,
|
||||
ResolverFunctionParameterValidationTest,
|
||||
testing::Values(
|
||||
TestParams{type::AddressSpace::kNone, Expectation::kInvalid},
|
||||
TestParams{type::AddressSpace::kUndefined, Expectation::kInvalid},
|
||||
TestParams{type::AddressSpace::kIn, Expectation::kInvalid},
|
||||
TestParams{type::AddressSpace::kOut, Expectation::kInvalid},
|
||||
TestParams{type::AddressSpace::kUniform, Expectation::kPassWithFullPtrParameterExtension},
|
||||
|
|
|
@ -1275,8 +1275,8 @@ Impl::Builtin Impl::Lookup(sem::BuiltinType builtin_type,
|
|||
params.Reserve(match.parameters.Length());
|
||||
for (auto& p : match.parameters) {
|
||||
params.Push(builder.create<sem::Parameter>(
|
||||
nullptr, static_cast<uint32_t>(params.Length()), p.type, type::AddressSpace::kNone,
|
||||
type::Access::kUndefined, p.usage));
|
||||
nullptr, static_cast<uint32_t>(params.Length()), p.type,
|
||||
type::AddressSpace::kUndefined, type::Access::kUndefined, p.usage));
|
||||
}
|
||||
sem::PipelineStageSet supported_stages;
|
||||
if (match.overload->flags.Contains(OverloadFlag::kSupportsVertexPipeline)) {
|
||||
|
@ -1476,8 +1476,8 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type,
|
|||
params.Reserve(match.parameters.Length());
|
||||
for (auto& p : match.parameters) {
|
||||
params.Push(builder.create<sem::Parameter>(
|
||||
nullptr, static_cast<uint32_t>(params.Length()), p.type, type::AddressSpace::kNone,
|
||||
type::Access::kUndefined, p.usage));
|
||||
nullptr, static_cast<uint32_t>(params.Length()), p.type,
|
||||
type::AddressSpace::kUndefined, type::Access::kUndefined, p.usage));
|
||||
}
|
||||
auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant
|
||||
: sem::EvaluationStage::kRuntime;
|
||||
|
@ -1491,7 +1491,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type,
|
|||
// Conversion.
|
||||
auto* target = converters.GetOrCreate(match, [&]() {
|
||||
auto param = builder.create<sem::Parameter>(
|
||||
nullptr, 0u, match.parameters[0].type, type::AddressSpace::kNone,
|
||||
nullptr, 0u, match.parameters[0].type, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, match.parameters[0].usage);
|
||||
auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant
|
||||
: sem::EvaluationStage::kRuntime;
|
||||
|
|
|
@ -255,11 +255,11 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
|
|||
ty = rhs->Type()->UnwrapRef(); // Implicit load of RHS
|
||||
}
|
||||
|
||||
if (rhs && !validator_.VariableInitializer(v, type::AddressSpace::kNone, ty, rhs)) {
|
||||
if (rhs && !validator_.VariableInitializer(v, type::AddressSpace::kUndefined, ty, rhs)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, const_cast<type::Type*>(ty),
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, const_cast<type::Type*>(ty),
|
||||
v->source)) {
|
||||
AddNote("while instantiating 'let' " + builder_->Symbols().NameFor(v->name->symbol),
|
||||
v->source);
|
||||
|
@ -269,12 +269,12 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) {
|
|||
sem::Variable* sem = nullptr;
|
||||
if (is_global) {
|
||||
sem = builder_->create<sem::GlobalVariable>(
|
||||
v, ty, sem::EvaluationStage::kRuntime, type::AddressSpace::kNone,
|
||||
v, ty, sem::EvaluationStage::kRuntime, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined,
|
||||
/* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt);
|
||||
} else {
|
||||
sem = builder_->create<sem::LocalVariable>(v, ty, sem::EvaluationStage::kRuntime,
|
||||
type::AddressSpace::kNone,
|
||||
type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, current_statement_,
|
||||
/* constant_value */ nullptr);
|
||||
}
|
||||
|
@ -318,11 +318,11 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (rhs && !validator_.VariableInitializer(v, type::AddressSpace::kNone, ty, rhs)) {
|
||||
if (rhs && !validator_.VariableInitializer(v, type::AddressSpace::kUndefined, ty, rhs)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, const_cast<type::Type*>(ty),
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, const_cast<type::Type*>(ty),
|
||||
v->source)) {
|
||||
AddNote("while instantiating 'override' " + builder_->Symbols().NameFor(v->name->symbol),
|
||||
v->source);
|
||||
|
@ -330,7 +330,8 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
|
|||
}
|
||||
|
||||
auto* sem = builder_->create<sem::GlobalVariable>(
|
||||
v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kNone, type::Access::kUndefined,
|
||||
v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined,
|
||||
/* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt);
|
||||
sem->SetInitializer(rhs);
|
||||
|
||||
|
@ -411,11 +412,11 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
|
|||
ty = rhs->Type();
|
||||
}
|
||||
|
||||
if (!validator_.VariableInitializer(c, type::AddressSpace::kNone, ty, rhs)) {
|
||||
if (!validator_.VariableInitializer(c, type::AddressSpace::kUndefined, ty, rhs)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, const_cast<type::Type*>(ty),
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, const_cast<type::Type*>(ty),
|
||||
c->source)) {
|
||||
AddNote("while instantiating 'const' " + builder_->Symbols().NameFor(c->name->symbol),
|
||||
c->source);
|
||||
|
@ -423,12 +424,13 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) {
|
|||
}
|
||||
|
||||
const auto value = rhs->ConstantValue();
|
||||
auto* sem = is_global ? static_cast<sem::Variable*>(builder_->create<sem::GlobalVariable>(
|
||||
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kNone,
|
||||
type::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt))
|
||||
: static_cast<sem::Variable*>(builder_->create<sem::LocalVariable>(
|
||||
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kNone,
|
||||
type::Access::kUndefined, current_statement_, value));
|
||||
auto* sem = is_global
|
||||
? static_cast<sem::Variable*>(builder_->create<sem::GlobalVariable>(
|
||||
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt))
|
||||
: static_cast<sem::Variable*>(builder_->create<sem::LocalVariable>(
|
||||
c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, current_statement_, value));
|
||||
|
||||
sem->SetInitializer(rhs);
|
||||
builder_->Sem().Add(c, sem);
|
||||
|
@ -472,7 +474,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
|||
}
|
||||
|
||||
auto address_space = var->declared_address_space;
|
||||
if (address_space == type::AddressSpace::kNone) {
|
||||
if (address_space == type::AddressSpace::kUndefined) {
|
||||
// No declared address space. Infer from usage / type.
|
||||
if (!is_global) {
|
||||
address_space = type::AddressSpace::kFunction;
|
||||
|
@ -608,7 +610,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, ty, param->type->source)) {
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, ty, param->type->source)) {
|
||||
add_note();
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -659,7 +661,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
|
|||
}
|
||||
|
||||
auto* sem = builder_->create<sem::Parameter>(
|
||||
param, index, ty, type::AddressSpace::kNone, type::Access::kUndefined,
|
||||
param, index, ty, type::AddressSpace::kUndefined, type::Access::kUndefined,
|
||||
sem::ParameterUsage::kNone, binding_point, location);
|
||||
builder_->Sem().Add(param, sem);
|
||||
return sem;
|
||||
|
@ -919,7 +921,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) {
|
|||
}
|
||||
|
||||
if (auto* str = return_type->As<sem::Struct>()) {
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kNone, str, decl->source)) {
|
||||
if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, str, decl->source)) {
|
||||
AddNote("while instantiating return type for " +
|
||||
builder_->Symbols().NameFor(decl->name->symbol),
|
||||
decl->source);
|
||||
|
@ -2009,10 +2011,10 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
[&]() -> sem::TypeInitializer* {
|
||||
auto params = utils::Transform(args, [&](auto, size_t i) {
|
||||
return builder_->create<sem::Parameter>(
|
||||
nullptr, // declaration
|
||||
static_cast<uint32_t>(i), // index
|
||||
arr->ElemType(), // type
|
||||
type::AddressSpace::kNone, // address_space
|
||||
nullptr, // declaration
|
||||
static_cast<uint32_t>(i), // index
|
||||
arr->ElemType(), // type
|
||||
type::AddressSpace::kUndefined, // address_space
|
||||
type::Access::kUndefined);
|
||||
});
|
||||
return builder_->create<sem::TypeInitializer>(arr, std::move(params),
|
||||
|
@ -2038,11 +2040,11 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) {
|
|||
params.Resize(std::min(args.Length(), str->Members().Length()));
|
||||
for (size_t i = 0, n = params.Length(); i < n; i++) {
|
||||
params[i] = builder_->create<sem::Parameter>(
|
||||
nullptr, // declaration
|
||||
static_cast<uint32_t>(i), // index
|
||||
str->Members()[i]->Type(), // type
|
||||
type::AddressSpace::kNone, // address_space
|
||||
type::Access::kUndefined); // access
|
||||
nullptr, // declaration
|
||||
static_cast<uint32_t>(i), // index
|
||||
str->Members()[i]->Type(), // type
|
||||
type::AddressSpace::kUndefined, // address_space
|
||||
type::Access::kUndefined); // access
|
||||
}
|
||||
return builder_->create<sem::TypeInitializer>(str, std::move(params),
|
||||
args_stage);
|
||||
|
|
|
@ -1901,7 +1901,7 @@ TEST_F(ResolverTest, AddressSpace_DoesNotSetOnConst) {
|
|||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
EXPECT_EQ(Sem().Get(var)->AddressSpace(), type::AddressSpace::kNone);
|
||||
EXPECT_EQ(Sem().Get(var)->AddressSpace(), type::AddressSpace::kUndefined);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Access_SetForStorageBuffer) {
|
||||
|
|
|
@ -72,7 +72,7 @@ TEST_F(ResolverRootIdentifierTest, GlobalUniformVar) {
|
|||
|
||||
TEST_F(ResolverRootIdentifierTest, GlobalTextureVar) {
|
||||
auto* a = GlobalVar("a", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
type::AddressSpace::kNone, Group(0_a), Binding(0_a));
|
||||
type::AddressSpace::kUndefined, Group(0_a), Binding(0_a));
|
||||
auto* expr = Expr(a);
|
||||
WrapInFunction(Call("textureDimensions", expr));
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableFromParameter) {
|
|||
|
||||
auto* sem = TypeOf(s)->As<sem::Struct>();
|
||||
ASSERT_NE(sem, nullptr);
|
||||
EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kNone));
|
||||
EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kUndefined));
|
||||
}
|
||||
|
||||
TEST_F(ResolverAddressSpaceUseTest, StructReachableFromReturnType) {
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableFromReturnType) {
|
|||
|
||||
auto* sem = TypeOf(s)->As<sem::Struct>();
|
||||
ASSERT_NE(sem, nullptr);
|
||||
EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kNone));
|
||||
EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kUndefined));
|
||||
}
|
||||
|
||||
TEST_F(ResolverAddressSpaceUseTest, StructReachableFromGlobal) {
|
||||
|
|
|
@ -612,7 +612,7 @@ bool Validator::GlobalVariable(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (global->AddressSpace() == type::AddressSpace::kNone) {
|
||||
if (global->AddressSpace() == type::AddressSpace::kUndefined) {
|
||||
AddError("module-scope 'var' declaration must have a address space", decl->source);
|
||||
return false;
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ bool Validator::Var(const sem::Variable* v) const {
|
|||
}
|
||||
|
||||
if (store_ty->is_handle()) {
|
||||
if (var->declared_address_space != type::AddressSpace::kNone) {
|
||||
if (var->declared_address_space != type::AddressSpace::kUndefined) {
|
||||
// https://gpuweb.github.io/gpuweb/wgsl/#module-scope-variables
|
||||
// If the store type is a texture type or a sampler type, then the variable declaration
|
||||
// must not have a address space attribute. The address space will always be handle.
|
||||
|
|
|
@ -113,7 +113,7 @@ TEST_F(ResolverVariableValidationTest, VarTypeNotConstructible) {
|
|||
// var p : pointer<function, i32> = &v;
|
||||
auto* i = Var("i", ty.i32());
|
||||
auto* p = Var("a", ty.pointer<i32>(Source{{56, 78}}, type::AddressSpace::kFunction),
|
||||
type::AddressSpace::kNone, AddressOf(Source{{12, 34}}, "i"));
|
||||
type::AddressSpace::kUndefined, AddressOf(Source{{12, 34}}, "i"));
|
||||
WrapInFunction(i, p);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
|
|
@ -321,7 +321,7 @@ struct ModuleScopeVarToEntryPointParam::State {
|
|||
|
||||
bool needs_processing = false;
|
||||
for (auto* var : func_sem->TransitivelyReferencedGlobals()) {
|
||||
if (var->AddressSpace() != type::AddressSpace::kNone) {
|
||||
if (var->AddressSpace() != type::AddressSpace::kUndefined) {
|
||||
needs_processing = true;
|
||||
break;
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ struct ModuleScopeVarToEntryPointParam::State {
|
|||
|
||||
// Process and redeclare all variables referenced by the function.
|
||||
for (auto* var : func_sem->TransitivelyReferencedGlobals()) {
|
||||
if (var->AddressSpace() == type::AddressSpace::kNone) {
|
||||
if (var->AddressSpace() == type::AddressSpace::kUndefined) {
|
||||
continue;
|
||||
}
|
||||
if (local_private_vars_.count(var)) {
|
||||
|
@ -470,7 +470,7 @@ struct ModuleScopeVarToEntryPointParam::State {
|
|||
// For entry points, pass non-handle types as pointers.
|
||||
for (auto* target_var : target_sem->TransitivelyReferencedGlobals()) {
|
||||
auto sc = target_var->AddressSpace();
|
||||
if (sc == type::AddressSpace::kNone) {
|
||||
if (sc == type::AddressSpace::kUndefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ struct ModuleScopeVarToEntryPointParam::State {
|
|||
// Now remove all module-scope variables with these address spaces.
|
||||
for (auto* var_ast : ctx.src->AST().GlobalVariables()) {
|
||||
auto* var_sem = ctx.src->Sem().Get(var_ast);
|
||||
if (var_sem->AddressSpace() != type::AddressSpace::kNone) {
|
||||
if (var_sem->AddressSpace() != type::AddressSpace::kUndefined) {
|
||||
ctx.Remove(ctx.src->AST().GlobalDeclarations(), var_ast);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,6 @@ std::ostream& operator<<(std::ostream& out, AddressSpace value) {
|
|||
return out << "handle";
|
||||
case AddressSpace::kIn:
|
||||
return out << "in";
|
||||
case AddressSpace::kNone:
|
||||
return out << "none";
|
||||
case AddressSpace::kOut:
|
||||
return out << "out";
|
||||
case AddressSpace::kPrivate:
|
||||
|
|
|
@ -33,7 +33,6 @@ enum class AddressSpace {
|
|||
kFunction,
|
||||
kHandle, // Tint-internal enum entry - not parsed
|
||||
kIn, // Tint-internal enum entry - not parsed
|
||||
kNone, // Tint-internal enum entry - not parsed
|
||||
kOut, // Tint-internal enum entry - not parsed
|
||||
kPrivate,
|
||||
kPushConstant,
|
||||
|
|
|
@ -45,7 +45,7 @@ bool Pointer::Equals(const UniqueNode& other) const {
|
|||
std::string Pointer::FriendlyName(const SymbolTable& symbols) const {
|
||||
std::ostringstream out;
|
||||
out << "ptr<";
|
||||
if (address_space_ != AddressSpace::kNone) {
|
||||
if (address_space_ != AddressSpace::kUndefined) {
|
||||
out << address_space_ << ", ";
|
||||
}
|
||||
out << subtype_->FriendlyName(symbols) << ", " << access_;
|
||||
|
|
|
@ -59,7 +59,7 @@ TEST_F(PointerTest, Equals) {
|
|||
}
|
||||
|
||||
TEST_F(PointerTest, FriendlyName) {
|
||||
auto* r = create<Pointer>(create<I32>(), AddressSpace::kNone, type::Access::kRead);
|
||||
auto* r = create<Pointer>(create<I32>(), AddressSpace::kUndefined, type::Access::kRead);
|
||||
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<i32, read>");
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ bool Reference::Equals(const UniqueNode& other) const {
|
|||
std::string Reference::FriendlyName(const SymbolTable& symbols) const {
|
||||
std::ostringstream out;
|
||||
out << "ref<";
|
||||
if (address_space_ != AddressSpace::kNone) {
|
||||
if (address_space_ != AddressSpace::kUndefined) {
|
||||
out << address_space_ << ", ";
|
||||
}
|
||||
out << subtype_->FriendlyName(symbols) << ", " << access_;
|
||||
|
|
|
@ -59,7 +59,7 @@ TEST_F(ReferenceTest, Equals) {
|
|||
}
|
||||
|
||||
TEST_F(ReferenceTest, FriendlyName) {
|
||||
auto* r = create<Reference>(create<I32>(), AddressSpace::kNone, type::Access::kRead);
|
||||
auto* r = create<Reference>(create<I32>(), AddressSpace::kUndefined, type::Access::kRead);
|
||||
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<i32, read>");
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ const sem::Call* AppendVector(ProgramBuilder* b,
|
|||
auto* scalar_cast_target = b->create<sem::TypeConversion>(
|
||||
packed_el_sem_ty,
|
||||
b->create<sem::Parameter>(nullptr, 0u, scalar_sem->Type()->UnwrapRef(),
|
||||
type::AddressSpace::kNone, type::Access::kUndefined),
|
||||
type::AddressSpace::kUndefined, type::Access::kUndefined),
|
||||
sem::EvaluationStage::kRuntime);
|
||||
auto* scalar_cast_sem = b->create<sem::Call>(
|
||||
scalar_cast_ast, scalar_cast_target, sem::EvaluationStage::kRuntime,
|
||||
|
@ -160,7 +160,7 @@ const sem::Call* AppendVector(ProgramBuilder* b,
|
|||
[&](const tint::sem::ValueExpression* arg, size_t i) -> const sem::Parameter* {
|
||||
return b->create<sem::Parameter>(
|
||||
nullptr, static_cast<uint32_t>(i), arg->Type()->UnwrapRef(),
|
||||
type::AddressSpace::kNone, type::Access::kUndefined);
|
||||
type::AddressSpace::kUndefined, type::Access::kUndefined);
|
||||
}),
|
||||
sem::EvaluationStage::kRuntime);
|
||||
auto* initializer_sem =
|
||||
|
|
|
@ -374,7 +374,8 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression*
|
|||
dst_type->is_float_scalar_or_vector()) {
|
||||
out << "uintBitsToFloat";
|
||||
} else {
|
||||
if (!EmitType(out, dst_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, dst_type, type::AddressSpace::kUndefined, type::Access::kReadWrite,
|
||||
"")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -437,12 +438,12 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres
|
|||
auto* uint_type = BoolTypeToUint(bool_type);
|
||||
|
||||
// Cast result to bool scalar or vector type.
|
||||
if (!EmitType(out, bool_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, bool_type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
ScopedParen outerCastParen(out);
|
||||
// Cast LHS to uint scalar or vector type.
|
||||
if (!EmitType(out, uint_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
{
|
||||
|
@ -462,7 +463,7 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres
|
|||
return false;
|
||||
}
|
||||
// Cast RHS to uint scalar or vector type.
|
||||
if (!EmitType(out, uint_type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
{
|
||||
|
@ -480,43 +481,43 @@ bool GeneratorImpl::EmitFloatModulo(std::ostream& out, const ast::BinaryExpressi
|
|||
auto* ret_ty = TypeOf(expr)->UnwrapRef();
|
||||
auto* lhs_ty = TypeOf(expr->lhs)->UnwrapRef();
|
||||
auto* rhs_ty = TypeOf(expr->rhs)->UnwrapRef();
|
||||
fn = utils::GetOrCreate(float_modulo_funcs_, BinaryOperandType{{lhs_ty, rhs_ty}},
|
||||
[&]() -> std::string {
|
||||
TextBuffer b;
|
||||
TINT_DEFER(helpers_.Append(b));
|
||||
fn = utils::GetOrCreate(
|
||||
float_modulo_funcs_, BinaryOperandType{{lhs_ty, rhs_ty}}, [&]() -> std::string {
|
||||
TextBuffer b;
|
||||
TINT_DEFER(helpers_.Append(b));
|
||||
|
||||
auto fn_name = UniqueIdentifier("tint_float_modulo");
|
||||
std::vector<std::string> parameter_names;
|
||||
{
|
||||
auto decl = line(&b);
|
||||
if (!EmitTypeAndName(decl, ret_ty, type::AddressSpace::kNone,
|
||||
type::Access::kUndefined, fn_name)) {
|
||||
return "";
|
||||
}
|
||||
{
|
||||
ScopedParen sp(decl);
|
||||
const auto* ty = TypeOf(expr->lhs)->UnwrapRef();
|
||||
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone,
|
||||
type::Access::kUndefined, "lhs")) {
|
||||
return "";
|
||||
}
|
||||
decl << ", ";
|
||||
ty = TypeOf(expr->rhs)->UnwrapRef();
|
||||
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone,
|
||||
type::Access::kUndefined, "rhs")) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
decl << " {";
|
||||
}
|
||||
{
|
||||
ScopedIndent si(&b);
|
||||
line(&b) << "return (lhs - rhs * trunc(lhs / rhs));";
|
||||
}
|
||||
line(&b) << "}";
|
||||
line(&b);
|
||||
return fn_name;
|
||||
});
|
||||
auto fn_name = UniqueIdentifier("tint_float_modulo");
|
||||
std::vector<std::string> parameter_names;
|
||||
{
|
||||
auto decl = line(&b);
|
||||
if (!EmitTypeAndName(decl, ret_ty, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, fn_name)) {
|
||||
return "";
|
||||
}
|
||||
{
|
||||
ScopedParen sp(decl);
|
||||
const auto* ty = TypeOf(expr->lhs)->UnwrapRef();
|
||||
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, "lhs")) {
|
||||
return "";
|
||||
}
|
||||
decl << ", ";
|
||||
ty = TypeOf(expr->rhs)->UnwrapRef();
|
||||
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, "rhs")) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
decl << " {";
|
||||
}
|
||||
{
|
||||
ScopedIndent si(&b);
|
||||
line(&b) << "return (lhs - rhs * trunc(lhs / rhs));";
|
||||
}
|
||||
line(&b) << "}";
|
||||
line(&b);
|
||||
return fn_name;
|
||||
});
|
||||
|
||||
if (fn.empty()) {
|
||||
return false;
|
||||
|
@ -826,7 +827,8 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out,
|
|||
bool GeneratorImpl::EmitTypeConversion(std::ostream& out,
|
||||
const sem::Call* call,
|
||||
const sem::TypeConversion* conv) {
|
||||
if (!EmitType(out, conv->Target(), type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, type::Access::kReadWrite,
|
||||
"")) {
|
||||
return false;
|
||||
}
|
||||
ScopedParen sp(out);
|
||||
|
@ -849,7 +851,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out,
|
|||
return EmitZeroValue(out, type);
|
||||
}
|
||||
|
||||
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
ScopedParen sp(out);
|
||||
|
@ -919,7 +921,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
|
||||
{
|
||||
auto pre = line();
|
||||
if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kNone,
|
||||
if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, result)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1057,7 +1059,7 @@ bool GeneratorImpl::EmitEmulatedFMA(std::ostream& out, const ast::CallExpression
|
|||
bool GeneratorImpl::EmitCountOneBitsCall(std::ostream& out, const ast::CallExpression* expr) {
|
||||
// GLSL's bitCount returns an integer type, so cast it to the appropriate
|
||||
// unsigned type.
|
||||
if (!EmitType(out, TypeOf(expr)->UnwrapRef(), type::AddressSpace::kNone,
|
||||
if (!EmitType(out, TypeOf(expr)->UnwrapRef(), type::AddressSpace::kUndefined,
|
||||
type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1129,24 +1131,24 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out,
|
|||
std::string v;
|
||||
{
|
||||
std::stringstream s;
|
||||
if (!EmitType(s, vec_ty->type(), type::AddressSpace::kNone, type::Access::kRead,
|
||||
"")) {
|
||||
if (!EmitType(s, vec_ty->type(), type::AddressSpace::kUndefined,
|
||||
type::Access::kRead, "")) {
|
||||
return "";
|
||||
}
|
||||
v = s.str();
|
||||
}
|
||||
{ // (u)int tint_int_dot([i|u]vecN a, [i|u]vecN b) {
|
||||
auto l = line(&b);
|
||||
if (!EmitType(l, vec_ty->type(), type::AddressSpace::kNone, type::Access::kRead,
|
||||
"")) {
|
||||
if (!EmitType(l, vec_ty->type(), type::AddressSpace::kUndefined,
|
||||
type::Access::kRead, "")) {
|
||||
return "";
|
||||
}
|
||||
l << " " << fn_name << "(";
|
||||
if (!EmitType(l, vec_ty, type::AddressSpace::kNone, type::Access::kRead, "")) {
|
||||
if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, type::Access::kRead, "")) {
|
||||
return "";
|
||||
}
|
||||
l << " a, ";
|
||||
if (!EmitType(l, vec_ty, type::AddressSpace::kNone, type::Access::kRead, "")) {
|
||||
if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, type::Access::kRead, "")) {
|
||||
return "";
|
||||
}
|
||||
l << " b) {";
|
||||
|
@ -1197,7 +1199,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
|||
|
||||
{
|
||||
auto l = line(b);
|
||||
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone,
|
||||
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, "")) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1223,7 +1225,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
|
|||
|
||||
{
|
||||
auto l = line(b);
|
||||
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kNone,
|
||||
if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, "")) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1881,8 +1883,8 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
{
|
||||
auto out = line();
|
||||
auto name = builder_.Symbols().NameFor(func->name->symbol);
|
||||
if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kNone, type::Access::kReadWrite,
|
||||
"")) {
|
||||
if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kUndefined,
|
||||
type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1907,7 +1909,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
type = ptr->StoreType();
|
||||
}
|
||||
|
||||
// Note: WGSL only allows for AddressSpace::kNone on parameters, however
|
||||
// Note: WGSL only allows for AddressSpace::kUndefined on parameters, however
|
||||
// the sanitizer transforms generates load / store functions for storage
|
||||
// or uniform buffers. These functions have a buffer parameter with
|
||||
// AddressSpace::kStorage or AddressSpace::kUniform. This is required to
|
||||
|
@ -2339,7 +2341,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
|
|||
return true;
|
||||
},
|
||||
[&](const type::Vector* v) {
|
||||
if (!EmitType(out, v, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
|
||||
if (!EmitType(out, v, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2360,7 +2362,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
|
|||
return true;
|
||||
},
|
||||
[&](const type::Matrix* m) {
|
||||
if (!EmitType(out, m, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
|
||||
if (!EmitType(out, m, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2377,7 +2379,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const
|
|||
return true;
|
||||
},
|
||||
[&](const type::Array* a) {
|
||||
if (!EmitType(out, a, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
|
||||
if (!EmitType(out, a, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2469,7 +2471,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
|||
} else if (type->Is<type::U32>()) {
|
||||
out << "0u";
|
||||
} else if (auto* vec = type->As<type::Vector>()) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
ScopedParen sp(out);
|
||||
|
@ -2482,7 +2484,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
|||
}
|
||||
}
|
||||
} else if (auto* mat = type->As<type::Matrix>()) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kReadWrite, "")) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kReadWrite, "")) {
|
||||
return false;
|
||||
}
|
||||
ScopedParen sp(out);
|
||||
|
@ -2495,7 +2497,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
|||
}
|
||||
}
|
||||
} else if (auto* str = type->As<sem::Struct>()) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
|
||||
return false;
|
||||
}
|
||||
bool first = true;
|
||||
|
@ -2509,7 +2511,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) {
|
|||
EmitZeroValue(out, member->Type());
|
||||
}
|
||||
} else if (auto* arr = type->As<type::Array>()) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kNone, type::Access::kUndefined, "")) {
|
||||
if (!EmitType(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined, "")) {
|
||||
return false;
|
||||
}
|
||||
ScopedParen sp(out);
|
||||
|
@ -3052,7 +3054,8 @@ bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) {
|
|||
|
||||
auto out = line(b);
|
||||
|
||||
if (!EmitTypeAndName(out, ty, type::AddressSpace::kNone, type::Access::kReadWrite, name)) {
|
||||
if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, type::Access::kReadWrite,
|
||||
name)) {
|
||||
return false;
|
||||
}
|
||||
out << ";";
|
||||
|
@ -3120,7 +3123,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) {
|
|||
|
||||
auto out = line();
|
||||
// TODO(senorblanco): handle const
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined,
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined,
|
||||
builder_.Symbols().NameFor(let->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3142,7 +3145,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
|
|||
|
||||
auto out = line();
|
||||
out << "const ";
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kNone, type::Access::kUndefined,
|
||||
if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, type::Access::kUndefined,
|
||||
builder_.Symbols().NameFor(var->name->symbol))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3169,7 +3172,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
|
|||
std::vector<std::string> parameter_names;
|
||||
{
|
||||
auto decl = line(&b);
|
||||
if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kNone,
|
||||
if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, fn_name)) {
|
||||
return "";
|
||||
}
|
||||
|
@ -3185,7 +3188,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out,
|
|||
decl << "inout ";
|
||||
ty = ptr->StoreType();
|
||||
}
|
||||
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kNone,
|
||||
if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined,
|
||||
type::Access::kUndefined, param_name)) {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kNone,
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined,
|
||||
type::Access::kReadWrite, "ary"))
|
||||
<< gen.error();
|
||||
EXPECT_EQ(out.str(), "bool ary[4]");
|
||||
|
@ -52,7 +52,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kNone,
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined,
|
||||
type::Access::kReadWrite, "ary"))
|
||||
<< gen.error();
|
||||
EXPECT_EQ(out.str( |