diff --git a/src/tint/cmd/generate_external_texture_bindings.cc b/src/tint/cmd/generate_external_texture_bindings.cc index 1b6ca74b6d..52650ea57e 100644 --- a/src/tint/cmd/generate_external_texture_bindings.cc +++ b/src/tint/cmd/generate_external_texture_bindings.cc @@ -36,12 +36,13 @@ writer::ExternalTextureOptions::BindingsMap GenerateExternalTextureBindings( std::vector ext_tex_bps; for (auto* var : program->AST().GlobalVariables()) { if (auto* sem_var = program->Sem().Get(var)->As()) { - auto bp = sem_var->BindingPoint(); - auto& n = group_to_next_binding_number[bp.group]; - n = std::max(n, bp.binding + 1); + if (auto bp = sem_var->BindingPoint()) { + auto& n = group_to_next_binding_number[bp->group]; + n = std::max(n, bp->binding + 1); - if (sem_var->Type()->UnwrapRef()->Is()) { - ext_tex_bps.emplace_back(bp); + if (sem_var->Type()->UnwrapRef()->Is()) { + ext_tex_bps.emplace_back(*bp); + } } } } diff --git a/src/tint/fuzzers/tint_common_fuzzer.cc b/src/tint/fuzzers/tint_common_fuzzer.cc index 6be9b982d5..7cbc8bfc9a 100644 --- a/src/tint/fuzzers/tint_common_fuzzer.cc +++ b/src/tint/fuzzers/tint_common_fuzzer.cc @@ -271,12 +271,13 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { std::vector ext_tex_bps; for (auto* var : program.AST().GlobalVariables()) { if (auto* sem_var = program.Sem().Get(var)->As()) { - auto bp = sem_var->BindingPoint(); - auto& n = group_to_next_binding_number[bp.group]; - n = std::max(n, bp.binding + 1); + if (auto bp = sem_var->BindingPoint()) { + auto& n = group_to_next_binding_number[bp->group]; + n = std::max(n, bp->binding + 1); - if (sem_var->Type()->UnwrapRef()->Is()) { - ext_tex_bps.emplace_back(bp); + if (sem_var->Type()->UnwrapRef()->Is()) { + ext_tex_bps.emplace_back(*bp); + } } } } diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index d2330e9043..f2749f312a 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -531,8 +531,8 @@ std::vector Inspector::GetSamplerTextureUses( auto* texture = pair.first->As(); auto* sampler = pair.second ? pair.second->As() : nullptr; SamplerTexturePair new_pair; - new_pair.sampler_binding_point = sampler ? sampler->BindingPoint() : placeholder; - new_pair.texture_binding_point = texture->BindingPoint(); + new_pair.sampler_binding_point = sampler ? *sampler->BindingPoint() : placeholder; + new_pair.texture_binding_point = *texture->BindingPoint(); new_pairs.push_back(new_pair); } return new_pairs; @@ -834,8 +834,8 @@ void Inspector::GenerateSamplerTargets() { GetOriginatingResources(std::array{t, s}, [&](std::array globals) { - auto texture_binding_point = globals[0]->BindingPoint(); - auto sampler_binding_point = globals[1]->BindingPoint(); + auto texture_binding_point = *globals[0]->BindingPoint(); + auto sampler_binding_point = *globals[1]->BindingPoint(); for (auto* entry_point : entry_points) { const auto& ep_name = diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 5aac00c618..bfe45c9037 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -276,7 +276,7 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) { sem = builder_->create( v, ty, sem::EvaluationStage::kRuntime, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, - /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); + /* constant_value */ nullptr, std::nullopt, std::nullopt); } else { sem = builder_->create(v, ty, sem::EvaluationStage::kRuntime, builtin::AddressSpace::kUndefined, @@ -336,7 +336,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) { auto* sem = builder_->create( v, ty, sem::EvaluationStage::kOverride, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, - /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); + /* constant_value */ nullptr, std::nullopt, std::nullopt); sem->SetInitializer(rhs); if (auto* id_attr = ast::GetAttribute(v->attributes)) { @@ -430,7 +430,7 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) { auto* sem = is_global ? static_cast(builder_->create( c, ty, sem::EvaluationStage::kConstant, builtin::AddressSpace::kUndefined, - builtin::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt)) + builtin::Access::kUndefined, value, std::nullopt, std::nullopt)) : static_cast(builder_->create( c, ty, sem::EvaluationStage::kConstant, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, current_statement_, value)); @@ -528,7 +528,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { sem::Variable* sem = nullptr; if (is_global) { - sem::BindingPoint binding_point; + std::optional binding_point; if (var->HasBindingPoint()) { uint32_t binding = 0; { @@ -640,8 +640,9 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) } } - sem::BindingPoint binding_point; + std::optional binding_point; if (param->HasBindingPoint()) { + binding_point = sem::BindingPoint{}; { ExprEvalStageConstraint constraint{sem::EvaluationStage::kConstant, "@binding value"}; TINT_SCOPED_ASSIGNMENT(expr_eval_stage_constraint_, constraint); @@ -651,7 +652,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) if (!materialized) { return nullptr; } - binding_point.binding = materialized->ConstantValue()->ValueAs(); + binding_point->binding = materialized->ConstantValue()->ValueAs(); } { ExprEvalStageConstraint constraint{sem::EvaluationStage::kConstant, "@group value"}; @@ -662,7 +663,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) if (!materialized) { return nullptr; } - binding_point.group = materialized->ConstantValue()->ValueAs(); + binding_point->group = materialized->ConstantValue()->ValueAs(); } } diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 65d731028d..36d5139154 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -1346,11 +1346,14 @@ bool Validator::EntryPoint(const sem::Function* func, ast::PipelineStage stage) utils::Hashmap binding_points; for (auto* global : func->TransitivelyReferencedGlobals()) { auto* var_decl = global->Declaration()->As(); - if (!var_decl || !var_decl->HasBindingPoint()) { + if (!var_decl) { continue; } auto bp = global->BindingPoint(); - if (auto added = binding_points.Add(bp, var_decl); + if (!bp) { + continue; + } + if (auto added = binding_points.Add(*bp, var_decl); !added && IsValidationEnabled(decl->attributes, ast::DisabledValidation::kBindingPointCollision) && @@ -1364,7 +1367,7 @@ bool Validator::EntryPoint(const sem::Function* func, ast::PipelineStage stage) AddError( "entry point '" + func_name + "' references multiple variables that use the same resource binding @group(" + - std::to_string(bp.group) + "), @binding(" + std::to_string(bp.binding) + ")", + std::to_string(bp->group) + "), @binding(" + std::to_string(bp->binding) + ")", var_decl->source); AddNote("first resource binding usage declared here", (*added.value)->source); return false; diff --git a/src/tint/sem/function.cc b/src/tint/sem/function.cc index ec51b7bef2..9484012ced 100644 --- a/src/tint/sem/function.cc +++ b/src/tint/sem/function.cc @@ -60,8 +60,8 @@ Function::VariableBindings Function::TransitivelyReferencedUniformVariables() co continue; } - if (global->Declaration()->HasBindingPoint()) { - ret.push_back({global, global->BindingPoint()}); + if (auto bp = global->BindingPoint()) { + ret.push_back({global, *bp}); } } return ret; @@ -75,8 +75,8 @@ Function::VariableBindings Function::TransitivelyReferencedStorageBufferVariable continue; } - if (global->Declaration()->HasBindingPoint()) { - ret.push_back({global, global->BindingPoint()}); + if (auto bp = global->BindingPoint()) { + ret.push_back({global, *bp}); } } return ret; @@ -119,8 +119,8 @@ Function::VariableBindings Function::TransitivelyReferencedVariablesOfType( for (auto* global : TransitivelyReferencedGlobals()) { auto* unwrapped_type = global->Type()->UnwrapRef(); if (unwrapped_type->TypeInfo().Is(type)) { - if (global->Declaration()->HasBindingPoint()) { - ret.push_back({global, global->BindingPoint()}); + if (auto bp = global->BindingPoint()) { + ret.push_back({global, *bp}); } } } @@ -147,8 +147,8 @@ Function::VariableBindings Function::TransitivelyReferencedSamplerVariablesImpl( continue; } - if (global->Declaration()->HasBindingPoint()) { - ret.push_back({global, global->BindingPoint()}); + if (auto bp = global->BindingPoint()) { + ret.push_back({global, *bp}); } } return ret; @@ -172,8 +172,8 @@ Function::VariableBindings Function::TransitivelyReferencedSampledTextureVariabl continue; } - if (global->Declaration()->HasBindingPoint()) { - ret.push_back({global, global->BindingPoint()}); + if (auto bp = global->BindingPoint()) { + ret.push_back({global, *bp}); } } diff --git a/src/tint/sem/variable.cc b/src/tint/sem/variable.cc index 8f8248ca31..2e3cb88c71 100644 --- a/src/tint/sem/variable.cc +++ b/src/tint/sem/variable.cc @@ -61,7 +61,7 @@ GlobalVariable::GlobalVariable(const ast::Variable* declaration, builtin::AddressSpace address_space, builtin::Access access, const constant::Value* constant_value, - sem::BindingPoint binding_point, + std::optional binding_point, std::optional location) : Base(declaration, type, stage, address_space, access, constant_value), binding_point_(binding_point), @@ -75,7 +75,7 @@ Parameter::Parameter(const ast::Parameter* declaration, builtin::AddressSpace address_space, builtin::Access access, const ParameterUsage usage /* = ParameterUsage::kNone */, - sem::BindingPoint binding_point /* = {} */, + std::optional binding_point /* = {} */, std::optional location /* = std::nullopt */) : Base(declaration, type, EvaluationStage::kRuntime, address_space, access, nullptr), index_(index), diff --git a/src/tint/sem/variable.h b/src/tint/sem/variable.h index 701a3f1107..647a77b13c 100644 --- a/src/tint/sem/variable.h +++ b/src/tint/sem/variable.h @@ -165,14 +165,14 @@ class GlobalVariable final : public Castable { builtin::AddressSpace address_space, builtin::Access access, const constant::Value* constant_value, - sem::BindingPoint binding_point = {}, + std::optional binding_point = std::nullopt, std::optional location = std::nullopt); /// Destructor ~GlobalVariable() override; /// @returns the resource binding point for the variable - sem::BindingPoint BindingPoint() const { return binding_point_; } + std::optional BindingPoint() const { return binding_point_; } /// @param id the constant identifier to assign to this variable void SetOverrideId(OverrideId id) { override_id_ = id; } @@ -184,7 +184,7 @@ class GlobalVariable final : public Castable { std::optional Location() const { return location_; } private: - const sem::BindingPoint binding_point_; + const std::optional binding_point_; tint::OverrideId override_id_; std::optional location_; @@ -208,7 +208,7 @@ class Parameter final : public Castable { builtin::AddressSpace address_space, builtin::Access access, const ParameterUsage usage = ParameterUsage::kNone, - sem::BindingPoint binding_point = {}, + std::optional binding_point = {}, std::optional location = std::nullopt); /// Destructor @@ -239,7 +239,7 @@ class Parameter final : public Castable { void SetShadows(const CastableBase* shadows) { shadows_ = shadows; } /// @returns the resource binding point for the parameter - sem::BindingPoint BindingPoint() const { return binding_point_; } + std::optional BindingPoint() const { return binding_point_; } /// @returns the location value for the parameter, if set std::optional Location() const { return location_; } @@ -249,7 +249,7 @@ class Parameter final : public Castable { const ParameterUsage usage_; CallTarget const* owner_ = nullptr; const CastableBase* shadows_ = nullptr; - const sem::BindingPoint binding_point_; + const std::optional binding_point_; const std::optional location_; }; diff --git a/src/tint/transform/array_length_from_uniform.cc b/src/tint/transform/array_length_from_uniform.cc index a396965ef2..e0358b45b4 100644 --- a/src/tint/transform/array_length_from_uniform.cc +++ b/src/tint/transform/array_length_from_uniform.cc @@ -82,13 +82,14 @@ struct ArrayLengthFromUniform::State { IterateArrayLengthOnStorageVar([&](const ast::CallExpression*, const sem::VariableUser*, const sem::GlobalVariable* var) { - auto binding = var->BindingPoint(); - auto idx_itr = cfg->bindpoint_to_size_index.find(binding); - if (idx_itr == cfg->bindpoint_to_size_index.end()) { - return; - } - if (idx_itr->second > max_buffer_size_index) { - max_buffer_size_index = idx_itr->second; + if (auto binding = var->BindingPoint()) { + auto idx_itr = cfg->bindpoint_to_size_index.find(*binding); + if (idx_itr == cfg->bindpoint_to_size_index.end()) { + return; + } + if (idx_itr->second > max_buffer_size_index) { + max_buffer_size_index = idx_itr->second; + } } }); @@ -120,7 +121,10 @@ struct ArrayLengthFromUniform::State { const sem::VariableUser* storage_buffer_sem, const sem::GlobalVariable* var) { auto binding = var->BindingPoint(); - auto idx_itr = cfg->bindpoint_to_size_index.find(binding); + if (!binding) { + return; + } + auto idx_itr = cfg->bindpoint_to_size_index.find(*binding); if (idx_itr == cfg->bindpoint_to_size_index.end()) { return; } diff --git a/src/tint/transform/binding_remapper.cc b/src/tint/transform/binding_remapper.cc index ecbd5cd6f9..6b1888d523 100644 --- a/src/tint/transform/binding_remapper.cc +++ b/src/tint/transform/binding_remapper.cc @@ -71,10 +71,8 @@ Transform::ApplyResult BindingRemapper::Apply(const Program* src, auto* func = src->Sem().Get(func_ast); std::unordered_map binding_point_counts; for (auto* global : func->TransitivelyReferencedGlobals()) { - if (global->Declaration()->HasBindingPoint()) { - BindingPoint from = global->BindingPoint(); - - auto bp_it = remappings->binding_points.find(from); + if (auto from = global->BindingPoint()) { + auto bp_it = remappings->binding_points.find(*from); if (bp_it != remappings->binding_points.end()) { // Remapped BindingPoint to = bp_it->second; @@ -83,8 +81,8 @@ Transform::ApplyResult BindingRemapper::Apply(const Program* src, } } else { // No remapping - if (binding_point_counts[from]++) { - add_collision_attr.emplace(from); + if (binding_point_counts[*from]++) { + add_collision_attr.emplace(*from); } } } @@ -97,7 +95,7 @@ Transform::ApplyResult BindingRemapper::Apply(const Program* src, auto* global_sem = src->Sem().Get(var); // The original binding point - BindingPoint from = global_sem->BindingPoint(); + BindingPoint from = *global_sem->BindingPoint(); // The binding point after remapping BindingPoint bp = from; diff --git a/src/tint/transform/combine_samplers.cc b/src/tint/transform/combine_samplers.cc index aa1a6866e0..3e9aa7fd91 100644 --- a/src/tint/transform/combine_samplers.cc +++ b/src/tint/transform/combine_samplers.cc @@ -107,10 +107,10 @@ struct CombineSamplers::State { const sem::Variable* sampler_var, std::string name) { SamplerTexturePair bp_pair; - bp_pair.texture_binding_point = texture_var->As()->BindingPoint(); - bp_pair.sampler_binding_point = sampler_var - ? sampler_var->As()->BindingPoint() - : binding_info->placeholder_binding_point; + bp_pair.texture_binding_point = *texture_var->As()->BindingPoint(); + bp_pair.sampler_binding_point = + sampler_var ? *sampler_var->As()->BindingPoint() + : binding_info->placeholder_binding_point; auto it = binding_info->binding_map.find(bp_pair); if (it != binding_info->binding_map.end()) { name = it->second; @@ -161,9 +161,8 @@ struct CombineSamplers::State { if (tint::IsAnyOf(type) && !type->Is()) { ctx.Remove(ctx.src->AST().GlobalDeclarations(), global); - } else if (global->HasBindingPoint()) { - auto binding_point = global_sem->BindingPoint(); - if (binding_point.group == 0 && binding_point.binding == 0) { + } else if (auto binding_point = global_sem->BindingPoint()) { + if (binding_point->group == 0 && binding_point->binding == 0) { auto* attribute = ctx.dst->Disable(ast::DisabledValidation::kBindingPointCollision); ctx.InsertFront(global->attributes, attribute); diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index dcf1e1c83a..2105781a43 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -115,7 +115,7 @@ struct MultiplanarExternalTexture::State { // The binding points for the newly introduced bindings must have been provided to this // transform. We fetch the new binding points by providing the original texture_external // binding points into the passed map. - sem::BindingPoint bp = sem_var->BindingPoint(); + sem::BindingPoint bp = *sem_var->BindingPoint(); BindingsMap::const_iterator it = new_binding_points->bindings_map.find(bp); if (it == new_binding_points->bindings_map.end()) { diff --git a/src/tint/transform/num_workgroups_from_uniform.cc b/src/tint/transform/num_workgroups_from_uniform.cc index e4bb05ebea..18889f4ca8 100644 --- a/src/tint/transform/num_workgroups_from_uniform.cc +++ b/src/tint/transform/num_workgroups_from_uniform.cc @@ -148,11 +148,10 @@ Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src, group = 0; for (auto* global : src->AST().GlobalVariables()) { - if (global->HasBindingPoint()) { - auto* global_sem = src->Sem().Get(global); - auto binding_point = global_sem->BindingPoint(); - if (binding_point.group >= group) { - group = binding_point.group + 1; + auto* global_sem = src->Sem().Get(global); + if (auto bp = global_sem->BindingPoint()) { + if (bp->group >= group) { + group = bp->group + 1; } } } diff --git a/src/tint/writer/flatten_bindings_test.cc b/src/tint/writer/flatten_bindings_test.cc index 7e53356a89..d1351d85a1 100644 --- a/src/tint/writer/flatten_bindings_test.cc +++ b/src/tint/writer/flatten_bindings_test.cc @@ -67,18 +67,18 @@ TEST_F(FlattenBindingsTest, NotFlat_SingleNamespace) { auto* sem = flattened->Sem().Get(vars[0]); ASSERT_NE(sem, nullptr); - EXPECT_EQ(sem->BindingPoint().group, 0u); - EXPECT_EQ(sem->BindingPoint().binding, 0u); + EXPECT_EQ(sem->BindingPoint()->group, 0u); + EXPECT_EQ(sem->BindingPoint()->binding, 0u); sem = flattened->Sem().Get(vars[1]); ASSERT_NE(sem, nullptr); - EXPECT_EQ(sem->BindingPoint().group, 0u); - EXPECT_EQ(sem->BindingPoint().binding, 1u); + EXPECT_EQ(sem->BindingPoint()->group, 0u); + EXPECT_EQ(sem->BindingPoint()->binding, 1u); sem = flattened->Sem().Get(vars[2]); ASSERT_NE(sem, nullptr); - EXPECT_EQ(sem->BindingPoint().group, 0u); - EXPECT_EQ(sem->BindingPoint().binding, 2u); + EXPECT_EQ(sem->BindingPoint()->group, 0u); + EXPECT_EQ(sem->BindingPoint()->binding, 2u); } TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) { @@ -131,20 +131,20 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) { for (size_t i = 0; i < num_buffers; ++i) { auto* sem = flattened->Sem().Get(vars[i]); ASSERT_NE(sem, nullptr); - EXPECT_EQ(sem->BindingPoint().group, 0u); - EXPECT_EQ(sem->BindingPoint().binding, i); + EXPECT_EQ(sem->BindingPoint()->group, 0u); + EXPECT_EQ(sem->BindingPoint()->binding, i); } for (size_t i = 0; i < num_samplers; ++i) { auto* sem = flattened->Sem().Get(vars[i + num_buffers]); ASSERT_NE(sem, nullptr); - EXPECT_EQ(sem->BindingPoint().group, 0u); - EXPECT_EQ(sem->BindingPoint().binding, i); + EXPECT_EQ(sem->BindingPoint()->group, 0u); + EXPECT_EQ(sem->BindingPoint()->binding, i); } for (size_t i = 0; i < num_textures; ++i) { auto* sem = flattened->Sem().Get(vars[i + num_buffers + num_samplers]); ASSERT_NE(sem, nullptr); - EXPECT_EQ(sem->BindingPoint().group, 0u); - EXPECT_EQ(sem->BindingPoint().binding, i); + EXPECT_EQ(sem->BindingPoint()->group, 0u); + EXPECT_EQ(sem->BindingPoint()->binding, i); } } diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index 4f46e662c8..72eb737ba8 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -2031,7 +2031,7 @@ bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable TINT_ICE(Writer, builder_.Diagnostics()) << "storage variable must be of struct type"; return false; } - auto bp = sem->As()->BindingPoint(); + auto bp = *sem->As()->BindingPoint(); { auto out = line(); out << "layout(binding = " << bp.binding << ", std140"; @@ -2052,7 +2052,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable TINT_ICE(Writer, builder_.Diagnostics()) << "storage variable must be of struct type"; return false; } - auto bp = sem->As()->BindingPoint(); + auto bp = *sem->As()->BindingPoint(); line() << "layout(binding = " << bp.binding << ", std430) buffer " << UniqueIdentifier(StructName(str) + "_ssbo") << " {"; EmitStructMembers(current_buffer_, str); diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index b37ebdca28..8b9bde81a3 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -3066,7 +3066,7 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) { } bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable* sem) { - auto binding_point = sem->As()->BindingPoint(); + auto binding_point = *sem->As()->BindingPoint(); auto* type = sem->Type()->UnwrapRef(); auto name = var->name->symbol.Name(); line() << "cbuffer cbuffer_" << name << RegisterAndSpace('b', binding_point) << " {"; @@ -3095,7 +3095,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable auto* global_sem = sem->As(); out << RegisterAndSpace(sem->Access() == builtin::Access::kRead ? 't' : 'u', - global_sem->BindingPoint()) + *global_sem->BindingPoint()) << ";"; return true; @@ -3124,14 +3124,14 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable* if (register_space) { auto bp = sem->As()->BindingPoint(); - out << " : register(" << register_space << bp.binding; + out << " : register(" << register_space << bp->binding; // Omit the space if it's 0, as it's the default. // SM 5.0 doesn't support spaces, so we don't emit them if group is 0 for better // compatibility. - if (bp.group == 0) { + if (bp->group == 0) { out << ")"; } else { - out << ", space" << bp.group << ")"; + out << ", space" << bp->group << ")"; } } diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 842f6cbb0d..f86a14422e 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -1996,12 +1996,12 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { } auto* param_sem = program_->Sem().Get(param); auto bp = param_sem->BindingPoint(); - if (TINT_UNLIKELY(bp.group != 0)) { + if (TINT_UNLIKELY(bp->group != 0)) { TINT_ICE(Writer, diagnostics_) << "encountered non-zero resource group index (use " "BindingRemapper to fix)"; return kInvalidBindingIndex; } - return bp.binding; + return bp->binding; }; { diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index 0a3009c7ab..4a5c90b23c 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -867,14 +867,14 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) { [&](const ast::BindingAttribute*) { auto bp = sem->BindingPoint(); push_annot(spv::Op::OpDecorate, {Operand(var_id), U32Operand(SpvDecorationBinding), - Operand(bp.binding)}); + Operand(bp->binding)}); return true; }, [&](const ast::GroupAttribute*) { auto bp = sem->BindingPoint(); push_annot( spv::Op::OpDecorate, - {Operand(var_id), U32Operand(SpvDecorationDescriptorSet), Operand(bp.group)}); + {Operand(var_id), U32Operand(SpvDecorationDescriptorSet), Operand(bp->group)}); return true; }, [&](const ast::IdAttribute*) {