mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-11 22:44:04 +00:00
Convert @location to store expression internally.
This CL updates the internal storage for a `@location` attribute to store the `Expression` instead of a raw `uint32_t`. The current parser is updated to generate an `IntLiteralExpression` so we still parse as a `uint32_t` at the moment. Bug: tint:1633 Change-Id: I2b9684754a657b39554160c81727cf1541bee96c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101461 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
145337f309
commit
f9eeed6106
@@ -172,7 +172,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) {
|
||||
for (auto* param : sem->Parameters()) {
|
||||
AddEntryPointInOutVariables(program_->Symbols().NameFor(param->Declaration()->symbol),
|
||||
param->Type(), param->Declaration()->attributes,
|
||||
entry_point.input_variables);
|
||||
param->Location(), entry_point.input_variables);
|
||||
|
||||
entry_point.input_position_used |= ContainsBuiltin(
|
||||
ast::BuiltinValue::kPosition, param->Type(), param->Declaration()->attributes);
|
||||
@@ -188,7 +188,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) {
|
||||
|
||||
if (!sem->ReturnType()->Is<sem::Void>()) {
|
||||
AddEntryPointInOutVariables("<retval>", sem->ReturnType(), func->return_type_attributes,
|
||||
entry_point.output_variables);
|
||||
sem->ReturnLocation(), entry_point.output_variables);
|
||||
|
||||
entry_point.output_sample_mask_used = ContainsBuiltin(
|
||||
ast::BuiltinValue::kSampleMask, sem->ReturnType(), func->return_type_attributes);
|
||||
@@ -623,6 +623,7 @@ const ast::Function* Inspector::FindEntryPointByName(const std::string& name) {
|
||||
void Inspector::AddEntryPointInOutVariables(std::string name,
|
||||
const sem::Type* type,
|
||||
utils::VectorRef<const ast::Attribute*> attributes,
|
||||
std::optional<uint32_t> location,
|
||||
std::vector<StageVariable>& variables) const {
|
||||
// Skip builtins.
|
||||
if (ast::HasAttribute<ast::BuiltinAttribute>(attributes)) {
|
||||
@@ -636,7 +637,7 @@ void Inspector::AddEntryPointInOutVariables(std::string name,
|
||||
for (auto* member : struct_ty->Members()) {
|
||||
AddEntryPointInOutVariables(
|
||||
name + "." + program_->Symbols().NameFor(member->Declaration()->symbol),
|
||||
member->Type(), member->Declaration()->attributes, variables);
|
||||
member->Type(), member->Declaration()->attributes, member->Location(), variables);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -648,10 +649,9 @@ void Inspector::AddEntryPointInOutVariables(std::string name,
|
||||
std::tie(stage_variable.component_type, stage_variable.composition_type) =
|
||||
CalculateComponentAndComposition(type);
|
||||
|
||||
auto* location = ast::GetAttribute<ast::LocationAttribute>(attributes);
|
||||
TINT_ASSERT(Inspector, location != nullptr);
|
||||
TINT_ASSERT(Inspector, location.has_value());
|
||||
stage_variable.has_location_attribute = true;
|
||||
stage_variable.location_attribute = location->value;
|
||||
stage_variable.location_attribute = location.value();
|
||||
|
||||
std::tie(stage_variable.interpolation_type, stage_variable.interpolation_sampling) =
|
||||
CalculateInterpolationData(type, attributes);
|
||||
|
||||
@@ -172,10 +172,12 @@ class Inspector {
|
||||
/// @param name the name of the variable being added
|
||||
/// @param type the type of the variable
|
||||
/// @param attributes the variable attributes
|
||||
/// @param location the location value if provided
|
||||
/// @param variables the list to add the variables to
|
||||
void AddEntryPointInOutVariables(std::string name,
|
||||
const sem::Type* type,
|
||||
utils::VectorRef<const ast::Attribute*> attributes,
|
||||
std::optional<uint32_t> location,
|
||||
std::vector<StageVariable>& variables) const;
|
||||
|
||||
/// Recursively determine if the type contains builtin.
|
||||
|
||||
@@ -291,7 +291,7 @@ TEST_P(InspectorGetEntryPointComponentAndCompositionTest, Test) {
|
||||
|
||||
auto* in_var = Param("in_var", tint_type(),
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
Flat(),
|
||||
});
|
||||
Func("foo", utils::Vector{in_var}, tint_type(),
|
||||
@@ -302,7 +302,7 @@ TEST_P(InspectorGetEntryPointComponentAndCompositionTest, Test) {
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
},
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
});
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@@ -336,17 +336,17 @@ INSTANTIATE_TEST_SUITE_P(InspectorGetEntryPointTest,
|
||||
TEST_F(InspectorGetEntryPointTest, MultipleInOutVariables) {
|
||||
auto* in_var0 = Param("in_var0", ty.u32(),
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
Flat(),
|
||||
});
|
||||
auto* in_var1 = Param("in_var1", ty.u32(),
|
||||
utils::Vector{
|
||||
Location(1u),
|
||||
Location(1_u),
|
||||
Flat(),
|
||||
});
|
||||
auto* in_var4 = Param("in_var4", ty.u32(),
|
||||
utils::Vector{
|
||||
Location(4u),
|
||||
Location(4_u),
|
||||
Flat(),
|
||||
});
|
||||
Func("foo", utils::Vector{in_var0, in_var1, in_var4}, ty.u32(),
|
||||
@@ -357,7 +357,7 @@ TEST_F(InspectorGetEntryPointTest, MultipleInOutVariables) {
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
},
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
});
|
||||
Inspector& inspector = Build();
|
||||
|
||||
@@ -393,7 +393,7 @@ TEST_F(InspectorGetEntryPointTest, MultipleInOutVariables) {
|
||||
TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutVariables) {
|
||||
auto* in_var_foo = Param("in_var_foo", ty.u32(),
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
Flat(),
|
||||
});
|
||||
Func("foo", utils::Vector{in_var_foo}, ty.u32(),
|
||||
@@ -404,12 +404,12 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutVariables) {
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
},
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
});
|
||||
|
||||
auto* in_var_bar = Param("in_var_bar", ty.u32(),
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
Flat(),
|
||||
});
|
||||
Func("bar", utils::Vector{in_var_bar}, ty.u32(),
|
||||
@@ -420,7 +420,7 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutVariables) {
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
},
|
||||
utils::Vector{
|
||||
Location(1u),
|
||||
Location(1_u),
|
||||
});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
@@ -464,7 +464,7 @@ TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) {
|
||||
});
|
||||
auto* in_var1 = Param("in_var1", ty.f32(),
|
||||
utils::Vector{
|
||||
Location(0u),
|
||||
Location(0_u),
|
||||
});
|
||||
Func("foo", utils::Vector{in_var0, in_var1}, ty.f32(),
|
||||
utils::Vector{
|
||||
@@ -596,8 +596,8 @@ TEST_F(InspectorGetEntryPointTest, MixInOutVariablesAndStruct) {
|
||||
utils::Vector{
|
||||
Param("param_a", ty.Of(struct_a)),
|
||||
Param("param_b", ty.Of(struct_b)),
|
||||
Param("param_c", ty.f32(), utils::Vector{Location(3u)}),
|
||||
Param("param_d", ty.f32(), utils::Vector{Location(4u)}),
|
||||
Param("param_c", ty.f32(), utils::Vector{Location(3_u)}),
|
||||
Param("param_d", ty.f32(), utils::Vector{Location(4_u)}),
|
||||
},
|
||||
ty.Of(struct_a),
|
||||
utils::Vector{
|
||||
@@ -1136,7 +1136,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
|
||||
|
||||
TEST_F(InspectorGetEntryPointTest, ImplicitInterpolate) {
|
||||
Structure("in_struct", utils::Vector{
|
||||
Member("struct_inner", ty.f32(), utils::Vector{Location(0)}),
|
||||
Member("struct_inner", ty.f32(), utils::Vector{Location(0_a)}),
|
||||
});
|
||||
|
||||
Func("ep_func",
|
||||
@@ -1167,7 +1167,7 @@ TEST_P(InspectorGetEntryPointInterpolateTest, Test) {
|
||||
"in_struct",
|
||||
utils::Vector{
|
||||
Member("struct_inner", ty.f32(),
|
||||
utils::Vector{Interpolate(params.in_type, params.in_sampling), Location(0)}),
|
||||
utils::Vector{Interpolate(params.in_type, params.in_sampling), Location(0_a)}),
|
||||
});
|
||||
|
||||
Func("ep_func",
|
||||
|
||||
@@ -54,7 +54,7 @@ const ast::Struct* InspectorBuilder::MakeInOutStruct(std::string name,
|
||||
std::tie(member_name, location) = var;
|
||||
members.Push(Member(member_name, ty.u32(),
|
||||
utils::Vector{
|
||||
Location(location),
|
||||
Location(AInt(location)),
|
||||
Flat(),
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user