writer/hlsl: Implement invariant attribute

Bug: tint:772
Change-Id: I228cd01b1e6b93ad5a5f4eacd0b495b3bcb3508f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57645
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
This commit is contained in:
James Price 2021-07-13 12:29:26 +00:00 committed by Tint LUCI CQ
parent af6fc5f5d9
commit 8d33b8593c
3 changed files with 23 additions and 18 deletions

View File

@ -3127,6 +3127,11 @@ bool GeneratorImpl::EmitStructType(const sem::Struct* str) {
}
pre += mod;
} else if (deco->Is<ast::InvariantDecoration>()) {
// Note: `precise` is not exactly the same as `invariant`, but is
// stricter and therefore provides the necessary guarantees.
// See discussion here: https://github.com/gpuweb/gpuweb/issues/893
pre += "precise ";
} else if (!deco->IsAnyOf<ast::StructMemberAlignDecoration,
ast::StructMemberSizeDecoration>()) {
TINT_ICE(Writer, diagnostics_)

View File

@ -1,10 +1,8 @@
SKIP: FAILED
../../src/writer/hlsl/generator_impl.cc:3056 internal compiler error: unhandled struct member attribute: invariant
********************************************************************
* 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. *
********************************************************************
struct tint_symbol {
precise float4 value : SV_Position;
};
tint_symbol main() {
const tint_symbol tint_symbol_1 = {float4(0.0f, 0.0f, 0.0f, 0.0f)};
return tint_symbol_1;
}

View File

@ -1,10 +1,12 @@
SKIP: FAILED
../../src/writer/hlsl/generator_impl.cc:3056 internal compiler error: unhandled struct member attribute: invariant
********************************************************************
* 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. *
********************************************************************
struct Out {
float4 pos;
};
struct tint_symbol {
precise float4 pos : SV_Position;
};
tint_symbol main() {
const Out tint_symbol_1 = (Out)0;
const tint_symbol tint_symbol_2 = {tint_symbol_1.pos};
return tint_symbol_2;
}