tint/ast: Generate interpolate_attribute.[h|cc]

Emits all the enum info from the single-source-of-truth `intrinsics.def` file

Change-Id: Ie9deba9e64927945133027cf243777944119ea41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105327
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-10-11 19:49:17 +00:00
committed by Dawn LUCI CQ
parent c1af0f5005
commit f9ed9d3a63
23 changed files with 312 additions and 118 deletions

View File

@@ -35,32 +35,5 @@ EntryPoint::EntryPoint(EntryPoint&) = default;
EntryPoint::EntryPoint(EntryPoint&&) = default;
EntryPoint::~EntryPoint() = default;
InterpolationType ASTToInspectorInterpolationType(ast::InterpolationType ast_type) {
switch (ast_type) {
case ast::InterpolationType::kPerspective:
return InterpolationType::kPerspective;
case ast::InterpolationType::kLinear:
return InterpolationType::kLinear;
case ast::InterpolationType::kFlat:
return InterpolationType::kFlat;
}
return InterpolationType::kUnknown;
}
InterpolationSampling ASTToInspectorInterpolationSampling(ast::InterpolationSampling sampling) {
switch (sampling) {
case ast::InterpolationSampling::kNone:
return InterpolationSampling::kNone;
case ast::InterpolationSampling::kCenter:
return InterpolationSampling::kCenter;
case ast::InterpolationSampling::kCentroid:
return InterpolationSampling::kCentroid;
case ast::InterpolationSampling::kSample:
return InterpolationSampling::kSample;
}
return InterpolationSampling::kUnknown;
}
} // namespace tint::inspector

View File

@@ -84,17 +84,6 @@ struct StageVariable {
InterpolationSampling interpolation_sampling = InterpolationSampling::kUnknown;
};
/// Convert from internal ast::InterpolationType to public ::InterpolationType.
/// @param ast_type internal value to convert from
/// @returns the publicly visible equivalent
InterpolationType ASTToInspectorInterpolationType(ast::InterpolationType ast_type);
/// Convert from internal ast::InterpolationSampling to public
/// ::InterpolationSampling
/// @param sampling internal value to convert from
/// @returns the publicly visible equivalent
InterpolationSampling ASTToInspectorInterpolationSampling(ast::InterpolationSampling sampling);
/// Reflection data about an override variable referenced by an entry point
struct Override {
/// Name of the override

View File

@@ -117,14 +117,45 @@ std::tuple<InterpolationType, InterpolationSampling> CalculateInterpolationData(
return {InterpolationType::kPerspective, InterpolationSampling::kCenter};
}
auto interpolation_type = interpolation_attribute->type;
auto sampling = interpolation_attribute->sampling;
if (interpolation_type != ast::InterpolationType::kFlat &&
sampling == ast::InterpolationSampling::kNone) {
sampling = ast::InterpolationSampling::kCenter;
auto ast_interpolation_type = interpolation_attribute->type;
auto ast_sampling_type = interpolation_attribute->sampling;
if (ast_interpolation_type != ast::InterpolationType::kFlat &&
ast_sampling_type == ast::InterpolationSampling::kInvalid) {
ast_sampling_type = ast::InterpolationSampling::kCenter;
}
return {ASTToInspectorInterpolationType(interpolation_type),
ASTToInspectorInterpolationSampling(sampling)};
auto interpolation_type = InterpolationType::kUnknown;
switch (ast_interpolation_type) {
case ast::InterpolationType::kPerspective:
interpolation_type = InterpolationType::kPerspective;
break;
case ast::InterpolationType::kLinear:
interpolation_type = InterpolationType::kLinear;
break;
case ast::InterpolationType::kFlat:
interpolation_type = InterpolationType::kFlat;
break;
case ast::InterpolationType::kInvalid:
break;
}
auto sampling_type = InterpolationSampling::kUnknown;
switch (ast_sampling_type) {
case ast::InterpolationSampling::kInvalid:
sampling_type = InterpolationSampling::kNone;
break;
case ast::InterpolationSampling::kCenter:
sampling_type = InterpolationSampling::kCenter;
break;
case ast::InterpolationSampling::kCentroid:
sampling_type = InterpolationSampling::kCentroid;
break;
case ast::InterpolationSampling::kSample:
sampling_type = InterpolationSampling::kSample;
break;
}
return {interpolation_type, sampling_type};
}
} // namespace

View File

@@ -1250,7 +1250,7 @@ INSTANTIATE_TEST_SUITE_P(
ast::InterpolationType::kPerspective, ast::InterpolationSampling::kSample,
InterpolationType::kPerspective, InterpolationSampling::kSample},
InspectorGetEntryPointInterpolateTestParams{
ast::InterpolationType::kPerspective, ast::InterpolationSampling::kNone,
ast::InterpolationType::kPerspective, ast::InterpolationSampling::kInvalid,
InterpolationType::kPerspective, InterpolationSampling::kCenter},
InspectorGetEntryPointInterpolateTestParams{
ast::InterpolationType::kLinear, ast::InterpolationSampling::kCenter,
@@ -1262,10 +1262,10 @@ INSTANTIATE_TEST_SUITE_P(
ast::InterpolationType::kLinear, ast::InterpolationSampling::kSample,
InterpolationType::kLinear, InterpolationSampling::kSample},
InspectorGetEntryPointInterpolateTestParams{
ast::InterpolationType::kLinear, ast::InterpolationSampling::kNone,
ast::InterpolationType::kLinear, ast::InterpolationSampling::kInvalid,
InterpolationType::kLinear, InterpolationSampling::kCenter},
InspectorGetEntryPointInterpolateTestParams{
ast::InterpolationType::kFlat, ast::InterpolationSampling::kNone,
ast::InterpolationType::kFlat, ast::InterpolationSampling::kInvalid,
InterpolationType::kFlat, InterpolationSampling::kNone}));
TEST_F(InspectorGetOverrideDefaultValuesTest, Bool) {