writer/wgsl: Implement interpolate attributes

Add E2E tests to cover all of the parameter combinations.

Mark the attribute as unimplemented in the other backends.

Bug: tint:746
Change-Id: I86881ff0b224fe93670db42473341ae185eeabdd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56244
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-06-28 23:04:43 +00:00
parent 03a7522276
commit 545f4e0f77
18 changed files with 278 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
#include "src/ast/call_statement.h"
#include "src/ast/fallthrough_statement.h"
#include "src/ast/internal_decoration.h"
#include "src/ast/interpolate_decoration.h"
#include "src/ast/override_decoration.h"
#include "src/ast/variable_decl_statement.h"
#include "src/sem/array.h"
@@ -2772,6 +2773,8 @@ bool GeneratorImpl::EmitStructType(const sem::Struct* str) {
return false;
}
out << " : " << attr;
} else if (deco->Is<ast::InterpolateDecoration>()) {
TINT_UNIMPLEMENTED(Writer, diagnostics_) << "interpolate decoration";
}
}

View File

@@ -25,6 +25,7 @@
#include "src/ast/disable_validation_decoration.h"
#include "src/ast/fallthrough_statement.h"
#include "src/ast/float_literal.h"
#include "src/ast/interpolate_decoration.h"
#include "src/ast/module.h"
#include "src/ast/override_decoration.h"
#include "src/ast/sint_literal.h"
@@ -1783,6 +1784,8 @@ bool GeneratorImpl::EmitStructType(const sem::Struct* str) {
TINT_ICE(Writer, diagnostics_)
<< "invalid use of location decoration";
}
} else if (deco->Is<ast::InterpolateDecoration>()) {
TINT_UNIMPLEMENTED(Writer, diagnostics_) << "interpolate decoration";
}
}

View File

@@ -30,6 +30,7 @@
#include "src/ast/float_literal.h"
#include "src/ast/i32.h"
#include "src/ast/internal_decoration.h"
#include "src/ast/interpolate_decoration.h"
#include "src/ast/matrix.h"
#include "src/ast/module.h"
#include "src/ast/multisampled_texture.h"
@@ -668,6 +669,12 @@ bool GeneratorImpl::EmitDecorations(const ast::DecorationList& decos) {
out_ << "location(" << location->value() << ")";
} else if (auto* builtin = deco->As<ast::BuiltinDecoration>()) {
out_ << "builtin(" << builtin->value() << ")";
} else if (auto* interpolate = deco->As<ast::InterpolateDecoration>()) {
out_ << "interpolate(" << interpolate->type();
if (interpolate->sampling() != ast::InterpolationSampling::kNone) {
out_ << ", " << interpolate->sampling();
}
out_ << ")";
} else if (auto* override_deco = deco->As<ast::OverrideDecoration>()) {
out_ << "override";
if (override_deco->HasValue()) {