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

View File

@ -0,0 +1,11 @@
[[stage(fragment)]]
fn main(
[[location(0)]] none : f32,
[[location(1), interpolate(flat)]] flat : f32,
[[location(2), interpolate(perspective, center)]] perspective_center : f32,
[[location(3), interpolate(perspective, centroid)]] perspective_centroid : f32,
[[location(4), interpolate(perspective, sample)]] perspective_sample : f32,
[[location(5), interpolate(linear, center)]] linear_center : f32,
[[location(6), interpolate(linear, centroid)]] linear_centroid : f32,
[[location(7), interpolate(linear, sample)]] linear_sample : f32) {
}

View File

@ -0,0 +1,10 @@
SKIP: FAILED
../../src/writer/hlsl/generator_impl.cc:2862 internal compiler error: TINT_UNIMPLEMENTED interpolate decoration
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
* *
* Please help us fix this issue by submitting a bug report at *
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************

View File

@ -0,0 +1,10 @@
SKIP: FAILED
../../src/writer/msl/generator_impl.cc:1782 internal compiler error: TINT_UNIMPLEMENTED interpolate decoration
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
* *
* Please help us fix this issue by submitting a bug report at *
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************

View File

@ -0,0 +1,24 @@
SKIP: FAILED
[[location(0), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol : f32;
[[location(1), interpolate(flat), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_1 : f32;
[[location(2), interpolate(perspective, center), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_2 : f32;
[[location(3), interpolate(perspective, centroid), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_3 : f32;
[[location(4), interpolate(perspective, sample), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_4 : f32;
[[location(5), interpolate(linear, center), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_5 : f32;
[[location(6), interpolate(linear, centroid), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_6 : f32;
[[location(7), interpolate(linear, sample), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_7 : f32;
[[stage(fragment)]]
fn main() {
}
Failed to generate: unknown decoration

View File

@ -0,0 +1,3 @@
[[stage(fragment)]]
fn main([[location(0)]] none : f32, [[location(1), interpolate(flat)]] flat : f32, [[location(2), interpolate(perspective, center)]] perspective_center : f32, [[location(3), interpolate(perspective, centroid)]] perspective_centroid : f32, [[location(4), interpolate(perspective, sample)]] perspective_sample : f32, [[location(5), interpolate(linear, center)]] linear_center : f32, [[location(6), interpolate(linear, centroid)]] linear_centroid : f32, [[location(7), interpolate(linear, sample)]] linear_sample : f32) {
}

View File

@ -0,0 +1,14 @@
struct In {
[[location(0)]] none : f32;
[[location(1), interpolate(flat)]] flat : f32;
[[location(2), interpolate(perspective, center)]] perspective_center : f32;
[[location(3), interpolate(perspective, centroid)]] perspective_centroid : f32;
[[location(4), interpolate(perspective, sample)]] perspective_sample : f32;
[[location(5), interpolate(linear, center)]] linear_center : f32;
[[location(6), interpolate(linear, centroid)]] linear_centroid : f32;
[[location(7), interpolate(linear, sample)]] linear_sample : f32;
};
[[stage(fragment)]]
fn main(in : In) {
}

View File

@ -0,0 +1,10 @@
SKIP: FAILED
../../src/writer/hlsl/generator_impl.cc:2862 internal compiler error: TINT_UNIMPLEMENTED interpolate decoration
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
* *
* Please help us fix this issue by submitting a bug report at *
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************

View File

@ -0,0 +1,10 @@
SKIP: FAILED
../../src/writer/msl/generator_impl.cc:1782 internal compiler error: TINT_UNIMPLEMENTED interpolate decoration
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
* *
* Please help us fix this issue by submitting a bug report at *
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************

View File

@ -0,0 +1,35 @@
SKIP: FAILED
struct In {
none : f32;
flat : f32;
perspective_center : f32;
perspective_centroid : f32;
perspective_sample : f32;
linear_center : f32;
linear_centroid : f32;
linear_sample : f32;
};
[[location(0), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol : f32;
[[location(1), interpolate(flat), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_1 : f32;
[[location(2), interpolate(perspective, center), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_2 : f32;
[[location(3), interpolate(perspective, centroid), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_3 : f32;
[[location(4), interpolate(perspective, sample), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_4 : f32;
[[location(5), interpolate(linear, center), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_5 : f32;
[[location(6), interpolate(linear, centroid), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_6 : f32;
[[location(7), interpolate(linear, sample), internal(disable_validation__ignore_storage_class)]] var<in> tint_symbol_7 : f32;
[[stage(fragment)]]
fn main() {
}
Failed to generate: unknown decoration

View File

@ -0,0 +1,22 @@
struct In {
[[location(0)]]
none : f32;
[[location(1), interpolate(flat)]]
flat : f32;
[[location(2), interpolate(perspective, center)]]
perspective_center : f32;
[[location(3), interpolate(perspective, centroid)]]
perspective_centroid : f32;
[[location(4), interpolate(perspective, sample)]]
perspective_sample : f32;
[[location(5), interpolate(linear, center)]]
linear_center : f32;
[[location(6), interpolate(linear, centroid)]]
linear_centroid : f32;
[[location(7), interpolate(linear, sample)]]
linear_sample : f32;
};
[[stage(fragment)]]
fn main(in : In) {
}

View File

@ -0,0 +1,16 @@
struct Out {
[[builtin(position)]] pos : vec4<f32>;
[[location(0)]] none : f32;
[[location(1), interpolate(flat)]] flat : f32;
[[location(2), interpolate(perspective, center)]] perspective_center : f32;
[[location(3), interpolate(perspective, centroid)]] perspective_centroid : f32;
[[location(4), interpolate(perspective, sample)]] perspective_sample : f32;
[[location(5), interpolate(linear, center)]] linear_center : f32;
[[location(6), interpolate(linear, centroid)]] linear_centroid : f32;
[[location(7), interpolate(linear, sample)]] linear_sample : f32;
};
[[stage(vertex)]]
fn main() -> Out {
return Out();
}

View File

@ -0,0 +1,10 @@
SKIP: FAILED
../../src/writer/hlsl/generator_impl.cc:2862 internal compiler error: TINT_UNIMPLEMENTED interpolate decoration
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
* *
* Please help us fix this issue by submitting a bug report at *
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************

View File

@ -0,0 +1,10 @@
SKIP: FAILED
../../src/writer/msl/generator_impl.cc:1782 internal compiler error: TINT_UNIMPLEMENTED interpolate decoration
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
* *
* Please help us fix this issue by submitting a bug report at *
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************

View File

@ -0,0 +1,55 @@
SKIP: FAILED
[[builtin(pointsize), internal(disable_validation__ignore_storage_class)]] var<out> tint_pointsize : f32;
struct Out {
pos : vec4<f32>;
none : f32;
flat : f32;
perspective_center : f32;
perspective_centroid : f32;
perspective_sample : f32;
linear_center : f32;
linear_centroid : f32;
linear_sample : f32;
};
[[builtin(position), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_1 : vec4<f32>;
[[location(0), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_2 : f32;
[[location(1), interpolate(flat), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_3 : f32;
[[location(2), interpolate(perspective, center), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_4 : f32;
[[location(3), interpolate(perspective, centroid), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_5 : f32;
[[location(4), interpolate(perspective, sample), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_6 : f32;
[[location(5), interpolate(linear, center), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_7 : f32;
[[location(6), interpolate(linear, centroid), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_8 : f32;
[[location(7), interpolate(linear, sample), internal(disable_validation__ignore_storage_class)]] var<out> tint_symbol_9 : f32;
fn tint_symbol_10(tint_symbol : Out) {
tint_symbol_1 = tint_symbol.pos;
tint_symbol_2 = tint_symbol.none;
tint_symbol_3 = tint_symbol.flat;
tint_symbol_4 = tint_symbol.perspective_center;
tint_symbol_5 = tint_symbol.perspective_centroid;
tint_symbol_6 = tint_symbol.perspective_sample;
tint_symbol_7 = tint_symbol.linear_center;
tint_symbol_8 = tint_symbol.linear_centroid;
tint_symbol_9 = tint_symbol.linear_sample;
}
[[stage(vertex)]]
fn main() {
tint_pointsize = 1.0;
tint_symbol_10(Out());
return;
}
Failed to generate: unknown decoration

View File

@ -0,0 +1,25 @@
struct Out {
[[builtin(position)]]
pos : vec4<f32>;
[[location(0)]]
none : f32;
[[location(1), interpolate(flat)]]
flat : f32;
[[location(2), interpolate(perspective, center)]]
perspective_center : f32;
[[location(3), interpolate(perspective, centroid)]]
perspective_centroid : f32;
[[location(4), interpolate(perspective, sample)]]
perspective_sample : f32;
[[location(5), interpolate(linear, center)]]
linear_center : f32;
[[location(6), interpolate(linear, centroid)]]
linear_centroid : f32;
[[location(7), interpolate(linear, sample)]]
linear_sample : f32;
};
[[stage(vertex)]]
fn main() -> Out {
return Out();
}