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

@ -27,7 +27,7 @@
namespace tint::ast {
/// Storage class of a given pointer.
/// Builtin value defined with `@builtin(<name>)`.
enum class BuiltinValue {
kInvalid,
kFragDepth,

View File

@ -18,7 +18,7 @@ See:
namespace tint::ast {
/// Storage class of a given pointer.
/// Builtin value defined with `@builtin(<name>)`.
{{ Eval "DeclareEnum" $enum}}
} // namespace tint::ast

View File

@ -12,6 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/ast/interpolate_attribute.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/interpolate_attribute.h"
#include <string>
@ -41,44 +49,64 @@ const InterpolateAttribute* InterpolateAttribute::Clone(CloneContext* ctx) const
return ctx->dst->create<InterpolateAttribute>(src, type, sampling);
}
std::ostream& operator<<(std::ostream& out, InterpolationType type) {
switch (type) {
case InterpolationType::kPerspective: {
out << "perspective";
break;
/// ParseInterpolationType parses a InterpolationType from a string.
/// @param str the string to parse
/// @returns the parsed enum, or InterpolationType::kInvalid if the string could not be parsed.
InterpolationType ParseInterpolationType(std::string_view str) {
if (str == "flat") {
return InterpolationType::kFlat;
}
case InterpolationType::kLinear: {
out << "linear";
break;
if (str == "linear") {
return InterpolationType::kLinear;
}
case InterpolationType::kFlat: {
out << "flat";
break;
if (str == "perspective") {
return InterpolationType::kPerspective;
}
}
return out;
return InterpolationType::kInvalid;
}
std::ostream& operator<<(std::ostream& out, InterpolationSampling sampling) {
switch (sampling) {
case InterpolationSampling::kNone: {
out << "none";
break;
std::ostream& operator<<(std::ostream& out, InterpolationType value) {
switch (value) {
case InterpolationType::kInvalid:
return out << "invalid";
case InterpolationType::kFlat:
return out << "flat";
case InterpolationType::kLinear:
return out << "linear";
case InterpolationType::kPerspective:
return out << "perspective";
}
case InterpolationSampling::kCenter: {
out << "center";
break;
return out << "<unknown>";
}
/// ParseInterpolationSampling parses a InterpolationSampling from a string.
/// @param str the string to parse
/// @returns the parsed enum, or InterpolationSampling::kInvalid if the string could not be parsed.
InterpolationSampling ParseInterpolationSampling(std::string_view str) {
if (str == "center") {
return InterpolationSampling::kCenter;
}
case InterpolationSampling::kCentroid: {
out << "centroid";
break;
if (str == "centroid") {
return InterpolationSampling::kCentroid;
}
case InterpolationSampling::kSample: {
out << "sample";
break;
if (str == "sample") {
return InterpolationSampling::kSample;
}
return InterpolationSampling::kInvalid;
}
std::ostream& operator<<(std::ostream& out, InterpolationSampling value) {
switch (value) {
case InterpolationSampling::kInvalid:
return out << "invalid";
case InterpolationSampling::kCenter:
return out << "center";
case InterpolationSampling::kCentroid:
return out << "centroid";
case InterpolationSampling::kSample:
return out << "sample";
}
return out;
return out << "<unknown>";
}
} // namespace tint::ast

View File

@ -0,0 +1,50 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate builtin_value.cc
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
#include "src/tint/ast/interpolate_attribute.h"
#include <string>
#include "src/tint/program_builder.h"
TINT_INSTANTIATE_TYPEINFO(tint::ast::InterpolateAttribute);
namespace tint::ast {
InterpolateAttribute::InterpolateAttribute(ProgramID pid,
NodeID nid,
const Source& src,
InterpolationType ty,
InterpolationSampling smpl)
: Base(pid, nid, src), type(ty), sampling(smpl) {}
InterpolateAttribute::~InterpolateAttribute() = default;
std::string InterpolateAttribute::Name() const {
return "interpolate";
}
const InterpolateAttribute* InterpolateAttribute::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto src = ctx->Clone(source);
return ctx->dst->create<InterpolateAttribute>(src, type, sampling);
}
{{ Eval "ParseEnum" (Sem.Enum "interpolation_type")}}
{{ Eval "EnumOStream" (Sem.Enum "interpolation_type")}}
{{ Eval "ParseEnum" (Sem.Enum "interpolation_sampling")}}
{{ Eval "EnumOStream" (Sem.Enum "interpolation_sampling")}}
} // namespace tint::ast

View File

@ -1,4 +1,4 @@
// Copyright 2021 The Tint Authors.
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,6 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/ast/interpolate_attribute.h.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#ifndef SRC_TINT_AST_INTERPOLATE_ATTRIBUTE_H_
#define SRC_TINT_AST_INTERPOLATE_ATTRIBUTE_H_
@ -23,10 +31,52 @@
namespace tint::ast {
/// The interpolation type.
enum class InterpolationType { kPerspective, kLinear, kFlat };
enum class InterpolationType {
kInvalid,
kFlat,
kLinear,
kPerspective,
};
/// @param out the std::ostream to write to
/// @param value the InterpolationType
/// @returns `out` so calls can be chained
std::ostream& operator<<(std::ostream& out, InterpolationType value);
/// ParseInterpolationType parses a InterpolationType from a string.
/// @param str the string to parse
/// @returns the parsed enum, or InterpolationType::kInvalid if the string could not be parsed.
InterpolationType ParseInterpolationType(std::string_view str);
constexpr const char* kInterpolationTypeStrings[] = {
"flat",
"linear",
"perspective",
};
/// The interpolation sampling.
enum class InterpolationSampling { kNone = -1, kCenter, kCentroid, kSample };
enum class InterpolationSampling {
kInvalid,
kCenter,
kCentroid,
kSample,
};
/// @param out the std::ostream to write to
/// @param value the InterpolationSampling
/// @returns `out` so calls can be chained
std::ostream& operator<<(std::ostream& out, InterpolationSampling value);
/// ParseInterpolationSampling parses a InterpolationSampling from a string.
/// @param str the string to parse
/// @returns the parsed enum, or InterpolationSampling::kInvalid if the string could not be parsed.
InterpolationSampling ParseInterpolationSampling(std::string_view str);
constexpr const char* kInterpolationSamplingStrings[] = {
"center",
"centroid",
"sample",
};
/// An interpolate attribute
class InterpolateAttribute final : public Castable<InterpolateAttribute, Attribute> {
@ -60,16 +110,6 @@ class InterpolateAttribute final : public Castable<InterpolateAttribute, Attribu
const InterpolationSampling sampling;
};
/// @param out the std::ostream to write to
/// @param type the interpolation type
/// @return the std::ostream so calls can be chained
std::ostream& operator<<(std::ostream& out, InterpolationType type);
/// @param out the std::ostream to write to
/// @param sampling the interpolation sampling
/// @return the std::ostream so calls can be chained
std::ostream& operator<<(std::ostream& out, InterpolationSampling sampling);
} // namespace tint::ast
#endif // SRC_TINT_AST_INTERPOLATE_ATTRIBUTE_H_

View File

@ -0,0 +1,63 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate interpolate_attribute.h
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
#ifndef SRC_TINT_AST_INTERPOLATE_ATTRIBUTE_H_
#define SRC_TINT_AST_INTERPOLATE_ATTRIBUTE_H_
#include <ostream>
#include <string>
#include "src/tint/ast/attribute.h"
namespace tint::ast {
/// The interpolation type.
{{ Eval "DeclareEnum" (Sem.Enum "interpolation_type") }}
/// The interpolation sampling.
{{ Eval "DeclareEnum" (Sem.Enum "interpolation_sampling") }}
/// An interpolate attribute
class InterpolateAttribute final : public Castable<InterpolateAttribute, Attribute> {
public:
/// Create an interpolate attribute.
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param type the interpolation type
/// @param sampling the interpolation sampling
InterpolateAttribute(ProgramID pid,
NodeID nid,
const Source& src,
InterpolationType type,
InterpolationSampling sampling);
~InterpolateAttribute() override;
/// @returns the WGSL name for the attribute
std::string Name() const override;
/// Clones this node and all transitive child nodes using the `CloneContext`
/// `ctx`.
/// @param ctx the clone context
/// @return the newly cloned node
const InterpolateAttribute* Clone(CloneContext* ctx) const override;
/// The interpolation type
const InterpolationType type;
/// The interpolation sampling
const InterpolationSampling sampling;
};
} // namespace tint::ast
#endif // SRC_TINT_AST_INTERPOLATE_ATTRIBUTE_H_

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) {

View File

@ -94,6 +94,20 @@ enum texel_format {
rgba32float
}
// https://www.w3.org/TR/WGSL/#interpolation
enum interpolation_type {
perspective
linear
flat
}
// https://www.w3.org/TR/WGSL/#interpolation
enum interpolation_sampling {
center
centroid
sample
}
////////////////////////////////////////////////////////////////////////////////
// WGSL primitive types //
// Types may be decorated with @precedence(N) to prioritize which type //

View File

@ -2909,7 +2909,7 @@ class ProgramBuilder {
const ast::InterpolateAttribute* Interpolate(
const Source& source,
ast::InterpolationType type,
ast::InterpolationSampling sampling = ast::InterpolationSampling::kNone) {
ast::InterpolationSampling sampling = ast::InterpolationSampling::kInvalid) {
return create<ast::InterpolateAttribute>(source, type, sampling);
}
@ -2919,7 +2919,7 @@ class ProgramBuilder {
/// @returns the interpolate attribute pointer
const ast::InterpolateAttribute* Interpolate(
ast::InterpolationType type,
ast::InterpolationSampling sampling = ast::InterpolationSampling::kNone) {
ast::InterpolationSampling sampling = ast::InterpolationSampling::kInvalid) {
return create<ast::InterpolateAttribute>(source_, type, sampling);
}

View File

@ -1749,7 +1749,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::kNone;
ast::InterpolationSampling sampling = ast::InterpolationSampling::kInvalid;
for (const auto& deco : decorations) {
TINT_ASSERT(Reader, deco.size() > 0);
@ -1804,7 +1804,7 @@ bool ParserImpl::ConvertPipelineDecorations(const Type* store_type,
// Apply interpolation.
if (type == ast::InterpolationType::kPerspective &&
sampling == ast::InterpolationSampling::kNone) {
sampling == ast::InterpolationSampling::kInvalid) {
// This is the default. Don't add a decoration.
} else {
attributes->Push(create<ast::InterpolateAttribute>(type, sampling));

View File

@ -3554,7 +3554,7 @@ Maybe<const ast::Attribute*> ParserImpl::attribute() {
return Failure::kErrored;
}
ast::InterpolationSampling sampling = ast::InterpolationSampling::kNone;
ast::InterpolationSampling sampling = ast::InterpolationSampling::kInvalid;
if (match(Token::Type::kComma)) {
if (!peek_is(Token::Type::kParenRight)) {
auto sample = expect_interpolation_sample_name();

View File

@ -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::kNone);
EXPECT_EQ(interp->sampling, ast::InterpolationSampling::kInvalid);
}
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::kNone);
EXPECT_EQ(interp->sampling, ast::InterpolationSampling::kInvalid);
}
TEST_F(ParserImplTest, Attribute_Interpolate_Single_DoubleTrailingComma) {

View File

@ -1386,16 +1386,16 @@ INSTANTIATE_TEST_SUITE_P(
ResolverAttributeValidationTest,
InterpolateParameterTest,
testing::Values(
Params{ast::InterpolationType::kPerspective, ast::InterpolationSampling::kNone, true},
Params{ast::InterpolationType::kPerspective, ast::InterpolationSampling::kInvalid, true},
Params{ast::InterpolationType::kPerspective, ast::InterpolationSampling::kCenter, true},
Params{ast::InterpolationType::kPerspective, ast::InterpolationSampling::kCentroid, true},
Params{ast::InterpolationType::kPerspective, ast::InterpolationSampling::kSample, true},
Params{ast::InterpolationType::kLinear, ast::InterpolationSampling::kNone, true},
Params{ast::InterpolationType::kLinear, ast::InterpolationSampling::kInvalid, true},
Params{ast::InterpolationType::kLinear, ast::InterpolationSampling::kCenter, true},
Params{ast::InterpolationType::kLinear, ast::InterpolationSampling::kCentroid, true},
Params{ast::InterpolationType::kLinear, ast::InterpolationSampling::kSample, true},
// flat interpolation must not have a sampling type
Params{ast::InterpolationType::kFlat, ast::InterpolationSampling::kNone, true},
Params{ast::InterpolationType::kFlat, ast::InterpolationSampling::kInvalid, true},
Params{ast::InterpolationType::kFlat, ast::InterpolationSampling::kCenter, false},
Params{ast::InterpolationType::kFlat, ast::InterpolationSampling::kCentroid, false},
Params{ast::InterpolationType::kFlat, ast::InterpolationSampling::kSample, false}));
@ -1443,7 +1443,7 @@ TEST_F(InterpolateTest, MissingLocationAttribute_Parameter) {
utils::Vector{
Builtin(ast::BuiltinValue::kPosition),
Interpolate(Source{{12, 34}}, ast::InterpolationType::kFlat,
ast::InterpolationSampling::kNone),
ast::InterpolationSampling::kInvalid),
}),
},
ty.void_(), utils::Empty,
@ -1467,7 +1467,7 @@ TEST_F(InterpolateTest, MissingLocationAttribute_ReturnType) {
utils::Vector{
Builtin(ast::BuiltinValue::kPosition),
Interpolate(Source{{12, 34}}, ast::InterpolationType::kFlat,
ast::InterpolationSampling::kNone),
ast::InterpolationSampling::kInvalid),
});
EXPECT_FALSE(r()->Resolve());
@ -1480,7 +1480,7 @@ TEST_F(InterpolateTest, MissingLocationAttribute_Struct) {
utils::Vector{
Member("a", ty.f32(),
utils::Vector{Interpolate(Source{{12, 34}}, ast::InterpolationType::kFlat,
ast::InterpolationSampling::kNone)}),
ast::InterpolationSampling::kInvalid)}),
});
EXPECT_FALSE(r()->Resolve());

View File

@ -1026,7 +1026,7 @@ bool Validator::InterpolateAttribute(const ast::InterpolateAttribute* attr,
}
if (attr->type == ast::InterpolationType::kFlat &&
attr->sampling != ast::InterpolationSampling::kNone) {
attr->sampling != ast::InterpolationSampling::kInvalid) {
AddError("flat interpolation attribute must not have a sampling parameter", attr->source);
return false;
}

View File

@ -223,7 +223,7 @@ struct CanonicalizeEntryPointIO::State {
(ast::HasAttribute<ast::LocationAttribute>(attributes) ||
cfg.shader_style == ShaderStyle::kSpirv)) {
attributes.Push(ctx.dst->Interpolate(ast::InterpolationType::kFlat,
ast::InterpolationSampling::kNone));
ast::InterpolationSampling::kInvalid));
}
// Disable validation for use of the `input` address space.
@ -292,7 +292,7 @@ struct CanonicalizeEntryPointIO::State {
ast::HasAttribute<ast::LocationAttribute>(attributes) &&
!ast::HasAttribute<ast::InterpolateAttribute>(attributes)) {
attributes.Push(ctx.dst->Interpolate(ast::InterpolationType::kFlat,
ast::InterpolationSampling::kNone));
ast::InterpolationSampling::kInvalid));
}
// In GLSL, if it's a builtin, override the name with the

View File

@ -2049,6 +2049,7 @@ void GeneratorImpl::EmitInterpolationQualifiers(
switch (interpolate->type) {
case ast::InterpolationType::kPerspective:
case ast::InterpolationType::kLinear:
case ast::InterpolationType::kInvalid:
break;
case ast::InterpolationType::kFlat:
out << "flat ";
@ -2060,7 +2061,7 @@ void GeneratorImpl::EmitInterpolationQualifiers(
break;
case ast::InterpolationSampling::kSample:
case ast::InterpolationSampling::kCenter:
case ast::InterpolationSampling::kNone:
case ast::InterpolationSampling::kInvalid:
break;
}
}

View File

@ -3010,6 +3010,8 @@ std::string GeneratorImpl::interpolation_to_modifiers(ast::InterpolationType typ
case ast::InterpolationType::kFlat:
modifiers += "nointerpolation ";
break;
case ast::InterpolationType::kInvalid:
break;
}
switch (sampling) {
case ast::InterpolationSampling::kCentroid:
@ -3019,7 +3021,7 @@ std::string GeneratorImpl::interpolation_to_modifiers(ast::InterpolationType typ
modifiers += "sample ";
break;
case ast::InterpolationSampling::kCenter:
case ast::InterpolationSampling::kNone:
case ast::InterpolationSampling::kInvalid:
break;
}
return modifiers;

View File

@ -1947,7 +1947,7 @@ std::string GeneratorImpl::interpolation_to_attribute(ast::InterpolationType typ
case ast::InterpolationSampling::kSample:
attr = "sample_";
break;
case ast::InterpolationSampling::kNone:
case ast::InterpolationSampling::kInvalid:
break;
}
switch (type) {
@ -1960,6 +1960,8 @@ std::string GeneratorImpl::interpolation_to_attribute(ast::InterpolationType typ
case ast::InterpolationType::kFlat:
attr += "flat";
break;
case ast::InterpolationType::kInvalid:
break;
}
return attr;
}

View File

@ -4088,6 +4088,7 @@ void Builder::AddInterpolationDecorations(uint32_t id,
push_annot(spv::Op::OpDecorate, {Operand(id), U32Operand(SpvDecorationFlat)});
break;
case ast::InterpolationType::kPerspective:
case ast::InterpolationType::kInvalid:
break;
}
switch (sampling) {
@ -4099,7 +4100,7 @@ void Builder::AddInterpolationDecorations(uint32_t id,
push_annot(spv::Op::OpDecorate, {Operand(id), U32Operand(SpvDecorationSample)});
break;
case ast::InterpolationSampling::kCenter:
case ast::InterpolationSampling::kNone:
case ast::InterpolationSampling::kInvalid:
break;
}
}

View File

@ -769,7 +769,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
},
[&](const ast::InterpolateAttribute* interpolate) {
out << "interpolate(" << interpolate->type;
if (interpolate->sampling != ast::InterpolationSampling::kNone) {
if (interpolate->sampling != ast::InterpolationSampling::kInvalid) {
out << ", " << interpolate->sampling;
}
out << ")";