diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 496be2d6fa..0c0c474b02 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -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()) { + TINT_UNIMPLEMENTED(Writer, diagnostics_) << "interpolate decoration"; } } diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index c1c73b239e..271da3b927 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -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()) { + TINT_UNIMPLEMENTED(Writer, diagnostics_) << "interpolate decoration"; } } diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 82875c408f..42785a827b 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -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()) { out_ << "builtin(" << builtin->value() << ")"; + } else if (auto* interpolate = deco->As()) { + out_ << "interpolate(" << interpolate->type(); + if (interpolate->sampling() != ast::InterpolationSampling::kNone) { + out_ << ", " << interpolate->sampling(); + } + out_ << ")"; } else if (auto* override_deco = deco->As()) { out_ << "override"; if (override_deco->HasValue()) { diff --git a/test/shader_io/interpolate_input_parameters.wgsl b/test/shader_io/interpolate_input_parameters.wgsl new file mode 100644 index 0000000000..64556cd434 --- /dev/null +++ b/test/shader_io/interpolate_input_parameters.wgsl @@ -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) { +} diff --git a/test/shader_io/interpolate_input_parameters.wgsl.expected.hlsl b/test/shader_io/interpolate_input_parameters.wgsl.expected.hlsl new file mode 100644 index 0000000000..3cd1e7f452 --- /dev/null +++ b/test/shader_io/interpolate_input_parameters.wgsl.expected.hlsl @@ -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. * +******************************************************************** + diff --git a/test/shader_io/interpolate_input_parameters.wgsl.expected.msl b/test/shader_io/interpolate_input_parameters.wgsl.expected.msl new file mode 100644 index 0000000000..41cb1faa35 --- /dev/null +++ b/test/shader_io/interpolate_input_parameters.wgsl.expected.msl @@ -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. * +******************************************************************** + diff --git a/test/shader_io/interpolate_input_parameters.wgsl.expected.spvasm b/test/shader_io/interpolate_input_parameters.wgsl.expected.spvasm new file mode 100644 index 0000000000..ca6d27ff2c --- /dev/null +++ b/test/shader_io/interpolate_input_parameters.wgsl.expected.spvasm @@ -0,0 +1,24 @@ +SKIP: FAILED + + +[[location(0), internal(disable_validation__ignore_storage_class)]] var tint_symbol : f32; + +[[location(1), interpolate(flat), internal(disable_validation__ignore_storage_class)]] var tint_symbol_1 : f32; + +[[location(2), interpolate(perspective, center), internal(disable_validation__ignore_storage_class)]] var tint_symbol_2 : f32; + +[[location(3), interpolate(perspective, centroid), internal(disable_validation__ignore_storage_class)]] var tint_symbol_3 : f32; + +[[location(4), interpolate(perspective, sample), internal(disable_validation__ignore_storage_class)]] var tint_symbol_4 : f32; + +[[location(5), interpolate(linear, center), internal(disable_validation__ignore_storage_class)]] var tint_symbol_5 : f32; + +[[location(6), interpolate(linear, centroid), internal(disable_validation__ignore_storage_class)]] var tint_symbol_6 : f32; + +[[location(7), interpolate(linear, sample), internal(disable_validation__ignore_storage_class)]] var tint_symbol_7 : f32; + +[[stage(fragment)]] +fn main() { +} + +Failed to generate: unknown decoration diff --git a/test/shader_io/interpolate_input_parameters.wgsl.expected.wgsl b/test/shader_io/interpolate_input_parameters.wgsl.expected.wgsl new file mode 100644 index 0000000000..3488ca7511 --- /dev/null +++ b/test/shader_io/interpolate_input_parameters.wgsl.expected.wgsl @@ -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) { +} diff --git a/test/shader_io/interpolate_input_struct.wgsl b/test/shader_io/interpolate_input_struct.wgsl new file mode 100644 index 0000000000..0299250fc3 --- /dev/null +++ b/test/shader_io/interpolate_input_struct.wgsl @@ -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) { +} diff --git a/test/shader_io/interpolate_input_struct.wgsl.expected.hlsl b/test/shader_io/interpolate_input_struct.wgsl.expected.hlsl new file mode 100644 index 0000000000..3cd1e7f452 --- /dev/null +++ b/test/shader_io/interpolate_input_struct.wgsl.expected.hlsl @@ -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. * +******************************************************************** + diff --git a/test/shader_io/interpolate_input_struct.wgsl.expected.msl b/test/shader_io/interpolate_input_struct.wgsl.expected.msl new file mode 100644 index 0000000000..41cb1faa35 --- /dev/null +++ b/test/shader_io/interpolate_input_struct.wgsl.expected.msl @@ -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. * +******************************************************************** + diff --git a/test/shader_io/interpolate_input_struct.wgsl.expected.spvasm b/test/shader_io/interpolate_input_struct.wgsl.expected.spvasm new file mode 100644 index 0000000000..619801a5a4 --- /dev/null +++ b/test/shader_io/interpolate_input_struct.wgsl.expected.spvasm @@ -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 tint_symbol : f32; + +[[location(1), interpolate(flat), internal(disable_validation__ignore_storage_class)]] var tint_symbol_1 : f32; + +[[location(2), interpolate(perspective, center), internal(disable_validation__ignore_storage_class)]] var tint_symbol_2 : f32; + +[[location(3), interpolate(perspective, centroid), internal(disable_validation__ignore_storage_class)]] var tint_symbol_3 : f32; + +[[location(4), interpolate(perspective, sample), internal(disable_validation__ignore_storage_class)]] var tint_symbol_4 : f32; + +[[location(5), interpolate(linear, center), internal(disable_validation__ignore_storage_class)]] var tint_symbol_5 : f32; + +[[location(6), interpolate(linear, centroid), internal(disable_validation__ignore_storage_class)]] var tint_symbol_6 : f32; + +[[location(7), interpolate(linear, sample), internal(disable_validation__ignore_storage_class)]] var tint_symbol_7 : f32; + +[[stage(fragment)]] +fn main() { +} + +Failed to generate: unknown decoration diff --git a/test/shader_io/interpolate_input_struct.wgsl.expected.wgsl b/test/shader_io/interpolate_input_struct.wgsl.expected.wgsl new file mode 100644 index 0000000000..b90c09b6c6 --- /dev/null +++ b/test/shader_io/interpolate_input_struct.wgsl.expected.wgsl @@ -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) { +} diff --git a/test/shader_io/interpolate_return_struct.wgsl b/test/shader_io/interpolate_return_struct.wgsl new file mode 100644 index 0000000000..9d24e6159e --- /dev/null +++ b/test/shader_io/interpolate_return_struct.wgsl @@ -0,0 +1,16 @@ +struct Out { + [[builtin(position)]] pos : vec4; + [[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(); +} diff --git a/test/shader_io/interpolate_return_struct.wgsl.expected.hlsl b/test/shader_io/interpolate_return_struct.wgsl.expected.hlsl new file mode 100644 index 0000000000..3cd1e7f452 --- /dev/null +++ b/test/shader_io/interpolate_return_struct.wgsl.expected.hlsl @@ -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. * +******************************************************************** + diff --git a/test/shader_io/interpolate_return_struct.wgsl.expected.msl b/test/shader_io/interpolate_return_struct.wgsl.expected.msl new file mode 100644 index 0000000000..41cb1faa35 --- /dev/null +++ b/test/shader_io/interpolate_return_struct.wgsl.expected.msl @@ -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. * +******************************************************************** + diff --git a/test/shader_io/interpolate_return_struct.wgsl.expected.spvasm b/test/shader_io/interpolate_return_struct.wgsl.expected.spvasm new file mode 100644 index 0000000000..fb6b3c6d4e --- /dev/null +++ b/test/shader_io/interpolate_return_struct.wgsl.expected.spvasm @@ -0,0 +1,55 @@ +SKIP: FAILED + + +[[builtin(pointsize), internal(disable_validation__ignore_storage_class)]] var tint_pointsize : f32; + +struct Out { + pos : vec4; + 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 tint_symbol_1 : vec4; + +[[location(0), internal(disable_validation__ignore_storage_class)]] var tint_symbol_2 : f32; + +[[location(1), interpolate(flat), internal(disable_validation__ignore_storage_class)]] var tint_symbol_3 : f32; + +[[location(2), interpolate(perspective, center), internal(disable_validation__ignore_storage_class)]] var tint_symbol_4 : f32; + +[[location(3), interpolate(perspective, centroid), internal(disable_validation__ignore_storage_class)]] var tint_symbol_5 : f32; + +[[location(4), interpolate(perspective, sample), internal(disable_validation__ignore_storage_class)]] var tint_symbol_6 : f32; + +[[location(5), interpolate(linear, center), internal(disable_validation__ignore_storage_class)]] var tint_symbol_7 : f32; + +[[location(6), interpolate(linear, centroid), internal(disable_validation__ignore_storage_class)]] var tint_symbol_8 : f32; + +[[location(7), interpolate(linear, sample), internal(disable_validation__ignore_storage_class)]] var 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 diff --git a/test/shader_io/interpolate_return_struct.wgsl.expected.wgsl b/test/shader_io/interpolate_return_struct.wgsl.expected.wgsl new file mode 100644 index 0000000000..fad2030640 --- /dev/null +++ b/test/shader_io/interpolate_return_struct.wgsl.expected.wgsl @@ -0,0 +1,25 @@ +struct Out { + [[builtin(position)]] + pos : vec4; + [[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(); +}