writer/msl: Implement interpolate attributes
Bug: tint:746 Change-Id: Ia96da94b948c0e2c6d99452d5e152113e2af1264 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56245 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:
parent
6a25bf944e
commit
f8e0b7dbf1
|
@ -1142,6 +1142,37 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const {
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string GeneratorImpl::interpolation_to_attribute(
|
||||
ast::InterpolationType type,
|
||||
ast::InterpolationSampling sampling) const {
|
||||
std::string attr;
|
||||
switch (sampling) {
|
||||
case ast::InterpolationSampling::kCenter:
|
||||
attr = "center_";
|
||||
break;
|
||||
case ast::InterpolationSampling::kCentroid:
|
||||
attr = "centroid_";
|
||||
break;
|
||||
case ast::InterpolationSampling::kSample:
|
||||
attr = "sample_";
|
||||
break;
|
||||
case ast::InterpolationSampling::kNone:
|
||||
break;
|
||||
}
|
||||
switch (type) {
|
||||
case ast::InterpolationType::kPerspective:
|
||||
attr += "perspective";
|
||||
break;
|
||||
case ast::InterpolationType::kLinear:
|
||||
attr += "no_perspective";
|
||||
break;
|
||||
case ast::InterpolationType::kFlat:
|
||||
attr += "flat";
|
||||
break;
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitEntryPointFunction(ast::Function* func) {
|
||||
auto* func_sem = program_->Sem().Get(func);
|
||||
|
||||
|
@ -1784,8 +1815,15 @@ 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";
|
||||
} else if (auto* interpolate = deco->As<ast::InterpolateDecoration>()) {
|
||||
auto attr = interpolation_to_attribute(interpolate->type(),
|
||||
interpolate->sampling());
|
||||
if (attr.empty()) {
|
||||
diagnostics_.add_error(diag::System::Writer,
|
||||
"unknown interpolation attribute");
|
||||
return false;
|
||||
}
|
||||
out << " [[" << attr << "]]";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "src/ast/continue_statement.h"
|
||||
#include "src/ast/discard_statement.h"
|
||||
#include "src/ast/if_statement.h"
|
||||
#include "src/ast/interpolate_decoration.h"
|
||||
#include "src/ast/loop_statement.h"
|
||||
#include "src/ast/member_accessor_expression.h"
|
||||
#include "src/ast/return_statement.h"
|
||||
|
@ -253,6 +254,14 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @returns the string name of the builtin or blank on error
|
||||
std::string builtin_to_attribute(ast::Builtin builtin) const;
|
||||
|
||||
/// Converts interpolation attributes to an MSL attribute
|
||||
/// @param type the interpolation type
|
||||
/// @param sampling the interpolation sampling
|
||||
/// @returns the string name of the attribute or blank on error
|
||||
std::string interpolation_to_attribute(
|
||||
ast::InterpolationType type,
|
||||
ast::InterpolationSampling sampling) const;
|
||||
|
||||
private:
|
||||
/// @returns the resolved type of the ast::Expression `expr`
|
||||
/// @param expr the expression
|
||||
|
|
|
@ -1,10 +1,26 @@
|
|||
SKIP: FAILED
|
||||
#include <metal_stdlib>
|
||||
|
||||
../../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. *
|
||||
********************************************************************
|
||||
using namespace metal;
|
||||
struct tint_symbol_2 {
|
||||
float none [[user(locn0)]];
|
||||
float flat [[user(locn1)]] [[flat]];
|
||||
float perspective_center [[user(locn2)]] [[center_perspective]];
|
||||
float perspective_centroid [[user(locn3)]] [[centroid_perspective]];
|
||||
float perspective_sample [[user(locn4)]] [[sample_perspective]];
|
||||
float linear_center [[user(locn5)]] [[center_no_perspective]];
|
||||
float linear_centroid [[user(locn6)]] [[centroid_no_perspective]];
|
||||
float linear_sample [[user(locn7)]] [[sample_no_perspective]];
|
||||
};
|
||||
|
||||
fragment void tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) {
|
||||
float const none = tint_symbol_1.none;
|
||||
float const flat = tint_symbol_1.flat;
|
||||
float const perspective_center = tint_symbol_1.perspective_center;
|
||||
float const perspective_centroid = tint_symbol_1.perspective_centroid;
|
||||
float const perspective_sample = tint_symbol_1.perspective_sample;
|
||||
float const linear_center = tint_symbol_1.linear_center;
|
||||
float const linear_centroid = tint_symbol_1.linear_centroid;
|
||||
float const linear_sample = tint_symbol_1.linear_sample;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,29 @@
|
|||
SKIP: FAILED
|
||||
#include <metal_stdlib>
|
||||
|
||||
../../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. *
|
||||
********************************************************************
|
||||
using namespace metal;
|
||||
struct In {
|
||||
float none;
|
||||
float flat;
|
||||
float perspective_center;
|
||||
float perspective_centroid;
|
||||
float perspective_sample;
|
||||
float linear_center;
|
||||
float linear_centroid;
|
||||
float linear_sample;
|
||||
};
|
||||
struct tint_symbol_2 {
|
||||
float none [[user(locn0)]];
|
||||
float flat [[user(locn1)]] [[flat]];
|
||||
float perspective_center [[user(locn2)]] [[center_perspective]];
|
||||
float perspective_centroid [[user(locn3)]] [[centroid_perspective]];
|
||||
float perspective_sample [[user(locn4)]] [[sample_perspective]];
|
||||
float linear_center [[user(locn5)]] [[center_no_perspective]];
|
||||
float linear_centroid [[user(locn6)]] [[centroid_no_perspective]];
|
||||
float linear_sample [[user(locn7)]] [[sample_no_perspective]];
|
||||
};
|
||||
|
||||
fragment void tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) {
|
||||
In const in = {.none=tint_symbol_1.none, .flat=tint_symbol_1.flat, .perspective_center=tint_symbol_1.perspective_center, .perspective_centroid=tint_symbol_1.perspective_centroid, .perspective_sample=tint_symbol_1.perspective_sample, .linear_center=tint_symbol_1.linear_center, .linear_centroid=tint_symbol_1.linear_centroid, .linear_sample=tint_symbol_1.linear_sample};
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,32 @@
|
|||
SKIP: FAILED
|
||||
#include <metal_stdlib>
|
||||
|
||||
../../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. *
|
||||
********************************************************************
|
||||
using namespace metal;
|
||||
struct Out {
|
||||
float4 pos;
|
||||
float none;
|
||||
float flat;
|
||||
float perspective_center;
|
||||
float perspective_centroid;
|
||||
float perspective_sample;
|
||||
float linear_center;
|
||||
float linear_centroid;
|
||||
float linear_sample;
|
||||
};
|
||||
struct tint_symbol_1 {
|
||||
float none [[user(locn0)]];
|
||||
float flat [[user(locn1)]] [[flat]];
|
||||
float perspective_center [[user(locn2)]] [[center_perspective]];
|
||||
float perspective_centroid [[user(locn3)]] [[centroid_perspective]];
|
||||
float perspective_sample [[user(locn4)]] [[sample_perspective]];
|
||||
float linear_center [[user(locn5)]] [[center_no_perspective]];
|
||||
float linear_centroid [[user(locn6)]] [[centroid_no_perspective]];
|
||||
float linear_sample [[user(locn7)]] [[sample_no_perspective]];
|
||||
float4 pos [[position]];
|
||||
};
|
||||
|
||||
vertex tint_symbol_1 tint_symbol() {
|
||||
Out const tint_symbol_2 = {};
|
||||
tint_symbol_1 const tint_symbol_3 = {.none=tint_symbol_2.none, .flat=tint_symbol_2.flat, .perspective_center=tint_symbol_2.perspective_center, .perspective_centroid=tint_symbol_2.perspective_centroid, .perspective_sample=tint_symbol_2.perspective_sample, .linear_center=tint_symbol_2.linear_center, .linear_centroid=tint_symbol_2.linear_centroid, .linear_sample=tint_symbol_2.linear_sample, .pos=tint_symbol_2.pos};
|
||||
return tint_symbol_3;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue