wgsl: Replace [[decoration]] with @decoration
Deprecate the old syntax. Migrate everything to the new syntax. Bug: tint:1382 Change-Id: Ide12b2e927b17dc93b9714c7049090864cc568d3 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77260 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
parent
8f1d5224ee
commit
01e4b6fc18
|
@ -11,7 +11,8 @@ Obviously infinite loops (no condition, no break) are now a validation error.
|
|||
The following features have been deprecated and will be removed in M102:
|
||||
|
||||
* The `[[block]]` attribute has been deprecated. [tint:1324](https://crbug.com/tint/1324)
|
||||
* `elseif` has been replaced with `else if` [tint:1289](https://crbug.com/tint/1289)
|
||||
* Attributes now use the `@decoration` syntax instead of the `[[decoration]]` syntax. [tint:1382](https://crbug.com/tint/1382)
|
||||
* `elseif` has been replaced with `else if`. [tint:1289](https://crbug.com/tint/1289)
|
||||
|
||||
### New Features
|
||||
|
||||
|
|
|
@ -85,8 +85,8 @@ through the copying and optimize the result.
|
|||
Current translation, through SPIR-V, SPIR-V reader, WGSL writer:
|
||||
|
||||
```groovy
|
||||
[[location(0)]] var<out> frag_colour : vec4<f32>;
|
||||
[[location(0)]] var<in> the_colour : vec4<f32>;
|
||||
@location(0) var<out> frag_colour : vec4<f32>;
|
||||
@location(0) var<in> the_colour : vec4<f32>;
|
||||
|
||||
fn bar_() -> void {
|
||||
const x_14 : vec4<f32> = the_colour;
|
||||
|
@ -94,7 +94,7 @@ Current translation, through SPIR-V, SPIR-V reader, WGSL writer:
|
|||
return;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() -> void {
|
||||
bar_();
|
||||
return;
|
||||
|
@ -123,14 +123,14 @@ Proposed translation, through SPIR-V, SPIR-V reader, WGSL writer:
|
|||
|
||||
// Declare a structure type to collect the return values.
|
||||
struct main_result_type {
|
||||
[[location(0)]] frag_color : vec4<f32>;
|
||||
@location(0) frag_color : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main(
|
||||
|
||||
// 'in' variables are entry point parameters
|
||||
[[location(0)]] the_color_arg : vec4<f32>
|
||||
@location(0) the_color_arg : vec4<f32>
|
||||
|
||||
) -> main_result_type {
|
||||
|
||||
|
|
|
@ -188,4 +188,4 @@ static const <type> <name> = WGSL_SPEC_CONSTANT_<id>
|
|||
```
|
||||
|
||||
## MSL
|
||||
`[[function_constant(<id>)]]`
|
||||
`@function_constant(<id>)`
|
||||
|
|
|
@ -287,13 +287,12 @@ TEST(ReplaceIdentifierTest, NotApplicable5) {
|
|||
// Can't replace `a` with `b` since the latter has a wrong access mode
|
||||
// (`read` for uniform storage class).
|
||||
std::string shader = R"(
|
||||
[[block]]
|
||||
struct S {
|
||||
a: i32;
|
||||
};
|
||||
|
||||
var<private> a: S;
|
||||
[[group(1), binding(1)]] var<uniform> b: S;
|
||||
@group(1) @binding(1) var<uniform> b: S;
|
||||
fn f() {
|
||||
*&a = S(4);
|
||||
}
|
||||
|
@ -323,13 +322,12 @@ fn f() {
|
|||
TEST(ReplaceIdentifierTest, NotApplicable6) {
|
||||
// Can't replace `ptr_b` with `a` since the latter is not a pointer.
|
||||
std::string shader = R"(
|
||||
[[block]]
|
||||
struct S {
|
||||
a: i32;
|
||||
};
|
||||
|
||||
var<private> a: S;
|
||||
[[group(1), binding(1)]] var<uniform> b: S;
|
||||
@group(1) @binding(1) var<uniform> b: S;
|
||||
fn f() {
|
||||
let ptr_b = &b;
|
||||
*&a = *ptr_b;
|
||||
|
@ -360,14 +358,13 @@ TEST(ReplaceIdentifierTest, NotApplicable8) {
|
|||
// Can't replace `ptr_b` with `c` since the latter has a wrong access mode and
|
||||
// storage class.
|
||||
std::string shader = R"(
|
||||
[[block]]
|
||||
struct S {
|
||||
a: i32;
|
||||
};
|
||||
|
||||
var<private> a: S;
|
||||
[[group(1), binding(1)]] var<uniform> b: S;
|
||||
[[group(1), binding(2)]] var<storage, write> c: S;
|
||||
@group(1) @binding(1) var<uniform> b: S;
|
||||
@group(1) @binding(2) var<storage, write> c: S;
|
||||
fn f() {
|
||||
let ptr_b = &b;
|
||||
*&a = *ptr_b;
|
||||
|
@ -397,14 +394,13 @@ fn f() {
|
|||
TEST(ReplaceIdentifierTest, NotApplicable9) {
|
||||
// Can't replace `b` with `e` since the latter is not a reference.
|
||||
std::string shader = R"(
|
||||
[[block]]
|
||||
struct S {
|
||||
a: i32;
|
||||
};
|
||||
|
||||
var<private> a: S;
|
||||
let e = 3;
|
||||
[[group(1), binding(1)]] var<uniform> b: S;
|
||||
@group(1) @binding(1) var<uniform> b: S;
|
||||
fn f() {
|
||||
*&a = *&b;
|
||||
}
|
||||
|
@ -434,14 +430,13 @@ fn f() {
|
|||
TEST(ReplaceIdentifierTest, NotApplicable10) {
|
||||
// Can't replace `b` with `e` since the latter has a wrong access mode.
|
||||
std::string shader = R"(
|
||||
[[block]]
|
||||
struct S {
|
||||
a: i32;
|
||||
};
|
||||
|
||||
var<private> a: S;
|
||||
[[group(0), binding(0)]] var<storage, write> e: S;
|
||||
[[group(1), binding(1)]] var<uniform> b: S;
|
||||
@group(0) @binding(0) var<storage, write> e: S;
|
||||
@group(1) @binding(1) var<uniform> b: S;
|
||||
fn f() {
|
||||
*&a = *&b;
|
||||
}
|
||||
|
|
|
@ -198,16 +198,16 @@ TEST(GetIdentifierTest, GetIdentifierTest1) {
|
|||
R"(fn clamp_0acf8f() {
|
||||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>());
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();"
|
||||
return vec4<f32>();
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {"
|
||||
var<private> foo: f32 = 0.0;
|
||||
clamp_0acf8f();
|
||||
|
@ -219,13 +219,13 @@ TEST(GetIdentifierTest, GetIdentifierTest1) {
|
|||
std::vector<std::pair<size_t, size_t>> ground_truth = {
|
||||
std::make_pair(3, 12), std::make_pair(28, 3), std::make_pair(37, 4),
|
||||
std::make_pair(49, 5), std::make_pair(60, 3), std::make_pair(68, 4),
|
||||
std::make_pair(81, 4), std::make_pair(111, 5), std::make_pair(133, 2),
|
||||
std::make_pair(143, 4), std::make_pair(155, 7), std::make_pair(175, 4),
|
||||
std::make_pair(196, 12), std::make_pair(222, 6), std::make_pair(234, 3),
|
||||
std::make_pair(258, 5), std::make_pair(282, 2), std::make_pair(294, 4),
|
||||
std::make_pair(311, 12), std::make_pair(343, 5), std::make_pair(359, 14),
|
||||
std::make_pair(385, 2), std::make_pair(396, 4), std::make_pair(414, 3),
|
||||
std::make_pair(427, 3), std::make_pair(432, 3), std::make_pair(451, 12)};
|
||||
std::make_pair(81, 4), std::make_pair(110, 5), std::make_pair(130, 2),
|
||||
std::make_pair(140, 4), std::make_pair(151, 7), std::make_pair(169, 4),
|
||||
std::make_pair(190, 12), std::make_pair(216, 6), std::make_pair(228, 3),
|
||||
std::make_pair(251, 5), std::make_pair(273, 2), std::make_pair(285, 4),
|
||||
std::make_pair(302, 12), std::make_pair(333, 5), std::make_pair(349, 14),
|
||||
std::make_pair(373, 2), std::make_pair(384, 4), std::make_pair(402, 3),
|
||||
std::make_pair(415, 3), std::make_pair(420, 3), std::make_pair(439, 12)};
|
||||
|
||||
ASSERT_EQ(ground_truth, identifiers_pos);
|
||||
}
|
||||
|
@ -234,18 +234,18 @@ TEST(TestGetLiteralsValues, TestGetLiteralsValues1) {
|
|||
std::string wgsl_code =
|
||||
R"(fn clamp_0acf8f() {
|
||||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>());
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
}
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();
|
||||
var foo_1: i32 = 3;
|
||||
return vec4<f32>();
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
|
@ -277,17 +277,17 @@ TEST(InsertReturnTest, FindClosingBrace) {
|
|||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>());
|
||||
}
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();
|
||||
var foo_1: i32 = 3;
|
||||
return vec4<f32>();
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
|
@ -323,17 +323,17 @@ TEST(InsertReturnTest, FindClosingBraceFailing) {
|
|||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>());
|
||||
}
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();
|
||||
var foo_1: i32 = 3;
|
||||
return vec4<f32>();
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
|
@ -362,17 +362,17 @@ TEST(TestInsertReturn, TestInsertReturn1) {
|
|||
R"(fn clamp_0acf8f() {
|
||||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>());
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();
|
||||
var foo_1: i32 = 3;
|
||||
return vec4<f32>();
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
|
@ -395,17 +395,17 @@ TEST(TestInsertReturn, TestInsertReturn1) {
|
|||
R"(fn clamp_0acf8f() {
|
||||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>());return true;
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();
|
||||
var foo_1: i32 = 3;
|
||||
return vec4<f32>();
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
|
@ -422,23 +422,23 @@ TEST(TestInsertReturn, TestFunctionPositions) {
|
|||
R"(fn clamp_0acf8f() {
|
||||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>());
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();
|
||||
var foo_1: i32 = 3;
|
||||
return vec4<f32>();
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
clamp_0acf8f();
|
||||
}
|
||||
fn vert_main() -> [[builtin(position)]] vec4<f32> {
|
||||
fn vert_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f();
|
||||
var foo_1: i32 = 3;
|
||||
return vec4<f32>();
|
||||
|
@ -447,7 +447,7 @@ TEST(TestInsertReturn, TestFunctionPositions) {
|
|||
var foo_3 : i32 = -20;)";
|
||||
|
||||
std::vector<size_t> function_positions = GetFunctionBodyPositions(wgsl_code);
|
||||
std::vector<size_t> expected_positions = {193, 622};
|
||||
std::vector<size_t> expected_positions = {187, 607};
|
||||
ASSERT_EQ(expected_positions, function_positions);
|
||||
}
|
||||
|
||||
|
@ -456,23 +456,23 @@ TEST(TestInsertReturn, TestMissingSemicolon) {
|
|||
R"(fn clamp_0acf8f() {
|
||||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>())
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f()
|
||||
var foo_1: i32 = 3
|
||||
return vec4<f32>()
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
clamp_0acf8f();
|
||||
}
|
||||
fn vert_main() -> [[builtin(position)]] vec4<f32> {
|
||||
fn vert_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f()
|
||||
var foo_1: i32 = 3
|
||||
return vec4<f32>()
|
||||
|
@ -489,23 +489,23 @@ TEST(TestInsertReturn, TestMissingSemicolon) {
|
|||
R"(fn clamp_0acf8f() {
|
||||
var res: vec2<f32> = clamp(vec2<f32>(), vec2<f32>(), vec2<f32>())
|
||||
}
|
||||
[[stage(vertex)]]
|
||||
fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f()
|
||||
var foo_1: i32 = 3
|
||||
return vec4<f32>()
|
||||
}
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fragment_main() {
|
||||
clamp_0acf8f();
|
||||
}
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn compute_main() {
|
||||
var<private> foo: f32 = 0.0;
|
||||
var foo_2: i32 = 10;
|
||||
clamp_0acf8f();
|
||||
}
|
||||
fn vert_main() -> [[builtin(position)]] vec4<f32> {
|
||||
fn vert_main() -> @builtin(position) vec4<f32> {
|
||||
clamp_0acf8f()
|
||||
var foo_1: i32 = 3
|
||||
return vec4<f32>()
|
||||
|
|
|
@ -54,7 +54,7 @@ std::string Array::FriendlyName(const SymbolTable& symbols) const {
|
|||
std::ostringstream out;
|
||||
for (auto* deco : decorations) {
|
||||
if (auto* stride = deco->As<ast::StrideDecoration>()) {
|
||||
out << "[[stride(" << stride->stride << ")]] ";
|
||||
out << "@stride(" << stride->stride << ") ";
|
||||
}
|
||||
}
|
||||
out << "array<" << type->FriendlyName(symbols);
|
||||
|
|
|
@ -63,7 +63,7 @@ TEST_F(AstArrayTest, FriendlyName_WithStride) {
|
|||
auto* i32 = create<I32>();
|
||||
auto* arr =
|
||||
create<Array>(i32, Expr(5), DecorationList{create<StrideDecoration>(32)});
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "[[stride(32)]] array<i32, 5>");
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(32) array<i32, 5>");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -65,7 +65,7 @@ class DisableValidationDecoration
|
|||
~DisableValidationDecoration() override;
|
||||
|
||||
/// @return a short description of the internal decoration which will be
|
||||
/// displayed in WGSL as `[[internal(<name>)]]` (but is not parsable).
|
||||
/// displayed in WGSL as `@internal(<name>)` (but is not parsable).
|
||||
std::string InternalName() const override;
|
||||
|
||||
/// Performs a deep clone of this object using the CloneContext `ctx`.
|
||||
|
|
|
@ -35,7 +35,7 @@ class InternalDecoration : public Castable<InternalDecoration, Decoration> {
|
|||
~InternalDecoration() override;
|
||||
|
||||
/// @return a short description of the internal decoration which will be
|
||||
/// displayed in WGSL as `[[internal(<name>)]]` (but is not parsable).
|
||||
/// displayed in WGSL as `@internal(<name>)` (but is not parsable).
|
||||
virtual std::string InternalName() const = 0;
|
||||
|
||||
/// @returns the WGSL name for the decoration
|
||||
|
|
|
@ -28,13 +28,13 @@ TEST(ModuleCloneTest, Clone) {
|
|||
// See also fuzzers/tint_ast_clone_fuzzer.cc for further coverage of cloning.
|
||||
Source::File file("test.wgsl", R"([[block]]
|
||||
struct S0 {
|
||||
[[size(4)]]
|
||||
@size(4)
|
||||
m0 : u32;
|
||||
m1 : array<u32>;
|
||||
};
|
||||
|
||||
[[block]] struct S1 {
|
||||
[[size(4)]]
|
||||
@size(4)
|
||||
m0 : u32;
|
||||
m1 : array<u32, 6>;
|
||||
};
|
||||
|
@ -42,21 +42,21 @@ struct S0 {
|
|||
let c0 : i32 = 10;
|
||||
let c1 : bool = true;
|
||||
|
||||
type t0 = [[stride(16)]] array<vec4<f32>>;
|
||||
type t0 = @stride(16) array<vec4<f32>>;
|
||||
type t1 = array<vec4<f32>>;
|
||||
|
||||
var<private> g0 : u32 = 20u;
|
||||
var<private> g1 : f32 = 123.0;
|
||||
[[group(0), binding(0)]] var g2 : texture_2d<f32>;
|
||||
[[group(1), binding(0)]] var g3 : texture_depth_2d;
|
||||
[[group(2), binding(0)]] var g4 : texture_storage_2d<rg32float, write>;
|
||||
[[group(3), binding(0)]] var g5 : texture_depth_cube_array;
|
||||
[[group(4), binding(0)]] var g6 : texture_external;
|
||||
@group(0) @binding(0) var g2 : texture_2d<f32>;
|
||||
@group(1) @binding(0) var g3 : texture_depth_2d;
|
||||
@group(2) @binding(0) var g4 : texture_storage_2d<rg32float, write>;
|
||||
@group(3) @binding(0) var g5 : texture_depth_cube_array;
|
||||
@group(4) @binding(0) var g6 : texture_external;
|
||||
|
||||
var<private> g7 : vec3<f32>;
|
||||
[[group(0), binding(1)]] var<storage, write> g8 : S0;
|
||||
[[group(1), binding(1)]] var<storage, read> g9 : S0;
|
||||
[[group(2), binding(1)]] var<storage, read_write> g10 : S0;
|
||||
@group(0) @binding(1) var<storage, write> g8 : S0;
|
||||
@group(1) @binding(1) var<storage, read> g9 : S0;
|
||||
@group(2) @binding(1) var<storage, read_write> g10 : S0;
|
||||
|
||||
fn f0(p0 : bool) -> f32 {
|
||||
if (p0) {
|
||||
|
@ -101,7 +101,7 @@ fn f1(p0 : f32, p1 : i32) -> f32 {
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f1(1.0, 2);
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A struct member offset decoration
|
||||
/// @note The WGSL spec removed the `[[offset(n)]]` decoration for `[[size(n)]]`
|
||||
/// and `[[align(n)]]` in https://github.com/gpuweb/gpuweb/pull/1447. However
|
||||
/// @note The WGSL spec removed the `@offset(n)` decoration for `@size(n)`
|
||||
/// and `@align(n)` in https://github.com/gpuweb/gpuweb/pull/1447. However
|
||||
/// this decoration is kept because the SPIR-V reader has to deal with absolute
|
||||
/// offsets, and transforming these to size / align is complex and can be done
|
||||
/// in a number of ways. The Resolver is responsible for consuming the size and
|
||||
/// align decorations and transforming these into absolute offsets. It is
|
||||
/// trivial for the Resolver to handle `[[offset(n)]]` or `[[size(n)]]` /
|
||||
/// `[[align(n)]]` decorations, so this is what we do, keeping all the layout
|
||||
/// trivial for the Resolver to handle `@offset(n)` or `@size(n)` /
|
||||
/// `@align(n)` decorations, so this is what we do, keeping all the layout
|
||||
/// logic in one place.
|
||||
class StructMemberOffsetDecoration
|
||||
: public Castable<StructMemberOffsetDecoration, Decoration> {
|
||||
|
|
|
@ -2726,7 +2726,7 @@ TEST_F(InspectorGetExternalTextureResourceBindingsTest, Simple) {
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, None) {
|
||||
std::string shader = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
})";
|
||||
|
||||
|
@ -2739,12 +2739,12 @@ fn main() {
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, Simple) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(myTexture, mySampler, fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -2762,12 +2762,12 @@ fn main([[location(0)]] fragUV: vec2<f32>,
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, UnknownEntryPoint) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(myTexture, mySampler, fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -2778,12 +2778,12 @@ fn main([[location(0)]] fragUV: vec2<f32>,
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, MultipleCalls) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(myTexture, mySampler, fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -2799,16 +2799,16 @@ fn main([[location(0)]] fragUV: vec2<f32>,
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, BothIndirect) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
fn doSample(t: texture_2d<f32>, s: sampler, uv: vec2<f32>) -> vec4<f32> {
|
||||
return textureSample(t, s, uv);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return doSample(myTexture, mySampler, fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -2826,16 +2826,16 @@ fn main([[location(0)]] fragUV: vec2<f32>,
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, SamplerIndirect) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
fn doSample(s: sampler, uv: vec2<f32>) -> vec4<f32> {
|
||||
return textureSample(myTexture, s, uv);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return doSample(mySampler, fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -2853,16 +2853,16 @@ fn main([[location(0)]] fragUV: vec2<f32>,
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, TextureIndirect) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
fn doSample(t: texture_2d<f32>, uv: vec2<f32>) -> vec4<f32> {
|
||||
return textureSample(t, mySampler, uv);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return doSample(myTexture, fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -2880,16 +2880,16 @@ fn main([[location(0)]] fragUV: vec2<f32>,
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, NeitherIndirect) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
fn doSample(uv: vec2<f32>) -> vec4<f32> {
|
||||
return textureSample(myTexture, mySampler, uv);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return doSample(fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -2907,8 +2907,8 @@ fn main([[location(0)]] fragUV: vec2<f32>,
|
|||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, Complex) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
|
||||
fn doSample(t: texture_2d<f32>, s: sampler, uv: vec2<f32>) -> vec4<f32> {
|
||||
|
@ -2927,21 +2927,21 @@ fn Z(t: texture_2d<f32>, s: sampler, uv: vec2<f32>) -> vec4<f32> {
|
|||
return X(t, s, uv) + Y(t, s, uv);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn via_call([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn via_call(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return Z(myTexture, mySampler, fragUV) * fragPosition;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn via_ptr([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn via_ptr(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(myTexture, mySampler, fragUV) + fragPosition;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn direct([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn direct(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(myTexture, mySampler, fragUV) + fragPosition;
|
||||
})";
|
||||
|
||||
|
@ -3075,16 +3075,16 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, StructAlignment) {
|
|||
// ::GetSamplerTextureUses was called.
|
||||
TEST_F(InspectorRegressionTest, tint967) {
|
||||
std::string shader = R"(
|
||||
[[group(0), binding(1)]] var mySampler: sampler;
|
||||
[[group(0), binding(2)]] var myTexture: texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler: sampler;
|
||||
@group(0) @binding(2) var myTexture: texture_2d<f32>;
|
||||
|
||||
fn doSample(t: texture_2d<f32>, s: sampler, uv: vec2<f32>) -> vec4<f32> {
|
||||
return textureSample(t, s, uv);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragUV: vec2<f32>,
|
||||
[[location(1)]] fragPosition: vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragUV: vec2<f32>,
|
||||
@location(1) fragPosition: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return doSample(myTexture, mySampler, fragUV) * fragPosition;
|
||||
})";
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ fn x_100_1() {
|
|||
return;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn x_100() {
|
||||
x_100_1();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ fn x_100_1() {
|
|||
return;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn x_100() {
|
||||
x_100_1();
|
||||
}
|
||||
|
|
|
@ -858,7 +858,7 @@ fn main_1() {
|
|||
return;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
main_1();
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ OpExecutionMode %main OriginUpperLeft
|
|||
return;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
main_1();
|
||||
}
|
||||
|
@ -950,14 +950,14 @@ TEST_F(SpvParserMemoryTest, RemapStorageBuffer_TypesAndVarDeclarations) {
|
|||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
const auto module_str = test::ToString(p->program());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(type RTArr = [[stride(4)]] array<u32>;
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(type RTArr = @stride(4) array<u32>;
|
||||
|
||||
struct S {
|
||||
field0 : u32;
|
||||
field1 : RTArr;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> myvar : S;
|
||||
@group(0) @binding(0) var<storage, read_write> myvar : S;
|
||||
)"));
|
||||
}
|
||||
|
||||
|
|
|
@ -338,9 +338,8 @@ TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
|||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
auto ast_body = fe.ast_body();
|
||||
EXPECT_THAT(
|
||||
test::ToString(p->program(), ast_body),
|
||||
HasSubstr("var x_200 : array<u32, 2u> = array<u32, 2u>();"));
|
||||
EXPECT_THAT(test::ToString(p->program(), ast_body),
|
||||
HasSubstr("var x_200 : array<u32, 2u> = array<u32, 2u>();"));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserFunctionVarTest,
|
||||
|
@ -368,7 +367,7 @@ TEST_F(SpvParserFunctionVarTest,
|
|||
|
||||
auto ast_body = fe.ast_body();
|
||||
EXPECT_THAT(test::ToString(p->program(), ast_body),
|
||||
HasSubstr("var x_200 : Arr = [[stride(16)]] array<u32, 2u>();"));
|
||||
HasSubstr("var x_200 : Arr = @stride(16) array<u32, 2u>();"));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserFunctionVarTest, EmitFunctionVariables_StructInitializer) {
|
||||
|
|
|
@ -124,13 +124,13 @@ OpFunctionEnd)";
|
|||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
struct main_out {
|
||||
[[builtin(position)]]
|
||||
@builtin(position)
|
||||
x_2_1 : vec4<f32>;
|
||||
}
|
||||
)")) << program_ast;
|
||||
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main() -> main_out {
|
||||
)"));
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_Fragment) {
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
)"));
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_GLCompute) {
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
fn main() {
|
||||
)"));
|
||||
}
|
||||
|
@ -186,11 +186,11 @@ OpExecutionMode %main OriginUpperLeft
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn first_shader() {
|
||||
)"));
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn second_shader() {
|
||||
)"));
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ OpFunctionEnd)";
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(compute), workgroup_size(2, 4, 8)]]
|
||||
@stage(compute) @workgroup_size(2, 4, 8)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ OpFunctionEnd)";
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(compute), workgroup_size(3, 5, 7)]]
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ OpFunctionEnd)";
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(compute), workgroup_size(3, 5, 7)]]
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ OpFunctionEnd)";
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(compute), workgroup_size(3, 5, 7)]]
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ OpFunctionEnd)";
|
|||
Program program = p->program();
|
||||
const auto program_ast = test::ToString(program);
|
||||
EXPECT_THAT(program_ast, HasSubstr(R"(
|
||||
[[stage(compute), workgroup_size(3, 5, 7)]]
|
||||
@stage(compute) @workgroup_size(3, 5, 7)
|
||||
fn comp_main() {
|
||||
)")) << program_ast;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -78,7 +78,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArrayWithDecoration) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(test::ToString(p->program()),
|
||||
HasSubstr("RTArr = [[stride(8)]] array<u32>;\n"));
|
||||
HasSubstr("RTArr = @stride(8) array<u32>;\n"));
|
||||
|
||||
p->DeliberatelyInvalidSpirv();
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArray_Dup_EmitBoth) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(test::ToString(p->program()),
|
||||
HasSubstr(R"(type RTArr = [[stride(8)]] array<u32>;
|
||||
HasSubstr(R"(type RTArr = @stride(8) array<u32>;
|
||||
|
||||
type RTArr_1 = [[stride(8)]] array<u32>;
|
||||
type RTArr_1 = @stride(8) array<u32>;
|
||||
)"));
|
||||
|
||||
p->DeliberatelyInvalidSpirv();
|
||||
|
@ -110,7 +110,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedRTArray) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(test::ToString(p->program()),
|
||||
HasSubstr("myrtarr = [[stride(8)]] array<u32>;\n"));
|
||||
HasSubstr("myrtarr = @stride(8) array<u32>;\n"));
|
||||
|
||||
p->DeliberatelyInvalidSpirv();
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedArray) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(test::ToString(p->program()),
|
||||
HasSubstr("myarr = [[stride(8)]] array<u32, 5u>;"));
|
||||
HasSubstr("myarr = @stride(8) array<u32, 5u>;"));
|
||||
|
||||
p->DeliberatelyInvalidSpirv();
|
||||
}
|
||||
|
@ -142,9 +142,9 @@ TEST_F(SpvParserTest, NamedTypes_AnonArray_Dup_EmitBoth) {
|
|||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(test::ToString(p->program()),
|
||||
HasSubstr(R"(type Arr = [[stride(8)]] array<u32, 5u>;
|
||||
HasSubstr(R"(type Arr = @stride(8) array<u32, 5u>;
|
||||
|
||||
type Arr_1 = [[stride(8)]] array<u32, 5u>;
|
||||
type Arr_1 = @stride(8) array<u32, 5u>;
|
||||
)"));
|
||||
|
||||
p->DeliberatelyInvalidSpirv();
|
||||
|
|
|
@ -777,7 +777,11 @@ Token Lexer::try_punctuation() {
|
|||
auto source = begin_source();
|
||||
auto type = Token::Type::kUninitialized;
|
||||
|
||||
if (matches(pos_, "[[")) {
|
||||
if (matches(pos_, "@")) {
|
||||
type = Token::Type::kAttr;
|
||||
pos_ += 1;
|
||||
location_.column += 1;
|
||||
} else if (matches(pos_, "[[")) {
|
||||
type = Token::Type::kAttrLeft;
|
||||
pos_ += 2;
|
||||
location_.column += 2;
|
||||
|
|
|
@ -662,6 +662,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
testing::Values(TokenData{"&", Token::Type::kAnd},
|
||||
TokenData{"&&", Token::Type::kAndAnd},
|
||||
TokenData{"->", Token::Type::kArrow},
|
||||
TokenData{"@", Token::Type::kAttr},
|
||||
TokenData{"[[", Token::Type::kAttrLeft},
|
||||
TokenData{"]]", Token::Type::kAttrRight},
|
||||
TokenData{"/", Token::Type::kForwardSlash},
|
||||
|
|
|
@ -161,9 +161,9 @@ struct BlockCounters {
|
|||
/// @return the current enter-exit depth for the given block token type. If
|
||||
/// `t` is not a block token type, then 0 is always returned.
|
||||
int consume(const Token& t) {
|
||||
if (t.Is(Token::Type::kAttrLeft))
|
||||
if (t.Is(Token::Type::kAttrLeft)) // [DEPRECATED]
|
||||
return attrs++;
|
||||
if (t.Is(Token::Type::kAttrRight))
|
||||
if (t.Is(Token::Type::kAttrRight)) // [DEPRECATED]
|
||||
return attrs--;
|
||||
if (t.Is(Token::Type::kBraceLeft))
|
||||
return brace++;
|
||||
|
@ -1383,7 +1383,8 @@ Expect<ast::VariableList> ParserImpl::expect_param_list() {
|
|||
while (continue_parsing()) {
|
||||
// Check for the end of the list.
|
||||
auto t = peek();
|
||||
if (!t.IsIdentifier() && !t.Is(Token::Type::kAttrLeft)) {
|
||||
if (!t.IsIdentifier() && !t.Is(Token::Type::kAttr) &&
|
||||
!t.Is(Token::Type::kAttrLeft)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2834,11 +2835,21 @@ Maybe<ast::DecorationList> ParserImpl::decoration_list() {
|
|||
ast::DecorationList decos;
|
||||
|
||||
while (continue_parsing()) {
|
||||
auto list = decoration_bracketed_list(decos);
|
||||
if (list.errored)
|
||||
errored = true;
|
||||
if (!list.matched)
|
||||
break;
|
||||
if (match(Token::Type::kAttr)) {
|
||||
if (auto deco = expect_decoration(); deco.errored) {
|
||||
errored = true;
|
||||
} else {
|
||||
decos.emplace_back(deco.value);
|
||||
}
|
||||
} else { // [DEPRECATED] - old [[decoration]] style
|
||||
auto list = decoration_bracketed_list(decos);
|
||||
if (list.errored) {
|
||||
errored = true;
|
||||
}
|
||||
if (!list.matched) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
matched = true;
|
||||
}
|
||||
|
@ -2855,11 +2866,15 @@ Maybe<ast::DecorationList> ParserImpl::decoration_list() {
|
|||
Maybe<bool> ParserImpl::decoration_bracketed_list(ast::DecorationList& decos) {
|
||||
const char* use = "decoration list";
|
||||
|
||||
if (!match(Token::Type::kAttrLeft)) {
|
||||
Source source;
|
||||
if (!match(Token::Type::kAttrLeft, &source)) {
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
|
||||
Source source;
|
||||
deprecated(source,
|
||||
"[[decoration]] style decorations have been replaced with "
|
||||
"@decoration style");
|
||||
|
||||
if (match(Token::Type::kAttrRight, &source))
|
||||
return add_error(source, "empty decoration list");
|
||||
|
||||
|
@ -2879,7 +2894,7 @@ Maybe<bool> ParserImpl::decoration_bracketed_list(ast::DecorationList& decos) {
|
|||
|
||||
if (is_decoration(peek())) {
|
||||
// We have two decorations in a bracket without a separating comma.
|
||||
// e.g. [[location(1) group(2)]]
|
||||
// e.g. @location(1) group(2)
|
||||
// ^^^ expected comma
|
||||
expect(use, Token::Type::kComma);
|
||||
return Failure::kErrored;
|
||||
|
@ -3092,7 +3107,7 @@ Maybe<const ast::Decoration*> ParserImpl::decoration() {
|
|||
const char* use = "override decoration";
|
||||
|
||||
if (peek_is(Token::Type::kParenLeft)) {
|
||||
// [[override(x)]]
|
||||
// @override(x)
|
||||
return expect_paren_block(use, [&]() -> Result {
|
||||
auto val = expect_positive_sint(use);
|
||||
if (val.errored)
|
||||
|
|
|
@ -669,7 +669,7 @@ class ParserImpl {
|
|||
/// Parses a `assignment_stmt` grammar element
|
||||
/// @returns the parsed assignment or nullptr
|
||||
Maybe<const ast::AssignmentStatement*> assignment_stmt();
|
||||
/// Parses one or more bracketed decoration lists.
|
||||
/// Parses one or more decoration lists.
|
||||
/// @return the parsed decoration list, or an empty list on error.
|
||||
Maybe<ast::DecorationList> decoration_list();
|
||||
/// Parses a list of decorations between `ATTR_LEFT` and `ATTR_RIGHT`
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,32 +40,29 @@ TEST_F(ParserImplErrorResyncTest, BadFunctionDecls) {
|
|||
EXPECT(R"(
|
||||
fn .() -> . {}
|
||||
fn x(.) {}
|
||||
[[.,.]] fn -> {}
|
||||
@_ fn -> {}
|
||||
fn good() {}
|
||||
)",
|
||||
"test.wgsl:2:4 error: expected identifier for function declaration\n"
|
||||
"fn .() -> . {}\n"
|
||||
" ^\n"
|
||||
"\n"
|
||||
"test.wgsl:2:11 error: unable to determine function return type\n"
|
||||
"fn .() -> . {}\n"
|
||||
" ^\n"
|
||||
"\n"
|
||||
"test.wgsl:3:6 error: expected ')' for function declaration\n"
|
||||
"fn x(.) {}\n"
|
||||
" ^\n"
|
||||
"\n"
|
||||
"test.wgsl:4:3 error: expected decoration\n"
|
||||
"[[.,.]] fn -> {}\n"
|
||||
" ^\n"
|
||||
"\n"
|
||||
"test.wgsl:4:5 error: expected decoration\n"
|
||||
"[[.,.]] fn -> {}\n"
|
||||
" ^\n"
|
||||
"\n"
|
||||
"test.wgsl:4:12 error: expected identifier for function declaration\n"
|
||||
"[[.,.]] fn -> {}\n"
|
||||
" ^^\n");
|
||||
R"(test.wgsl:2:4 error: expected identifier for function declaration
|
||||
fn .() -> . {}
|
||||
^
|
||||
|
||||
test.wgsl:2:11 error: unable to determine function return type
|
||||
fn .() -> . {}
|
||||
^
|
||||
|
||||
test.wgsl:3:6 error: expected ')' for function declaration
|
||||
fn x(.) {}
|
||||
^
|
||||
|
||||
test.wgsl:4:2 error: expected decoration
|
||||
@_ fn -> {}
|
||||
^
|
||||
|
||||
test.wgsl:4:7 error: expected identifier for function declaration
|
||||
@_ fn -> {}
|
||||
^^
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorResyncTest, AssignmentStatement) {
|
||||
|
@ -78,17 +75,18 @@ fn f() {
|
|||
good = 1;
|
||||
}
|
||||
)",
|
||||
"test.wgsl:3:8 error: expected '=' for assignment\n"
|
||||
" blah blah blah blah;\n"
|
||||
" ^^^^\n"
|
||||
"\n"
|
||||
"test.wgsl:5:8 error: expected '=' for assignment\n"
|
||||
" blah blah blah blah;\n"
|
||||
" ^^^^\n"
|
||||
"\n"
|
||||
"test.wgsl:6:7 error: unable to parse right side of assignment\n"
|
||||
" x = .;\n"
|
||||
" ^\n");
|
||||
R"(test.wgsl:3:8 error: expected '=' for assignment
|
||||
blah blah blah blah;
|
||||
^^^^
|
||||
|
||||
test.wgsl:5:8 error: expected '=' for assignment
|
||||
blah blah blah blah;
|
||||
^^^^
|
||||
|
||||
test.wgsl:6:7 error: unable to parse right side of assignment
|
||||
x = .;
|
||||
^
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorResyncTest, DiscardStatement) {
|
||||
|
@ -99,13 +97,14 @@ fn f() {
|
|||
discard blah blah blah;
|
||||
}
|
||||
)",
|
||||
"test.wgsl:3:11 error: expected ';' for discard statement\n"
|
||||
" discard blah blah blah;\n"
|
||||
" ^^^^\n"
|
||||
"\n"
|
||||
"test.wgsl:5:11 error: expected ';' for discard statement\n"
|
||||
" discard blah blah blah;\n"
|
||||
" ^^^^\n");
|
||||
R"(test.wgsl:3:11 error: expected ';' for discard statement
|
||||
discard blah blah blah;
|
||||
^^^^
|
||||
|
||||
test.wgsl:5:11 error: expected ';' for discard statement
|
||||
discard blah blah blah;
|
||||
^^^^
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorResyncTest, StructMembers) {
|
||||
|
@ -115,21 +114,22 @@ struct S {
|
|||
a : i32;
|
||||
blah blah blah;
|
||||
b : i32;
|
||||
[[]] x : i32;
|
||||
@- x : i32;
|
||||
c : i32;
|
||||
}
|
||||
)",
|
||||
"test.wgsl:3:10 error: expected ':' for struct member\n"
|
||||
" blah blah blah;\n"
|
||||
" ^^^^\n"
|
||||
"\n"
|
||||
"test.wgsl:5:10 error: expected ':' for struct member\n"
|
||||
" blah blah blah;\n"
|
||||
" ^^^^\n"
|
||||
"\n"
|
||||
"test.wgsl:7:7 error: empty decoration list\n"
|
||||
" [[]] x : i32;\n"
|
||||
" ^^\n");
|
||||
R"(test.wgsl:3:10 error: expected ':' for struct member
|
||||
blah blah blah;
|
||||
^^^^
|
||||
|
||||
test.wgsl:5:10 error: expected ':' for struct member
|
||||
blah blah blah;
|
||||
^^^^
|
||||
|
||||
test.wgsl:7:6 error: expected decoration
|
||||
@- x : i32;
|
||||
^
|
||||
)");
|
||||
}
|
||||
|
||||
// Check that the forward scan in resynchronize() stop at nested sync points.
|
||||
|
@ -144,38 +144,36 @@ fn f() {
|
|||
}
|
||||
struct S { blah };
|
||||
)",
|
||||
"test.wgsl:5:1 error: expected ';' for discard statement\n"
|
||||
"}\n"
|
||||
"^\n"
|
||||
"\n"
|
||||
"test.wgsl:6:17 error: expected ':' for struct member\n"
|
||||
"struct S { blah };\n"
|
||||
" ^\n");
|
||||
R"(test.wgsl:5:1 error: expected ';' for discard statement
|
||||
}
|
||||
^
|
||||
|
||||
test.wgsl:6:17 error: expected ':' for struct member
|
||||
struct S { blah };
|
||||
^
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorResyncTest, BracketCounting) {
|
||||
EXPECT(R"(
|
||||
[[woof[[[[]]]]]]
|
||||
EXPECT(
|
||||
R"(
|
||||
fn f(x(((())))) {
|
||||
meow = {{{}}}
|
||||
}
|
||||
struct S { blah };
|
||||
)",
|
||||
"test.wgsl:2:3 error: expected decoration\n"
|
||||
"[[woof[[[[]]]]]]\n"
|
||||
" ^^^^\n"
|
||||
"\n"
|
||||
"test.wgsl:3:7 error: expected ':' for parameter\n"
|
||||
"fn f(x(((())))) {\n"
|
||||
" ^\n"
|
||||
"\n"
|
||||
"test.wgsl:4:10 error: unable to parse right side of assignment\n"
|
||||
" meow = {{{}}}\n"
|
||||
" ^\n"
|
||||
"\n"
|
||||
"test.wgsl:6:17 error: expected ':' for struct member\n"
|
||||
"struct S { blah };\n"
|
||||
" ^\n");
|
||||
R"(test.wgsl:2:7 error: expected ':' for parameter
|
||||
fn f(x(((())))) {
|
||||
^
|
||||
|
||||
test.wgsl:3:10 error: unable to parse right side of assignment
|
||||
meow = {{{}}}
|
||||
^
|
||||
|
||||
test.wgsl:5:17 error: expected ':' for struct member
|
||||
struct S { blah };
|
||||
^
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, FunctionDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_DecorationList) {
|
||||
auto p = parser("[[workgroup_size(2, 3, 4)]] fn main() { return; }");
|
||||
auto p = parser("@workgroup_size(2, 3, 4) fn main() { return; }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, FunctionDecl_DecorationList) {
|
|||
|
||||
TEST_F(ParserImplTest, FunctionDecl_DecorationList_MultipleEntries) {
|
||||
auto p = parser(R"(
|
||||
[[workgroup_size(2, 3, 4), stage(compute)]]
|
||||
@workgroup_size(2, 3, 4) @stage(compute)
|
||||
fn main() { return; })");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
|
@ -130,8 +130,8 @@ fn main() { return; })");
|
|||
|
||||
TEST_F(ParserImplTest, FunctionDecl_DecorationList_MultipleLists) {
|
||||
auto p = parser(R"(
|
||||
[[workgroup_size(2, 3, 4)]]
|
||||
[[stage(compute)]]
|
||||
@workgroup_size(2, 3, 4)
|
||||
@stage(compute)
|
||||
fn main() { return; })");
|
||||
auto decorations = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
|
@ -173,7 +173,7 @@ fn main() { return; })");
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_ReturnTypeDecorationList) {
|
||||
auto p = parser("fn main() -> [[location(1)]] f32 { return 1.0; }");
|
||||
auto p = parser("fn main() -> @location(1) f32 { return 1.0; }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_Parses) {
|
||||
auto p = parser("[[workgroup_size(2), stage(compute)]]");
|
||||
auto p = parser("@workgroup_size(2) @stage(compute)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
@ -46,23 +46,14 @@ TEST_F(ParserImplTest, DecorationList_Parses) {
|
|||
ast::PipelineStage::kCompute);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_Empty) {
|
||||
auto p = parser("[[]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:3: empty decoration list");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_Invalid) {
|
||||
auto p = parser("[[invalid]]");
|
||||
auto p = parser("@invalid");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:3: expected decoration");
|
||||
EXPECT_EQ(p->error(), "1:2: expected decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_ExtraComma) {
|
||||
|
@ -71,34 +62,98 @@ TEST_F(ParserImplTest, DecorationList_ExtraComma) {
|
|||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:22: expected decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:22: expected decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_MissingComma) {
|
||||
TEST_F(ParserImplTest, DecorationList_BadDecoration) {
|
||||
auto p = parser("@stage()");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:8: invalid value for stage decoration");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_Empty) {
|
||||
auto p = parser("[[]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:3: empty decoration list)");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_Invalid) {
|
||||
auto p = parser("[[invalid]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:3: expected decoration)");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_ExtraComma) {
|
||||
auto p = parser("[[workgroup_size(2), ]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:22: expected decoration)");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_MissingComma) {
|
||||
auto p = parser("[[workgroup_size(2) workgroup_size(2)]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:21: expected ',' for decoration list");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:21: expected ',' for decoration list)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_BadDecoration) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_BadDecoration) {
|
||||
auto p = parser("[[stage()]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:9: invalid value for stage decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:9: invalid value for stage decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_MissingRightAttr) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_MissingRightAttr) {
|
||||
auto p = parser("[[workgroup_size(2), workgroup_size(3, 4, 5)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:45: expected ']]' for decoration list");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:45: expected ']]' for decoration list)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -46,7 +46,7 @@ TEST_F(ParserImplTest, FunctionHeader_TrailingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_DecoratedReturnType) {
|
||||
auto p = parser("fn main() -> [[location(1)]] f32");
|
||||
auto p = parser("fn main() -> @location(1) f32");
|
||||
auto f = p->function_header();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(f.matched);
|
||||
|
@ -76,7 +76,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvariantReturnType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_DecoratedReturnType_WithArrayStride) {
|
||||
auto p = parser("fn main() -> [[location(1), stride(16)]] array<f32, 4>");
|
||||
auto p = parser("fn main() -> @location(1) @stride(16) array<f32, 4>");
|
||||
auto f = p->function_header();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(f.matched);
|
||||
|
|
|
@ -102,7 +102,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl_MissingExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_Override_WithId) {
|
||||
auto p = parser("[[override(7)]] let a : f32 = 1.");
|
||||
auto p = parser("@override(7) let a : f32 = 1.");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -119,9 +119,9 @@ TEST_F(ParserImplTest, GlobalConstantDec_Override_WithId) {
|
|||
EXPECT_TRUE(e->type->Is<ast::F32>());
|
||||
|
||||
EXPECT_EQ(e->source.range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 21u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 18u);
|
||||
EXPECT_EQ(e->source.range.end.line, 1u);
|
||||
EXPECT_EQ(e->source.range.end.column, 22u);
|
||||
EXPECT_EQ(e->source.range.end.column, 19u);
|
||||
|
||||
ASSERT_NE(e->constructor, nullptr);
|
||||
EXPECT_TRUE(e->constructor->Is<ast::LiteralExpression>());
|
||||
|
@ -165,7 +165,7 @@ TEST_F(ParserImplTest, GlobalConstantDec_Override_WithoutId) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_Override_MissingId) {
|
||||
auto p = parser("[[override()]] let a : f32 = 1.");
|
||||
auto p = parser("@override() let a : f32 = 1.");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -177,11 +177,11 @@ TEST_F(ParserImplTest, GlobalConstantDec_Override_MissingId) {
|
|||
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:12: expected signed integer literal for override decoration");
|
||||
"1:11: expected signed integer literal for override decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDec_Override_InvalidId) {
|
||||
auto p = parser("[[override(-7)]] let a : f32 = 1.");
|
||||
auto p = parser("@override(-7) let a : f32 = 1.");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -192,7 +192,7 @@ TEST_F(ParserImplTest, GlobalConstantDec_Override_InvalidId) {
|
|||
ASSERT_NE(e.value, nullptr);
|
||||
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:12: override decoration must be positive");
|
||||
EXPECT_EQ(p->error(), "1:11: override decoration must be positive");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -132,7 +132,7 @@ TEST_F(ParserImplTest, GlobalDecl_Function) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Function_WithDecoration) {
|
||||
auto p = parser("[[workgroup_size(2)]] fn main() { return; }");
|
||||
auto p = parser("@workgroup_size(2) fn main() { return; }");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -167,7 +167,7 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
|
||||
auto p = parser("struct A { data: [[stride(4)]] array<f32>; }");
|
||||
auto p = parser("struct A { data: @stride(4) array<f32>; }");
|
||||
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
|
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
||||
auto p = parser("[[binding(2), group(1)]] var<uniform> a : f32");
|
||||
auto p = parser("@binding(2) @group(1) var<uniform> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -83,9 +83,9 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
|||
EXPECT_EQ(e->declared_storage_class, ast::StorageClass::kUniform);
|
||||
|
||||
EXPECT_EQ(e->source.range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 39u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 36u);
|
||||
EXPECT_EQ(e->source.range.end.line, 1u);
|
||||
EXPECT_EQ(e->source.range.end.column, 40u);
|
||||
EXPECT_EQ(e->source.range.end.column, 37u);
|
||||
|
||||
ASSERT_EQ(e->constructor, nullptr);
|
||||
|
||||
|
@ -96,7 +96,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
||||
auto p = parser("[[binding(2)]] [[group(1)]] var<uniform> a : f32");
|
||||
auto p = parser("@binding(2) @group(1) var<uniform> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -113,9 +113,9 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
|||
EXPECT_EQ(e->declared_storage_class, ast::StorageClass::kUniform);
|
||||
|
||||
EXPECT_EQ(e->source.range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 42u);
|
||||
EXPECT_EQ(e->source.range.begin.column, 36u);
|
||||
EXPECT_EQ(e->source.range.end.line, 1u);
|
||||
EXPECT_EQ(e->source.range.end.column, 43u);
|
||||
EXPECT_EQ(e->source.range.end.column, 37u);
|
||||
|
||||
ASSERT_EQ(e->constructor, nullptr);
|
||||
|
||||
|
@ -126,7 +126,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) {
|
||||
auto p = parser("[[binding()]] var<uniform> a : f32");
|
||||
auto p = parser("@binding() var<uniform> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -138,7 +138,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) {
|
|||
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:11: expected signed integer literal for binding decoration");
|
||||
"1:10: expected signed integer literal for binding decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidConstExpr) {
|
||||
|
|
|
@ -92,9 +92,8 @@ TEST_F(ParserImplTest, ParamList_TrailingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParamList_Decorations) {
|
||||
auto p = parser(
|
||||
"[[builtin(position)]] coord : vec4<f32>, "
|
||||
"[[location(1)]] loc1 : f32");
|
||||
auto p =
|
||||
parser("@builtin(position) coord : vec4<f32>, @location(1) loc1 : f32");
|
||||
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
@ -113,9 +112,9 @@ TEST_F(ParserImplTest, ParamList_Decorations) {
|
|||
ast::Builtin::kPosition);
|
||||
|
||||
ASSERT_EQ(e.value[0]->source.range.begin.line, 1u);
|
||||
ASSERT_EQ(e.value[0]->source.range.begin.column, 23u);
|
||||
ASSERT_EQ(e.value[0]->source.range.begin.column, 20u);
|
||||
ASSERT_EQ(e.value[0]->source.range.end.line, 1u);
|
||||
ASSERT_EQ(e.value[0]->source.range.end.column, 28u);
|
||||
ASSERT_EQ(e.value[0]->source.range.end.column, 25u);
|
||||
|
||||
EXPECT_EQ(e.value[1]->symbol, p->builder().Symbols().Get("loc1"));
|
||||
EXPECT_TRUE(e.value[1]->type->Is<ast::F32>());
|
||||
|
@ -125,10 +124,10 @@ TEST_F(ParserImplTest, ParamList_Decorations) {
|
|||
EXPECT_TRUE(decos1[0]->Is<ast::LocationDecoration>());
|
||||
EXPECT_EQ(decos1[0]->As<ast::LocationDecoration>()->value, 1u);
|
||||
|
||||
ASSERT_EQ(e.value[1]->source.range.begin.line, 1u);
|
||||
ASSERT_EQ(e.value[1]->source.range.begin.column, 58u);
|
||||
ASSERT_EQ(e.value[1]->source.range.end.line, 1u);
|
||||
ASSERT_EQ(e.value[1]->source.range.end.column, 62u);
|
||||
EXPECT_EQ(e.value[1]->source.range.begin.line, 1u);
|
||||
EXPECT_EQ(e.value[1]->source.range.begin.column, 52u);
|
||||
EXPECT_EQ(e.value[1]->source.range.end.line, 1u);
|
||||
EXPECT_EQ(e.value[1]->source.range.end.column, 56u);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -46,25 +46,25 @@ TEST_F(ParserImplTest, StructBodyDecl_ParsesEmpty) {
|
|||
TEST_F(ParserImplTest, StructBodyDecl_InvalidAlign) {
|
||||
auto p = parser(R"(
|
||||
{
|
||||
[[align(nan)]] a : i32;
|
||||
@align(nan) a : i32;
|
||||
})");
|
||||
auto m = p->expect_struct_body_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(m.errored);
|
||||
EXPECT_EQ(p->error(),
|
||||
"3:11: expected signed integer literal for align decoration");
|
||||
"3:10: expected signed integer literal for align decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructBodyDecl_InvalidSize) {
|
||||
auto p = parser(R"(
|
||||
{
|
||||
[[size(nan)]] a : i32;
|
||||
@size(nan) a : i32;
|
||||
})");
|
||||
auto m = p->expect_struct_body_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(m.errored);
|
||||
EXPECT_EQ(p->error(),
|
||||
"3:10: expected signed integer literal for size decoration");
|
||||
"3:9: expected signed integer literal for size decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructBodyDecl_MissingClosingBracket) {
|
||||
|
|
|
@ -154,7 +154,8 @@ TEST_F(ParserImplTest, StructDecl_InvalidDecorationDecl) {
|
|||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:3: use of deprecated language feature: [[block]] attributes have been removed from WGSL
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:3: use of deprecated language feature: [[block]] attributes have been removed from WGSL
|
||||
1:9: expected ']]' for decoration list)");
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,60 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_Parses) {
|
||||
auto p = parser("@override");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
ASSERT_EQ(decos.value.size(), 1u);
|
||||
auto* override_deco = decos.value[0]->As<ast::Decoration>();
|
||||
EXPECT_TRUE(override_deco->Is<ast::OverrideDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_MissingParenLeft) {
|
||||
auto p = parser("@location 1)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:11: expected '(' for location decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_MissingValue) {
|
||||
auto p = parser("@location()");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:11: expected signed integer literal for location decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_MissingParenRight) {
|
||||
auto p = parser("@location(1");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:12: expected ')' for location decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_InvalidDecoration) {
|
||||
auto p = parser("@invalid");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationDecl_Parses) {
|
||||
auto p = parser("[[override]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
|
@ -31,17 +85,22 @@ TEST_F(ParserImplTest, DecorationDecl_Parses) {
|
|||
EXPECT_TRUE(override_deco->Is<ast::OverrideDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_MissingAttrRight) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationDecl_MissingAttrRight) {
|
||||
auto p = parser("[[override");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:11: expected ']]' for decoration list");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:11: expected ']]' for decoration list)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_InvalidDecoration) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationDecl_InvalidDecoration) {
|
||||
auto p = parser("[[invalid]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
|
|
|
@ -28,18 +28,20 @@ TEST_F(ParserImplTest, DecorationDecl_EmptyStr) {
|
|||
EXPECT_EQ(decos.value.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_EmptyBlock) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationDecl_EmptyBlock) {
|
||||
auto p = parser("[[]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(decos.value.size(), 0u);
|
||||
EXPECT_EQ(p->error(), "1:3: empty decoration list");
|
||||
EXPECT_EQ(p->error(), R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:3: empty decoration list)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_Single) {
|
||||
auto p = parser("[[size(4)]]");
|
||||
auto p = parser("@size(4)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
@ -51,13 +53,13 @@ TEST_F(ParserImplTest, DecorationDecl_Single) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_InvalidDecoration) {
|
||||
auto p = parser("[[size(nan)]]");
|
||||
auto p = parser("@size(nan)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:8: expected signed integer literal for size decoration");
|
||||
"1:7: expected signed integer literal for size decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationDecl_MissingClose) {
|
||||
|
@ -66,7 +68,8 @@ TEST_F(ParserImplTest, DecorationDecl_MissingClose) {
|
|||
EXPECT_TRUE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:10: expected ']]' for decoration list");
|
||||
EXPECT_EQ(p->error(), R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:10: expected ']]' for decoration list)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecorationDecl_SizeMissingClose) {
|
||||
|
@ -75,7 +78,8 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_SizeMissingClose) {
|
|||
EXPECT_TRUE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_EQ(p->error(), "1:10: expected ']]' for decoration list");
|
||||
EXPECT_EQ(p->error(), R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:10: expected ']]' for decoration list)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, StructMember_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_ParsesWithAlignDecoration) {
|
||||
auto p = parser("[[align(2)]] a : i32;");
|
||||
auto p = parser("@align(2) a : i32;");
|
||||
|
||||
auto& builder = p->builder();
|
||||
|
||||
|
@ -64,12 +64,12 @@ TEST_F(ParserImplTest, StructMember_ParsesWithAlignDecoration) {
|
|||
EXPECT_EQ(m->decorations[0]->As<ast::StructMemberAlignDecoration>()->align,
|
||||
2u);
|
||||
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{1u, 14u}, {1u, 15u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{1u, 18u}, {1u, 21u}}));
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{1u, 11u}, {1u, 12u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{1u, 15u}, {1u, 18u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_ParsesWithSizeDecoration) {
|
||||
auto p = parser("[[size(2)]] a : i32;");
|
||||
auto p = parser("@size(2) a : i32;");
|
||||
|
||||
auto& builder = p->builder();
|
||||
|
||||
|
@ -89,12 +89,12 @@ TEST_F(ParserImplTest, StructMember_ParsesWithSizeDecoration) {
|
|||
EXPECT_TRUE(m->decorations[0]->Is<ast::StructMemberSizeDecoration>());
|
||||
EXPECT_EQ(m->decorations[0]->As<ast::StructMemberSizeDecoration>()->size, 2u);
|
||||
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{1u, 13u}, {1u, 14u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{1u, 17u}, {1u, 20u}}));
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{1u, 10u}, {1u, 11u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{1u, 14u}, {1u, 17u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) {
|
||||
auto p = parser("[[size(2)]] a : i32;");
|
||||
auto p = parser("@size(2) a : i32;");
|
||||
|
||||
auto& builder = p->builder();
|
||||
|
||||
|
@ -114,13 +114,13 @@ TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) {
|
|||
EXPECT_TRUE(m->decorations[0]->Is<ast::StructMemberSizeDecoration>());
|
||||
EXPECT_EQ(m->decorations[0]->As<ast::StructMemberSizeDecoration>()->size, 2u);
|
||||
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{1u, 13u}, {1u, 14u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{1u, 17u}, {1u, 20u}}));
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{1u, 10u}, {1u, 11u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{1u, 14u}, {1u, 17u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) {
|
||||
auto p = parser(R"([[size(2)]]
|
||||
[[align(4)]] a : i32;)");
|
||||
auto p = parser(R"(@size(2)
|
||||
@align(4) a : i32;)");
|
||||
|
||||
auto& builder = p->builder();
|
||||
|
||||
|
@ -143,12 +143,12 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) {
|
|||
EXPECT_EQ(m->decorations[1]->As<ast::StructMemberAlignDecoration>()->align,
|
||||
4u);
|
||||
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{2u, 14u}, {2u, 15u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{2u, 18u}, {2u, 21u}}));
|
||||
EXPECT_EQ(m->source.range, (Source::Range{{2u, 11u}, {2u, 12u}}));
|
||||
EXPECT_EQ(m->type->source.range, (Source::Range{{2u, 15u}, {2u, 18u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_InvalidDecoration) {
|
||||
auto p = parser("[[size(nan)]] a : i32;");
|
||||
auto p = parser("@size(nan) a : i32;");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -159,7 +159,7 @@ TEST_F(ParserImplTest, StructMember_InvalidDecoration) {
|
|||
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:8: expected signed integer literal for size decoration");
|
||||
"1:7: expected signed integer literal for size decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_MissingSemicolon) {
|
||||
|
|
|
@ -26,8 +26,8 @@ TEST_F(ParserImplTest, Empty) {
|
|||
|
||||
TEST_F(ParserImplTest, Parses) {
|
||||
auto p = parser(R"(
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(.4, .2, .3, 1);
|
||||
}
|
||||
)");
|
||||
|
@ -114,11 +114,11 @@ TEST_F(ParserImplTest, Comments_TerminatedBlockComment) {
|
|||
* /* I can nest /**/ comments. */
|
||||
* // I can nest line comments too.
|
||||
**/
|
||||
[[stage(fragment)]] // This is the stage
|
||||
@stage(fragment) // This is the stage
|
||||
fn main(/*
|
||||
no
|
||||
parameters
|
||||
*/) -> [[location(0)]] vec4<f32> {
|
||||
*/) -> @location(0) vec4<f32> {
|
||||
return/*block_comments_delimit_tokens*/vec4<f32>(.4, .2, .3, 1);
|
||||
}/* block comments are OK at EOF...*/)");
|
||||
|
||||
|
@ -128,8 +128,8 @@ parameters
|
|||
|
||||
TEST_F(ParserImplTest, Comments_UnterminatedBlockComment) {
|
||||
auto p = parser(R"(
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(.4, .2, .3, 1);
|
||||
} /* unterminated block comments are invalid ...)");
|
||||
|
||||
|
|
|
@ -440,7 +440,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_ConstantSize) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride) {
|
||||
auto p = parser("[[stride(16)]] array<f32, 5>");
|
||||
auto p = parser("@stride(16) array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -460,11 +460,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) {
|
|||
auto* stride = a->decorations[0];
|
||||
ASSERT_TRUE(stride->Is<ast::StrideDecoration>());
|
||||
ASSERT_EQ(stride->As<ast::StrideDecoration>()->stride, 16u);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 16u}, {1u, 29u}}));
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 13u}, {1u, 26u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) {
|
||||
auto p = parser("[[stride(16)]] array<f32>");
|
||||
auto p = parser("@stride(16) array<f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -480,11 +480,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) {
|
|||
auto* stride = a->decorations[0];
|
||||
ASSERT_TRUE(stride->Is<ast::StrideDecoration>());
|
||||
ASSERT_EQ(stride->As<ast::StrideDecoration>()->stride, 16u);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 16u}, {1u, 26u}}));
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 13u}, {1u, 23u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) {
|
||||
auto p = parser("[[stride(16), stride(32)]] array<f32>");
|
||||
auto p = parser("@stride(16) @stride(32) array<f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -502,11 +502,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) {
|
|||
EXPECT_EQ(decos[0]->As<ast::StrideDecoration>()->stride, 16u);
|
||||
EXPECT_TRUE(decos[1]->Is<ast::StrideDecoration>());
|
||||
EXPECT_EQ(decos[1]->As<ast::StrideDecoration>()->stride, 32u);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 28u}, {1u, 38u}}));
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 25u}, {1u, 35u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) {
|
||||
auto p = parser("[[stride(16)]] [[stride(32)]] array<f32>");
|
||||
auto p = parser("@stride(16) @stride(32) array<f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -524,89 +524,163 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) {
|
|||
EXPECT_EQ(decos[0]->As<ast::StrideDecoration>()->stride, 16u);
|
||||
EXPECT_TRUE(decos[1]->Is<ast::StrideDecoration>());
|
||||
EXPECT_EQ(decos[1]->As<ast::StrideDecoration>()->stride, 32u);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 31u}, {1u, 41u}}));
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 25u}, {1u, 35u}}));
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Decoration_MissingArray) {
|
||||
auto p = parser("[[stride(16)]] f32");
|
||||
auto p = parser("@stride(16) f32");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:3: unexpected decorations");
|
||||
EXPECT_EQ(p->error(), "1:2: unexpected decorations");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Decoration_MissingClosingAttr) {
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Decoration_UnknownDecoration) {
|
||||
auto p = parser("@unknown(16) array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), R"(1:2: expected decoration)");
|
||||
}
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingLeftParen) {
|
||||
auto p = parser("@stride 4) array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), R"(1:9: expected '(' for stride decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingRightParen) {
|
||||
auto p = parser("@stride(4 array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), R"(1:11: expected ')' for stride decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingValue) {
|
||||
auto p = parser("@stride() array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:9: expected signed integer literal for stride decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue) {
|
||||
auto p = parser("@stride(invalid) array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:9: expected signed integer literal for stride decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue_Negative) {
|
||||
auto p = parser("@stride(-1) array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:9: stride decoration must be greater than 0");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest,
|
||||
DEPRECATED_TypeDecl_Array_Decoration_MissingClosingAttr) {
|
||||
auto p = parser("[[stride(16) array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:14: expected ']]' for decoration list");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:14: expected ']]' for decoration list)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Decoration_UnknownDecoration) {
|
||||
auto p = parser("[[unknown 16]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:3: expected decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingLeftParen) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_TypeDecl_Array_Stride_MissingLeftParen) {
|
||||
auto p = parser("[[stride 4)]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:10: expected '(' for stride decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:10: expected '(' for stride decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingRightParen) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_TypeDecl_Array_Stride_MissingRightParen) {
|
||||
auto p = parser("[[stride(4]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:11: expected ')' for stride decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:11: expected ')' for stride decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingValue) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_TypeDecl_Array_Stride_MissingValue) {
|
||||
auto p = parser("[[stride()]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:10: expected signed integer literal for stride decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:10: expected signed integer literal for stride decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_TypeDecl_Array_Stride_InvalidValue) {
|
||||
auto p = parser("[[stride(invalid)]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:10: expected signed integer literal for stride decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:10: expected signed integer literal for stride decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue_Negative) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_TypeDecl_Array_Stride_InvalidValue_Negative) {
|
||||
auto p = parser("[[stride(-1)]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
ASSERT_EQ(t.value, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:10: stride decoration must be greater than 0");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:10: stride decoration must be greater than 0)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Runtime) {
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_Parses) {
|
||||
auto p = parser(R"([[location(4), builtin(position)]])");
|
||||
auto p = parser(R"(@location(4) @builtin(position))");
|
||||
auto decos = p->decoration_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
@ -39,65 +39,94 @@ TEST_F(ParserImplTest, DecorationList_Parses) {
|
|||
ast::Builtin::kPosition);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_Empty) {
|
||||
TEST_F(ParserImplTest, DecorationList_Invalid) {
|
||||
auto p = parser(R"(@invalid)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), R"(1:2: expected decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_InvalidValue) {
|
||||
auto p = parser("@builtin(invalid)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:10: invalid value for builtin decoration");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_Empty) {
|
||||
auto p = parser(R"([[]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:3: empty decoration list");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:3: empty decoration list)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_Invalid) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_Invalid) {
|
||||
auto p = parser(R"([[invalid]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:3: expected decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:3: expected decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_ExtraComma) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_ExtraComma) {
|
||||
auto p = parser(R"([[builtin(position), ]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:22: expected decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:22: expected decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_MissingComma) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_MissingComma) {
|
||||
auto p = parser(R"([[binding(4) location(5)]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:14: expected ',' for decoration list");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:14: expected ',' for decoration list)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_BadDecoration) {
|
||||
auto p = parser(R"([[location(bad)]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(),
|
||||
"1:12: expected signed integer literal for location decoration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, DecorationList_InvalidBuiltin) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_DecorationList_InvalidValue) {
|
||||
auto p = parser("[[builtin(invalid)]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
EXPECT_TRUE(decos.value.empty());
|
||||
EXPECT_EQ(p->error(), "1:11: invalid value for builtin decoration");
|
||||
EXPECT_EQ(
|
||||
p->error(),
|
||||
R"(1:1: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:11: invalid value for builtin decoration)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
||||
auto p = parser("my_var : [[stride(1)]] S");
|
||||
auto p = parser("my_var : @stride(1) S");
|
||||
|
||||
auto* mem = Member("a", ty.i32(), ast::DecorationList{});
|
||||
ast::StructMemberList members;
|
||||
|
@ -90,19 +90,11 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
|||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
ASSERT_EQ(p->error(), "1:12: unexpected decorations");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_DecorationMissingRightBlock) {
|
||||
auto p = parser("my_var : [[stride(4) S");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
ASSERT_EQ(p->error(), "1:22: expected ']]' for decoration list");
|
||||
ASSERT_EQ(p->error(), "1:11: unexpected decorations");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_DecorationMissingRightParen) {
|
||||
auto p = parser("my_var : [[stride(4]] S");
|
||||
auto p = parser("my_var : @stride(4 S");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
|
@ -110,19 +102,62 @@ TEST_F(ParserImplTest, VariableIdentDecl_DecorationMissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_DecorationMissingLeftParen) {
|
||||
auto p = parser("my_var : @stride 4) S");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
ASSERT_EQ(p->error(), "1:18: expected '(' for stride decoration");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest,
|
||||
DEPRECATED_VariableIdentDecl_DecorationMissingRightBlock) {
|
||||
auto p = parser("my_var : [[stride(4) S");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
ASSERT_EQ(
|
||||
p->error(),
|
||||
R"(1:10: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:22: expected ']]' for decoration list)");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest,
|
||||
DEPRECATED_VariableIdentDecl_DecorationMissingRightParen) {
|
||||
auto p = parser("my_var : [[stride(4]] S");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
ASSERT_EQ(
|
||||
p->error(),
|
||||
R"(1:10: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:20: expected ')' for stride decoration)");
|
||||
}
|
||||
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest,
|
||||
DEPRECATED_VariableIdentDecl_DecorationMissingLeftParen) {
|
||||
auto p = parser("my_var : [[stride 4)]] S");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
ASSERT_EQ(p->error(), "1:19: expected '(' for stride decoration");
|
||||
ASSERT_EQ(
|
||||
p->error(),
|
||||
R"(1:10: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:19: expected '(' for stride decoration)");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_DecorationEmpty) {
|
||||
// TODO(crbug.com/tint/1382): Remove
|
||||
TEST_F(ParserImplTest, DEPRECATED_VariableIdentDecl_DecorationEmpty) {
|
||||
auto p = parser("my_var : [[]] S");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
ASSERT_EQ(p->error(), "1:12: empty decoration list");
|
||||
ASSERT_EQ(
|
||||
p->error(),
|
||||
R"(1:10: use of deprecated language feature: [[decoration]] style decorations have been replaced with @decoration style
|
||||
1:12: empty decoration list)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -34,8 +34,8 @@ TEST_F(ParserTest, Empty) {
|
|||
|
||||
TEST_F(ParserTest, Parses) {
|
||||
Source::File file("test.wgsl", R"(
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(.4, .2, .3, 1.);
|
||||
}
|
||||
)");
|
||||
|
|
|
@ -42,6 +42,8 @@ std::string Token::TypeToName(Type type) {
|
|||
return "&&";
|
||||
case Token::Type::kArrow:
|
||||
return "->";
|
||||
case Token::Type::kAttr:
|
||||
return "@";
|
||||
case Token::Type::kAttrLeft:
|
||||
return "[[";
|
||||
case Token::Type::kAttrRight:
|
||||
|
|
|
@ -50,9 +50,11 @@ class Token {
|
|||
kAndAnd,
|
||||
/// A '->'
|
||||
kArrow,
|
||||
/// A '[['
|
||||
/// A '@'
|
||||
kAttr,
|
||||
/// A '[[' - [DEPRECATED] now '@'
|
||||
kAttrLeft,
|
||||
/// A ']]'
|
||||
/// A ']]' - [DEPRECATED] now '@'
|
||||
kAttrRight,
|
||||
/// A '/'
|
||||
kForwardSlash,
|
||||
|
|
|
@ -27,7 +27,7 @@ using ResolverAssignmentValidationTest = ResolverTest;
|
|||
|
||||
TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) {
|
||||
// [[block]] struct S { m : i32 };
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<storage,read> a : S;
|
||||
auto* s = Structure("S", {Member("m", ty.i32())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
|
@ -251,7 +251,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
|
|||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
|
||||
// [[block]] struct S { a : atomic<i32>; };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> v : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> v : S;
|
||||
// v.a = v.a;
|
||||
|
||||
auto* s = Structure("S", {Member("a", ty.atomic(ty.i32()))},
|
||||
|
@ -273,7 +273,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
|
|||
|
||||
TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) {
|
||||
// [[block]] struct S { a : array<f32>; };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> v : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> v : S;
|
||||
// v.a = v.a;
|
||||
|
||||
auto* s = Structure("S", {Member("a", ty.array(ty.f32()))},
|
||||
|
@ -299,7 +299,7 @@ TEST_F(ResolverAssignmentValidationTest,
|
|||
// struct S {
|
||||
// arr: array<i32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
// fn f() {
|
||||
// _ = s;
|
||||
// }
|
||||
|
@ -320,7 +320,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) {
|
|||
// struct S {
|
||||
// arr: array<i32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
// fn f() {
|
||||
// _ = s.arr;
|
||||
// }
|
||||
|
@ -347,10 +347,10 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
|
|||
// struct U {
|
||||
// i: i32;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var tex texture_2d;
|
||||
// [[group(0), binding(1)]] var smp sampler;
|
||||
// [[group(0), binding(2)]] var<uniform> u : U;
|
||||
// [[group(0), binding(3)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var tex texture_2d;
|
||||
// @group(0) @binding(1) var smp sampler;
|
||||
// @group(0) @binding(2) var<uniform> u : U;
|
||||
// @group(0) @binding(3) var<storage, read_write> s : S;
|
||||
// var<workgroup> wg : array<f32, 10>
|
||||
// fn f() {
|
||||
// _ = 1;
|
||||
|
|
|
@ -201,10 +201,10 @@ INSTANTIATE_TEST_SUITE_P(ResolverBuiltinsValidationTest,
|
|||
testing::ValuesIn(cases));
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInput_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn fs_main(
|
||||
// [[builtin(frag_depth)]] fd: f32,
|
||||
// ) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @builtin(frag_depth) fd: f32,
|
||||
// ) -> @location(0) f32 { return 1.0; }
|
||||
auto* fd = Param(
|
||||
"fd", ty.f32(),
|
||||
ast::DecorationList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)});
|
||||
|
@ -219,10 +219,10 @@ TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInput_Fail) {
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInputStruct_Fail) {
|
||||
// struct MyInputs {
|
||||
// [[builtin(frag_depth)]] ff: f32;
|
||||
// @builtin(frag_depth) ff: f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn fragShader(arg: MyInputs) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn fragShader(arg: MyInputs) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* s = Structure(
|
||||
"MyInputs", {Member("frag_depth", ty.f32(),
|
||||
|
@ -240,9 +240,9 @@ TEST_F(ResolverBuiltinsValidationTest, FragDepthIsInputStruct_Fail) {
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, StructBuiltinInsideEntryPoint_Ignored) {
|
||||
// struct S {
|
||||
// [[builtin(vertex_index)]] idx: u32;
|
||||
// @builtin(vertex_index) idx: u32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn fragShader() { var s : S; }
|
||||
|
||||
Structure("S",
|
||||
|
@ -257,10 +257,10 @@ TEST_F(ResolverBuiltinsValidationTest, StructBuiltinInsideEntryPoint_Ignored) {
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_Struct_Fail) {
|
||||
// struct MyInputs {
|
||||
// [[builtin(kPosition)]] p: vec4<u32>;
|
||||
// @builtin(kPosition) p: vec4<u32>;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn fragShader(is_front: MyInputs) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn fragShader(is_front: MyInputs) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* m = Member(
|
||||
"position", ty.vec4<u32>(),
|
||||
|
@ -275,8 +275,8 @@ TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_Struct_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_ReturnType_Fail) {
|
||||
// [[stage(vertex)]]
|
||||
// fn main() -> [[builtin(position)]] f32 { return 1.0; }
|
||||
// @stage(vertex)
|
||||
// fn main() -> @builtin(position) f32 { return 1.0; }
|
||||
Func("main", {}, ty.f32(), {Return(1.0f)},
|
||||
{Stage(ast::PipelineStage::kVertex)},
|
||||
{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
||||
|
@ -288,10 +288,10 @@ TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_ReturnType_Fail) {
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FragDepthNotF32_Struct_Fail) {
|
||||
// struct MyInputs {
|
||||
// [[builtin(kFragDepth)]] p: i32;
|
||||
// @builtin(kFragDepth) p: i32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn fragShader(is_front: MyInputs) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn fragShader(is_front: MyInputs) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* m = Member(
|
||||
"frag_depth", ty.i32(),
|
||||
|
@ -307,10 +307,10 @@ TEST_F(ResolverBuiltinsValidationTest, FragDepthNotF32_Struct_Fail) {
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_Struct_Fail) {
|
||||
// struct MyInputs {
|
||||
// [[builtin(sample_mask)]] m: f32;
|
||||
// @builtin(sample_mask) m: f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn fragShader(is_front: MyInputs) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn fragShader(is_front: MyInputs) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* s = Structure(
|
||||
"MyInputs", {Member("m", ty.f32(),
|
||||
|
@ -325,8 +325,8 @@ TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_Struct_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_ReturnType_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main() -> [[builtin(sample_mask)]] i32 { return 1; }
|
||||
// @stage(fragment)
|
||||
// fn main() -> @builtin(sample_mask) i32 { return 1; }
|
||||
Func("main", {}, ty.i32(), {Return(1)},
|
||||
{Stage(ast::PipelineStage::kFragment)},
|
||||
{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)});
|
||||
|
@ -337,10 +337,10 @@ TEST_F(ResolverBuiltinsValidationTest, SampleMaskNotU32_ReturnType_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, SampleMaskIsNotU32_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn fs_main(
|
||||
// [[builtin(sample_mask)]] arg: bool
|
||||
// ) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @builtin(sample_mask) arg: bool
|
||||
// ) -> @location(0) f32 { return 1.0; }
|
||||
auto* arg = Param("arg", ty.bool_(),
|
||||
ast::DecorationList{
|
||||
Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)});
|
||||
|
@ -354,10 +354,10 @@ TEST_F(ResolverBuiltinsValidationTest, SampleMaskIsNotU32_Fail) {
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Struct_Fail) {
|
||||
// struct MyInputs {
|
||||
// [[builtin(sample_index)]] m: f32;
|
||||
// @builtin(sample_index) m: f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn fragShader(is_front: MyInputs) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn fragShader(is_front: MyInputs) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* s = Structure(
|
||||
"MyInputs", {Member("m", ty.f32(),
|
||||
|
@ -372,10 +372,10 @@ TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Struct_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn fs_main(
|
||||
// [[builtin(sample_index)]] arg: bool
|
||||
// ) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @builtin(sample_index) arg: bool
|
||||
// ) -> @location(0) f32 { return 1.0; }
|
||||
auto* arg = Param("arg", ty.bool_(),
|
||||
ast::DecorationList{
|
||||
Builtin(Source{{12, 34}}, ast::Builtin::kSampleIndex)});
|
||||
|
@ -388,10 +388,10 @@ TEST_F(ResolverBuiltinsValidationTest, SampleIndexIsNotU32_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, PositionIsNotF32_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn fs_main(
|
||||
// [[builtin(kPosition)]] p: vec3<f32>,
|
||||
// ) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @builtin(kPosition) p: vec3<f32>,
|
||||
// ) -> @location(0) f32 { return 1.0; }
|
||||
auto* p = Param(
|
||||
"p", ty.vec3<f32>(),
|
||||
ast::DecorationList{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
|
||||
|
@ -404,8 +404,8 @@ TEST_F(ResolverBuiltinsValidationTest, PositionIsNotF32_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FragDepthIsNotF32_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// fn fs_main() -> [[builtin(kFragDepth)]] f32 { var fd: i32; return fd; }
|
||||
// @stage(fragment)
|
||||
// fn fs_main() -> @builtin(kFragDepth) f32 { var fd: i32; return fd; }
|
||||
auto* fd = Var("fd", ty.i32());
|
||||
Func(
|
||||
"fs_main", {}, ty.i32(), {Decl(fd), Return(fd)},
|
||||
|
@ -417,11 +417,11 @@ TEST_F(ResolverBuiltinsValidationTest, FragDepthIsNotF32_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, VertexIndexIsNotU32_Fail) {
|
||||
// [[stage(vertex)]]
|
||||
// @stage(vertex)
|
||||
// fn main(
|
||||
// [[builtin(kVertexIndex)]] vi : f32,
|
||||
// [[builtin(kPosition)]] p :vec4<f32>
|
||||
// ) -> [[builtin(kPosition)]] vec4<f32> { return vec4<f32>(); }
|
||||
// @builtin(kVertexIndex) vi : f32,
|
||||
// @builtin(kPosition) p :vec4<f32>
|
||||
// ) -> @builtin(kPosition) vec4<f32> { return vec4<f32>(); }
|
||||
auto* p = Param("p", ty.vec4<f32>(),
|
||||
ast::DecorationList{Builtin(ast::Builtin::kPosition)});
|
||||
auto* vi = Param("vi", ty.f32(),
|
||||
|
@ -436,11 +436,11 @@ TEST_F(ResolverBuiltinsValidationTest, VertexIndexIsNotU32_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, InstanceIndexIsNotU32) {
|
||||
// [[stage(vertex)]]
|
||||
// @stage(vertex)
|
||||
// fn main(
|
||||
// [[builtin(kInstanceIndex)]] ii : f32,
|
||||
// [[builtin(kPosition)]] p :vec4<f32>
|
||||
// ) -> [[builtin(kPosition)]] vec4<f32> { return vec4<f32>(); }
|
||||
// @builtin(kInstanceIndex) ii : f32,
|
||||
// @builtin(kPosition) p :vec4<f32>
|
||||
// ) -> @builtin(kPosition) vec4<f32> { return vec4<f32>(); }
|
||||
auto* p = Param("p", ty.vec4<f32>(),
|
||||
ast::DecorationList{Builtin(ast::Builtin::kPosition)});
|
||||
auto* ii = Param("ii", ty.f32(),
|
||||
|
@ -455,13 +455,13 @@ TEST_F(ResolverBuiltinsValidationTest, InstanceIndexIsNotU32) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FragmentBuiltin_Pass) {
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn fs_main(
|
||||
// [[builtin(kPosition)]] p: vec4<f32>,
|
||||
// [[builtin(front_facing)]] ff: bool,
|
||||
// [[builtin(sample_index)]] si: u32,
|
||||
// [[builtin(sample_mask)]] sm : u32
|
||||
// ) -> [[builtin(frag_depth)]] f32 { var fd: f32; return fd; }
|
||||
// @builtin(kPosition) p: vec4<f32>,
|
||||
// @builtin(front_facing) ff: bool,
|
||||
// @builtin(sample_index) si: u32,
|
||||
// @builtin(sample_mask) sm : u32
|
||||
// ) -> @builtin(frag_depth) f32 { var fd: f32; return fd; }
|
||||
auto* p = Param("p", ty.vec4<f32>(),
|
||||
ast::DecorationList{Builtin(ast::Builtin::kPosition)});
|
||||
auto* ff = Param("ff", ty.bool_(),
|
||||
|
@ -479,11 +479,11 @@ TEST_F(ResolverBuiltinsValidationTest, FragmentBuiltin_Pass) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, VertexBuiltin_Pass) {
|
||||
// [[stage(vertex)]]
|
||||
// @stage(vertex)
|
||||
// fn main(
|
||||
// [[builtin(vertex_index)]] vi : u32,
|
||||
// [[builtin(instance_index)]] ii : u32,
|
||||
// ) -> [[builtin(position)]] vec4<f32> { var p :vec4<f32>; return p; }
|
||||
// @builtin(vertex_index) vi : u32,
|
||||
// @builtin(instance_index) ii : u32,
|
||||
// ) -> @builtin(position) vec4<f32> { var p :vec4<f32>; return p; }
|
||||
auto* vi = Param("vi", ty.u32(),
|
||||
ast::DecorationList{
|
||||
Builtin(Source{{12, 34}}, ast::Builtin::kVertexIndex)});
|
||||
|
@ -504,13 +504,13 @@ TEST_F(ResolverBuiltinsValidationTest, VertexBuiltin_Pass) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, ComputeBuiltin_Pass) {
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn main(
|
||||
// [[builtin(local_invocationId)]] li_id: vec3<u32>,
|
||||
// [[builtin(local_invocationIndex)]] li_index: u32,
|
||||
// [[builtin(global_invocationId)]] gi: vec3<u32>,
|
||||
// [[builtin(workgroup_id)]] wi: vec3<u32>,
|
||||
// [[builtin(num_workgroups)]] nwgs: vec3<u32>,
|
||||
// @builtin(local_invocationId) li_id: vec3<u32>,
|
||||
// @builtin(local_invocationIndex) li_index: u32,
|
||||
// @builtin(global_invocationId) gi: vec3<u32>,
|
||||
// @builtin(workgroup_id) wi: vec3<u32>,
|
||||
// @builtin(num_workgroups) nwgs: vec3<u32>,
|
||||
// ) {}
|
||||
|
||||
auto* li_id =
|
||||
|
@ -618,13 +618,13 @@ TEST_F(ResolverBuiltinsValidationTest,
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FragmentBuiltinStruct_Pass) {
|
||||
// Struct MyInputs {
|
||||
// [[builtin(kPosition)]] p: vec4<f32>;
|
||||
// [[builtin(frag_depth)]] fd: f32;
|
||||
// [[builtin(sample_index)]] si: u32;
|
||||
// [[builtin(sample_mask)]] sm : u32;;
|
||||
// @builtin(kPosition) p: vec4<f32>;
|
||||
// @builtin(frag_depth) fd: f32;
|
||||
// @builtin(sample_index) si: u32;
|
||||
// @builtin(sample_mask) sm : u32;;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn fragShader(arg: MyInputs) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn fragShader(arg: MyInputs) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* s = Structure(
|
||||
"MyInputs",
|
||||
|
@ -642,10 +642,10 @@ TEST_F(ResolverBuiltinsValidationTest, FragmentBuiltinStruct_Pass) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FrontFacingParamIsNotBool_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn fs_main(
|
||||
// [[builtin(front_facing)]] is_front: i32;
|
||||
// ) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @builtin(front_facing) is_front: i32;
|
||||
// ) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* is_front = Param("is_front", ty.i32(),
|
||||
ast::DecorationList{Builtin(
|
||||
|
@ -661,10 +661,10 @@ TEST_F(ResolverBuiltinsValidationTest, FrontFacingParamIsNotBool_Fail) {
|
|||
|
||||
TEST_F(ResolverBuiltinsValidationTest, FrontFacingMemberIsNotBool_Fail) {
|
||||
// struct MyInputs {
|
||||
// [[builtin(front_facing)]] pos: f32;
|
||||
// @builtin(front_facing) pos: f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn fragShader(is_front: MyInputs) -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn fragShader(is_front: MyInputs) -> @location(0) f32 { return 1.0; }
|
||||
|
||||
auto* s = Structure(
|
||||
"MyInputs", {Member("pos", ty.f32(),
|
||||
|
|
|
@ -172,7 +172,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_FunctionParamWithMain) {
|
|||
// fn bar(p: ptr<function, i32>) {
|
||||
// foo(p);
|
||||
// }
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() {
|
||||
// var v: i32;
|
||||
// bar(&v);
|
||||
|
@ -195,7 +195,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_FunctionParamWithMain) {
|
|||
|
||||
TEST_F(ResolverCallValidationTest, LetPointer) {
|
||||
// fn x(p : ptr<function, i32>) -> i32 {}
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() {
|
||||
// var v: i32;
|
||||
// let p: ptr<function, i32> = &v;
|
||||
|
@ -227,7 +227,7 @@ TEST_F(ResolverCallValidationTest, LetPointerPrivate) {
|
|||
// let p: ptr<private, i32> = &v;
|
||||
// fn foo(p : ptr<private, i32>) -> i32 {}
|
||||
// var v: i32;
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() {
|
||||
// var c: i32 = foo(p);
|
||||
// }
|
||||
|
|
|
@ -973,9 +973,9 @@ TEST_F(ResourceDecorationTest, UniformBufferMissingBinding) {
|
|||
Global(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kUniform);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: resource variables require [[group]] and [[binding]] "
|
||||
"decorations");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: resource variables require @group and @binding decorations)");
|
||||
}
|
||||
|
||||
TEST_F(ResourceDecorationTest, StorageBufferMissingBinding) {
|
||||
|
@ -985,9 +985,9 @@ TEST_F(ResourceDecorationTest, StorageBufferMissingBinding) {
|
|||
ast::Access::kRead);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: resource variables require [[group]] and [[binding]] "
|
||||
"decorations");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: resource variables require @group and @binding decorations)");
|
||||
}
|
||||
|
||||
TEST_F(ResourceDecorationTest, TextureMissingBinding) {
|
||||
|
@ -995,9 +995,9 @@ TEST_F(ResourceDecorationTest, TextureMissingBinding) {
|
|||
ast::StorageClass::kNone);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: resource variables require [[group]] and [[binding]] "
|
||||
"decorations");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: resource variables require @group and @binding decorations)");
|
||||
}
|
||||
|
||||
TEST_F(ResourceDecorationTest, SamplerMissingBinding) {
|
||||
|
@ -1005,9 +1005,9 @@ TEST_F(ResourceDecorationTest, SamplerMissingBinding) {
|
|||
ast::StorageClass::kNone);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: resource variables require [[group]] and [[binding]] "
|
||||
"decorations");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: resource variables require @group and @binding decorations)");
|
||||
}
|
||||
|
||||
TEST_F(ResourceDecorationTest, BindingPairMissingBinding) {
|
||||
|
@ -1018,9 +1018,9 @@ TEST_F(ResourceDecorationTest, BindingPairMissingBinding) {
|
|||
});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: resource variables require [[group]] and [[binding]] "
|
||||
"decorations");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: resource variables require @group and @binding decorations)");
|
||||
}
|
||||
|
||||
TEST_F(ResourceDecorationTest, BindingPairMissingGroup) {
|
||||
|
@ -1031,9 +1031,9 @@ TEST_F(ResourceDecorationTest, BindingPairMissingGroup) {
|
|||
});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: resource variables require [[group]] and [[binding]] "
|
||||
"decorations");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: resource variables require @group and @binding decorations)");
|
||||
}
|
||||
|
||||
TEST_F(ResourceDecorationTest, BindingPointUsedTwiceByEntryPoint) {
|
||||
|
@ -1064,7 +1064,7 @@ TEST_F(ResourceDecorationTest, BindingPointUsedTwiceByEntryPoint) {
|
|||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: entry point 'F' references multiple variables that use the same resource binding [[group(2), binding(1)]]
|
||||
R"(56:78 error: entry point 'F' references multiple variables that use the same resource binding @group(2), @binding(1)
|
||||
12:34 note: first resource binding usage declared here)");
|
||||
}
|
||||
|
||||
|
@ -1108,9 +1108,9 @@ TEST_F(ResourceDecorationTest, BindingPointOnNonResource) {
|
|||
});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: non-resource variables must not have [[group]] or "
|
||||
"[[binding]] decorations");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: non-resource variables must not have @group or @binding decorations)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -1368,9 +1368,9 @@ TEST_F(InterpolateTest, MissingLocationAttribute_Parameter) {
|
|||
ast::DecorationList{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: interpolate attribute must only be used with "
|
||||
"[[location]]");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: interpolate attribute must only be used with @location)");
|
||||
}
|
||||
|
||||
TEST_F(InterpolateTest, MissingLocationAttribute_ReturnType) {
|
||||
|
@ -1381,9 +1381,9 @@ TEST_F(InterpolateTest, MissingLocationAttribute_ReturnType) {
|
|||
ast::InterpolationSampling::kNone)});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: interpolate attribute must only be used with "
|
||||
"[[location]]");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: interpolate attribute must only be used with @location)");
|
||||
}
|
||||
|
||||
TEST_F(InterpolateTest, MissingLocationAttribute_Struct) {
|
||||
|
@ -1393,9 +1393,9 @@ TEST_F(InterpolateTest, MissingLocationAttribute_Struct) {
|
|||
ast::InterpolationSampling::kNone)})});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
"12:34 error: interpolate attribute must only be used with "
|
||||
"[[location]]");
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: interpolate attribute must only be used with @location)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -51,8 +51,8 @@ class ResolverEntryPointValidationTest : public TestHelper,
|
|||
public testing::Test {};
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Location) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main() -> [[location(0)]] f32 { return 1.0; }
|
||||
// @stage(fragment)
|
||||
// fn main() -> @location(0) f32 { return 1.0; }
|
||||
Func(Source{{12, 34}}, "main", {}, ty.f32(), {Return(1.0f)},
|
||||
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
|
||||
|
||||
|
@ -60,8 +60,8 @@ TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Location) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Builtin) {
|
||||
// [[stage(vertex)]]
|
||||
// fn main() -> [[builtin(position)]] vec4<f32> { return vec4<f32>(); }
|
||||
// @stage(vertex)
|
||||
// fn main() -> @builtin(position) vec4<f32> { return vec4<f32>(); }
|
||||
Func(Source{{12, 34}}, "main", {}, ty.vec4<f32>(),
|
||||
{Return(Construct(ty.vec4<f32>()))},
|
||||
{Stage(ast::PipelineStage::kVertex)},
|
||||
|
@ -71,7 +71,7 @@ TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Builtin) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Missing) {
|
||||
// [[stage(vertex)]]
|
||||
// @stage(vertex)
|
||||
// fn main() -> f32 {
|
||||
// return 1.0;
|
||||
// }
|
||||
|
@ -85,8 +85,8 @@ TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Missing) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Multiple) {
|
||||
// [[stage(vertex)]]
|
||||
// fn main() -> [[location(0)]] [[builtin(position)]] vec4<f32> {
|
||||
// @stage(vertex)
|
||||
// fn main() -> @location(0) @builtin(position) vec4<f32> {
|
||||
// return vec4<f32>();
|
||||
// }
|
||||
Func(Source{{12, 34}}, "main", {}, ty.vec4<f32>(),
|
||||
|
@ -102,10 +102,10 @@ TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Multiple) {
|
|||
|
||||
TEST_F(ResolverEntryPointValidationTest, ReturnType_Struct_Valid) {
|
||||
// struct Output {
|
||||
// [[location(0)]] a : f32;
|
||||
// [[builtin(frag_depth)]] b : f32;
|
||||
// @location(0) a : f32;
|
||||
// @builtin(frag_depth) b : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output {
|
||||
// return Output();
|
||||
// }
|
||||
|
@ -122,9 +122,9 @@ TEST_F(ResolverEntryPointValidationTest, ReturnType_Struct_Valid) {
|
|||
TEST_F(ResolverEntryPointValidationTest,
|
||||
ReturnType_Struct_MemberMultipleAttributes) {
|
||||
// struct Output {
|
||||
// [[location(0)]] [[builtin(frag_depth)]] a : f32;
|
||||
// @location(0) @builtin(frag_depth) a : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output {
|
||||
// return Output();
|
||||
// }
|
||||
|
@ -146,10 +146,10 @@ TEST_F(ResolverEntryPointValidationTest,
|
|||
TEST_F(ResolverEntryPointValidationTest,
|
||||
ReturnType_Struct_MemberMissingAttribute) {
|
||||
// struct Output {
|
||||
// [[location(0)]] a : f32;
|
||||
// @location(0) a : f32;
|
||||
// b : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output {
|
||||
// return Output();
|
||||
// }
|
||||
|
@ -168,10 +168,10 @@ TEST_F(ResolverEntryPointValidationTest,
|
|||
|
||||
TEST_F(ResolverEntryPointValidationTest, ReturnType_Struct_DuplicateBuiltins) {
|
||||
// struct Output {
|
||||
// [[builtin(frag_depth)]] a : f32;
|
||||
// [[builtin(frag_depth)]] b : f32;
|
||||
// @builtin(frag_depth) a : f32;
|
||||
// @builtin(frag_depth) b : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output {
|
||||
// return Output();
|
||||
// }
|
||||
|
@ -190,8 +190,8 @@ TEST_F(ResolverEntryPointValidationTest, ReturnType_Struct_DuplicateBuiltins) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Location) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main([[location(0)]] param : f32) {}
|
||||
// @stage(fragment)
|
||||
// fn main(@location(0) param : f32) {}
|
||||
auto* param = Param("param", ty.f32(), {Location(0)});
|
||||
Func(Source{{12, 34}}, "main", {param}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
@ -200,7 +200,7 @@ TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Location) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Missing) {
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param : f32) {}
|
||||
auto* param = Param(Source{{13, 43}}, "param", ty.vec4<f32>());
|
||||
Func(Source{{12, 34}}, "main", {param}, ty.void_(), {},
|
||||
|
@ -212,8 +212,8 @@ TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Missing) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Multiple) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main([[location(0)]] [[builtin(sample_index)]] param : u32) {}
|
||||
// @stage(fragment)
|
||||
// fn main(@location(0) @builtin(sample_index) param : u32) {}
|
||||
auto* param = Param("param", ty.u32(),
|
||||
{Location(Source{{13, 43}}, 0),
|
||||
Builtin(Source{{14, 52}}, ast::Builtin::kSampleIndex)});
|
||||
|
@ -227,10 +227,10 @@ TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Multiple) {
|
|||
|
||||
TEST_F(ResolverEntryPointValidationTest, Parameter_Struct_Valid) {
|
||||
// struct Input {
|
||||
// [[location(0)]] a : f32;
|
||||
// [[builtin(sample_index)]] b : u32;
|
||||
// @location(0) a : f32;
|
||||
// @builtin(sample_index) b : u32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param : Input) {}
|
||||
auto* input = Structure(
|
||||
"Input", {Member("a", ty.f32(), {Location(0)}),
|
||||
|
@ -245,9 +245,9 @@ TEST_F(ResolverEntryPointValidationTest, Parameter_Struct_Valid) {
|
|||
TEST_F(ResolverEntryPointValidationTest,
|
||||
Parameter_Struct_MemberMultipleAttributes) {
|
||||
// struct Input {
|
||||
// [[location(0)]] [[builtin(sample_index)]] a : u32;
|
||||
// @location(0) @builtin(sample_index) a : u32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param : Input) {}
|
||||
auto* input = Structure(
|
||||
"Input",
|
||||
|
@ -267,10 +267,10 @@ TEST_F(ResolverEntryPointValidationTest,
|
|||
TEST_F(ResolverEntryPointValidationTest,
|
||||
Parameter_Struct_MemberMissingAttribute) {
|
||||
// struct Input {
|
||||
// [[location(0)]] a : f32;
|
||||
// @location(0) a : f32;
|
||||
// b : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param : Input) {}
|
||||
auto* input = Structure(
|
||||
"Input", {Member(Source{{13, 43}}, "a", ty.f32(), {Location(0)}),
|
||||
|
@ -285,9 +285,9 @@ TEST_F(ResolverEntryPointValidationTest,
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, Parameter_DuplicateBuiltins) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main([[builtin(sample_index)]] param_a : u32,
|
||||
// [[builtin(sample_index)]] param_b : u32) {}
|
||||
// @stage(fragment)
|
||||
// fn main(@builtin(sample_index) param_a : u32,
|
||||
// @builtin(sample_index) param_b : u32) {}
|
||||
auto* param_a =
|
||||
Param("param_a", ty.u32(), {Builtin(ast::Builtin::kSampleIndex)});
|
||||
auto* param_b =
|
||||
|
@ -304,12 +304,12 @@ TEST_F(ResolverEntryPointValidationTest, Parameter_DuplicateBuiltins) {
|
|||
|
||||
TEST_F(ResolverEntryPointValidationTest, Parameter_Struct_DuplicateBuiltins) {
|
||||
// struct InputA {
|
||||
// [[builtin(sample_index)]] a : u32;
|
||||
// @builtin(sample_index) a : u32;
|
||||
// };
|
||||
// struct InputB {
|
||||
// [[builtin(sample_index)]] a : u32;
|
||||
// @builtin(sample_index) a : u32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param_a : InputA, param_b : InputB) {}
|
||||
auto* input_a = Structure(
|
||||
"InputA", {Member("a", ty.u32(), {Builtin(ast::Builtin::kSampleIndex)})});
|
||||
|
@ -328,7 +328,7 @@ TEST_F(ResolverEntryPointValidationTest, Parameter_Struct_DuplicateBuiltins) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, VertexShaderMustReturnPosition) {
|
||||
// [[stage(vertex)]]
|
||||
// @stage(vertex)
|
||||
// fn main() {}
|
||||
Func(Source{{12, 34}}, "main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kVertex)});
|
||||
|
@ -370,8 +370,8 @@ static constexpr Params cases[] = {
|
|||
};
|
||||
|
||||
TEST_P(TypeValidationTest, BareInputs) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main([[location(0)]] a : *) {}
|
||||
// @stage(fragment)
|
||||
// fn main(@location(0) a : *) {}
|
||||
auto params = GetParam();
|
||||
auto* a = Param("a", params.create_ast_type(*this), {Location(0)});
|
||||
Func(Source{{12, 34}}, "main", {a}, ty.void_(), {},
|
||||
|
@ -386,9 +386,9 @@ TEST_P(TypeValidationTest, BareInputs) {
|
|||
|
||||
TEST_P(TypeValidationTest, StructInputs) {
|
||||
// struct Input {
|
||||
// [[location(0)]] a : *;
|
||||
// @location(0) a : *;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(a : Input) {}
|
||||
auto params = GetParam();
|
||||
auto* input = Structure(
|
||||
|
@ -405,8 +405,8 @@ TEST_P(TypeValidationTest, StructInputs) {
|
|||
}
|
||||
|
||||
TEST_P(TypeValidationTest, BareOutputs) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main() -> [[location(0)]] * {
|
||||
// @stage(fragment)
|
||||
// fn main() -> @location(0) * {
|
||||
// return *();
|
||||
// }
|
||||
auto params = GetParam();
|
||||
|
@ -423,9 +423,9 @@ TEST_P(TypeValidationTest, BareOutputs) {
|
|||
|
||||
TEST_P(TypeValidationTest, StructOutputs) {
|
||||
// struct Output {
|
||||
// [[location(0)]] a : *;
|
||||
// @location(0) a : *;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output {
|
||||
// return Output();
|
||||
// }
|
||||
|
@ -453,8 +453,8 @@ namespace {
|
|||
using LocationDecorationTests = ResolverTest;
|
||||
|
||||
TEST_F(LocationDecorationTests, Pass) {
|
||||
// [[stage(fragment)]]
|
||||
// fn frag_main([[location(0)]] a: i32) {}
|
||||
// @stage(fragment)
|
||||
// fn frag_main(@location(0) a: i32) {}
|
||||
|
||||
auto* p = Param(Source{{12, 34}}, "a", ty.i32(), {Location(0)});
|
||||
Func("frag_main", {p}, ty.void_(), {},
|
||||
|
@ -464,8 +464,8 @@ TEST_F(LocationDecorationTests, Pass) {
|
|||
}
|
||||
|
||||
TEST_F(LocationDecorationTests, BadType_Input_bool) {
|
||||
// [[stage(fragment)]]
|
||||
// fn frag_main([[location(0)]] a: bool) {}
|
||||
// @stage(fragment)
|
||||
// fn frag_main(@location(0) a: bool) {}
|
||||
|
||||
auto* p =
|
||||
Param(Source{{12, 34}}, "a", ty.bool_(), {Location(Source{{34, 56}}, 0)});
|
||||
|
@ -481,8 +481,8 @@ TEST_F(LocationDecorationTests, BadType_Input_bool) {
|
|||
}
|
||||
|
||||
TEST_F(LocationDecorationTests, BadType_Output_Array) {
|
||||
// [[stage(fragment)]]
|
||||
// fn frag_main()->[[location(0)]] array<f32, 2> { return array<f32, 2>(); }
|
||||
// @stage(fragment)
|
||||
// fn frag_main()->@location(0) array<f32, 2> { return array<f32, 2>(); }
|
||||
|
||||
Func(Source{{12, 34}}, "frag_main", {}, ty.array<f32, 2>(),
|
||||
{Return(Construct(ty.array<f32, 2>()))},
|
||||
|
@ -500,8 +500,8 @@ TEST_F(LocationDecorationTests, BadType_Input_Struct) {
|
|||
// struct Input {
|
||||
// a : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn main([[location(0)]] param : Input) {}
|
||||
// @stage(fragment)
|
||||
// fn main(@location(0) param : Input) {}
|
||||
auto* input = Structure("Input", {Member("a", ty.f32())});
|
||||
auto* param = Param(Source{{12, 34}}, "param", ty.Of(input),
|
||||
{Location(Source{{13, 43}}, 0)});
|
||||
|
@ -518,12 +518,12 @@ TEST_F(LocationDecorationTests, BadType_Input_Struct) {
|
|||
|
||||
TEST_F(LocationDecorationTests, BadType_Input_Struct_NestedStruct) {
|
||||
// struct Inner {
|
||||
// [[location(0)]] b : f32;
|
||||
// @location(0) b : f32;
|
||||
// };
|
||||
// struct Input {
|
||||
// a : Inner;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param : Input) {}
|
||||
auto* inner = Structure(
|
||||
"Inner", {Member(Source{{13, 43}}, "a", ty.f32(), {Location(0)})});
|
||||
|
@ -542,9 +542,9 @@ TEST_F(LocationDecorationTests, BadType_Input_Struct_NestedStruct) {
|
|||
TEST_F(LocationDecorationTests, BadType_Input_Struct_RuntimeArray) {
|
||||
// [[block]]
|
||||
// struct Input {
|
||||
// [[location(0)]] a : array<f32>;
|
||||
// @location(0) a : array<f32>;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param : Input) {}
|
||||
auto* input = Structure(
|
||||
"Input",
|
||||
|
@ -564,8 +564,8 @@ TEST_F(LocationDecorationTests, BadType_Input_Struct_RuntimeArray) {
|
|||
|
||||
TEST_F(LocationDecorationTests, BadMemberType_Input) {
|
||||
// [[block]]
|
||||
// struct S { [[location(0)]] m: array<i32>; };
|
||||
// [[stage(fragment)]]
|
||||
// struct S { @location(0) m: array<i32>; };
|
||||
// @stage(fragment)
|
||||
// fn frag_main( a: S) {}
|
||||
|
||||
auto* m = Member(Source{{34, 56}}, "m", ty.array<i32>(),
|
||||
|
@ -585,8 +585,8 @@ TEST_F(LocationDecorationTests, BadMemberType_Input) {
|
|||
}
|
||||
|
||||
TEST_F(LocationDecorationTests, BadMemberType_Output) {
|
||||
// struct S { [[location(0)]] m: atomic<i32>; };
|
||||
// [[stage(fragment)]]
|
||||
// struct S { @location(0) m: atomic<i32>; };
|
||||
// @stage(fragment)
|
||||
// fn frag_main() -> S {}
|
||||
auto* m = Member(Source{{34, 56}}, "m", ty.atomic<i32>(),
|
||||
ast::DecorationList{Location(Source{{12, 34}}, 0u)});
|
||||
|
@ -604,7 +604,7 @@ TEST_F(LocationDecorationTests, BadMemberType_Output) {
|
|||
}
|
||||
|
||||
TEST_F(LocationDecorationTests, BadMemberType_Unused) {
|
||||
// struct S { [[location(0)]] m: mat3x2<f32>; };
|
||||
// struct S { @location(0) m: mat3x2<f32>; };
|
||||
|
||||
auto* m = Member(Source{{34, 56}}, "m", ty.mat3x2<f32>(),
|
||||
ast::DecorationList{Location(Source{{12, 34}}, 0u)});
|
||||
|
@ -620,10 +620,10 @@ TEST_F(LocationDecorationTests, BadMemberType_Unused) {
|
|||
|
||||
TEST_F(LocationDecorationTests, ReturnType_Struct_Valid) {
|
||||
// struct Output {
|
||||
// [[location(0)]] a : f32;
|
||||
// [[builtin(frag_depth)]] b : f32;
|
||||
// @location(0) a : f32;
|
||||
// @builtin(frag_depth) b : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output {
|
||||
// return Output();
|
||||
// }
|
||||
|
@ -641,8 +641,8 @@ TEST_F(LocationDecorationTests, ReturnType_Struct) {
|
|||
// struct Output {
|
||||
// a : f32;
|
||||
// };
|
||||
// [[stage(vertex)]]
|
||||
// fn main() -> [[location(0)]] Output {
|
||||
// @stage(vertex)
|
||||
// fn main() -> @location(0) Output {
|
||||
// return Output();
|
||||
// }
|
||||
auto* output = Structure("Output", {Member("a", ty.f32())});
|
||||
|
@ -660,12 +660,12 @@ TEST_F(LocationDecorationTests, ReturnType_Struct) {
|
|||
|
||||
TEST_F(LocationDecorationTests, ReturnType_Struct_NestedStruct) {
|
||||
// struct Inner {
|
||||
// [[location(0)]] b : f32;
|
||||
// @location(0) b : f32;
|
||||
// };
|
||||
// struct Output {
|
||||
// a : Inner;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output { return Output(); }
|
||||
auto* inner = Structure(
|
||||
"Inner", {Member(Source{{13, 43}}, "a", ty.f32(), {Location(0)})});
|
||||
|
@ -684,9 +684,9 @@ TEST_F(LocationDecorationTests, ReturnType_Struct_NestedStruct) {
|
|||
TEST_F(LocationDecorationTests, ReturnType_Struct_RuntimeArray) {
|
||||
// [[block]]
|
||||
// struct Output {
|
||||
// [[location(0)]] a : array<f32>;
|
||||
// @location(0) a : array<f32>;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main() -> Output {
|
||||
// return Output();
|
||||
// }
|
||||
|
@ -760,9 +760,9 @@ TEST_F(LocationDecorationTests, ComputeShaderLocationStructMember_Input) {
|
|||
}
|
||||
|
||||
TEST_F(LocationDecorationTests, Duplicate_input) {
|
||||
// [[stage(fragment)]]
|
||||
// fn main([[location(1)]] param_a : f32,
|
||||
// [[location(1)]] param_b : f32) {}
|
||||
// @stage(fragment)
|
||||
// fn main(@location(1) param_a : f32,
|
||||
// @location(1) param_b : f32) {}
|
||||
auto* param_a = Param("param_a", ty.f32(), {Location(1)});
|
||||
auto* param_b = Param("param_b", ty.f32(), {Location(Source{{12, 34}}, 1)});
|
||||
Func(Source{{12, 34}}, "main", {param_a, param_b}, ty.void_(), {},
|
||||
|
@ -775,12 +775,12 @@ TEST_F(LocationDecorationTests, Duplicate_input) {
|
|||
|
||||
TEST_F(LocationDecorationTests, Duplicate_struct) {
|
||||
// struct InputA {
|
||||
// [[location(1)]] a : f32;
|
||||
// @location(1) a : f32;
|
||||
// };
|
||||
// struct InputB {
|
||||
// [[location(1)]] a : f32;
|
||||
// @location(1) a : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn main(param_a : InputA, param_b : InputB) {}
|
||||
auto* input_a = Structure("InputA", {Member("a", ty.f32(), {Location(1)})});
|
||||
auto* input_b = Structure(
|
||||
|
|
|
@ -353,7 +353,7 @@ TEST_F(ResolverFunctionValidationTest,
|
|||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, CannotCallEntryPoint) {
|
||||
// [[stage(compute), workgroup_size(1)]] fn entrypoint() {}
|
||||
// @stage(compute) @workgroup_size(1) fn entrypoint() {}
|
||||
// fn func() { return entrypoint(); }
|
||||
Func("entrypoint", ast::VariableList{}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1)});
|
||||
|
@ -371,8 +371,8 @@ TEST_F(ResolverFunctionValidationTest, CannotCallEntryPoint) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, PipelineStage_MustBeUnique_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// [[stage(vertex)]]
|
||||
// @stage(fragment)
|
||||
// @stage(vertex)
|
||||
// fn main() { return; }
|
||||
Func(Source{{12, 34}}, "main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
|
@ -440,7 +440,7 @@ TEST_F(ResolverFunctionValidationTest, FunctionParamsConst) {
|
|||
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_GoodType_ConstU32) {
|
||||
// let x = 4u;
|
||||
// let x = 8u;
|
||||
// [[stage(compute), workgroup_size(x, y, 16u)]]
|
||||
// @stage(compute) @workgroup_size(x, y, 16u)
|
||||
// fn main() {}
|
||||
auto* x = GlobalConst("x", ty.u32(), Expr(4u));
|
||||
auto* y = GlobalConst("y", ty.u32(), Expr(8u));
|
||||
|
|
|
@ -36,7 +36,7 @@ TEST_F(ResolverIntrinsicValidationTest,
|
|||
}
|
||||
|
||||
TEST_F(ResolverIntrinsicValidationTest, InvalidPipelineStageDirect) {
|
||||
// [[stage(compute), workgroup_size(1)]] fn func { return dpdx(1.0); }
|
||||
// @stage(compute) @workgroup_size(1) fn func { return dpdx(1.0); }
|
||||
|
||||
auto* dpdx = create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"),
|
||||
ast::ExpressionList{Expr(1.0f)});
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ResolverIntrinsicValidationTest, InvalidPipelineStageIndirect) {
|
|||
// fn f0 { return dpdx(1.0); }
|
||||
// fn f1 { f0(); }
|
||||
// fn f2 { f1(); }
|
||||
// [[stage(compute), workgroup_size(1)]] fn main { return f2(); }
|
||||
// @stage(compute) @workgroup_size(1) fn main { return f2(); }
|
||||
|
||||
auto* dpdx = create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"),
|
||||
ast::ExpressionList{Expr(1.0f)});
|
||||
|
|
|
@ -53,7 +53,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfLet) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverPtrRefValidationTest, AddressOfHandle) {
|
||||
// [[group(0), binding(0)]] var t: texture_3d<f32>;
|
||||
// @group(0) @binding(0) var t: texture_3d<f32>;
|
||||
// &t
|
||||
Global("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()),
|
||||
GroupAndBinding(0u, 0u));
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_IndexAccessor) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverPtrRefValidationTest, IndirectOfAddressOfHandle) {
|
||||
// [[group(0), binding(0)]] var t: texture_3d<f32>;
|
||||
// @group(0) @binding(0) var t: texture_3d<f32>;
|
||||
// *&t
|
||||
Global("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()),
|
||||
GroupAndBinding(0u, 0u));
|
||||
|
@ -142,7 +142,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
|
|||
// [[block]] struct S {
|
||||
// inner: Inner;
|
||||
// }
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
// fn f() {
|
||||
// let p : pointer<storage, i32> = &s.inner.arr[2];
|
||||
// }
|
||||
|
|
|
@ -2151,7 +2151,7 @@ sem::Array* Resolver::Array(const ast::Array* arr) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// Look for explicit stride via [[stride(n)]] decoration
|
||||
// Look for explicit stride via @stride(n) decoration
|
||||
uint32_t explicit_stride = 0;
|
||||
for (auto* deco : arr->decorations) {
|
||||
Mark(deco);
|
||||
|
|
|
@ -920,7 +920,7 @@ TEST_F(ResolverTest, Function_CallSites) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_NotSet) {
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn main() {}
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_(), {}, {});
|
||||
|
||||
|
@ -938,7 +938,7 @@ TEST_F(ResolverTest, Function_WorkgroupSize_NotSet) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_Literals) {
|
||||
// [[stage(compute), workgroup_size(8, 2, 3)]]
|
||||
// @stage(compute) @workgroup_size(8, 2, 3)
|
||||
// fn main() {}
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_(), {},
|
||||
|
@ -961,7 +961,7 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Consts) {
|
|||
// let width = 16;
|
||||
// let height = 8;
|
||||
// let depth = 2;
|
||||
// [[stage(compute), workgroup_size(width, height, depth)]]
|
||||
// @stage(compute) @workgroup_size(width, height, depth)
|
||||
// fn main() {}
|
||||
GlobalConst("width", ty.i32(), Expr(16));
|
||||
GlobalConst("height", ty.i32(), Expr(8));
|
||||
|
@ -986,7 +986,7 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Consts) {
|
|||
TEST_F(ResolverTest, Function_WorkgroupSize_Consts_NestedInitializer) {
|
||||
// let width = i32(i32(i32(8)));
|
||||
// let height = i32(i32(i32(4)));
|
||||
// [[stage(compute), workgroup_size(width, height)]]
|
||||
// @stage(compute) @workgroup_size(width, height)
|
||||
// fn main() {}
|
||||
GlobalConst("width", ty.i32(),
|
||||
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 8))));
|
||||
|
@ -1010,10 +1010,10 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Consts_NestedInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts) {
|
||||
// [[override(0)]] let width = 16;
|
||||
// [[override(1)]] let height = 8;
|
||||
// [[override(2)]] let depth = 2;
|
||||
// [[stage(compute), workgroup_size(width, height, depth)]]
|
||||
// @override(0) let width = 16;
|
||||
// @override(1) let height = 8;
|
||||
// @override(2) let depth = 2;
|
||||
// @stage(compute) @workgroup_size(width, height, depth)
|
||||
// fn main() {}
|
||||
auto* width = GlobalConst("width", ty.i32(), Expr(16), {Override(0)});
|
||||
auto* height = GlobalConst("height", ty.i32(), Expr(8), {Override(1)});
|
||||
|
@ -1036,10 +1036,10 @@ TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts_NoInit) {
|
||||
// [[override(0)]] let width : i32;
|
||||
// [[override(1)]] let height : i32;
|
||||
// [[override(2)]] let depth : i32;
|
||||
// [[stage(compute), workgroup_size(width, height, depth)]]
|
||||
// @override(0) let width : i32;
|
||||
// @override(1) let height : i32;
|
||||
// @override(2) let depth : i32;
|
||||
// @stage(compute) @workgroup_size(width, height, depth)
|
||||
// fn main() {}
|
||||
auto* width = GlobalConst("width", ty.i32(), nullptr, {Override(0)});
|
||||
auto* height = GlobalConst("height", ty.i32(), nullptr, {Override(1)});
|
||||
|
@ -1062,9 +1062,9 @@ TEST_F(ResolverTest, Function_WorkgroupSize_OverridableConsts_NoInit) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Function_WorkgroupSize_Mixed) {
|
||||
// [[override(1)]] let height = 2;
|
||||
// @override(1) let height = 2;
|
||||
// let depth = 3;
|
||||
// [[stage(compute), workgroup_size(8, height, depth)]]
|
||||
// @stage(compute) @workgroup_size(8, height, depth)
|
||||
// fn main() {}
|
||||
auto* height = GlobalConst("height", ty.i32(), Expr(2), {Override(0)});
|
||||
GlobalConst("depth", ty.i32(), Expr(3));
|
||||
|
@ -1816,8 +1816,8 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, BindingPoint_SetForResources) {
|
||||
// [[group(1), binding(2)]] var s1 : sampler;
|
||||
// [[group(3), binding(4)]] var s2 : sampler;
|
||||
// @group(1) @binding(2) var s1 : sampler;
|
||||
// @group(3) @binding(4) var s2 : sampler;
|
||||
auto* s1 = Global(Sym(), ty.sampler(ast::SamplerKind::kSampler),
|
||||
ast::DecorationList{create<ast::GroupDecoration>(1),
|
||||
create<ast::BindingDecoration>(2)});
|
||||
|
|
|
@ -271,8 +271,8 @@ bool Resolver::ValidateStorageClassLayout(const sem::Struct* str,
|
|||
"' must be a multiple of " + std::to_string(required_align) +
|
||||
" bytes, but '" + member_name_of(m) +
|
||||
"' is currently at offset " + std::to_string(m->Offset()) +
|
||||
". Consider setting [[align(" +
|
||||
std::to_string(required_align) + ")]] on this member",
|
||||
". Consider setting @align(" +
|
||||
std::to_string(required_align) + ") on this member",
|
||||
m->Declaration()->source);
|
||||
|
||||
AddNote("see layout of struct:\n" + str->Layout(builder_->Symbols()),
|
||||
|
@ -299,7 +299,7 @@ bool Resolver::ValidateStorageClassLayout(const sem::Struct* str,
|
|||
"member be a multiple of 16 bytes, but there are currently " +
|
||||
std::to_string(prev_to_curr_offset) + " bytes between '" +
|
||||
member_name_of(prev_member) + "' and '" + member_name_of(m) +
|
||||
"'. Consider setting [[align(16)]] on this member",
|
||||
"'. Consider setting @align(16) on this member",
|
||||
m->Declaration()->source);
|
||||
|
||||
AddNote("see layout of struct:\n" + str->Layout(builder_->Symbols()),
|
||||
|
@ -326,10 +326,10 @@ bool Resolver::ValidateStorageClassLayout(const sem::Struct* str,
|
|||
"bytes, but array stride of '" +
|
||||
member_name_of(m) + "' is currently " +
|
||||
std::to_string(arr->Stride()) +
|
||||
". Consider setting [[stride(" +
|
||||
". Consider setting @stride(" +
|
||||
std::to_string(
|
||||
utils::RoundUp(required_align, arr->Stride())) +
|
||||
")]] on the array type",
|
||||
") on the array type",
|
||||
m->Declaration()->type->source);
|
||||
AddNote("see layout of struct:\n" + str->Layout(builder_->Symbols()),
|
||||
str->Declaration()->source);
|
||||
|
@ -429,7 +429,7 @@ bool Resolver::ValidateGlobalVariable(const sem::Variable* var) {
|
|||
// attributes.
|
||||
if (!binding_point) {
|
||||
AddError(
|
||||
"resource variables require [[group]] and [[binding]] "
|
||||
"resource variables require @group and @binding "
|
||||
"decorations",
|
||||
decl->source);
|
||||
return false;
|
||||
|
@ -441,7 +441,7 @@ bool Resolver::ValidateGlobalVariable(const sem::Variable* var) {
|
|||
// https://gpuweb.github.io/gpuweb/wgsl/#attribute-binding
|
||||
// Must only be applied to a resource variable
|
||||
AddError(
|
||||
"non-resource variables must not have [[group]] or [[binding]] "
|
||||
"non-resource variables must not have @group or @binding "
|
||||
"decorations",
|
||||
decl->source);
|
||||
return false;
|
||||
|
@ -1037,7 +1037,7 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
|||
if (interpolate_attribute) {
|
||||
if (!pipeline_io_attribute ||
|
||||
!pipeline_io_attribute->Is<ast::LocationDecoration>()) {
|
||||
AddError("interpolate attribute must only be used with [[location]]",
|
||||
AddError("interpolate attribute must only be used with @location",
|
||||
interpolate_attribute->source);
|
||||
return false;
|
||||
}
|
||||
|
@ -1167,9 +1167,9 @@ bool Resolver::ValidateEntryPoint(const sem::Function* func) {
|
|||
auto func_name = builder_->Symbols().NameFor(decl->symbol);
|
||||
AddError("entry point '" + func_name +
|
||||
"' references multiple variables that use the "
|
||||
"same resource binding [[group(" +
|
||||
std::to_string(bp.group) + "), binding(" +
|
||||
std::to_string(bp.binding) + ")]]",
|
||||
"same resource binding @group(" +
|
||||
std::to_string(bp.group) + "), @binding(" +
|
||||
std::to_string(bp.binding) + ")",
|
||||
var_decl->source);
|
||||
AddNote("first resource binding usage declared here",
|
||||
res.first->second->source);
|
||||
|
@ -2035,7 +2035,7 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
|
|||
}
|
||||
|
||||
if (interpolate_attribute && !has_location) {
|
||||
AddError("interpolate attribute must only be used with [[location]]",
|
||||
AddError("interpolate attribute must only be used with @location",
|
||||
interpolate_attribute->source);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
StorageBuffer_UnalignedMember) {
|
||||
// [[block]]
|
||||
// struct S {
|
||||
// [[size(5)]] a : f32;
|
||||
// [[align(1)]] b : f32;
|
||||
// @size(5) a : f32;
|
||||
// @align(1) b : f32;
|
||||
// };
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<storage> a : S;
|
||||
|
||||
Structure(Source{{12, 34}}, "S",
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(34:56 error: the offset of a struct member of type 'f32' in storage class 'storage' must be a multiple of 4 bytes, but 'b' is currently at offset 5. Consider setting [[align(4)]] on this member
|
||||
R"(34:56 error: the offset of a struct member of type 'f32' in storage class 'storage' must be a multiple of 4 bytes, but 'b' is currently at offset 5. Consider setting @align(4) on this member
|
||||
12:34 note: see layout of struct:
|
||||
/* align(4) size(12) */ struct S {
|
||||
/* offset(0) align(4) size( 5) */ a : f32;
|
||||
|
@ -59,10 +59,10 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
StorageBuffer_UnalignedMember_SuggestedFix) {
|
||||
// [[block]]
|
||||
// struct S {
|
||||
// [[size(5)]] a : f32;
|
||||
// [[align(4)]] b : f32;
|
||||
// @size(5) a : f32;
|
||||
// @align(4) b : f32;
|
||||
// };
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<storage> a : S;
|
||||
|
||||
Structure(Source{{12, 34}}, "S",
|
||||
|
@ -89,7 +89,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// inner : Inner;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Structure(Source{{12, 34}}, "Inner", {Member("scalar", ty.i32())});
|
||||
|
@ -107,7 +107,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: the offset of a struct member of type 'Inner' in storage class 'uniform' must be a multiple of 16 bytes, but 'inner' is currently at offset 4. Consider setting [[align(16)]] on this member
|
||||
R"(56:78 error: the offset of a struct member of type 'Inner' in storage class 'uniform' must be a multiple of 16 bytes, but 'inner' is currently at offset 4. Consider setting @align(16) on this member
|
||||
34:56 note: see layout of struct:
|
||||
/* align(4) size(8) */ struct Outer {
|
||||
/* offset(0) align(4) size(4) */ scalar : f32;
|
||||
|
@ -129,10 +129,10 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// [[block]]
|
||||
// struct Outer {
|
||||
// scalar : f32;
|
||||
// [[align(16)]] inner : Inner;
|
||||
// @align(16) inner : Inner;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Structure(Source{{12, 34}}, "Inner", {Member("scalar", ty.i32())});
|
||||
|
@ -154,7 +154,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// Detect unaligned array member for uniform buffers
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest,
|
||||
UniformBuffer_UnalignedMember_Array) {
|
||||
// type Inner = [[stride(16)]] array<f32, 10>;
|
||||
// type Inner = @stride(16) array<f32, 10>;
|
||||
//
|
||||
// [[block]]
|
||||
// struct Outer {
|
||||
|
@ -162,7 +162,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// inner : Inner;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
Alias("Inner", ty.array(ty.f32(), 10, 16));
|
||||
|
||||
|
@ -179,26 +179,26 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(56:78 error: the offset of a struct member of type '[[stride(16)]] array<f32, 10>' in storage class 'uniform' must be a multiple of 16 bytes, but 'inner' is currently at offset 4. Consider setting [[align(16)]] on this member
|
||||
R"(56:78 error: the offset of a struct member of type '@stride(16) array<f32, 10>' in storage class 'uniform' must be a multiple of 16 bytes, but 'inner' is currently at offset 4. Consider setting @align(16) on this member
|
||||
12:34 note: see layout of struct:
|
||||
/* align(4) size(164) */ struct Outer {
|
||||
/* offset( 0) align(4) size( 4) */ scalar : f32;
|
||||
/* offset( 4) align(4) size(160) */ inner : [[stride(16)]] array<f32, 10>;
|
||||
/* offset( 4) align(4) size(160) */ inner : @stride(16) array<f32, 10>;
|
||||
/* */ };
|
||||
78:90 note: see declaration of variable)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest,
|
||||
UniformBuffer_UnalignedMember_Array_SuggestedFix) {
|
||||
// type Inner = [[stride(16)]] array<f32, 10>;
|
||||
// type Inner = @stride(16) array<f32, 10>;
|
||||
//
|
||||
// [[block]]
|
||||
// struct Outer {
|
||||
// scalar : f32;
|
||||
// [[align(16)]] inner : Inner;
|
||||
// @align(16) inner : Inner;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
Alias("Inner", ty.array(ty.f32(), 10, 16));
|
||||
|
||||
|
@ -221,7 +221,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
TEST_F(ResolverStorageClassLayoutValidationTest,
|
||||
UniformBuffer_MembersOffsetNotMultipleOf16) {
|
||||
// struct Inner {
|
||||
// [[align(1), size(5)]] scalar : i32;
|
||||
// @align(1) @size(5) scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[block]]
|
||||
|
@ -230,7 +230,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Structure(Source{{12, 34}}, "Inner",
|
||||
|
@ -249,7 +249,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(78:90 error: uniform storage requires that the number of bytes between the start of the previous member of type struct and the current member be a multiple of 16 bytes, but there are currently 8 bytes between 'inner' and 'scalar'. Consider setting [[align(16)]] on this member
|
||||
R"(78:90 error: uniform storage requires that the number of bytes between the start of the previous member of type struct and the current member be a multiple of 16 bytes, but there are currently 8 bytes between 'inner' and 'scalar'. Consider setting @align(16) on this member
|
||||
34:56 note: see layout of struct:
|
||||
/* align(4) size(12) */ struct Outer {
|
||||
/* offset( 0) align(1) size( 5) */ inner : Inner;
|
||||
|
@ -270,7 +270,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// a : i32;
|
||||
// b : i32;
|
||||
// c : i32;
|
||||
// [[align(1), size(5)]] scalar : i32;
|
||||
// @align(1) @size(5) scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[block]]
|
||||
|
@ -279,7 +279,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Structure(Source{{12, 34}}, "Inner",
|
||||
|
@ -303,7 +303,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(78:90 error: uniform storage requires that the number of bytes between the start of the previous member of type struct and the current member be a multiple of 16 bytes, but there are currently 20 bytes between 'inner' and 'scalar'. Consider setting [[align(16)]] on this member
|
||||
R"(78:90 error: uniform storage requires that the number of bytes between the start of the previous member of type struct and the current member be a multiple of 16 bytes, but there are currently 20 bytes between 'inner' and 'scalar'. Consider setting @align(16) on this member
|
||||
34:56 note: see layout of struct:
|
||||
/* align(4) size(24) */ struct Outer {
|
||||
/* offset( 0) align(4) size(20) */ inner : Inner;
|
||||
|
@ -323,16 +323,16 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
TEST_F(ResolverStorageClassLayoutValidationTest,
|
||||
UniformBuffer_MembersOffsetNotMultipleOf16_SuggestedFix) {
|
||||
// struct Inner {
|
||||
// [[align(1), size(5)]] scalar : i32;
|
||||
// @align(1) @size(5) scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[block]]
|
||||
// struct Outer {
|
||||
// [[align(16)]] inner : Inner;
|
||||
// @align(16) inner : Inner;
|
||||
// scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Structure(Source{{12, 34}}, "Inner",
|
||||
|
@ -360,7 +360,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// v : vec3<f32>;
|
||||
// s : f32;
|
||||
// };
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : ScalarPackedAtEndOfVec3;
|
||||
|
||||
Structure("ScalarPackedAtEndOfVec3",
|
||||
|
@ -379,7 +379,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// Detect array stride must be a multiple of 16 bytes for uniform buffers
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest,
|
||||
UniformBuffer_InvalidArrayStride) {
|
||||
// type Inner = [[stride(8)]] array<f32, 10>;
|
||||
// type Inner = @stride(8) array<f32, 10>;
|
||||
//
|
||||
// [[block]]
|
||||
// struct Outer {
|
||||
|
@ -387,7 +387,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Alias("Inner", ty.array(ty.f32(), 10, 8));
|
||||
|
@ -405,10 +405,10 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(34:56 error: uniform storage requires that array elements be aligned to 16 bytes, but array stride of 'inner' is currently 8. Consider setting [[stride(16)]] on the array type
|
||||
R"(34:56 error: uniform storage requires that array elements be aligned to 16 bytes, but array stride of 'inner' is currently 8. Consider setting @stride(16) on the array type
|
||||
12:34 note: see layout of struct:
|
||||
/* align(4) size(84) */ struct Outer {
|
||||
/* offset( 0) align(4) size(80) */ inner : [[stride(8)]] array<f32, 10>;
|
||||
/* offset( 0) align(4) size(80) */ inner : @stride(8) array<f32, 10>;
|
||||
/* offset(80) align(4) size( 4) */ scalar : i32;
|
||||
/* */ };
|
||||
78:90 note: see declaration of variable)");
|
||||
|
@ -416,7 +416,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
|
||||
TEST_F(ResolverStorageClassLayoutValidationTest,
|
||||
UniformBuffer_InvalidArrayStride_SuggestedFix) {
|
||||
// type Inner = [[stride(16)]] array<f32, 10>;
|
||||
// type Inner = @stride(16) array<f32, 10>;
|
||||
//
|
||||
// [[block]]
|
||||
// struct Outer {
|
||||
|
@ -424,7 +424,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
|
|||
// scalar : i32;
|
||||
// };
|
||||
//
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var<uniform> a : Outer;
|
||||
|
||||
Alias("Inner", ty.array(ty.f32(), 10, 16));
|
||||
|
|
|
@ -226,7 +226,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
|
|||
|
||||
TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) {
|
||||
// [[block]] struct S { m: array<f32>; };
|
||||
// [[group(0), binding(0)]] var<uniform, > svar : S;
|
||||
// @group(0) @binding(0) var<uniform, > svar : S;
|
||||
|
||||
auto* s = Structure(Source{{12, 34}}, "S", {Member("m", ty.array<i32>())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
|
|
|
@ -79,7 +79,7 @@ TEST_F(ResolverTypeValidationTest, VariableDeclNoConstructor_Pass) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, GlobalConstantNoConstructor_Pass) {
|
||||
// [[override(0)]] let a :i32;
|
||||
// @override(0) let a :i32;
|
||||
GlobalConst(Source{{12, 34}}, "a", ty.i32(), nullptr,
|
||||
ast::DecorationList{create<ast::OverrideDecoration>(0)});
|
||||
|
||||
|
@ -336,7 +336,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ExplicitStride) {
|
||||
// var<private> a : [[stride(8)]] array<f32, 0x20000000>;
|
||||
// var<private> a : @stride(8) array<f32, 0x20000000>;
|
||||
Global("a", ty.array(Source{{12, 34}}, ty.f32(), 0x20000000, 8),
|
||||
ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -396,7 +396,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_InvalidExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, RuntimeArrayInFunction_Fail) {
|
||||
/// [[stage(vertex)]]
|
||||
/// @stage(vertex)
|
||||
// fn func() { var a : array<i32>; }
|
||||
|
||||
auto* var =
|
||||
|
@ -594,7 +594,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayAsLocalVariable) {
|
|||
|
||||
TEST_F(ResolverTypeValidationTest, RuntimeArrayAsParameter_Fail) {
|
||||
// fn func(a : array<u32>) {}
|
||||
// [[stage(vertex)]] fn main() {}
|
||||
// @stage(vertex) fn main() {}
|
||||
|
||||
auto* param = Param(Source{{12, 34}}, "a", ty.array<i32>());
|
||||
|
||||
|
@ -855,7 +855,7 @@ static constexpr DimensionParams Dimension_cases[] = {
|
|||
|
||||
using StorageTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
||||
TEST_P(StorageTextureDimensionTest, All) {
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_*<ru32int, write>;
|
||||
auto& params = GetParam();
|
||||
|
||||
|
@ -905,13 +905,13 @@ static constexpr FormatParams format_cases[] = {
|
|||
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
|
||||
TEST_P(StorageTextureFormatTest, All) {
|
||||
auto& params = GetParam();
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<*, write>;
|
||||
// [[group(0), binding(1)]]
|
||||
// @group(0) @binding(1)
|
||||
// var b : texture_storage_2d<*, write>;
|
||||
// [[group(0), binding(2)]]
|
||||
// @group(0) @binding(2)
|
||||
// var c : texture_storage_2d_array<*, write>;
|
||||
// [[group(0), binding(3)]]
|
||||
// @group(0) @binding(3)
|
||||
// var d : texture_storage_3d<*, write>;
|
||||
|
||||
auto* st_a = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
|
@ -951,7 +951,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
|||
using StorageTextureAccessTest = ResolverTest;
|
||||
|
||||
TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int>;
|
||||
|
||||
auto* st =
|
||||
|
@ -967,7 +967,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int, read_write>;
|
||||
|
||||
auto* st =
|
||||
|
@ -984,7 +984,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int, read>;
|
||||
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
|
@ -1000,7 +1000,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
|
||||
// [[group(0), binding(0)]]
|
||||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int, write>;
|
||||
|
||||
auto* st =
|
||||
|
|
|
@ -80,7 +80,7 @@ TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInFragmentStage) {
|
|||
// var<workgroup> dst : vec4<f32>;
|
||||
// fn f2(){ dst = wg; }
|
||||
// fn f1() { f2(); }
|
||||
// [[stage(fragment)]]
|
||||
// @stage(fragment)
|
||||
// fn f0() {
|
||||
// f1();
|
||||
//}
|
||||
|
|
|
@ -288,7 +288,7 @@ TEST_F(ResolverVarLetTest, LetInheritsAccessFromOriginatingVariable) {
|
|||
// [[block]] struct S {
|
||||
// inner: Inner;
|
||||
// }
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
// fn f() {
|
||||
// let p = &s.inner.arr[2];
|
||||
// }
|
||||
|
|
|
@ -79,7 +79,7 @@ TEST_F(ResolverVarLetValidationTest, VarTypeNotStorable) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, LetTypeNotConstructible) {
|
||||
// [[group(0), binding(0)]] var t1 : texture_2d<f32>;
|
||||
// @group(0) @binding(0) var t1 : texture_2d<f32>;
|
||||
// let t2 : t1;
|
||||
auto* t1 =
|
||||
Global("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
|
@ -223,7 +223,7 @@ TEST_F(ResolverVarLetValidationTest, InferredPtrStorageAccessMismatch) {
|
|||
// [[block]] struct S {
|
||||
// inner: Inner;
|
||||
// }
|
||||
// [[group(0), binding(0)]] var<storage> s : S;
|
||||
// @group(0) @binding(0) var<storage> s : S;
|
||||
// fn f() {
|
||||
// let p : pointer<storage, i32, read_write> = &s.inner.arr[2];
|
||||
// }
|
||||
|
@ -286,7 +286,7 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_Struct_WithAtomic) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, NonConstructibleType_InferredType) {
|
||||
// [[group(0), binding(0)]] var s : sampler;
|
||||
// @group(0) @binding(0) var s : sampler;
|
||||
// fn foo() {
|
||||
// var v = s;
|
||||
// }
|
||||
|
|
|
@ -58,7 +58,7 @@ std::string Array::type_name() const {
|
|||
std::string Array::FriendlyName(const SymbolTable& symbols) const {
|
||||
std::ostringstream out;
|
||||
if (!IsStrideImplicit()) {
|
||||
out << "[[stride(" << stride_ << ")]] ";
|
||||
out << "@stride(" << stride_ << ") ";
|
||||
}
|
||||
out << "array<" << element_->FriendlyName(symbols);
|
||||
if (!IsRuntimeSized()) {
|
||||
|
|
|
@ -61,12 +61,12 @@ class Array : public Castable<Array, Type> {
|
|||
|
||||
/// @returns the byte alignment of the array
|
||||
/// @note this may differ from the alignment of a structure member of this
|
||||
/// array type, if the member is annotated with the `[[align(n)]]` decoration.
|
||||
/// array type, if the member is annotated with the `@align(n)` decoration.
|
||||
uint32_t Align() const override;
|
||||
|
||||
/// @returns the byte size of the array
|
||||
/// @note this may differ from the size of a structure member of this array
|
||||
/// type, if the member is annotated with the `[[size(n)]]` decoration.
|
||||
/// type, if the member is annotated with the `@size(n)` decoration.
|
||||
uint32_t Size() const override;
|
||||
|
||||
/// @returns the number of bytes from the start of one element of the
|
||||
|
|
|
@ -65,12 +65,12 @@ TEST_F(ArrayTest, FriendlyNameStaticSized) {
|
|||
|
||||
TEST_F(ArrayTest, FriendlyNameRuntimeSizedNonImplicitStride) {
|
||||
auto* arr = create<Array>(create<I32>(), 0, 0, 4, 8, 4);
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "[[stride(8)]] array<i32>");
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32>");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) {
|
||||
auto* arr = create<Array>(create<I32>(), 5, 4, 20, 8, 4);
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "[[stride(8)]] array<i32, 5>");
|
||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32, 5>");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, TypeName_RuntimeArray) {
|
||||
|
|
|
@ -89,13 +89,13 @@ class Struct : public Castable<Struct, Type> {
|
|||
|
||||
/// @returns the byte alignment of the structure
|
||||
/// @note this may differ from the alignment of a structure member of this
|
||||
/// structure type, if the member is annotated with the `[[align(n)]]`
|
||||
/// structure type, if the member is annotated with the `@align(n)`
|
||||
/// decoration.
|
||||
uint32_t Align() const override;
|
||||
|
||||
/// @returns the byte size of the structure
|
||||
/// @note this may differ from the size of a structure member of this
|
||||
/// structure type, if the member is annotated with the `[[size(n)]]`
|
||||
/// structure type, if the member is annotated with the `@size(n)`
|
||||
/// decoration.
|
||||
uint32_t Size() const override;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(AddEmptyEntryPointTest, EmptyModule) {
|
|||
auto* src = R"()";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn unused_entry_point() {
|
||||
}
|
||||
)";
|
||||
|
@ -40,7 +40,7 @@ fn unused_entry_point() {
|
|||
|
||||
TEST_F(AddEmptyEntryPointTest, ExistingEntryPoint) {
|
||||
auto* src = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
}
|
||||
)";
|
||||
|
@ -56,7 +56,7 @@ TEST_F(AddEmptyEntryPointTest, NameClash) {
|
|||
auto* src = R"(var<private> unused_entry_point : f32;)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn unused_entry_point_1() {
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ namespace tint {
|
|||
namespace transform {
|
||||
|
||||
/// AddSpirvBlockDecoration is a transform that adds an
|
||||
/// [[internal(spirv_block)]] attribute to any structure that is used as the
|
||||
/// `@internal(spirv_block)` attribute to any structure that is used as the
|
||||
/// store type of a buffer. If that structure is nested inside another structure
|
||||
/// or an array, then it is wrapped inside another structure which gets the
|
||||
/// [[internal(spirv_block)]] attribute instead.
|
||||
/// `@internal(spirv_block)` attribute instead.
|
||||
class AddSpirvBlockDecoration
|
||||
: public Castable<AddSpirvBlockDecoration, Transform> {
|
||||
public:
|
||||
|
@ -43,7 +43,7 @@ class AddSpirvBlockDecoration
|
|||
~SpirvBlockDecoration() override;
|
||||
|
||||
/// @return a short description of the internal decoration which will be
|
||||
/// displayed as `[[internal(<name>)]]`
|
||||
/// displayed as `@internal(<name>)`
|
||||
std::string InternalName() const override;
|
||||
|
||||
/// Performs a deep clone of this object using the CloneContext `ctx`.
|
||||
|
|
|
@ -42,7 +42,7 @@ struct S {
|
|||
|
||||
var<private> p : S;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
p.f = 1.0;
|
||||
}
|
||||
|
@ -57,11 +57,11 @@ fn main() {
|
|||
TEST_F(AddSpirvBlockDecorationTest, Noop_UsedForShaderIO) {
|
||||
auto* src = R"(
|
||||
struct S {
|
||||
[[location(0)]]
|
||||
@location(0)
|
||||
f : f32;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() -> S {
|
||||
return S();
|
||||
}
|
||||
|
@ -75,23 +75,23 @@ fn main() -> S {
|
|||
|
||||
TEST_F(AddSpirvBlockDecorationTest, BasicScalar) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : f32;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u;
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u_block {
|
||||
inner : f32;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u : u_block;
|
||||
@group(0) @binding(0) var<uniform> u : u_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u.inner;
|
||||
}
|
||||
|
@ -104,23 +104,23 @@ fn main() {
|
|||
|
||||
TEST_F(AddSpirvBlockDecorationTest, BasicArray) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : array<vec4<f32>, 4u>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let a = u;
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u_block {
|
||||
inner : array<vec4<f32>, 4u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u : u_block;
|
||||
@group(0) @binding(0) var<uniform> u : u_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let a = u.inner;
|
||||
}
|
||||
|
@ -135,10 +135,10 @@ TEST_F(AddSpirvBlockDecorationTest, BasicArray_Alias) {
|
|||
auto* src = R"(
|
||||
type Numbers = array<vec4<f32>, 4u>;
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : Numbers;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let a = u;
|
||||
}
|
||||
|
@ -146,14 +146,14 @@ fn main() {
|
|||
auto* expect = R"(
|
||||
type Numbers = array<vec4<f32>, 4u>;
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u_block {
|
||||
inner : array<vec4<f32>, 4u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u : u_block;
|
||||
@group(0) @binding(0) var<uniform> u : u_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let a = u.inner;
|
||||
}
|
||||
|
@ -170,23 +170,23 @@ struct S {
|
|||
f : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : S;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u.f;
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct S {
|
||||
f : f32;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u : S;
|
||||
@group(0) @binding(0) var<uniform> u : S;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u.f;
|
||||
}
|
||||
|
@ -207,10 +207,10 @@ struct Outer {
|
|||
i : Inner;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : Outer;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u.i.f;
|
||||
}
|
||||
|
@ -220,14 +220,14 @@ struct Inner {
|
|||
f : f32;
|
||||
}
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct Outer {
|
||||
i : Inner;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u : Outer;
|
||||
@group(0) @binding(0) var<uniform> u : Outer;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u.i.f;
|
||||
}
|
||||
|
@ -248,13 +248,13 @@ struct Outer {
|
|||
i : Inner;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u0 : Outer;
|
||||
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<uniform> u1 : Inner;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.i.f;
|
||||
let f1 = u1.f;
|
||||
|
@ -265,21 +265,21 @@ struct Inner {
|
|||
f : f32;
|
||||
}
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct Outer {
|
||||
i : Inner;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u0 : Outer;
|
||||
@group(0) @binding(0) var<uniform> u0 : Outer;
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u1_block {
|
||||
inner : Inner;
|
||||
}
|
||||
|
||||
[[group(0), binding(1)]] var<uniform> u1 : u1_block;
|
||||
@group(0) @binding(1) var<uniform> u1 : u1_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.i.f;
|
||||
let f1 = u1.inner.f;
|
||||
|
@ -303,10 +303,10 @@ struct Outer {
|
|||
|
||||
var<private> p : Outer;
|
||||
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<uniform> u : Inner;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = p.i.f;
|
||||
let f1 = u.f;
|
||||
|
@ -323,14 +323,14 @@ struct Outer {
|
|||
|
||||
var<private> p : Outer;
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u_block {
|
||||
inner : Inner;
|
||||
}
|
||||
|
||||
[[group(0), binding(1)]] var<uniform> u : u_block;
|
||||
@group(0) @binding(1) var<uniform> u : u_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = p.i.f;
|
||||
let f1 = u.inner.f;
|
||||
|
@ -352,16 +352,16 @@ struct S {
|
|||
i : Inner;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u0 : S;
|
||||
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<uniform> u1 : Inner;
|
||||
|
||||
[[group(0), binding(2)]]
|
||||
@group(0) @binding(2)
|
||||
var<uniform> u2 : Inner;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.i.f;
|
||||
let f1 = u1.f;
|
||||
|
@ -373,23 +373,23 @@ struct Inner {
|
|||
f : f32;
|
||||
}
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct S {
|
||||
i : Inner;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u0 : S;
|
||||
@group(0) @binding(0) var<uniform> u0 : S;
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u1_block {
|
||||
inner : Inner;
|
||||
}
|
||||
|
||||
[[group(0), binding(1)]] var<uniform> u1 : u1_block;
|
||||
@group(0) @binding(1) var<uniform> u1 : u1_block;
|
||||
|
||||
[[group(0), binding(2)]] var<uniform> u2 : u1_block;
|
||||
@group(0) @binding(2) var<uniform> u2 : u1_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.i.f;
|
||||
let f1 = u1.inner.f;
|
||||
|
@ -408,10 +408,10 @@ struct S {
|
|||
f : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : S;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u.f;
|
||||
let a = array<S, 4>();
|
||||
|
@ -422,14 +422,14 @@ struct S {
|
|||
f : f32;
|
||||
}
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u_block {
|
||||
inner : S;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u : u_block;
|
||||
@group(0) @binding(0) var<uniform> u : u_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f = u.inner.f;
|
||||
let a = array<S, 4>();
|
||||
|
@ -447,13 +447,13 @@ struct S {
|
|||
f : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u0 : S;
|
||||
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<uniform> u1 : S;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.f;
|
||||
let f1 = u1.f;
|
||||
|
@ -465,16 +465,16 @@ struct S {
|
|||
f : f32;
|
||||
}
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u0_block {
|
||||
inner : S;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u0 : u0_block;
|
||||
@group(0) @binding(0) var<uniform> u0 : u0_block;
|
||||
|
||||
[[group(0), binding(1)]] var<uniform> u1 : u0_block;
|
||||
@group(0) @binding(1) var<uniform> u1 : u0_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.inner.f;
|
||||
let f1 = u1.inner.f;
|
||||
|
@ -501,13 +501,13 @@ struct Outer {
|
|||
|
||||
type MyOuter = Outer;
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u0 : MyOuter;
|
||||
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<uniform> u1 : MyInner;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.i.f;
|
||||
let f1 = u1.f;
|
||||
|
@ -520,23 +520,23 @@ struct Inner {
|
|||
|
||||
type MyInner = Inner;
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct Outer {
|
||||
i : MyInner;
|
||||
}
|
||||
|
||||
type MyOuter = Outer;
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> u0 : MyOuter;
|
||||
@group(0) @binding(0) var<uniform> u0 : MyOuter;
|
||||
|
||||
[[internal(spirv_block)]]
|
||||
@internal(spirv_block)
|
||||
struct u1_block {
|
||||
inner : Inner;
|
||||
}
|
||||
|
||||
[[group(0), binding(1)]] var<uniform> u1 : u1_block;
|
||||
@group(0) @binding(1) var<uniform> u1 : u1_block;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let f0 = u0.i.f;
|
||||
let f1 = u1.inner.f;
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace transform {
|
|||
/// buffer_size : array<u32, 8>;
|
||||
/// };
|
||||
///
|
||||
/// [[group(0), binding(30)]]
|
||||
/// @group(0) @binding(30)
|
||||
/// var<uniform> buffer_size_ubo : buffer_size_struct;
|
||||
/// ```
|
||||
/// The binding group and number used for this uniform buffer is provided via
|
||||
|
|
|
@ -52,9 +52,9 @@ TEST_F(ArrayLengthFromUniformTest, Error_MissingSimplifyPointers) {
|
|||
|
||||
TEST_F(ArrayLengthFromUniformTest, Basic) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var<storage, read> sb : array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb);
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ struct tint_symbol {
|
|||
buffer_size : array<vec4<u32>, 1u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = (tint_symbol_1.buffer_size[0u][0u] / 4u);
|
||||
}
|
||||
|
@ -95,9 +95,9 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb.arr);
|
||||
}
|
||||
|
@ -108,16 +108,16 @@ struct tint_symbol {
|
|||
buffer_size : array<vec4<u32>, 1u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
struct SB {
|
||||
x : i32;
|
||||
arr : array<i32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = ((tint_symbol_1.buffer_size[0u][0u] - 4u) / 4u);
|
||||
}
|
||||
|
@ -138,9 +138,9 @@ fn main() {
|
|||
|
||||
TEST_F(ArrayLengthFromUniformTest, WithStride) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var<storage, read> sb : [[stride(64)]] array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : @stride(64) array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb);
|
||||
}
|
||||
|
@ -151,11 +151,11 @@ struct tint_symbol {
|
|||
buffer_size : array<vec4<u32>, 1u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : [[stride(64)]] array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : @stride(64) array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = (tint_symbol_1.buffer_size[0u][0u] / 64u);
|
||||
}
|
||||
|
@ -179,12 +179,12 @@ TEST_F(ArrayLengthFromUniformTest, WithStride_InStruct) {
|
|||
struct SB {
|
||||
x : i32;
|
||||
y : f32;
|
||||
arr : [[stride(64)]] array<i32>;
|
||||
arr : @stride(64) array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb.arr);
|
||||
}
|
||||
|
@ -195,17 +195,17 @@ struct tint_symbol {
|
|||
buffer_size : array<vec4<u32>, 1u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
struct SB {
|
||||
x : i32;
|
||||
y : f32;
|
||||
arr : [[stride(64)]] array<i32>;
|
||||
arr : @stride(64) array<i32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = ((tint_symbol_1.buffer_size[0u][0u] - 8u) / 64u);
|
||||
}
|
||||
|
@ -239,13 +239,13 @@ struct SB4 {
|
|||
arr4 : array<vec4<f32>>;
|
||||
};
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb1 : SB1;
|
||||
[[group(1), binding(2)]] var<storage, read> sb2 : SB2;
|
||||
[[group(2), binding(2)]] var<storage, read> sb3 : array<vec4<f32>>;
|
||||
[[group(3), binding(2)]] var<storage, read> sb4 : SB4;
|
||||
[[group(4), binding(2)]] var<storage, read> sb5 : array<vec4<f32>>;
|
||||
@group(0) @binding(2) var<storage, read> sb1 : SB1;
|
||||
@group(1) @binding(2) var<storage, read> sb2 : SB2;
|
||||
@group(2) @binding(2) var<storage, read> sb3 : array<vec4<f32>>;
|
||||
@group(3) @binding(2) var<storage, read> sb4 : SB4;
|
||||
@group(4) @binding(2) var<storage, read> sb5 : array<vec4<f32>>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len1 : u32 = arrayLength(&(sb1.arr1));
|
||||
var len2 : u32 = arrayLength(&(sb2.arr2));
|
||||
|
@ -261,7 +261,7 @@ struct tint_symbol {
|
|||
buffer_size : array<vec4<u32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
struct SB1 {
|
||||
x : i32;
|
||||
|
@ -278,17 +278,17 @@ struct SB4 {
|
|||
arr4 : array<vec4<f32>>;
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb1 : SB1;
|
||||
@group(0) @binding(2) var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(1), binding(2)]] var<storage, read> sb2 : SB2;
|
||||
@group(1) @binding(2) var<storage, read> sb2 : SB2;
|
||||
|
||||
[[group(2), binding(2)]] var<storage, read> sb3 : array<vec4<f32>>;
|
||||
@group(2) @binding(2) var<storage, read> sb3 : array<vec4<f32>>;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> sb4 : SB4;
|
||||
@group(3) @binding(2) var<storage, read> sb4 : SB4;
|
||||
|
||||
[[group(4), binding(2)]] var<storage, read> sb5 : array<vec4<f32>>;
|
||||
@group(4) @binding(2) var<storage, read> sb5 : array<vec4<f32>>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len1 : u32 = ((tint_symbol_1.buffer_size[0u][0u] - 4u) / 4u);
|
||||
var len2 : u32 = ((tint_symbol_1.buffer_size[0u][1u] - 16u) / 16u);
|
||||
|
@ -331,13 +331,13 @@ struct SB4 {
|
|||
arr4 : array<vec4<f32>>;
|
||||
};
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb1 : SB1;
|
||||
[[group(1), binding(2)]] var<storage, read> sb2 : SB2;
|
||||
[[group(2), binding(2)]] var<storage, read> sb3 : array<vec4<f32>>;
|
||||
[[group(3), binding(2)]] var<storage, read> sb4 : SB4;
|
||||
[[group(4), binding(2)]] var<storage, read> sb5 : array<vec4<f32>>;
|
||||
@group(0) @binding(2) var<storage, read> sb1 : SB1;
|
||||
@group(1) @binding(2) var<storage, read> sb2 : SB2;
|
||||
@group(2) @binding(2) var<storage, read> sb3 : array<vec4<f32>>;
|
||||
@group(3) @binding(2) var<storage, read> sb4 : SB4;
|
||||
@group(4) @binding(2) var<storage, read> sb5 : array<vec4<f32>>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len1 : u32 = arrayLength(&(sb1.arr1));
|
||||
var len3 : u32 = arrayLength(&sb3);
|
||||
|
@ -350,7 +350,7 @@ struct tint_symbol {
|
|||
buffer_size : array<vec4<u32>, 1u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
struct SB1 {
|
||||
x : i32;
|
||||
|
@ -367,17 +367,17 @@ struct SB4 {
|
|||
arr4 : array<vec4<f32>>;
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb1 : SB1;
|
||||
@group(0) @binding(2) var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(1), binding(2)]] var<storage, read> sb2 : SB2;
|
||||
@group(1) @binding(2) var<storage, read> sb2 : SB2;
|
||||
|
||||
[[group(2), binding(2)]] var<storage, read> sb3 : array<vec4<f32>>;
|
||||
@group(2) @binding(2) var<storage, read> sb3 : array<vec4<f32>>;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> sb4 : SB4;
|
||||
@group(3) @binding(2) var<storage, read> sb4 : SB4;
|
||||
|
||||
[[group(4), binding(2)]] var<storage, read> sb5 : array<vec4<f32>>;
|
||||
@group(4) @binding(2) var<storage, read> sb5 : array<vec4<f32>>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len1 : u32 = ((tint_symbol_1.buffer_size[0u][0u] - 4u) / 4u);
|
||||
var len3 : u32 = (tint_symbol_1.buffer_size[0u][2u] / 16u);
|
||||
|
@ -409,9 +409,9 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
ignore(&(sb.arr));
|
||||
}
|
||||
|
@ -442,11 +442,11 @@ struct SB2 {
|
|||
arr2 : array<vec4<f32>>;
|
||||
};
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb1 : SB1;
|
||||
@group(0) @binding(2) var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(1), binding(2)]] var<storage, read> sb2 : SB2;
|
||||
@group(1) @binding(2) var<storage, read> sb2 : SB2;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len1 : u32 = arrayLength(&(sb1.arr1));
|
||||
var len2 : u32 = arrayLength(&(sb2.arr2));
|
||||
|
@ -459,7 +459,7 @@ struct tint_symbol {
|
|||
buffer_size : array<vec4<u32>, 1u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
struct SB1 {
|
||||
x : i32;
|
||||
|
@ -471,11 +471,11 @@ struct SB2 {
|
|||
arr2 : array<vec4<f32>>;
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb1 : SB1;
|
||||
@group(0) @binding(2) var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(1), binding(2)]] var<storage, read> sb2 : SB2;
|
||||
@group(1) @binding(2) var<storage, read> sb2 : SB2;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len1 : u32 = ((tint_symbol_1.buffer_size[0u][0u] - 4u) / 4u);
|
||||
var len2 : u32 = arrayLength(&(sb2.arr2));
|
||||
|
|
|
@ -30,11 +30,11 @@ struct S {
|
|||
a : f32;
|
||||
}
|
||||
|
||||
[[group(2), binding(1)]] var<storage, read> a : S;
|
||||
@group(2) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> b : S;
|
||||
@group(3) @binding(2) var<storage, read> b : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -55,11 +55,11 @@ struct S {
|
|||
a : f32;
|
||||
};
|
||||
|
||||
[[group(2), binding(1)]] var<storage, read> a : S;
|
||||
@group(2) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> b : S;
|
||||
@group(3) @binding(2) var<storage, read> b : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -69,11 +69,11 @@ struct S {
|
|||
a : f32;
|
||||
}
|
||||
|
||||
[[group(1), binding(2)]] var<storage, read> a : S;
|
||||
@group(1) @binding(2) var<storage, read> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> b : S;
|
||||
@group(3) @binding(2) var<storage, read> b : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -83,7 +83,7 @@ fn f() {
|
|||
BindingRemapper::BindingPoints{
|
||||
{{2, 1}, {1, 2}}, // Remap
|
||||
{{4, 5}, {6, 7}}, // Not found
|
||||
// Keep [[group(3), binding(2)]] as is
|
||||
// Keep @group(3) @binding(2) as is
|
||||
},
|
||||
BindingRemapper::AccessControls{});
|
||||
auto got = Run<BindingRemapper>(src, data);
|
||||
|
@ -97,13 +97,13 @@ struct S {
|
|||
a : f32;
|
||||
};
|
||||
|
||||
[[group(2), binding(1)]] var<storage, read> a : S;
|
||||
@group(2) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, write> b : S;
|
||||
@group(3) @binding(2) var<storage, write> b : S;
|
||||
|
||||
[[group(4), binding(3)]] var<storage, read> c : S;
|
||||
@group(4) @binding(3) var<storage, read> c : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -113,13 +113,13 @@ struct S {
|
|||
a : f32;
|
||||
}
|
||||
|
||||
[[group(2), binding(1)]] var<storage, write> a : S;
|
||||
@group(2) @binding(1) var<storage, write> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, write> b : S;
|
||||
@group(3) @binding(2) var<storage, write> b : S;
|
||||
|
||||
[[group(4), binding(3)]] var<storage, read> c : S;
|
||||
@group(4) @binding(3) var<storage, read> c : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -129,7 +129,7 @@ fn f() {
|
|||
BindingRemapper::BindingPoints{},
|
||||
BindingRemapper::AccessControls{
|
||||
{{2, 1}, ast::Access::kWrite}, // Modify access control
|
||||
// Keep [[group(3), binding(2)]] as is
|
||||
// Keep @group(3) @binding(2) as is
|
||||
{{4, 3}, ast::Access::kRead}, // Add access control
|
||||
});
|
||||
auto got = Run<BindingRemapper>(src, data);
|
||||
|
@ -151,13 +151,13 @@ type, write WriteOnlyS = S;
|
|||
|
||||
type A = S;
|
||||
|
||||
[[group(2), binding(1)]] var<storage> a : ReadOnlyS;
|
||||
@group(2) @binding(1) var<storage> a : ReadOnlyS;
|
||||
|
||||
[[group(3), binding(2)]] var<storage> b : WriteOnlyS;
|
||||
@group(3) @binding(2) var<storage> b : WriteOnlyS;
|
||||
|
||||
[[group(4), binding(3)]] var<storage> c : A;
|
||||
@group(4) @binding(3) var<storage> c : A;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -173,13 +173,13 @@ type, write WriteOnlyS = S;
|
|||
|
||||
type A = S;
|
||||
|
||||
[[group(2), binding(1)]] var<storage, write> a : S;
|
||||
@group(2) @binding(1) var<storage, write> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage> b : WriteOnlyS;
|
||||
@group(3) @binding(2) var<storage> b : WriteOnlyS;
|
||||
|
||||
[[group(4), binding(3)]] var<storage, write> c : S;
|
||||
@group(4) @binding(3) var<storage, write> c : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -189,7 +189,7 @@ fn f() {
|
|||
BindingRemapper::BindingPoints{},
|
||||
BindingRemapper::AccessControls{
|
||||
{{2, 1}, ast::Access::kWrite}, // Modify access control
|
||||
// Keep [[group(3), binding(2)]] as is
|
||||
// Keep @group(3) @binding(2) as is
|
||||
{{4, 3}, ast::Access::kRead}, // Add access control
|
||||
});
|
||||
auto got = Run<BindingRemapper>(src, data);
|
||||
|
@ -203,11 +203,11 @@ struct S {
|
|||
a : f32;
|
||||
};
|
||||
|
||||
[[group(2), binding(1)]] var<storage, read> a : S;
|
||||
@group(2) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> b : S;
|
||||
@group(3) @binding(2) var<storage, read> b : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -217,11 +217,11 @@ struct S {
|
|||
a : f32;
|
||||
}
|
||||
|
||||
[[group(4), binding(5)]] var<storage, write> a : S;
|
||||
@group(4) @binding(5) var<storage, write> a : S;
|
||||
|
||||
[[group(6), binding(7)]] var<storage, write> b : S;
|
||||
@group(6) @binding(7) var<storage, write> b : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -247,15 +247,15 @@ struct S {
|
|||
i : i32;
|
||||
};
|
||||
|
||||
[[group(2), binding(1)]] var<storage, read> a : S;
|
||||
@group(2) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> b : S;
|
||||
@group(3) @binding(2) var<storage, read> b : S;
|
||||
|
||||
[[group(4), binding(3)]] var<storage, read> c : S;
|
||||
@group(4) @binding(3) var<storage, read> c : S;
|
||||
|
||||
[[group(5), binding(4)]] var<storage, read> d : S;
|
||||
@group(5) @binding(4) var<storage, read> d : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : i32 = (((a.i + b.i) + c.i) + d.i);
|
||||
}
|
||||
|
@ -266,15 +266,15 @@ struct S {
|
|||
i : i32;
|
||||
}
|
||||
|
||||
[[internal(disable_validation__binding_point_collision), group(1), binding(1)]] var<storage, read> a : S;
|
||||
@internal(disable_validation__binding_point_collision) @group(1) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[internal(disable_validation__binding_point_collision), group(1), binding(1)]] var<storage, read> b : S;
|
||||
@internal(disable_validation__binding_point_collision) @group(1) @binding(1) var<storage, read> b : S;
|
||||
|
||||
[[internal(disable_validation__binding_point_collision), group(5), binding(4)]] var<storage, read> c : S;
|
||||
@internal(disable_validation__binding_point_collision) @group(5) @binding(4) var<storage, read> c : S;
|
||||
|
||||
[[internal(disable_validation__binding_point_collision), group(5), binding(4)]] var<storage, read> d : S;
|
||||
@internal(disable_validation__binding_point_collision) @group(5) @binding(4) var<storage, read> d : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : i32 = (((a.i + b.i) + c.i) + d.i);
|
||||
}
|
||||
|
@ -299,20 +299,20 @@ struct S {
|
|||
i : i32;
|
||||
};
|
||||
|
||||
[[group(2), binding(1)]] var<storage, read> a : S;
|
||||
@group(2) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[group(3), binding(2)]] var<storage, read> b : S;
|
||||
@group(3) @binding(2) var<storage, read> b : S;
|
||||
|
||||
[[group(4), binding(3)]] var<storage, read> c : S;
|
||||
@group(4) @binding(3) var<storage, read> c : S;
|
||||
|
||||
[[group(5), binding(4)]] var<storage, read> d : S;
|
||||
@group(5) @binding(4) var<storage, read> d : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f1() {
|
||||
let x : i32 = (a.i + c.i);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f2() {
|
||||
let x : i32 = (b.i + d.i);
|
||||
}
|
||||
|
@ -323,20 +323,20 @@ struct S {
|
|||
i : i32;
|
||||
}
|
||||
|
||||
[[group(1), binding(1)]] var<storage, read> a : S;
|
||||
@group(1) @binding(1) var<storage, read> a : S;
|
||||
|
||||
[[group(1), binding(1)]] var<storage, read> b : S;
|
||||
@group(1) @binding(1) var<storage, read> b : S;
|
||||
|
||||
[[group(5), binding(4)]] var<storage, read> c : S;
|
||||
@group(5) @binding(4) var<storage, read> c : S;
|
||||
|
||||
[[group(5), binding(4)]] var<storage, read> d : S;
|
||||
@group(5) @binding(4) var<storage, read> d : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f1() {
|
||||
let x : i32 = (a.i + c.i);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f2() {
|
||||
let x : i32 = (b.i + d.i);
|
||||
}
|
||||
|
@ -361,10 +361,10 @@ struct S {
|
|||
a : f32;
|
||||
};
|
||||
|
||||
[[group(2), binding(1)]] var<storage, read> a : S;
|
||||
[[group(3), binding(2)]] var<storage, read> b : S;
|
||||
@group(2) @binding(1) var<storage, read> a : S;
|
||||
@group(3) @binding(2) var<storage, read> b : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {}
|
||||
)";
|
||||
|
||||
|
|
|
@ -38,21 +38,21 @@ TEST_F(CalculateArrayLengthTest, Error_MissingCalculateArrayLength) {
|
|||
|
||||
TEST_F(CalculateArrayLengthTest, Basic) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var<storage, read> sb : array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : array<i32>, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : array<i32>, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
|
@ -73,9 +73,9 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb.arr);
|
||||
}
|
||||
|
@ -87,12 +87,12 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
}
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : SB, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
|
@ -108,9 +108,9 @@ fn main() {
|
|||
|
||||
TEST_F(CalculateArrayLengthTest, InSameBlock) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var<storage, read> sb : array<i32>;;
|
||||
@group(0) @binding(0) var<storage, read> sb : array<i32>;;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var a : u32 = arrayLength(&sb);
|
||||
var b : u32 = arrayLength(&sb);
|
||||
|
@ -119,12 +119,12 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : array<i32>, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : array<i32>, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
|
@ -147,9 +147,9 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var a : u32 = arrayLength(&sb.arr);
|
||||
var b : u32 = arrayLength(&sb.arr);
|
||||
|
@ -163,12 +163,12 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
}
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : SB, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
|
@ -186,21 +186,21 @@ fn main() {
|
|||
|
||||
TEST_F(CalculateArrayLengthTest, WithStride) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var<storage, read> sb : [[stride(64)]] array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : @stride(64) array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : [[stride(64)]] array<i32>, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : @stride(64) array<i32>, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : [[stride(64)]] array<i32>;
|
||||
@group(0) @binding(0) var<storage, read> sb : @stride(64) array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
|
@ -219,12 +219,12 @@ TEST_F(CalculateArrayLengthTest, WithStride_InStruct) {
|
|||
struct SB {
|
||||
x : i32;
|
||||
y : f32;
|
||||
arr : [[stride(64)]] array<i32>;
|
||||
arr : @stride(64) array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len : u32 = arrayLength(&sb.arr);
|
||||
}
|
||||
|
@ -234,15 +234,15 @@ fn main() {
|
|||
struct SB {
|
||||
x : i32;
|
||||
y : f32;
|
||||
arr : [[stride(64)]] array<i32>;
|
||||
arr : @stride(64) array<i32>;
|
||||
}
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : SB, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb, &(tint_symbol_1));
|
||||
|
@ -263,9 +263,9 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
if (true) {
|
||||
var len : u32 = arrayLength(&sb.arr);
|
||||
|
@ -283,12 +283,12 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
}
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : SB, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb : SB;
|
||||
@group(0) @binding(0) var<storage, read> sb : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
if (true) {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
|
@ -323,13 +323,13 @@ struct SB2 {
|
|||
arr2 : array<vec4<f32>>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb1 : SB1;
|
||||
@group(0) @binding(0) var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(0), binding(1)]] var<storage, read> sb2 : SB2;
|
||||
@group(0) @binding(1) var<storage, read> sb2 : SB2;
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb3 : array<i32>;
|
||||
@group(0) @binding(2) var<storage, read> sb3 : array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var len1 : u32 = arrayLength(&(sb1.arr1));
|
||||
var len2 : u32 = arrayLength(&(sb2.arr2));
|
||||
|
@ -339,32 +339,32 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol_6([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : array<i32>, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol_6(@internal(disable_validation__ignore_constructible_function_parameter) buffer : array<i32>, result : ptr<function, u32>)
|
||||
|
||||
struct SB1 {
|
||||
x : i32;
|
||||
arr1 : array<i32>;
|
||||
}
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : SB1, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : SB1, result : ptr<function, u32>)
|
||||
|
||||
struct SB2 {
|
||||
x : i32;
|
||||
arr2 : array<vec4<f32>>;
|
||||
}
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol_3([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : SB2, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol_3(@internal(disable_validation__ignore_constructible_function_parameter) buffer : SB2, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> sb1 : SB1;
|
||||
@group(0) @binding(0) var<storage, read> sb1 : SB1;
|
||||
|
||||
[[group(0), binding(1)]] var<storage, read> sb2 : SB2;
|
||||
@group(0) @binding(1) var<storage, read> sb2 : SB2;
|
||||
|
||||
[[group(0), binding(2)]] var<storage, read> sb3 : array<i32>;
|
||||
@group(0) @binding(2) var<storage, read> sb3 : array<i32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(sb1, &(tint_symbol_1));
|
||||
|
@ -394,10 +394,10 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> a : SB;
|
||||
[[group(0), binding(1)]] var<storage, read> b : SB;
|
||||
@group(0) @binding(0) var<storage, read> a : SB;
|
||||
@group(0) @binding(1) var<storage, read> b : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
let x = &a;
|
||||
var a : u32 = arrayLength(&a.arr);
|
||||
|
@ -414,14 +414,14 @@ struct SB {
|
|||
arr : array<i32>;
|
||||
}
|
||||
|
||||
[[internal(intrinsic_buffer_size)]]
|
||||
fn tint_symbol([[internal(disable_validation__ignore_constructible_function_parameter)]] buffer : SB, result : ptr<function, u32>)
|
||||
@internal(intrinsic_buffer_size)
|
||||
fn tint_symbol(@internal(disable_validation__ignore_constructible_function_parameter) buffer : SB, result : ptr<function, u32>)
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> a : SB;
|
||||
@group(0) @binding(0) var<storage, read> a : SB;
|
||||
|
||||
[[group(0), binding(1)]] var<storage, read> b : SB;
|
||||
@group(0) @binding(1) var<storage, read> b : SB;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var tint_symbol_1 : u32 = 0u;
|
||||
tint_symbol(a, &(tint_symbol_1));
|
||||
|
|
|
@ -31,13 +31,13 @@ namespace transform {
|
|||
/// Before:
|
||||
/// ```
|
||||
/// struct Locations{
|
||||
/// [[location(1)]] loc1 : f32;
|
||||
/// [[location(2)]] loc2 : vec4<u32>;
|
||||
/// @location(1) loc1 : f32;
|
||||
/// @location(2) loc2 : vec4<u32>;
|
||||
/// };
|
||||
///
|
||||
/// [[stage(fragment)]]
|
||||
/// fn frag_main([[builtin(position)]] coord : vec4<f32>,
|
||||
/// locations : Locations) -> [[location(0)]] f32 {
|
||||
/// @stage(fragment)
|
||||
/// fn frag_main(@builtin(position) coord : vec4<f32>,
|
||||
/// locations : Locations) -> @location(0) f32 {
|
||||
/// if (coord.w > 1.0) {
|
||||
/// return 0.0;
|
||||
/// }
|
||||
|
@ -54,13 +54,13 @@ namespace transform {
|
|||
/// };
|
||||
///
|
||||
/// struct frag_main_in {
|
||||
/// [[builtin(position)]] coord : vec4<f32>;
|
||||
/// [[location(1)]] loc1 : f32;
|
||||
/// [[location(2)]] loc2 : vec4<u32>
|
||||
/// @builtin(position) coord : vec4<f32>;
|
||||
/// @location(1) loc1 : f32;
|
||||
/// @location(2) loc2 : vec4<u32>
|
||||
/// };
|
||||
///
|
||||
/// struct frag_main_out {
|
||||
/// [[location(0)]] loc0 : f32;
|
||||
/// @location(0) loc0 : f32;
|
||||
/// };
|
||||
///
|
||||
/// fn frag_main_inner(coord : vec4<f32>,
|
||||
|
@ -72,7 +72,7 @@ namespace transform {
|
|||
/// return col;
|
||||
/// }
|
||||
///
|
||||
/// [[stage(fragment)]]
|
||||
/// @stage(fragment)
|
||||
/// fn frag_main(in : frag_main_in) -> frag_main_out {
|
||||
/// let inner_retval = frag_main_inner(in.coord, Locations(in.loc1, in.loc2));
|
||||
/// var wrapper_result : frag_main_out;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -82,7 +82,7 @@ class DecomposeMemoryAccess
|
|||
~Intrinsic() override;
|
||||
|
||||
/// @return a short description of the internal decoration which will be
|
||||
/// displayed as `[[internal(<name>)]]`
|
||||
/// displayed as `@internal(<name>)`
|
||||
std::string InternalName() const override;
|
||||
|
||||
/// Performs a deep clone of this object using the CloneContext `ctx`.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -52,13 +52,13 @@ TEST_F(DecomposeStridedMatrixTest, MissingDependencySimplify) {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) {
|
||||
// struct S {
|
||||
// [[offset(16), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(16) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<uniform> s : S;
|
||||
// @group(0) @binding(0) var<uniform> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let x : mat2x2<f32> = s.m;
|
||||
// }
|
||||
|
@ -88,18 +88,18 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(16)]]
|
||||
@size(16)
|
||||
padding : u32;
|
||||
m : [[stride(32)]] array<vec2<f32>, 2u>;
|
||||
m : @stride(32) array<vec2<f32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> s : S;
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
fn arr_to_mat2x2_stride_32(arr : [[stride(32)]] array<vec2<f32>, 2u>) -> mat2x2<f32> {
|
||||
fn arr_to_mat2x2_stride_32(arr : @stride(32) array<vec2<f32>, 2u>) -> mat2x2<f32> {
|
||||
return mat2x2<f32>(arr[0u], arr[1u]);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = arr_to_mat2x2_stride_32(s.m);
|
||||
}
|
||||
|
@ -113,13 +113,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) {
|
||||
// struct S {
|
||||
// [[offset(16), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(16) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<uniform> s : S;
|
||||
// @group(0) @binding(0) var<uniform> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let x : vec2<f32> = s.m[1];
|
||||
// }
|
||||
|
@ -149,14 +149,14 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(16)]]
|
||||
@size(16)
|
||||
padding : u32;
|
||||
m : [[stride(32)]] array<vec2<f32>, 2u>;
|
||||
m : @stride(32) array<vec2<f32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> s : S;
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : vec2<f32> = s.m[1];
|
||||
}
|
||||
|
@ -170,13 +170,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) {
|
||||
// struct S {
|
||||
// [[offset(16), stride(8)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(16) @stride(8)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<uniform> s : S;
|
||||
// @group(0) @binding(0) var<uniform> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let x : mat2x2<f32> = s.m;
|
||||
// }
|
||||
|
@ -206,15 +206,15 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(16)]]
|
||||
@size(16)
|
||||
padding : u32;
|
||||
[[stride(8), internal(disable_validation__ignore_stride)]]
|
||||
@stride(8) @internal(disable_validation__ignore_stride)
|
||||
m : mat2x2<f32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> s : S;
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = s.m;
|
||||
}
|
||||
|
@ -228,13 +228,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
|
||||
// struct S {
|
||||
// [[offset(8), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(8) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let x : mat2x2<f32> = s.m;
|
||||
// }
|
||||
|
@ -264,18 +264,18 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
padding : u32;
|
||||
m : [[stride(32)]] array<vec2<f32>, 2u>;
|
||||
m : @stride(32) array<vec2<f32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
fn arr_to_mat2x2_stride_32(arr : [[stride(32)]] array<vec2<f32>, 2u>) -> mat2x2<f32> {
|
||||
fn arr_to_mat2x2_stride_32(arr : @stride(32) array<vec2<f32>, 2u>) -> mat2x2<f32> {
|
||||
return mat2x2<f32>(arr[0u], arr[1u]);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = arr_to_mat2x2_stride_32(s.m);
|
||||
}
|
||||
|
@ -289,13 +289,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
|
||||
// struct S {
|
||||
// [[offset(16), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(16) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let x : vec2<f32> = s.m[1];
|
||||
// }
|
||||
|
@ -325,14 +325,14 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(16)]]
|
||||
@size(16)
|
||||
padding : u32;
|
||||
m : [[stride(32)]] array<vec2<f32>, 2u>;
|
||||
m : @stride(32) array<vec2<f32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : vec2<f32> = s.m[1];
|
||||
}
|
||||
|
@ -346,13 +346,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
|
||||
// struct S {
|
||||
// [[offset(8), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(8) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// s.m = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
// }
|
||||
|
@ -383,18 +383,18 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
padding : u32;
|
||||
m : [[stride(32)]] array<vec2<f32>, 2u>;
|
||||
m : @stride(32) array<vec2<f32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
fn mat2x2_stride_32_to_arr(mat : mat2x2<f32>) -> [[stride(32)]] array<vec2<f32>, 2u> {
|
||||
return [[stride(32)]] array<vec2<f32>, 2u>(mat[0u], mat[1u]);
|
||||
fn mat2x2_stride_32_to_arr(mat : mat2x2<f32>) -> @stride(32) array<vec2<f32>, 2u> {
|
||||
return @stride(32) array<vec2<f32>, 2u>(mat[0u], mat[1u]);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
s.m = mat2x2_stride_32_to_arr(mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0)));
|
||||
}
|
||||
|
@ -408,13 +408,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
|
||||
// struct S {
|
||||
// [[offset(8), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(8) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// s.m[1] = vec2<f32>(1.0, 2.0);
|
||||
// }
|
||||
|
@ -444,14 +444,14 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
padding : u32;
|
||||
m : [[stride(32)]] array<vec2<f32>, 2u>;
|
||||
m : @stride(32) array<vec2<f32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
s.m[1] = vec2<f32>(1.0, 2.0);
|
||||
}
|
||||
|
@ -465,13 +465,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
|
||||
// struct S {
|
||||
// [[offset(8), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(8) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// [[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a = &s.m;
|
||||
// let b = &*&*(a);
|
||||
|
@ -516,22 +516,22 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
padding : u32;
|
||||
m : [[stride(32)]] array<vec2<f32>, 2u>;
|
||||
m : @stride(32) array<vec2<f32>, 2u>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
fn arr_to_mat2x2_stride_32(arr : [[stride(32)]] array<vec2<f32>, 2u>) -> mat2x2<f32> {
|
||||
fn arr_to_mat2x2_stride_32(arr : @stride(32) array<vec2<f32>, 2u>) -> mat2x2<f32> {
|
||||
return mat2x2<f32>(arr[0u], arr[1u]);
|
||||
}
|
||||
|
||||
fn mat2x2_stride_32_to_arr(mat : mat2x2<f32>) -> [[stride(32)]] array<vec2<f32>, 2u> {
|
||||
return [[stride(32)]] array<vec2<f32>, 2u>(mat[0u], mat[1u]);
|
||||
fn mat2x2_stride_32_to_arr(mat : mat2x2<f32>) -> @stride(32) array<vec2<f32>, 2u> {
|
||||
return @stride(32) array<vec2<f32>, 2u>(mat[0u], mat[1u]);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x = arr_to_mat2x2_stride_32(s.m);
|
||||
let y = s.m[1];
|
||||
|
@ -549,13 +549,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) {
|
||||
// struct S {
|
||||
// [[offset(8), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(8) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// var<private> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let x : mat2x2<f32> = s.m;
|
||||
// }
|
||||
|
@ -584,15 +584,15 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
padding : u32;
|
||||
[[stride(32), internal(disable_validation__ignore_stride)]]
|
||||
@stride(32) @internal(disable_validation__ignore_stride)
|
||||
m : mat2x2<f32>;
|
||||
}
|
||||
|
||||
var<private> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = s.m;
|
||||
}
|
||||
|
@ -606,13 +606,13 @@ fn f() {
|
|||
|
||||
TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
|
||||
// struct S {
|
||||
// [[offset(8), stride(32)]]
|
||||
// [[internal(ignore_stride_decoration)]]
|
||||
// @offset(8) @stride(32)
|
||||
// @internal(ignore_stride_decoration)
|
||||
// m : mat2x2<f32>;
|
||||
// };
|
||||
// var<private> s : S;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// s.m = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
// }
|
||||
|
@ -642,15 +642,15 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
|
|||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
padding : u32;
|
||||
[[stride(32), internal(disable_validation__ignore_stride)]]
|
||||
@stride(32) @internal(disable_validation__ignore_stride)
|
||||
m : mat2x2<f32>;
|
||||
}
|
||||
|
||||
var<private> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
s.m = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
}
|
||||
|
|
|
@ -24,23 +24,23 @@ using ExternalTextureTransformTest = TransformTest;
|
|||
|
||||
TEST_F(ExternalTextureTransformTest, SampleLevelSinglePlane) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
|
||||
[[group(0), binding(1)]] var t : texture_external;
|
||||
@group(0) @binding(1) var t : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(t, s, (coord.xy / vec2<f32>(4.0, 4.0)));
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
|
||||
[[group(0), binding(1)]] var t : texture_2d<f32>;
|
||||
@group(0) @binding(1) var t : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(t, s, (coord.xy / vec2<f32>(4.0, 4.0)), 0.0);
|
||||
}
|
||||
)";
|
||||
|
@ -52,19 +52,19 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
|
||||
TEST_F(ExternalTextureTransformTest, LoadSinglePlane) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var t : texture_external;
|
||||
@group(0) @binding(0) var t : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoad(t, vec2<i32>(1, 1));
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var t : texture_2d<f32>;
|
||||
@group(0) @binding(0) var t : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoad(t, vec2<i32>(1, 1), 0);
|
||||
}
|
||||
)";
|
||||
|
@ -76,10 +76,10 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
|
||||
TEST_F(ExternalTextureTransformTest, DimensionsSinglePlane) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var t : texture_external;
|
||||
@group(0) @binding(0) var t : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
var dim : vec2<i32>;
|
||||
dim = textureDimensions(t);
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -87,10 +87,10 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var t : texture_2d<f32>;
|
||||
@group(0) @binding(0) var t : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
var dim : vec2<i32>;
|
||||
dim = textureDimensions(t);
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
|
|
|
@ -35,24 +35,28 @@ namespace transform {
|
|||
/// Therefore, these values must by passed to the shader.
|
||||
///
|
||||
/// Before:
|
||||
/// [[builtin(vertex_index)]] var<in> vert_idx : u32;
|
||||
/// ```
|
||||
/// @builtin(vertex_index) var<in> vert_idx : u32;
|
||||
/// fn func() -> u32 {
|
||||
/// return vert_idx;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// After:
|
||||
/// ```
|
||||
/// struct TintFirstIndexOffsetData {
|
||||
/// tint_first_vertex_index : u32;
|
||||
/// tint_first_instance_index : u32;
|
||||
/// };
|
||||
/// [[builtin(vertex_index)]] var<in> tint_first_index_offset_vert_idx : u32;
|
||||
/// [[binding(N), group(M)]] var<uniform> tint_first_index_data :
|
||||
/// @builtin(vertex_index) var<in> tint_first_index_offset_vert_idx : u32;
|
||||
/// @binding(N) @group(M) var<uniform> tint_first_index_data :
|
||||
/// TintFirstIndexOffsetData;
|
||||
/// fn func() -> u32 {
|
||||
/// const vert_idx = (tint_first_index_offset_vert_idx +
|
||||
/// tint_first_index_data.tint_first_vertex_index);
|
||||
/// return vert_idx;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
class FirstIndexOffset : public Castable<FirstIndexOffset, Transform> {
|
||||
public:
|
||||
|
@ -71,9 +75,9 @@ class FirstIndexOffset : public Castable<FirstIndexOffset, Transform> {
|
|||
/// Destructor
|
||||
~BindingPoint() override;
|
||||
|
||||
/// [[binding()]] for the first vertex / first instance uniform buffer
|
||||
/// `@binding()` for the first vertex / first instance uniform buffer
|
||||
uint32_t binding = 0;
|
||||
/// [[group()]] for the first vertex / first instance uniform buffer
|
||||
/// `@group()` for the first vertex / first instance uniform buffer
|
||||
uint32_t group = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ fn test(vert_idx : u32) -> u32 {
|
|||
return vert_idx;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
test(vert_idx);
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ struct tint_symbol {
|
|||
first_vertex_index : u32;
|
||||
}
|
||||
|
||||
[[binding(1), group(2)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@binding(1) @group(2) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
fn test(vert_idx : u32) -> u32 {
|
||||
return vert_idx;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
test((vert_idx + tint_symbol_1.first_vertex_index));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ fn test(inst_idx : u32) -> u32 {
|
|||
return inst_idx;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
test(inst_idx);
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -109,14 +109,14 @@ struct tint_symbol {
|
|||
first_instance_index : u32;
|
||||
}
|
||||
|
||||
[[binding(1), group(7)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@binding(1) @group(7) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
fn test(inst_idx : u32) -> u32 {
|
||||
return inst_idx;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
test((inst_idx + tint_symbol_1.first_instance_index));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -144,12 +144,12 @@ fn test(instance_idx : u32, vert_idx : u32) -> u32 {
|
|||
}
|
||||
|
||||
struct Inputs {
|
||||
[[builtin(instance_index)]] instance_idx : u32;
|
||||
[[builtin(vertex_index)]] vert_idx : u32;
|
||||
@builtin(instance_index) instance_idx : u32;
|
||||
@builtin(vertex_index) vert_idx : u32;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(inputs : Inputs) -> @builtin(position) vec4<f32> {
|
||||
test(inputs.instance_idx, inputs.vert_idx);
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -161,21 +161,21 @@ struct tint_symbol {
|
|||
first_instance_index : u32;
|
||||
}
|
||||
|
||||
[[binding(1), group(2)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@binding(1) @group(2) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
fn test(instance_idx : u32, vert_idx : u32) -> u32 {
|
||||
return (instance_idx + vert_idx);
|
||||
}
|
||||
|
||||
struct Inputs {
|
||||
[[builtin(instance_index)]]
|
||||
@builtin(instance_index)
|
||||
instance_idx : u32;
|
||||
[[builtin(vertex_index)]]
|
||||
@builtin(vertex_index)
|
||||
vert_idx : u32;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(inputs : Inputs) -> @builtin(position) vec4<f32> {
|
||||
test((inputs.instance_idx + tint_symbol_1.first_instance_index), (inputs.vert_idx + tint_symbol_1.first_vertex_index));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -206,8 +206,8 @@ fn func2(vert_idx : u32) -> u32 {
|
|||
return func1(vert_idx);
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func2(vert_idx);
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ struct tint_symbol {
|
|||
first_vertex_index : u32;
|
||||
}
|
||||
|
||||
[[binding(1), group(2)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@binding(1) @group(2) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
fn func1(vert_idx : u32) -> u32 {
|
||||
return vert_idx;
|
||||
|
@ -228,8 +228,8 @@ fn func2(vert_idx : u32) -> u32 {
|
|||
return func1(vert_idx);
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func2((vert_idx + tint_symbol_1.first_vertex_index));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -256,20 +256,20 @@ fn func(i : u32) -> u32 {
|
|||
return i;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry_a(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func(vert_idx);
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry_b(@builtin(vertex_index) vert_idx : u32, @builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func(vert_idx + inst_idx);
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry_c([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry_c(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func(inst_idx);
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -281,26 +281,26 @@ struct tint_symbol {
|
|||
first_instance_index : u32;
|
||||
}
|
||||
|
||||
[[binding(1), group(2)]] var<uniform> tint_symbol_1 : tint_symbol;
|
||||
@binding(1) @group(2) var<uniform> tint_symbol_1 : tint_symbol;
|
||||
|
||||
fn func(i : u32) -> u32 {
|
||||
return i;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry_a(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func((vert_idx + tint_symbol_1.first_vertex_index));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry_b(@builtin(vertex_index) vert_idx : u32, @builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func(((vert_idx + tint_symbol_1.first_vertex_index) + (inst_idx + tint_symbol_1.first_instance_index)));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry_c([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry_c(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f32> {
|
||||
func((inst_idx + tint_symbol_1.first_instance_index));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ TEST_F(GlslTest, AddEmptyEntryPoint) {
|
|||
auto* src = R"()";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn unused_entry_point() {
|
||||
}
|
||||
)";
|
||||
|
|
|
@ -44,7 +44,7 @@ TEST_F(LocalizeStructArrayAssignmentTest, EmptyModule) {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, StructArray) {
|
||||
auto* src = R"(
|
||||
[[block]] struct Uniforms {
|
||||
@block struct Uniforms {
|
||||
i : u32;
|
||||
};
|
||||
|
||||
|
@ -56,9 +56,9 @@ struct OuterS {
|
|||
a1 : array<InnerS, 8>;
|
||||
};
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -67,7 +67,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
}
|
||||
|
@ -80,9 +80,9 @@ struct OuterS {
|
|||
a1 : array<InnerS, 8>;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -102,7 +102,7 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, StructStructArray) {
|
||||
auto* src = R"(
|
||||
[[block]] struct Uniforms {
|
||||
@block struct Uniforms {
|
||||
i : u32;
|
||||
};
|
||||
|
||||
|
@ -118,9 +118,9 @@ struct OuterS {
|
|||
s2 : S1;
|
||||
};
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -129,7 +129,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
}
|
||||
|
@ -146,9 +146,9 @@ struct OuterS {
|
|||
s2 : S1;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -168,7 +168,7 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, StructArrayArray) {
|
||||
auto* src = R"(
|
||||
[[block]] struct Uniforms {
|
||||
@block struct Uniforms {
|
||||
i : u32;
|
||||
j : u32;
|
||||
};
|
||||
|
@ -181,9 +181,9 @@ struct OuterS {
|
|||
a1 : array<array<InnerS, 8>, 8>;
|
||||
};
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -192,7 +192,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
j : u32;
|
||||
|
@ -206,9 +206,9 @@ struct OuterS {
|
|||
a1 : array<array<InnerS, 8>, 8>;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -228,7 +228,7 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, StructArrayStruct) {
|
||||
auto* src = R"(
|
||||
[[block]] struct Uniforms {
|
||||
@block struct Uniforms {
|
||||
i : u32;
|
||||
};
|
||||
|
||||
|
@ -244,9 +244,9 @@ struct OuterS {
|
|||
a1 : array<S1, 8>;
|
||||
};
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -255,7 +255,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
}
|
||||
|
@ -272,9 +272,9 @@ struct OuterS {
|
|||
a1 : array<S1, 8>;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -294,7 +294,7 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, StructArrayStructArray) {
|
||||
auto* src = R"(
|
||||
[[block]] struct Uniforms {
|
||||
@block struct Uniforms {
|
||||
i : u32;
|
||||
j : u32;
|
||||
};
|
||||
|
@ -311,9 +311,9 @@ struct OuterS {
|
|||
a1 : array<S1, 8>;
|
||||
};
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s : OuterS;
|
||||
|
@ -322,7 +322,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
j : u32;
|
||||
|
@ -340,9 +340,9 @@ struct OuterS {
|
|||
a1 : array<S1, 8>;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s : OuterS;
|
||||
|
@ -365,7 +365,7 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, IndexingWithSideEffectFunc) {
|
||||
auto* src = R"(
|
||||
[[block]] struct Uniforms {
|
||||
@block struct Uniforms {
|
||||
i : u32;
|
||||
j : u32;
|
||||
};
|
||||
|
@ -388,9 +388,9 @@ fn getNextIndex() -> u32 {
|
|||
return nextIndex;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s : OuterS;
|
||||
|
@ -399,7 +399,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
j : u32;
|
||||
|
@ -424,9 +424,9 @@ fn getNextIndex() -> u32 {
|
|||
return nextIndex;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s : OuterS;
|
||||
|
@ -449,7 +449,7 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, ViaPointerArg) {
|
||||
auto* src = R"(
|
||||
[[block]] struct Uniforms {
|
||||
@block struct Uniforms {
|
||||
i : u32;
|
||||
};
|
||||
struct InnerS {
|
||||
|
@ -458,14 +458,14 @@ struct InnerS {
|
|||
struct OuterS {
|
||||
a1 : array<InnerS, 8>;
|
||||
};
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
fn f(p : ptr<function, OuterS>) {
|
||||
var v : InnerS;
|
||||
(*p).a1[uniforms.i] = v;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var s1 : OuterS;
|
||||
f(&s1);
|
||||
|
@ -473,7 +473,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ struct OuterS {
|
|||
a1 : array<InnerS, 8>;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
fn f(p : ptr<function, OuterS>) {
|
||||
var v : InnerS;
|
||||
|
@ -498,7 +498,7 @@ fn f(p : ptr<function, OuterS>) {
|
|||
}
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var s1 : OuterS;
|
||||
f(&(s1));
|
||||
|
@ -512,7 +512,7 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, ViaPointerVar) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
};
|
||||
|
@ -525,13 +525,13 @@ struct OuterS {
|
|||
a1 : array<InnerS, 8>;
|
||||
};
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
fn f(p : ptr<function, InnerS>, v : InnerS) {
|
||||
*(p) = v;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -541,7 +541,7 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
}
|
||||
|
@ -554,13 +554,13 @@ struct OuterS {
|
|||
a1 : array<InnerS, 8>;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
fn f(p : ptr<function, InnerS>, v : InnerS) {
|
||||
*(p) = v;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var v : InnerS;
|
||||
var s1 : OuterS;
|
||||
|
@ -581,23 +581,23 @@ fn main() {
|
|||
|
||||
TEST_F(LocalizeStructArrayAssignmentTest, VectorAssignment) {
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
@block
|
||||
struct Uniforms {
|
||||
i : u32;
|
||||
}
|
||||
|
||||
[[block]]
|
||||
@block
|
||||
struct OuterS {
|
||||
a1 : array<u32, 8>;
|
||||
}
|
||||
|
||||
[[group(1), binding(4)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(4) var<uniform> uniforms : Uniforms;
|
||||
|
||||
fn f(i : u32) -> u32 {
|
||||
return (i + 1u);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var s1 : OuterS;
|
||||
var v : vec3<f32>;
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace transform {
|
|||
/// struct S {
|
||||
/// f : f32;
|
||||
/// };
|
||||
/// [[binding(0), group(0)]]
|
||||
/// @binding(0) @group(0)
|
||||
/// var<storage, read> s : S;
|
||||
/// var<private> p : f32 = 2.0;
|
||||
///
|
||||
|
@ -44,7 +44,7 @@ namespace transform {
|
|||
/// p = p + f;
|
||||
/// }
|
||||
///
|
||||
/// [[stage(compute), workgroup_size(1)]]
|
||||
/// @stage(compute) @workgroup_size(1)
|
||||
/// fn main() {
|
||||
/// foo();
|
||||
/// }
|
||||
|
@ -56,7 +56,7 @@ namespace transform {
|
|||
/// *p = *p + (*sptr).f;
|
||||
/// }
|
||||
///
|
||||
/// [[stage(compute), workgroup_size(1)]]
|
||||
/// @stage(compute) @workgroup_size(1)
|
||||
/// fn main(sptr : ptr<storage, S, read>) {
|
||||
/// var<private> p : f32 = 2.0;
|
||||
/// foo(&p, sptr);
|
||||
|
|
|
@ -29,17 +29,17 @@ TEST_F(ModuleScopeVarToEntryPointParamTest, Basic) {
|
|||
var<private> p : f32;
|
||||
var<workgroup> w : f32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
w = p;
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<workgroup> tint_symbol : f32;
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<private> tint_symbol_1 : f32;
|
||||
@internal(disable_validation__ignore_storage_class) var<workgroup> tint_symbol : f32;
|
||||
@internal(disable_validation__ignore_storage_class) var<private> tint_symbol_1 : f32;
|
||||
tint_symbol = tint_symbol_1;
|
||||
}
|
||||
)";
|
||||
|
@ -68,7 +68,7 @@ fn foo(a : f32) {
|
|||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
foo(1.0);
|
||||
}
|
||||
|
@ -78,21 +78,21 @@ fn main() {
|
|||
fn no_uses() {
|
||||
}
|
||||
|
||||
fn bar(a : f32, b : f32, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol : ptr<private, f32>, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol_1 : ptr<workgroup, f32>) {
|
||||
fn bar(a : f32, b : f32, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol : ptr<private, f32>, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol_1 : ptr<workgroup, f32>) {
|
||||
*(tint_symbol) = a;
|
||||
*(tint_symbol_1) = b;
|
||||
}
|
||||
|
||||
fn foo(a : f32, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol_2 : ptr<private, f32>, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol_3 : ptr<workgroup, f32>) {
|
||||
fn foo(a : f32, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol_2 : ptr<private, f32>, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol_3 : ptr<workgroup, f32>) {
|
||||
let b : f32 = 2.0;
|
||||
bar(a, b, tint_symbol_2, tint_symbol_3);
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<private> tint_symbol_4 : f32;
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<workgroup> tint_symbol_5 : f32;
|
||||
@internal(disable_validation__ignore_storage_class) var<private> tint_symbol_4 : f32;
|
||||
@internal(disable_validation__ignore_storage_class) var<workgroup> tint_symbol_5 : f32;
|
||||
foo(1.0, &(tint_symbol_4), &(tint_symbol_5));
|
||||
}
|
||||
)";
|
||||
|
@ -107,17 +107,17 @@ TEST_F(ModuleScopeVarToEntryPointParamTest, Constructors) {
|
|||
var<private> a : f32 = 1.0;
|
||||
var<private> b : f32 = f32();
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
let x : f32 = a + b;
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<private> tint_symbol : f32 = 1.0;
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<private> tint_symbol_1 : f32 = f32();
|
||||
@internal(disable_validation__ignore_storage_class) var<private> tint_symbol : f32 = 1.0;
|
||||
@internal(disable_validation__ignore_storage_class) var<private> tint_symbol_1 : f32 = f32();
|
||||
let x : f32 = (tint_symbol + tint_symbol_1);
|
||||
}
|
||||
)";
|
||||
|
@ -132,7 +132,7 @@ TEST_F(ModuleScopeVarToEntryPointParamTest, Pointers) {
|
|||
var<private> p : f32;
|
||||
var<workgroup> w : f32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
let p_ptr : ptr<private, f32> = &p;
|
||||
let w_ptr : ptr<workgroup, f32> = &w;
|
||||
|
@ -142,10 +142,10 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<private> tint_symbol : f32;
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<workgroup> tint_symbol_1 : f32;
|
||||
@internal(disable_validation__ignore_storage_class) var<private> tint_symbol : f32;
|
||||
@internal(disable_validation__ignore_storage_class) var<workgroup> tint_symbol_1 : f32;
|
||||
let p_ptr : ptr<private, f32> = &(tint_symbol);
|
||||
let w_ptr : ptr<workgroup, f32> = &(tint_symbol_1);
|
||||
let x : f32 = (*(p_ptr) + *(w_ptr));
|
||||
|
@ -170,7 +170,7 @@ fn foo() {
|
|||
bar(&v);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
foo();
|
||||
}
|
||||
|
@ -181,13 +181,13 @@ fn bar(p : ptr<private, f32>) {
|
|||
*(p) = 0.0;
|
||||
}
|
||||
|
||||
fn foo([[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol : ptr<private, f32>) {
|
||||
fn foo(@internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol : ptr<private, f32>) {
|
||||
bar(tint_symbol);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
[[internal(disable_validation__ignore_storage_class)]] var<private> tint_symbol_1 : f32;
|
||||
@internal(disable_validation__ignore_storage_class) var<private> tint_symbol_1 : f32;
|
||||
foo(&(tint_symbol_1));
|
||||
}
|
||||
)";
|
||||
|
@ -203,12 +203,12 @@ struct S {
|
|||
a : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : S;
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<storage> s : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
_ = u;
|
||||
_ = s;
|
||||
|
@ -220,8 +220,8 @@ struct S {
|
|||
a : f32;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol : ptr<uniform, S>, [[group(0), binding(1), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol_1 : ptr<storage, S>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol : ptr<uniform, S>, @group(0) @binding(1) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol_1 : ptr<storage, S>) {
|
||||
_ = *(tint_symbol);
|
||||
_ = *(tint_symbol_1);
|
||||
}
|
||||
|
@ -234,10 +234,10 @@ fn main([[group(0), binding(0), internal(disable_validation__entry_point_paramet
|
|||
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, Buffer_RuntimeArray) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<storage> buffer : array<f32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
_ = buffer[0];
|
||||
}
|
||||
|
@ -248,8 +248,8 @@ struct tint_symbol_1 {
|
|||
arr : array<f32>;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol : ptr<storage, tint_symbol_1>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol : ptr<storage, tint_symbol_1>) {
|
||||
_ = (*(tint_symbol)).arr[0];
|
||||
}
|
||||
)";
|
||||
|
@ -261,14 +261,14 @@ fn main([[group(0), binding(0), internal(disable_validation__entry_point_paramet
|
|||
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, Buffer_RuntimeArrayInsideFunction) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<storage> buffer : array<f32>;
|
||||
|
||||
fn foo() {
|
||||
_ = buffer[0];
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
foo();
|
||||
}
|
||||
|
@ -279,12 +279,12 @@ struct tint_symbol_2 {
|
|||
arr : array<f32>;
|
||||
}
|
||||
|
||||
fn foo([[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol : ptr<storage, array<f32>>) {
|
||||
fn foo(@internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol : ptr<storage, array<f32>>) {
|
||||
_ = (*(tint_symbol))[0];
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol_1 : ptr<storage, tint_symbol_2>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol_1 : ptr<storage, tint_symbol_2>) {
|
||||
foo(&((*(tint_symbol_1)).arr));
|
||||
}
|
||||
)";
|
||||
|
@ -298,10 +298,10 @@ TEST_F(ModuleScopeVarToEntryPointParamTest, Buffer_RuntimeArray_Alias) {
|
|||
auto* src = R"(
|
||||
type myarray = array<f32>;
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<storage> buffer : myarray;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
_ = buffer[0];
|
||||
}
|
||||
|
@ -314,8 +314,8 @@ struct tint_symbol_1 {
|
|||
|
||||
type myarray = array<f32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol : ptr<storage, tint_symbol_1>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol : ptr<storage, tint_symbol_1>) {
|
||||
_ = (*(tint_symbol)).arr[0];
|
||||
}
|
||||
)";
|
||||
|
@ -331,10 +331,10 @@ struct S {
|
|||
f : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<storage> buffer : array<S>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
_ = buffer[0];
|
||||
}
|
||||
|
@ -349,8 +349,8 @@ struct tint_symbol_1 {
|
|||
arr : array<S>;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol : ptr<storage, tint_symbol_1>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol : ptr<storage, tint_symbol_1>) {
|
||||
_ = (*(tint_symbol)).arr[0];
|
||||
}
|
||||
)";
|
||||
|
@ -366,9 +366,9 @@ struct S {
|
|||
a : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> u : S;
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<storage> s : S;
|
||||
|
||||
fn no_uses() {
|
||||
|
@ -386,7 +386,7 @@ fn foo(a : f32) {
|
|||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
foo(1.0);
|
||||
}
|
||||
|
@ -400,20 +400,20 @@ struct S {
|
|||
fn no_uses() {
|
||||
}
|
||||
|
||||
fn bar(a : f32, b : f32, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol : ptr<uniform, S>, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol_1 : ptr<storage, S>) {
|
||||
fn bar(a : f32, b : f32, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol : ptr<uniform, S>, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol_1 : ptr<storage, S>) {
|
||||
_ = *(tint_symbol);
|
||||
_ = *(tint_symbol_1);
|
||||
}
|
||||
|
||||
fn foo(a : f32, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol_2 : ptr<uniform, S>, [[internal(disable_validation__ignore_storage_class), internal(disable_validation__ignore_invalid_pointer_argument)]] tint_symbol_3 : ptr<storage, S>) {
|
||||
fn foo(a : f32, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol_2 : ptr<uniform, S>, @internal(disable_validation__ignore_storage_class) @internal(disable_validation__ignore_invalid_pointer_argument) tint_symbol_3 : ptr<storage, S>) {
|
||||
let b : f32 = 2.0;
|
||||
_ = *(tint_symbol_2);
|
||||
bar(a, b, tint_symbol_2, tint_symbol_3);
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol_4 : ptr<uniform, S>, [[group(0), binding(1), internal(disable_validation__entry_point_parameter), internal(disable_validation__ignore_storage_class)]] tint_symbol_5 : ptr<storage, S>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol_4 : ptr<uniform, S>, @group(0) @binding(1) @internal(disable_validation__entry_point_parameter) @internal(disable_validation__ignore_storage_class) tint_symbol_5 : ptr<storage, S>) {
|
||||
foo(1.0, tint_symbol_4, tint_symbol_5);
|
||||
}
|
||||
)";
|
||||
|
@ -425,10 +425,10 @@ fn main([[group(0), binding(0), internal(disable_validation__entry_point_paramet
|
|||
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, HandleTypes_Basic) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var t : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var s : sampler;
|
||||
@group(0) @binding(0) var t : texture_2d<f32>;
|
||||
@group(0) @binding(1) var s : sampler;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
_ = t;
|
||||
_ = s;
|
||||
|
@ -436,8 +436,8 @@ fn main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter)]] tint_symbol : texture_2d<f32>, [[group(0), binding(1), internal(disable_validation__entry_point_parameter)]] tint_symbol_1 : sampler) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) tint_symbol : texture_2d<f32>, @group(0) @binding(1) @internal(disable_validation__entry_point_parameter) tint_symbol_1 : sampler) {
|
||||
_ = tint_symbol;
|
||||
_ = tint_symbol_1;
|
||||
}
|
||||
|
@ -450,8 +450,8 @@ fn main([[group(0), binding(0), internal(disable_validation__entry_point_paramet
|
|||
|
||||
TEST_F(ModuleScopeVarToEntryPointParamTest, HandleTypes_FunctionCalls) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var t : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var s : sampler;
|
||||
@group(0) @binding(0) var t : texture_2d<f32>;
|
||||
@group(0) @binding(1) var s : sampler;
|
||||
|
||||
fn no_uses() {
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ fn foo(a : f32) {
|
|||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
foo(1.0);
|
||||
}
|
||||
|
@ -490,8 +490,8 @@ fn foo(a : f32, tint_symbol_2 : texture_2d<f32>, tint_symbol_3 : sampler) {
|
|||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[group(0), binding(0), internal(disable_validation__entry_point_parameter)]] tint_symbol_4 : texture_2d<f32>, [[group(0), binding(1), internal(disable_validation__entry_point_parameter)]] tint_symbol_5 : sampler) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@group(0) @binding(0) @internal(disable_validation__entry_point_parameter) tint_symbol_4 : texture_2d<f32>, @group(0) @binding(1) @internal(disable_validation__entry_point_parameter) tint_symbol_5 : sampler) {
|
||||
foo(1.0, tint_symbol_4, tint_symbol_5);
|
||||
}
|
||||
)";
|
||||
|
@ -505,7 +505,7 @@ TEST_F(ModuleScopeVarToEntryPointParamTest, Matrix) {
|
|||
auto* src = R"(
|
||||
var<workgroup> m : mat2x2<f32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
let x = m;
|
||||
}
|
||||
|
@ -516,8 +516,8 @@ struct tint_symbol_2 {
|
|||
m : mat2x2<f32>;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[internal(disable_validation__entry_point_parameter)]] tint_symbol_1 : ptr<workgroup, tint_symbol_2>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@internal(disable_validation__entry_point_parameter) tint_symbol_1 : ptr<workgroup, tint_symbol_2>) {
|
||||
let tint_symbol : ptr<workgroup, mat2x2<f32>> = &((*(tint_symbol_1)).m);
|
||||
let x = *(tint_symbol);
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ struct S2 {
|
|||
};
|
||||
var<workgroup> m : array<S2, 4>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
let x = m;
|
||||
}
|
||||
|
@ -557,8 +557,8 @@ struct tint_symbol_2 {
|
|||
m : array<S2, 4u>;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[internal(disable_validation__entry_point_parameter)]] tint_symbol_1 : ptr<workgroup, tint_symbol_2>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@internal(disable_validation__entry_point_parameter) tint_symbol_1 : ptr<workgroup, tint_symbol_2>) {
|
||||
let tint_symbol : ptr<workgroup, array<S2, 4u>> = &((*(tint_symbol_1)).m);
|
||||
let x = *(tint_symbol);
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ var<workgroup> a : S;
|
|||
|
||||
var<workgroup> b : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
let x = a;
|
||||
let y = b;
|
||||
|
@ -598,8 +598,8 @@ struct tint_symbol_3 {
|
|||
b : S;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[internal(disable_validation__entry_point_parameter)]] tint_symbol_1 : ptr<workgroup, tint_symbol_3>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@internal(disable_validation__entry_point_parameter) tint_symbol_1 : ptr<workgroup, tint_symbol_3>) {
|
||||
let tint_symbol : ptr<workgroup, S> = &((*(tint_symbol_1)).a);
|
||||
let tint_symbol_2 : ptr<workgroup, S> = &((*(tint_symbol_1)).b);
|
||||
let x = *(tint_symbol);
|
||||
|
@ -621,15 +621,15 @@ struct S {
|
|||
var<private> p : f32;
|
||||
var<workgroup> w : f32;
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
@group(0) @binding(0)
|
||||
var<uniform> ub : S;
|
||||
[[group(0), binding(1)]]
|
||||
@group(0) @binding(1)
|
||||
var<storage> sb : S;
|
||||
|
||||
[[group(0), binding(2)]] var t : texture_2d<f32>;
|
||||
[[group(0), binding(3)]] var s : sampler;
|
||||
@group(0) @binding(2) var t : texture_2d<f32>;
|
||||
@group(0) @binding(3) var s : sampler;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
}
|
||||
)";
|
||||
|
@ -639,7 +639,7 @@ struct S {
|
|||
a : f32;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
}
|
||||
)";
|
||||
|
|
|
@ -25,11 +25,11 @@ using MultiplanarExternalTextureTest = TransformTest;
|
|||
// result in an error.
|
||||
TEST_F(MultiplanarExternalTextureTest, ErrorNoPassedData) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
[[group(0), binding(1)]] var ext_tex : texture_external;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
@group(0) @binding(1) var ext_tex : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(ext_tex, s, coord.xy);
|
||||
}
|
||||
)";
|
||||
|
@ -43,11 +43,11 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
// Running the transform with incorrect binding data should result in an error.
|
||||
TEST_F(MultiplanarExternalTextureTest, ErrorIncorrectBindingPont) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
[[group(0), binding(1)]] var ext_tex : texture_external;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
@group(0) @binding(1) var ext_tex : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(ext_tex, s, coord.xy);
|
||||
}
|
||||
)";
|
||||
|
@ -67,10 +67,10 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
// Tests that the transform works with a textureDimensions call.
|
||||
TEST_F(MultiplanarExternalTextureTest, Dimensions) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var ext_tex : texture_external;
|
||||
@group(0) @binding(0) var ext_tex : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
var dim : vec2<i32>;
|
||||
dim = textureDimensions(ext_tex);
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -86,14 +86,14 @@ struct ExternalTextureParams {
|
|||
ub : f32;
|
||||
}
|
||||
|
||||
[[group(0), binding(1)]] var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(2)]] var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
@group(0) @binding(2) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
var dim : vec2<i32>;
|
||||
dim = textureDimensions(ext_tex);
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -110,17 +110,17 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
// Test that the transform works with a textureSampleLevel call.
|
||||
TEST_F(MultiplanarExternalTextureTest, BasicTextureSampleLevel) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
[[group(0), binding(1)]] var ext_tex : texture_external;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
@group(0) @binding(1) var ext_tex : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(ext_tex, s, coord.xy);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32;
|
||||
|
@ -130,11 +130,11 @@ struct ExternalTextureParams {
|
|||
ub : f32;
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(3)]] var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(1)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
if ((params.numPlanes == 1u)) {
|
||||
|
@ -150,8 +150,8 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
|||
return vec4<f32>(r, g, b, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleExternal(ext_tex, ext_tex_plane_1, s, coord.xy, ext_tex_params);
|
||||
}
|
||||
)";
|
||||
|
@ -166,10 +166,10 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
// Tests that the transform works with a textureLoad call.
|
||||
TEST_F(MultiplanarExternalTextureTest, BasicTextureLoad) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var ext_tex : texture_external;
|
||||
@group(0) @binding(0) var ext_tex : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoad(ext_tex, vec2<i32>(1, 1));
|
||||
}
|
||||
)";
|
||||
|
@ -183,11 +183,11 @@ struct ExternalTextureParams {
|
|||
ub : f32;
|
||||
}
|
||||
|
||||
[[group(0), binding(1)]] var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(2)]] var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
@group(0) @binding(2) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
if ((params.numPlanes == 1u)) {
|
||||
|
@ -203,8 +203,8 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
|||
return vec4<f32>(r, g, b, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoadExternal(ext_tex, ext_tex_plane_1, vec2<i32>(1, 1), ext_tex_params);
|
||||
}
|
||||
)";
|
||||
|
@ -220,17 +220,17 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
// call.
|
||||
TEST_F(MultiplanarExternalTextureTest, TextureSampleAndTextureLoad) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
[[group(0), binding(1)]] var ext_tex : texture_external;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
@group(0) @binding(1) var ext_tex : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(ext_tex, s, coord.xy) + textureLoad(ext_tex, vec2<i32>(1, 1));
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32;
|
||||
|
@ -240,11 +240,11 @@ struct ExternalTextureParams {
|
|||
ub : f32;
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(3)]] var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(1)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
if ((params.numPlanes == 1u)) {
|
||||
|
@ -274,8 +274,8 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
|||
return vec4<f32>(r, g, b, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return (textureSampleExternal(ext_tex, ext_tex_plane_1, s, coord.xy, ext_tex_params) + textureLoadExternal(ext_tex, ext_tex_plane_1, vec2<i32>(1, 1), ext_tex_params));
|
||||
}
|
||||
)";
|
||||
|
@ -290,20 +290,20 @@ fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
// Tests that the transform works with many instances of texture_external.
|
||||
TEST_F(MultiplanarExternalTextureTest, ManyTextureSampleLevel) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
[[group(0), binding(1)]] var ext_tex : texture_external;
|
||||
[[group(0), binding(2)]] var ext_tex_1 : texture_external;
|
||||
[[group(0), binding(3)]] var ext_tex_2 : texture_external;
|
||||
[[group(1), binding(0)]] var ext_tex_3 : texture_external;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
@group(0) @binding(1) var ext_tex : texture_external;
|
||||
@group(0) @binding(2) var ext_tex_1 : texture_external;
|
||||
@group(0) @binding(3) var ext_tex_2 : texture_external;
|
||||
@group(1) @binding(0) var ext_tex_3 : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(ext_tex, s, coord.xy) + textureSampleLevel(ext_tex_1, s, coord.xy) + textureSampleLevel(ext_tex_2, s, coord.xy) + textureSampleLevel(ext_tex_3, s, coord.xy);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32;
|
||||
|
@ -313,29 +313,29 @@ struct ExternalTextureParams {
|
|||
ub : f32;
|
||||
}
|
||||
|
||||
[[group(0), binding(4)]] var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@group(0) @binding(4) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(5)]] var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
@group(0) @binding(5) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(1)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(6)]] var ext_tex_plane_1_1 : texture_2d<f32>;
|
||||
@group(0) @binding(6) var ext_tex_plane_1_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(7)]] var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
@group(0) @binding(7) var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(2)]] var ext_tex_1 : texture_2d<f32>;
|
||||
@group(0) @binding(2) var ext_tex_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(8)]] var ext_tex_plane_1_2 : texture_2d<f32>;
|
||||
@group(0) @binding(8) var ext_tex_plane_1_2 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(9)]] var<uniform> ext_tex_params_2 : ExternalTextureParams;
|
||||
@group(0) @binding(9) var<uniform> ext_tex_params_2 : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(3)]] var ext_tex_2 : texture_2d<f32>;
|
||||
@group(0) @binding(3) var ext_tex_2 : texture_2d<f32>;
|
||||
|
||||
[[group(1), binding(1)]] var ext_tex_plane_1_3 : texture_2d<f32>;
|
||||
@group(1) @binding(1) var ext_tex_plane_1_3 : texture_2d<f32>;
|
||||
|
||||
[[group(1), binding(2)]] var<uniform> ext_tex_params_3 : ExternalTextureParams;
|
||||
@group(1) @binding(2) var<uniform> ext_tex_params_3 : ExternalTextureParams;
|
||||
|
||||
[[group(1), binding(0)]] var ext_tex_3 : texture_2d<f32>;
|
||||
@group(1) @binding(0) var ext_tex_3 : texture_2d<f32>;
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
if ((params.numPlanes == 1u)) {
|
||||
|
@ -351,8 +351,8 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
|||
return vec4<f32>(r, g, b, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return (((textureSampleExternal(ext_tex, ext_tex_plane_1, s, coord.xy, ext_tex_params) + textureSampleExternal(ext_tex_1, ext_tex_plane_1_1, s, coord.xy, ext_tex_params_1)) + textureSampleExternal(ext_tex_2, ext_tex_plane_1_2, s, coord.xy, ext_tex_params_2)) + textureSampleExternal(ext_tex_3, ext_tex_plane_1_3, s, coord.xy, ext_tex_params_3));
|
||||
}
|
||||
)";
|
||||
|
@ -377,10 +377,10 @@ fn f(t : texture_external, s : sampler) {
|
|||
textureSampleLevel(t, s, vec2<f32>(1.0, 2.0));
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_external;
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
@group(0) @binding(0) var ext_tex : texture_external;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(ext_tex, smp);
|
||||
}
|
||||
|
@ -413,15 +413,15 @@ fn f(t : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : Ex
|
|||
textureSampleExternal(t, ext_tex_plane_1, s, vec2<f32>(1.0, 2.0), ext_tex_params);
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var ext_tex_plane_1_1 : texture_2d<f32>;
|
||||
@group(0) @binding(2) var ext_tex_plane_1_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(3)]] var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(ext_tex, ext_tex_plane_1_1, ext_tex_params_1, smp);
|
||||
}
|
||||
|
@ -443,10 +443,10 @@ fn f(s : sampler, t : texture_external) {
|
|||
textureSampleLevel(t, s, vec2<f32>(1.0, 2.0));
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_external;
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
@group(0) @binding(0) var ext_tex : texture_external;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(smp, ext_tex);
|
||||
}
|
||||
|
@ -479,15 +479,15 @@ fn f(s : sampler, t : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_te
|
|||
textureSampleExternal(t, ext_tex_plane_1, s, vec2<f32>(1.0, 2.0), ext_tex_params);
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var ext_tex_plane_1_1 : texture_2d<f32>;
|
||||
@group(0) @binding(2) var ext_tex_plane_1_1 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(3)]] var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(smp, ext_tex, ext_tex_plane_1_1, ext_tex_params_1);
|
||||
}
|
||||
|
@ -510,11 +510,11 @@ fn f(t : texture_external, s : sampler, t2 : texture_external) {
|
|||
textureSampleLevel(t2, s, vec2<f32>(1.0, 2.0));
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_external;
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
[[group(0), binding(2)]] var ext_tex2 : texture_external;
|
||||
@group(0) @binding(0) var ext_tex : texture_external;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
@group(0) @binding(2) var ext_tex2 : texture_external;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(ext_tex, smp, ext_tex2);
|
||||
}
|
||||
|
@ -548,21 +548,21 @@ fn f(t : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : Ex
|
|||
textureSampleExternal(t2, ext_tex_plane_1_1, s, vec2<f32>(1.0, 2.0), ext_tex_params_1);
|
||||
}
|
||||
|
||||
[[group(0), binding(3)]] var ext_tex_plane_1_2 : texture_2d<f32>;
|
||||
@group(0) @binding(3) var ext_tex_plane_1_2 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(4)]] var<uniform> ext_tex_params_2 : ExternalTextureParams;
|
||||
@group(0) @binding(4) var<uniform> ext_tex_params_2 : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
|
||||
[[group(0), binding(5)]] var ext_tex_plane_1_3 : texture_2d<f32>;
|
||||
@group(0) @binding(5) var ext_tex_plane_1_3 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(6)]] var<uniform> ext_tex_params_3 : ExternalTextureParams;
|
||||
@group(0) @binding(6) var<uniform> ext_tex_params_3 : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(2)]] var ext_tex2 : texture_2d<f32>;
|
||||
@group(0) @binding(2) var ext_tex2 : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(ext_tex, ext_tex_plane_1_2, ext_tex_params_2, smp, ext_tex2, ext_tex_plane_1_3, ext_tex_params_3);
|
||||
}
|
||||
|
@ -589,10 +589,10 @@ fn f(t : texture_external, s : sampler) {
|
|||
nested(t, s);
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_external;
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
@group(0) @binding(0) var ext_tex : texture_external;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(ext_tex, smp);
|
||||
}
|
||||
|
@ -629,15 +629,15 @@ fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1
|
|||
nested(t, ext_tex_plane_1_1, ext_tex_params_1, s);
|
||||
}
|
||||
|
||||
[[group(0), binding(2)]] var ext_tex_plane_1_2 : texture_2d<f32>;
|
||||
@group(0) @binding(2) var ext_tex_plane_1_2 : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(3)]] var<uniform> ext_tex_params_2 : ExternalTextureParams;
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params_2 : ExternalTextureParams;
|
||||
|
||||
[[group(0), binding(0)]] var ext_tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(1)]] var smp : sampler;
|
||||
@group(0) @binding(1) var smp : sampler;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
f(ext_tex, ext_tex_plane_1_2, ext_tex_params_2, smp);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace transform {
|
|||
/// num_workgroups : vec3<u32>;
|
||||
/// };
|
||||
///
|
||||
/// [[group(0), binding(0)]]
|
||||
/// @group(0) @binding(0)
|
||||
/// var<uniform> num_workgroups_ubo : num_workgroups_struct;
|
||||
/// ```
|
||||
/// The binding group and number used for this uniform buffer is provided via
|
||||
|
|
|
@ -57,8 +57,8 @@ TEST_F(NumWorkgroupsFromUniformTest, Error_MissingCanonicalizeEntryPointIO) {
|
|||
|
||||
TEST_F(NumWorkgroupsFromUniformTest, Basic) {
|
||||
auto* src = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(num_workgroups)]] num_wgs : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(num_workgroups) num_wgs : vec3<u32>) {
|
||||
let groups_x = num_wgs.x;
|
||||
let groups_y = num_wgs.y;
|
||||
let groups_z = num_wgs.z;
|
||||
|
@ -70,7 +70,7 @@ struct tint_symbol_2 {
|
|||
num_workgroups : vec3<u32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_3 : tint_symbol_2;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_3 : tint_symbol_2;
|
||||
|
||||
fn main_inner(num_wgs : vec3<u32>) {
|
||||
let groups_x = num_wgs.x;
|
||||
|
@ -78,7 +78,7 @@ fn main_inner(num_wgs : vec3<u32>) {
|
|||
let groups_z = num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
main_inner(tint_symbol_3.num_workgroups);
|
||||
}
|
||||
|
@ -96,10 +96,10 @@ fn main() {
|
|||
TEST_F(NumWorkgroupsFromUniformTest, StructOnlyMember) {
|
||||
auto* src = R"(
|
||||
struct Builtins {
|
||||
[[builtin(num_workgroups)]] num_wgs : vec3<u32>;
|
||||
@builtin(num_workgroups) num_wgs : vec3<u32>;
|
||||
};
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(in : Builtins) {
|
||||
let groups_x = in.num_wgs.x;
|
||||
let groups_y = in.num_wgs.y;
|
||||
|
@ -112,7 +112,7 @@ struct tint_symbol_2 {
|
|||
num_workgroups : vec3<u32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_3 : tint_symbol_2;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_3 : tint_symbol_2;
|
||||
|
||||
struct Builtins {
|
||||
num_wgs : vec3<u32>;
|
||||
|
@ -124,7 +124,7 @@ fn main_inner(in : Builtins) {
|
|||
let groups_z = in.num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
main_inner(Builtins(tint_symbol_3.num_workgroups));
|
||||
}
|
||||
|
@ -142,12 +142,12 @@ fn main() {
|
|||
TEST_F(NumWorkgroupsFromUniformTest, StructMultipleMembers) {
|
||||
auto* src = R"(
|
||||
struct Builtins {
|
||||
[[builtin(global_invocation_id)]] gid : vec3<u32>;
|
||||
[[builtin(num_workgroups)]] num_wgs : vec3<u32>;
|
||||
[[builtin(workgroup_id)]] wgid : vec3<u32>;
|
||||
@builtin(global_invocation_id) gid : vec3<u32>;
|
||||
@builtin(num_workgroups) num_wgs : vec3<u32>;
|
||||
@builtin(workgroup_id) wgid : vec3<u32>;
|
||||
};
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(in : Builtins) {
|
||||
let groups_x = in.num_wgs.x;
|
||||
let groups_y = in.num_wgs.y;
|
||||
|
@ -160,7 +160,7 @@ struct tint_symbol_2 {
|
|||
num_workgroups : vec3<u32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_3 : tint_symbol_2;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_3 : tint_symbol_2;
|
||||
|
||||
struct Builtins {
|
||||
gid : vec3<u32>;
|
||||
|
@ -169,9 +169,9 @@ struct Builtins {
|
|||
}
|
||||
|
||||
struct tint_symbol_1 {
|
||||
[[builtin(global_invocation_id)]]
|
||||
@builtin(global_invocation_id)
|
||||
gid : vec3<u32>;
|
||||
[[builtin(workgroup_id)]]
|
||||
@builtin(workgroup_id)
|
||||
wgid : vec3<u32>;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ fn main_inner(in : Builtins) {
|
|||
let groups_z = in.num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(tint_symbol : tint_symbol_1) {
|
||||
main_inner(Builtins(tint_symbol.gid, tint_symbol_3.num_workgroups, tint_symbol.wgid));
|
||||
}
|
||||
|
@ -199,31 +199,31 @@ fn main(tint_symbol : tint_symbol_1) {
|
|||
TEST_F(NumWorkgroupsFromUniformTest, MultipleEntryPoints) {
|
||||
auto* src = R"(
|
||||
struct Builtins1 {
|
||||
[[builtin(num_workgroups)]] num_wgs : vec3<u32>;
|
||||
@builtin(num_workgroups) num_wgs : vec3<u32>;
|
||||
};
|
||||
|
||||
struct Builtins2 {
|
||||
[[builtin(global_invocation_id)]] gid : vec3<u32>;
|
||||
[[builtin(num_workgroups)]] num_wgs : vec3<u32>;
|
||||
[[builtin(workgroup_id)]] wgid : vec3<u32>;
|
||||
@builtin(global_invocation_id) gid : vec3<u32>;
|
||||
@builtin(num_workgroups) num_wgs : vec3<u32>;
|
||||
@builtin(workgroup_id) wgid : vec3<u32>;
|
||||
};
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main1(in : Builtins1) {
|
||||
let groups_x = in.num_wgs.x;
|
||||
let groups_y = in.num_wgs.y;
|
||||
let groups_z = in.num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main2(in : Builtins2) {
|
||||
let groups_x = in.num_wgs.x;
|
||||
let groups_y = in.num_wgs.y;
|
||||
let groups_z = in.num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main3([[builtin(num_workgroups)]] num_wgs : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main3(@builtin(num_workgroups) num_wgs : vec3<u32>) {
|
||||
let groups_x = num_wgs.x;
|
||||
let groups_y = num_wgs.y;
|
||||
let groups_z = num_wgs.z;
|
||||
|
@ -235,7 +235,7 @@ struct tint_symbol_6 {
|
|||
num_workgroups : vec3<u32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(30)]] var<uniform> tint_symbol_7 : tint_symbol_6;
|
||||
@group(0) @binding(30) var<uniform> tint_symbol_7 : tint_symbol_6;
|
||||
|
||||
struct Builtins1 {
|
||||
num_wgs : vec3<u32>;
|
||||
|
@ -253,15 +253,15 @@ fn main1_inner(in : Builtins1) {
|
|||
let groups_z = in.num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main1() {
|
||||
main1_inner(Builtins1(tint_symbol_7.num_workgroups));
|
||||
}
|
||||
|
||||
struct tint_symbol_3 {
|
||||
[[builtin(global_invocation_id)]]
|
||||
@builtin(global_invocation_id)
|
||||
gid : vec3<u32>;
|
||||
[[builtin(workgroup_id)]]
|
||||
@builtin(workgroup_id)
|
||||
wgid : vec3<u32>;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ fn main2_inner(in : Builtins2) {
|
|||
let groups_z = in.num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main2(tint_symbol_2 : tint_symbol_3) {
|
||||
main2_inner(Builtins2(tint_symbol_2.gid, tint_symbol_7.num_workgroups, tint_symbol_2.wgid));
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ fn main3_inner(num_wgs : vec3<u32>) {
|
|||
let groups_z = num_wgs.z;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main3() {
|
||||
main3_inner(tint_symbol_7.num_workgroups);
|
||||
}
|
||||
|
@ -300,11 +300,11 @@ fn main3() {
|
|||
TEST_F(NumWorkgroupsFromUniformTest, NoUsages) {
|
||||
auto* src = R"(
|
||||
struct Builtins {
|
||||
[[builtin(global_invocation_id)]] gid : vec3<u32>;
|
||||
[[builtin(workgroup_id)]] wgid : vec3<u32>;
|
||||
@builtin(global_invocation_id) gid : vec3<u32>;
|
||||
@builtin(workgroup_id) wgid : vec3<u32>;
|
||||
};
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(in : Builtins) {
|
||||
}
|
||||
)";
|
||||
|
@ -316,16 +316,16 @@ struct Builtins {
|
|||
}
|
||||
|
||||
struct tint_symbol_1 {
|
||||
[[builtin(global_invocation_id)]]
|
||||
@builtin(global_invocation_id)
|
||||
gid : vec3<u32>;
|
||||
[[builtin(workgroup_id)]]
|
||||
@builtin(workgroup_id)
|
||||
wgid : vec3<u32>;
|
||||
}
|
||||
|
||||
fn main_inner(in : Builtins) {
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(tint_symbol : tint_symbol_1) {
|
||||
main_inner(Builtins(tint_symbol.gid, tint_symbol.wgid));
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ var<private> arr : array<i32, 4>;
|
|||
|
||||
TEST_F(PadArrayElementsTest, ArrayAsGlobal) {
|
||||
auto* src = R"(
|
||||
var<private> arr : [[stride(8)]] array<i32, 4>;
|
||||
var<private> arr : @stride(8) array<i32, 4>;
|
||||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,12 @@ var<private> arr : array<tint_padded_array_element, 4u>;
|
|||
TEST_F(PadArrayElementsTest, RuntimeArray) {
|
||||
auto* src = R"(
|
||||
struct S {
|
||||
rta : [[stride(8)]] array<i32>;
|
||||
rta : @stride(8) array<i32>;
|
||||
};
|
||||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -87,15 +87,15 @@ struct S {
|
|||
TEST_F(PadArrayElementsTest, ArrayFunctionVar) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var arr : [[stride(16)]] array<i32, 4>;
|
||||
arr = [[stride(16)]] array<i32, 4>();
|
||||
arr = [[stride(16)]] array<i32, 4>(1, 2, 3, 4);
|
||||
var arr : @stride(16) array<i32, 4>;
|
||||
arr = @stride(16) array<i32, 4>();
|
||||
arr = @stride(16) array<i32, 4>(1, 2, 3, 4);
|
||||
let x = arr[3];
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(16)]]
|
||||
@size(16)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -114,13 +114,13 @@ fn f() {
|
|||
|
||||
TEST_F(PadArrayElementsTest, ArrayAsParam) {
|
||||
auto* src = R"(
|
||||
fn f(a : [[stride(12)]] array<i32, 4>) -> i32 {
|
||||
fn f(a : @stride(12) array<i32, 4>) -> i32 {
|
||||
return a[2];
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(12)]]
|
||||
@size(12)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -137,14 +137,14 @@ fn f(a : array<tint_padded_array_element, 4u>) -> i32 {
|
|||
// TODO(crbug.com/tint/781): Cannot parse the stride on the return array type.
|
||||
TEST_F(PadArrayElementsTest, DISABLED_ArrayAsReturn) {
|
||||
auto* src = R"(
|
||||
fn f() -> [[stride(8)]] array<i32, 4> {
|
||||
fn f() -> @stride(8) array<i32, 4> {
|
||||
return array<i32, 4>(1, 2, 3, 4);
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
el : i32;
|
||||
[[size(4)]]
|
||||
@size(4)
|
||||
padding : u32;
|
||||
};
|
||||
|
||||
|
@ -160,7 +160,7 @@ fn f() -> array<tint_padded_array_element, 4> {
|
|||
|
||||
TEST_F(PadArrayElementsTest, ArrayAlias) {
|
||||
auto* src = R"(
|
||||
type Array = [[stride(16)]] array<i32, 4>;
|
||||
type Array = @stride(16) array<i32, 4>;
|
||||
|
||||
fn f() {
|
||||
var arr : Array;
|
||||
|
@ -173,7 +173,7 @@ fn f() {
|
|||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(16)]]
|
||||
@size(16)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -197,25 +197,25 @@ fn f() {
|
|||
TEST_F(PadArrayElementsTest, ArraysInStruct) {
|
||||
auto* src = R"(
|
||||
struct S {
|
||||
a : [[stride(8)]] array<i32, 4>;
|
||||
b : [[stride(8)]] array<i32, 8>;
|
||||
c : [[stride(8)]] array<i32, 4>;
|
||||
d : [[stride(12)]] array<i32, 8>;
|
||||
a : @stride(8) array<i32, 4>;
|
||||
b : @stride(8) array<i32, 8>;
|
||||
c : @stride(8) array<i32, 4>;
|
||||
d : @stride(12) array<i32, 8>;
|
||||
};
|
||||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_1 {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_2 {
|
||||
[[size(12)]]
|
||||
@size(12)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -235,39 +235,39 @@ struct S {
|
|||
TEST_F(PadArrayElementsTest, ArraysOfArraysInStruct) {
|
||||
auto* src = R"(
|
||||
struct S {
|
||||
a : [[stride(512)]] array<i32, 4>;
|
||||
b : [[stride(512)]] array<[[stride(32)]] array<i32, 4>, 4>;
|
||||
c : [[stride(512)]] array<[[stride(64)]] array<[[stride(8)]] array<i32, 4>, 4>, 4>;
|
||||
a : @stride(512) array<i32, 4>;
|
||||
b : @stride(512) array<@stride(32) array<i32, 4>, 4>;
|
||||
c : @stride(512) array<@stride(64) array<@stride(8) array<i32, 4>, 4>, 4>;
|
||||
};
|
||||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(512)]]
|
||||
@size(512)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_2 {
|
||||
[[size(32)]]
|
||||
@size(32)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_1 {
|
||||
[[size(512)]]
|
||||
@size(512)
|
||||
el : array<tint_padded_array_element_2, 4u>;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_5 {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_4 {
|
||||
[[size(64)]]
|
||||
@size(64)
|
||||
el : array<tint_padded_array_element_5, 4u>;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_3 {
|
||||
[[size(512)]]
|
||||
@size(512)
|
||||
el : array<tint_padded_array_element_4, 4u>;
|
||||
}
|
||||
|
||||
|
@ -286,9 +286,9 @@ struct S {
|
|||
TEST_F(PadArrayElementsTest, AccessArraysOfArraysInStruct) {
|
||||
auto* src = R"(
|
||||
struct S {
|
||||
a : [[stride(512)]] array<i32, 4>;
|
||||
b : [[stride(512)]] array<[[stride(32)]] array<i32, 4>, 4>;
|
||||
c : [[stride(512)]] array<[[stride(64)]] array<[[stride(8)]] array<i32, 4>, 4>, 4>;
|
||||
a : @stride(512) array<i32, 4>;
|
||||
b : @stride(512) array<@stride(32) array<i32, 4>, 4>;
|
||||
c : @stride(512) array<@stride(64) array<@stride(8) array<i32, 4>, 4>, 4>;
|
||||
};
|
||||
|
||||
fn f(s : S) -> i32 {
|
||||
|
@ -297,32 +297,32 @@ fn f(s : S) -> i32 {
|
|||
)";
|
||||
auto* expect = R"(
|
||||
struct tint_padded_array_element {
|
||||
[[size(512)]]
|
||||
@size(512)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_2 {
|
||||
[[size(32)]]
|
||||
@size(32)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_1 {
|
||||
[[size(512)]]
|
||||
@size(512)
|
||||
el : array<tint_padded_array_element_2, 4u>;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_5 {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_4 {
|
||||
[[size(64)]]
|
||||
@size(64)
|
||||
el : array<tint_padded_array_element_5, 4u>;
|
||||
}
|
||||
|
||||
struct tint_padded_array_element_3 {
|
||||
[[size(512)]]
|
||||
@size(512)
|
||||
el : array<tint_padded_array_element_4, 4u>;
|
||||
}
|
||||
|
||||
|
@ -346,24 +346,24 @@ TEST_F(PadArrayElementsTest, DeclarationOrder) {
|
|||
auto* src = R"(
|
||||
type T0 = i32;
|
||||
|
||||
type T1 = [[stride(8)]] array<i32, 1>;
|
||||
type T1 = @stride(8) array<i32, 1>;
|
||||
|
||||
type T2 = i32;
|
||||
|
||||
fn f1(a : [[stride(8)]] array<i32, 2>) {
|
||||
fn f1(a : @stride(8) array<i32, 2>) {
|
||||
}
|
||||
|
||||
type T3 = i32;
|
||||
|
||||
fn f2() {
|
||||
var v : [[stride(8)]] array<i32, 3>;
|
||||
var v : @stride(8) array<i32, 3>;
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
type T0 = i32;
|
||||
|
||||
struct tint_padded_array_element {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ type T1 = array<tint_padded_array_element, 1u>;
|
|||
type T2 = i32;
|
||||
|
||||
struct tint_padded_array_element_1 {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ fn f1(a : array<tint_padded_array_element_1, 2u>) {
|
|||
type T3 = i32;
|
||||
|
||||
struct tint_padded_array_element_2 {
|
||||
[[size(8)]]
|
||||
@size(8)
|
||||
el : i32;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(RemovePhoniesTest, EmptyModule) {
|
|||
|
||||
TEST_F(RemovePhoniesTest, NoSideEffects) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var t : texture_2d<f32>;
|
||||
@group(0) @binding(0) var t : texture_2d<f32>;
|
||||
|
||||
fn f() {
|
||||
var v : i32;
|
||||
|
@ -54,7 +54,7 @@ fn f() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var t : texture_2d<f32>;
|
||||
@group(0) @binding(0) var t : texture_2d<f32>;
|
||||
|
||||
fn f() {
|
||||
var v : i32;
|
||||
|
@ -177,7 +177,7 @@ struct S {
|
|||
arr : array<i32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
fn x() -> i32 {
|
||||
return 0;
|
||||
|
@ -206,7 +206,7 @@ struct S {
|
|||
arr : array<i32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> s : S;
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
fn x() -> i32 {
|
||||
return 0;
|
||||
|
|
|
@ -46,9 +46,9 @@ fn test(vert_idx : u32) -> u32 {
|
|||
return vert_idx;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn entry([[builtin(vertex_index)]] vert_idx : u32
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry(@builtin(vertex_index) vert_idx : u32
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
ignore(test(vert_idx));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ fn tint_symbol(tint_symbol_1 : u32) -> u32 {
|
|||
return tint_symbol_1;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn tint_symbol_2([[builtin(vertex_index)]] tint_symbol_1 : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn tint_symbol_2(@builtin(vertex_index) tint_symbol_1 : u32) -> @builtin(position) vec4<f32> {
|
||||
ignore(tint_symbol(tint_symbol_1));
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ fn tint_symbol_2([[builtin(vertex_index)]] tint_symbol_1 : u32) -> [[builtin(pos
|
|||
|
||||
TEST_F(RenamerTest, PreserveSwizzles) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn entry() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry() -> @builtin(position) vec4<f32> {
|
||||
var v : vec4<f32>;
|
||||
var rgba : f32;
|
||||
var xyzw : f32;
|
||||
|
@ -93,8 +93,8 @@ fn entry() -> [[builtin(position)]] vec4<f32> {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(vertex)]]
|
||||
fn tint_symbol() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn tint_symbol() -> @builtin(position) vec4<f32> {
|
||||
var tint_symbol_1 : vec4<f32>;
|
||||
var tint_symbol_2 : f32;
|
||||
var tint_symbol_3 : f32;
|
||||
|
@ -120,16 +120,16 @@ fn tint_symbol() -> [[builtin(position)]] vec4<f32> {
|
|||
|
||||
TEST_F(RenamerTest, PreserveIntrinsics) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn entry() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry() -> @builtin(position) vec4<f32> {
|
||||
var blah : vec4<f32>;
|
||||
return abs(blah);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(vertex)]]
|
||||
fn tint_symbol() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn tint_symbol() -> @builtin(position) vec4<f32> {
|
||||
var tint_symbol_1 : vec4<f32>;
|
||||
return abs(tint_symbol_1);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ fn tint_symbol() -> [[builtin(position)]] vec4<f32> {
|
|||
|
||||
TEST_F(RenamerTest, PreserveBuiltinTypes) {
|
||||
auto* src = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn entry() {
|
||||
var a = modf(1.0).whole;
|
||||
var b = modf(1.0).fract;
|
||||
|
@ -161,7 +161,7 @@ fn entry() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn tint_symbol() {
|
||||
var tint_symbol_1 = modf(1.0).whole;
|
||||
var tint_symbol_2 = modf(1.0).fract;
|
||||
|
@ -186,8 +186,8 @@ fn tint_symbol() {
|
|||
|
||||
TEST_F(RenamerTest, AttemptSymbolCollision) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn entry() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn entry() -> @builtin(position) vec4<f32> {
|
||||
var tint_symbol : vec4<f32>;
|
||||
var tint_symbol_2 : vec4<f32>;
|
||||
var tint_symbol_4 : vec4<f32>;
|
||||
|
@ -196,8 +196,8 @@ fn entry() -> [[builtin(position)]] vec4<f32> {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(vertex)]]
|
||||
fn tint_symbol() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn tint_symbol() -> @builtin(position) vec4<f32> {
|
||||
var tint_symbol_1 : vec4<f32>;
|
||||
var tint_symbol_2 : vec4<f32>;
|
||||
var tint_symbol_3 : vec4<f32>;
|
||||
|
@ -229,7 +229,7 @@ TEST_P(RenamerTestGlsl, Keywords) {
|
|||
auto keyword = GetParam();
|
||||
|
||||
auto src = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
var )" + keyword +
|
||||
R"( : i32;
|
||||
|
@ -237,7 +237,7 @@ fn frag_main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
var tint_symbol : i32;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ TEST_P(RenamerTestHlsl, Keywords) {
|
|||
auto keyword = GetParam();
|
||||
|
||||
auto src = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
var )" + keyword +
|
||||
R"( : i32;
|
||||
|
@ -262,7 +262,7 @@ fn frag_main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
var tint_symbol : i32;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ TEST_P(RenamerTestMsl, Keywords) {
|
|||
auto keyword = GetParam();
|
||||
|
||||
auto src = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
var )" + keyword +
|
||||
R"( : i32;
|
||||
|
@ -287,7 +287,7 @@ fn frag_main() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
var tint_symbol : i32;
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ struct S {
|
|||
a : array<f32, 0x7fffffff>;
|
||||
b : array<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
fn f() {
|
||||
// Signed
|
||||
|
@ -217,7 +217,7 @@ struct S {
|
|||
b : array<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
fn f() {
|
||||
var i32_a1 : f32 = s.a[2147483646];
|
||||
|
@ -579,7 +579,7 @@ fn f() {
|
|||
|
||||
// TODO(dsinclair): Implement when constant_id exists
|
||||
TEST_F(RobustnessTest, DISABLED_Vector_Constant_Id_Clamps) {
|
||||
// [[override(1300)]] let idx : i32;
|
||||
// @override(1300) let idx : i32;
|
||||
// var a : vec3<f32>
|
||||
// var b : f32 = a[idx]
|
||||
//
|
||||
|
@ -588,7 +588,7 @@ TEST_F(RobustnessTest, DISABLED_Vector_Constant_Id_Clamps) {
|
|||
|
||||
// TODO(dsinclair): Implement when constant_id exists
|
||||
TEST_F(RobustnessTest, DISABLED_Array_Constant_Id_Clamps) {
|
||||
// [[override(1300)]] let idx : i32;
|
||||
// @override(1300) let idx : i32;
|
||||
// var a : array<f32, 4>
|
||||
// var b : f32 = a[idx]
|
||||
//
|
||||
|
@ -597,7 +597,7 @@ TEST_F(RobustnessTest, DISABLED_Array_Constant_Id_Clamps) {
|
|||
|
||||
// TODO(dsinclair): Implement when constant_id exists
|
||||
TEST_F(RobustnessTest, DISABLED_Matrix_Column_Constant_Id_Clamps) {
|
||||
// [[override(1300)]] let idx : i32;
|
||||
// @override(1300) let idx : i32;
|
||||
// var a : mat3x2<f32>
|
||||
// var b : f32 = a[idx][1]
|
||||
//
|
||||
|
@ -606,7 +606,7 @@ TEST_F(RobustnessTest, DISABLED_Matrix_Column_Constant_Id_Clamps) {
|
|||
|
||||
// TODO(dsinclair): Implement when constant_id exists
|
||||
TEST_F(RobustnessTest, DISABLED_Matrix_Row_Constant_Id_Clamps) {
|
||||
// [[override(1300)]] let idx : i32;
|
||||
// @override(1300) let idx : i32;
|
||||
// var a : mat3x2<f32>
|
||||
// var b : f32 = a[1][idx]
|
||||
//
|
||||
|
@ -619,7 +619,7 @@ struct S {
|
|||
a : f32;
|
||||
b : array<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
fn f() {
|
||||
var d : f32 = s.b[25];
|
||||
|
@ -632,7 +632,7 @@ struct S {
|
|||
b : array<f32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
fn f() {
|
||||
var d : f32 = s.b[min(25u, (arrayLength(&(s.b)) - 1u))];
|
||||
|
@ -652,14 +652,14 @@ TEST_F(RobustnessTest, DISABLED_Atomics_Clamp) {
|
|||
// Clamp textureLoad() coord, array_index and level values
|
||||
TEST_F(RobustnessTest, TextureLoad_Clamp) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var tex_1d : texture_1d<f32>;
|
||||
[[group(0), binding(0)]] var tex_2d : texture_2d<f32>;
|
||||
[[group(0), binding(0)]] var tex_2d_arr : texture_2d_array<f32>;
|
||||
[[group(0), binding(0)]] var tex_3d : texture_3d<f32>;
|
||||
[[group(0), binding(0)]] var tex_ms_2d : texture_multisampled_2d<f32>;
|
||||
[[group(0), binding(0)]] var tex_depth_2d : texture_depth_2d;
|
||||
[[group(0), binding(0)]] var tex_depth_2d_arr : texture_depth_2d_array;
|
||||
[[group(0), binding(0)]] var tex_external : texture_external;
|
||||
@group(0) @binding(0) var tex_1d : texture_1d<f32>;
|
||||
@group(0) @binding(0) var tex_2d : texture_2d<f32>;
|
||||
@group(0) @binding(0) var tex_2d_arr : texture_2d_array<f32>;
|
||||
@group(0) @binding(0) var tex_3d : texture_3d<f32>;
|
||||
@group(0) @binding(0) var tex_ms_2d : texture_multisampled_2d<f32>;
|
||||
@group(0) @binding(0) var tex_depth_2d : texture_depth_2d;
|
||||
@group(0) @binding(0) var tex_depth_2d_arr : texture_depth_2d_array;
|
||||
@group(0) @binding(0) var tex_external : texture_external;
|
||||
|
||||
fn f() {
|
||||
var array_idx : i32;
|
||||
|
@ -679,21 +679,21 @@ fn f() {
|
|||
|
||||
auto* expect =
|
||||
R"(
|
||||
[[group(0), binding(0)]] var tex_1d : texture_1d<f32>;
|
||||
@group(0) @binding(0) var tex_1d : texture_1d<f32>;
|
||||
|
||||
[[group(0), binding(0)]] var tex_2d : texture_2d<f32>;
|
||||
@group(0) @binding(0) var tex_2d : texture_2d<f32>;
|
||||
|
||||
[[group(0), binding(0)]] var tex_2d_arr : texture_2d_array<f32>;
|
||||
@group(0) @binding(0) var tex_2d_arr : texture_2d_array<f32>;
|
||||
|
||||
[[group(0), binding(0)]] var tex_3d : texture_3d<f32>;
|
||||
@group(0) @binding(0) var tex_3d : texture_3d<f32>;
|
||||
|
||||
[[group(0), binding(0)]] var tex_ms_2d : texture_multisampled_2d<f32>;
|
||||
@group(0) @binding(0) var tex_ms_2d : texture_multisampled_2d<f32>;
|
||||
|
||||
[[group(0), binding(0)]] var tex_depth_2d : texture_depth_2d;
|
||||
@group(0) @binding(0) var tex_depth_2d : texture_depth_2d;
|
||||
|
||||
[[group(0), binding(0)]] var tex_depth_2d_arr : texture_depth_2d_array;
|
||||
@group(0) @binding(0) var tex_depth_2d_arr : texture_depth_2d_array;
|
||||
|
||||
[[group(0), binding(0)]] var tex_external : texture_external;
|
||||
@group(0) @binding(0) var tex_external : texture_external;
|
||||
|
||||
fn f() {
|
||||
var array_idx : i32;
|
||||
|
@ -718,13 +718,13 @@ fn f() {
|
|||
// Clamp textureStore() coord, array_index and level values
|
||||
TEST_F(RobustnessTest, TextureStore_Clamp) {
|
||||
auto* src = R"(
|
||||
[[group(0), binding(0)]] var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
@group(0) @binding(0) var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
|
||||
[[group(0), binding(1)]] var tex2d : texture_storage_2d<rgba8sint, write>;
|
||||
@group(0) @binding(1) var tex2d : texture_storage_2d<rgba8sint, write>;
|
||||
|
||||
[[group(0), binding(2)]] var tex2d_arr : texture_storage_2d_array<rgba8sint, write>;
|
||||
@group(0) @binding(2) var tex2d_arr : texture_storage_2d_array<rgba8sint, write>;
|
||||
|
||||
[[group(0), binding(3)]] var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
@group(0) @binding(3) var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
|
||||
fn f() {
|
||||
textureStore(tex1d, 10, vec4<i32>());
|
||||
|
@ -735,13 +735,13 @@ fn f() {
|
|||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[group(0), binding(0)]] var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
@group(0) @binding(0) var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
|
||||
[[group(0), binding(1)]] var tex2d : texture_storage_2d<rgba8sint, write>;
|
||||
@group(0) @binding(1) var tex2d : texture_storage_2d<rgba8sint, write>;
|
||||
|
||||
[[group(0), binding(2)]] var tex2d_arr : texture_storage_2d_array<rgba8sint, write>;
|
||||
@group(0) @binding(2) var tex2d_arr : texture_storage_2d_array<rgba8sint, write>;
|
||||
|
||||
[[group(0), binding(3)]] var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
@group(0) @binding(3) var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
|
||||
fn f() {
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1))), vec4<i32>());
|
||||
|
@ -779,7 +779,7 @@ struct S {
|
|||
b : array<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
let c : u32 = 1u;
|
||||
|
||||
|
@ -796,7 +796,7 @@ struct S {
|
|||
b : array<f32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
let c : u32 = 1u;
|
||||
|
||||
|
@ -817,13 +817,13 @@ struct S {
|
|||
a : array<f32, 4>;
|
||||
b : array<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
type UArr = [[stride(16)]] array<f32, 4>;
|
||||
type UArr = @stride(16) array<f32, 4>;
|
||||
struct U {
|
||||
a : UArr;
|
||||
};
|
||||
[[group(1), binding(0)]] var<uniform> u : U;
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
// Signed
|
||||
|
@ -876,15 +876,15 @@ struct S {
|
|||
b : array<f32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
type UArr = [[stride(16)]] array<f32, 4>;
|
||||
type UArr = @stride(16) array<f32, 4>;
|
||||
|
||||
struct U {
|
||||
a : UArr;
|
||||
}
|
||||
|
||||
[[group(1), binding(0)]] var<uniform> u : U;
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[3];
|
||||
|
@ -939,15 +939,15 @@ struct S {
|
|||
b : array<f32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
type UArr = [[stride(16)]] array<f32, 4>;
|
||||
type UArr = @stride(16) array<f32, 4>;
|
||||
|
||||
struct U {
|
||||
a : UArr;
|
||||
}
|
||||
|
||||
[[group(1), binding(0)]] var<uniform> u : U;
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[4];
|
||||
|
@ -1004,15 +1004,15 @@ struct S {
|
|||
b : array<f32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
type UArr = [[stride(16)]] array<f32, 4>;
|
||||
type UArr = @stride(16) array<f32, 4>;
|
||||
|
||||
struct U {
|
||||
a : UArr;
|
||||
}
|
||||
|
||||
[[group(1), binding(0)]] var<uniform> u : U;
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[3];
|
||||
|
@ -1069,15 +1069,15 @@ struct S {
|
|||
b : array<f32>;
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> s : S;
|
||||
@group(0) @binding(0) var<storage, read> s : S;
|
||||
|
||||
type UArr = [[stride(16)]] array<f32, 4>;
|
||||
type UArr = @stride(16) array<f32, 4>;
|
||||
|
||||
struct U {
|
||||
a : UArr;
|
||||
}
|
||||
|
||||
[[group(1), binding(0)]] var<uniform> u : U;
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[4];
|
||||
|
|
|
@ -249,7 +249,7 @@ fn foo() -> i32 {
|
|||
return 1;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
var arr = array<f32, 4>();
|
||||
for (let a = &arr[foo()]; ;) {
|
||||
|
@ -264,7 +264,7 @@ fn foo() -> i32 {
|
|||
return 1;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
var arr = array<f32, 4>();
|
||||
let a_save = foo();
|
||||
|
@ -350,7 +350,7 @@ TEST_F(SimplifyPointersTest, ShadowPointer) {
|
|||
auto* src = R"(
|
||||
var<private> a : array<i32, 2>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
let x = &a;
|
||||
var a : i32 = (*x)[0];
|
||||
|
@ -363,7 +363,7 @@ fn main() {
|
|||
auto* expect = R"(
|
||||
var<private> a : array<i32, 2>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
var a_1 : i32 = a[0];
|
||||
{
|
||||
|
|
|
@ -49,8 +49,8 @@ TEST_F(SingleEntryPointTest, Error_NoEntryPoints) {
|
|||
|
||||
TEST_F(SingleEntryPointTest, Error_InvalidEntryPoint) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
@ -70,7 +70,7 @@ TEST_F(SingleEntryPointTest, Error_NotAnEntryPoint) {
|
|||
auto* src = R"(
|
||||
fn foo() {}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {}
|
||||
)";
|
||||
|
||||
|
@ -87,7 +87,7 @@ fn main() {}
|
|||
|
||||
TEST_F(SingleEntryPointTest, SingleEntryPoint) {
|
||||
auto* src = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main() {
|
||||
}
|
||||
)";
|
||||
|
@ -103,26 +103,26 @@ fn main() {
|
|||
|
||||
TEST_F(SingleEntryPointTest, MultipleEntryPoints) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn vert_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vert_main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main2() {
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
}
|
||||
)";
|
||||
|
@ -146,23 +146,23 @@ var<private> c : f32;
|
|||
|
||||
var<private> d : f32;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vert_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vert_main() -> @builtin(position) vec4<f32> {
|
||||
a = 0.0;
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
b = 0.0;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
c = 0.0;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main2() {
|
||||
d = 0.0;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ fn comp_main2() {
|
|||
auto* expect = R"(
|
||||
var<private> c : f32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
c = 0.0;
|
||||
}
|
||||
|
@ -196,23 +196,23 @@ let c : f32 = 1.0;
|
|||
|
||||
let d : f32 = 1.0;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vert_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn vert_main() -> @builtin(position) vec4<f32> {
|
||||
let local_a : f32 = a;
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn frag_main() {
|
||||
let local_b : f32 = b;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
let local_c : f32 = c;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main2() {
|
||||
let local_d : f32 = d;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ fn comp_main2() {
|
|||
auto* expect = R"(
|
||||
let c : f32 = 1.0;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
let local_c : f32 = c;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ TEST_F(SingleEntryPointTest, WorkgroupSizeLetPreserved) {
|
|||
auto* src = R"(
|
||||
let size : i32 = 1;
|
||||
|
||||
[[stage(compute), workgroup_size(size)]]
|
||||
@stage(compute) @workgroup_size(size)
|
||||
fn main() {
|
||||
}
|
||||
)";
|
||||
|
@ -258,32 +258,32 @@ fn main() {
|
|||
|
||||
TEST_F(SingleEntryPointTest, OverridableConstants) {
|
||||
auto* src = R"(
|
||||
[[override(1001)]] let c1 : u32 = 1u;
|
||||
@override(1001) let c1 : u32 = 1u;
|
||||
[[override]] let c2 : u32 = 1u;
|
||||
[[override(0)]] let c3 : u32 = 1u;
|
||||
[[override(9999)]] let c4 : u32 = 1u;
|
||||
@override(0) let c3 : u32 = 1u;
|
||||
@override(9999) let c4 : u32 = 1u;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
let local_d = c1;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main2() {
|
||||
let local_d = c2;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main3() {
|
||||
let local_d = c3;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main4() {
|
||||
let local_d = c4;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main5() {
|
||||
let local_d = 1u;
|
||||
}
|
||||
|
@ -292,9 +292,9 @@ fn comp_main5() {
|
|||
{
|
||||
SingleEntryPoint::Config cfg("comp_main1");
|
||||
auto* expect = R"(
|
||||
[[override(1001)]] let c1 : u32 = 1u;
|
||||
@override(1001) let c1 : u32 = 1u;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
let local_d = c1;
|
||||
}
|
||||
|
@ -310,9 +310,9 @@ fn comp_main1() {
|
|||
// The decorator is replaced with the one with explicit id
|
||||
// And should not be affected by other constants stripped away
|
||||
auto* expect = R"(
|
||||
[[override(1)]] let c2 : u32 = 1u;
|
||||
@override(1) let c2 : u32 = 1u;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main2() {
|
||||
let local_d = c2;
|
||||
}
|
||||
|
@ -326,9 +326,9 @@ fn comp_main2() {
|
|||
{
|
||||
SingleEntryPoint::Config cfg("comp_main3");
|
||||
auto* expect = R"(
|
||||
[[override(0)]] let c3 : u32 = 1u;
|
||||
@override(0) let c3 : u32 = 1u;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main3() {
|
||||
let local_d = c3;
|
||||
}
|
||||
|
@ -342,9 +342,9 @@ fn comp_main3() {
|
|||
{
|
||||
SingleEntryPoint::Config cfg("comp_main4");
|
||||
auto* expect = R"(
|
||||
[[override(9999)]] let c4 : u32 = 1u;
|
||||
@override(9999) let c4 : u32 = 1u;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main4() {
|
||||
let local_d = c4;
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ fn comp_main4() {
|
|||
{
|
||||
SingleEntryPoint::Config cfg("comp_main5");
|
||||
auto* expect = R"(
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main5() {
|
||||
let local_d = 1u;
|
||||
}
|
||||
|
@ -391,12 +391,12 @@ fn outer2() {
|
|||
inner_shared();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
outer1();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main2() {
|
||||
outer2();
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ fn outer1() {
|
|||
inner_shared();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
outer1();
|
||||
}
|
||||
|
@ -465,12 +465,12 @@ fn outer2() {
|
|||
outer2_var = 0.0;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
outer1();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main2() {
|
||||
outer2();
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ fn outer1() {
|
|||
outer1_var = 0.0;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main1() {
|
||||
outer1();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ TEST_P(VectorizeScalarMatrixConstructorsTest, Basic) {
|
|||
}
|
||||
|
||||
std::string tmpl = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let m = ${matrix}(${values});
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ TEST_P(VectorizeScalarMatrixConstructorsTest, NonScalarConstructors) {
|
|||
}
|
||||
|
||||
std::string tmpl = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let m = ${matrix}(${columns});
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ TEST_F(VertexPullingTest, Error_NoEntryPoint) {
|
|||
|
||||
TEST_F(VertexPullingTest, Error_InvalidEntryPoint) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
@ -58,7 +58,7 @@ fn main() -> [[builtin(position)]] vec4<f32> {
|
|||
|
||||
TEST_F(VertexPullingTest, Error_EntryPointWrongStage) {
|
||||
auto* src = R"(
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() {}
|
||||
)";
|
||||
|
||||
|
@ -76,8 +76,8 @@ fn main() {}
|
|||
|
||||
TEST_F(VertexPullingTest, Error_BadStride) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : f32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : f32) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(var_a, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
@ -100,19 +100,19 @@ fn main([[location(0)]] var_a : f32) -> [[builtin(position)]] vec4<f32> {
|
|||
|
||||
TEST_F(VertexPullingTest, BasicModule) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
@ -129,21 +129,21 @@ fn main() -> [[builtin(position)]] vec4<f32> {
|
|||
|
||||
TEST_F(VertexPullingTest, OneAttribute) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : f32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : f32) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(var_a, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var var_a : f32;
|
||||
{
|
||||
let buffer_array_base_0 = tint_pulling_vertex_index;
|
||||
|
@ -167,21 +167,21 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
|
|||
|
||||
TEST_F(VertexPullingTest, OneInstancedAttribute) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : f32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : f32) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(var_a, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(instance_index)]] tint_pulling_instance_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(instance_index) tint_pulling_instance_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var var_a : f32;
|
||||
{
|
||||
let buffer_array_base_0 = tint_pulling_instance_index;
|
||||
|
@ -205,21 +205,21 @@ fn main([[builtin(instance_index)]] tint_pulling_instance_index : u32) -> [[buil
|
|||
|
||||
TEST_F(VertexPullingTest, OneAttributeDifferentOutputSet) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : f32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : f32) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(var_a, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(5)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(5) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var var_a : f32;
|
||||
{
|
||||
let buffer_array_base_0 = tint_pulling_vertex_index;
|
||||
|
@ -245,29 +245,29 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
|
|||
TEST_F(VertexPullingTest, OneAttribute_Struct) {
|
||||
auto* src = R"(
|
||||
struct Inputs {
|
||||
[[location(0)]] var_a : f32;
|
||||
@location(0) var_a : f32;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(inputs : Inputs) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(inputs.var_a, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
struct Inputs {
|
||||
[[location(0)]]
|
||||
@location(0)
|
||||
var_a : f32;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var inputs : Inputs;
|
||||
{
|
||||
let buffer_array_base_0 = tint_pulling_vertex_index;
|
||||
|
@ -292,27 +292,27 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
|
|||
// We expect the transform to use an existing builtin variables if it finds them
|
||||
TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : f32,
|
||||
[[location(1)]] var_b : f32,
|
||||
[[builtin(vertex_index)]] custom_vertex_index : u32,
|
||||
[[builtin(instance_index)]] custom_instance_index : u32
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : f32,
|
||||
@location(1) var_b : f32,
|
||||
@builtin(vertex_index) custom_vertex_index : u32,
|
||||
@builtin(instance_index) custom_instance_index : u32
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(var_a, var_b, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[binding(1), group(4)]] var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
@binding(1) @group(4) var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] custom_vertex_index : u32, [[builtin(instance_index)]] custom_instance_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) custom_vertex_index : u32, @builtin(instance_index) custom_instance_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var var_a : f32;
|
||||
var var_b : f32;
|
||||
{
|
||||
|
@ -350,47 +350,47 @@ fn main([[builtin(vertex_index)]] custom_vertex_index : u32, [[builtin(instance_
|
|||
TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex_Struct) {
|
||||
auto* src = R"(
|
||||
struct Inputs {
|
||||
[[location(0)]] var_a : f32;
|
||||
[[location(1)]] var_b : f32;
|
||||
[[builtin(vertex_index)]] custom_vertex_index : u32;
|
||||
[[builtin(instance_index)]] custom_instance_index : u32;
|
||||
@location(0) var_a : f32;
|
||||
@location(1) var_b : f32;
|
||||
@builtin(vertex_index) custom_vertex_index : u32;
|
||||
@builtin(instance_index) custom_instance_index : u32;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(inputs : Inputs) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(inputs.var_a, inputs.var_b, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[binding(1), group(4)]] var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
@binding(1) @group(4) var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
|
||||
struct tint_symbol {
|
||||
[[builtin(vertex_index)]]
|
||||
@builtin(vertex_index)
|
||||
custom_vertex_index : u32;
|
||||
[[builtin(instance_index)]]
|
||||
@builtin(instance_index)
|
||||
custom_instance_index : u32;
|
||||
}
|
||||
|
||||
struct Inputs {
|
||||
[[location(0)]]
|
||||
@location(0)
|
||||
var_a : f32;
|
||||
[[location(1)]]
|
||||
@location(1)
|
||||
var_b : f32;
|
||||
[[builtin(vertex_index)]]
|
||||
@builtin(vertex_index)
|
||||
custom_vertex_index : u32;
|
||||
[[builtin(instance_index)]]
|
||||
@builtin(instance_index)
|
||||
custom_instance_index : u32;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main(tint_symbol_1 : tint_symbol) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(tint_symbol_1 : tint_symbol) -> @builtin(position) vec4<f32> {
|
||||
var inputs : Inputs;
|
||||
inputs.custom_vertex_index = tint_symbol_1.custom_vertex_index;
|
||||
inputs.custom_instance_index = tint_symbol_1.custom_instance_index;
|
||||
|
@ -429,46 +429,46 @@ fn main(tint_symbol_1 : tint_symbol) -> [[builtin(position)]] vec4<f32> {
|
|||
TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex_SeparateStruct) {
|
||||
auto* src = R"(
|
||||
struct Inputs {
|
||||
[[location(0)]] var_a : f32;
|
||||
[[location(1)]] var_b : f32;
|
||||
@location(0) var_a : f32;
|
||||
@location(1) var_b : f32;
|
||||
};
|
||||
|
||||
struct Indices {
|
||||
[[builtin(vertex_index)]] custom_vertex_index : u32;
|
||||
[[builtin(instance_index)]] custom_instance_index : u32;
|
||||
@builtin(vertex_index) custom_vertex_index : u32;
|
||||
@builtin(instance_index) custom_instance_index : u32;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main(inputs : Inputs, indices : Indices) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(inputs : Inputs, indices : Indices) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(inputs.var_a, inputs.var_b, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[binding(1), group(4)]] var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
@binding(1) @group(4) var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
|
||||
struct Inputs {
|
||||
[[location(0)]]
|
||||
@location(0)
|
||||
var_a : f32;
|
||||
[[location(1)]]
|
||||
@location(1)
|
||||
var_b : f32;
|
||||
}
|
||||
|
||||
struct Indices {
|
||||
[[builtin(vertex_index)]]
|
||||
@builtin(vertex_index)
|
||||
custom_vertex_index : u32;
|
||||
[[builtin(instance_index)]]
|
||||
@builtin(instance_index)
|
||||
custom_instance_index : u32;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main(indices : Indices) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(indices : Indices) -> @builtin(position) vec4<f32> {
|
||||
var inputs : Inputs;
|
||||
{
|
||||
let buffer_array_base_0 = indices.custom_vertex_index;
|
||||
|
@ -504,22 +504,22 @@ fn main(indices : Indices) -> [[builtin(position)]] vec4<f32> {
|
|||
|
||||
TEST_F(VertexPullingTest, TwoAttributesSameBuffer) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : f32,
|
||||
[[location(1)]] var_b : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : f32,
|
||||
@location(1) var_b : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var var_a : f32;
|
||||
var var_b : vec4<f32>;
|
||||
{
|
||||
|
@ -547,28 +547,28 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
|
|||
|
||||
TEST_F(VertexPullingTest, FloatVectorAttributes) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : vec2<f32>,
|
||||
[[location(1)]] var_b : vec3<f32>,
|
||||
[[location(2)]] var_c : vec4<f32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : vec2<f32>,
|
||||
@location(1) var_b : vec3<f32>,
|
||||
@location(2) var_c : vec4<f32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[binding(1), group(4)]] var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
@binding(1) @group(4) var<storage, read> tint_pulling_vertex_buffer_1 : TintVertexData;
|
||||
|
||||
[[binding(2), group(4)]] var<storage, read> tint_pulling_vertex_buffer_2 : TintVertexData;
|
||||
@binding(2) @group(4) var<storage, read> tint_pulling_vertex_buffer_2 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var var_a : vec2<f32>;
|
||||
var var_b : vec3<f32>;
|
||||
var var_c : vec4<f32>;
|
||||
|
@ -601,9 +601,9 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
|
|||
|
||||
TEST_F(VertexPullingTest, AttemptSymbolCollision) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] var_a : f32,
|
||||
[[location(1)]] var_b : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) var_a : f32,
|
||||
@location(1) var_b : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
var tint_pulling_vertex_index : i32;
|
||||
var tint_pulling_vertex_buffer_0 : i32;
|
||||
var tint_vertex_data : i32;
|
||||
|
@ -614,13 +614,13 @@ fn main([[location(0)]] var_a : f32,
|
|||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data_1 : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data_1 : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0_1 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0_1 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index_1 : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index_1 : u32) -> @builtin(position) vec4<f32> {
|
||||
var var_a : f32;
|
||||
var var_b : vec4<f32>;
|
||||
{
|
||||
|
@ -652,52 +652,52 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index_1 : u32) -> [[builti
|
|||
|
||||
TEST_F(VertexPullingTest, FormatsAligned) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(
|
||||
[[location(0)]] uint8x2 : vec2<u32>,
|
||||
[[location(1)]] uint8x4 : vec4<u32>,
|
||||
[[location(2)]] sint8x2 : vec2<i32>,
|
||||
[[location(3)]] sint8x4 : vec4<i32>,
|
||||
[[location(4)]] unorm8x2 : vec2<f32>,
|
||||
[[location(5)]] unorm8x4 : vec4<f32>,
|
||||
[[location(6)]] snorm8x2 : vec2<f32>,
|
||||
[[location(7)]] snorm8x4 : vec4<f32>,
|
||||
[[location(8)]] uint16x2 : vec2<u32>,
|
||||
[[location(9)]] uint16x4 : vec4<u32>,
|
||||
[[location(10)]] sint16x2 : vec2<i32>,
|
||||
[[location(11)]] sint16x4 : vec4<i32>,
|
||||
[[location(12)]] unorm16x2 : vec2<f32>,
|
||||
[[location(13)]] unorm16x4 : vec4<f32>,
|
||||
[[location(14)]] snorm16x2 : vec2<f32>,
|
||||
[[location(15)]] snorm16x4 : vec4<f32>,
|
||||
[[location(16)]] float16x2 : vec2<f32>,
|
||||
[[location(17)]] float16x4 : vec4<f32>,
|
||||
[[location(18)]] float32 : f32,
|
||||
[[location(19)]] float32x2 : vec2<f32>,
|
||||
[[location(20)]] float32x3 : vec3<f32>,
|
||||
[[location(21)]] float32x4 : vec4<f32>,
|
||||
[[location(22)]] uint32 : u32,
|
||||
[[location(23)]] uint32x2 : vec2<u32>,
|
||||
[[location(24)]] uint32x3 : vec3<u32>,
|
||||
[[location(25)]] uint32x4 : vec4<u32>,
|
||||
[[location(26)]] sint32 : i32,
|
||||
[[location(27)]] sint32x2 : vec2<i32>,
|
||||
[[location(28)]] sint32x3 : vec3<i32>,
|
||||
[[location(29)]] sint32x4 : vec4<i32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@location(0) uint8x2 : vec2<u32>,
|
||||
@location(1) uint8x4 : vec4<u32>,
|
||||
@location(2) sint8x2 : vec2<i32>,
|
||||
@location(3) sint8x4 : vec4<i32>,
|
||||
@location(4) unorm8x2 : vec2<f32>,
|
||||
@location(5) unorm8x4 : vec4<f32>,
|
||||
@location(6) snorm8x2 : vec2<f32>,
|
||||
@location(7) snorm8x4 : vec4<f32>,
|
||||
@location(8) uint16x2 : vec2<u32>,
|
||||
@location(9) uint16x4 : vec4<u32>,
|
||||
@location(10) sint16x2 : vec2<i32>,
|
||||
@location(11) sint16x4 : vec4<i32>,
|
||||
@location(12) unorm16x2 : vec2<f32>,
|
||||
@location(13) unorm16x4 : vec4<f32>,
|
||||
@location(14) snorm16x2 : vec2<f32>,
|
||||
@location(15) snorm16x4 : vec4<f32>,
|
||||
@location(16) float16x2 : vec2<f32>,
|
||||
@location(17) float16x4 : vec4<f32>,
|
||||
@location(18) float32 : f32,
|
||||
@location(19) float32x2 : vec2<f32>,
|
||||
@location(20) float32x3 : vec3<f32>,
|
||||
@location(21) float32x4 : vec4<f32>,
|
||||
@location(22) uint32 : u32,
|
||||
@location(23) uint32x2 : vec2<u32>,
|
||||
@location(24) uint32x3 : vec3<u32>,
|
||||
@location(25) uint32x4 : vec4<u32>,
|
||||
@location(26) sint32 : i32,
|
||||
@location(27) sint32x2 : vec2<i32>,
|
||||
@location(28) sint32x3 : vec3<i32>,
|
||||
@location(29) sint32x4 : vec4<i32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var uint8x2 : vec2<u32>;
|
||||
var uint8x4 : vec4<u32>;
|
||||
var sint8x2 : vec2<i32>;
|
||||
|
@ -811,39 +811,39 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
|
|||
|
||||
TEST_F(VertexPullingTest, FormatsStrideUnaligned) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(
|
||||
[[location(0)]] uint8x2 : vec2<u32>,
|
||||
[[location(1)]] uint8x4 : vec4<u32>,
|
||||
[[location(2)]] sint8x2 : vec2<i32>,
|
||||
[[location(3)]] sint8x4 : vec4<i32>,
|
||||
[[location(4)]] unorm8x2 : vec2<f32>,
|
||||
[[location(5)]] unorm8x4 : vec4<f32>,
|
||||
[[location(6)]] snorm8x2 : vec2<f32>,
|
||||
[[location(7)]] snorm8x4 : vec4<f32>,
|
||||
[[location(8)]] uint16x2 : vec2<u32>,
|
||||
[[location(9)]] uint16x4 : vec4<u32>,
|
||||
[[location(10)]] sint16x2 : vec2<i32>,
|
||||
[[location(11)]] sint16x4 : vec4<i32>,
|
||||
[[location(12)]] unorm16x2 : vec2<f32>,
|
||||
[[location(13)]] unorm16x4 : vec4<f32>,
|
||||
[[location(14)]] snorm16x2 : vec2<f32>,
|
||||
[[location(15)]] snorm16x4 : vec4<f32>,
|
||||
[[location(16)]] float16x2 : vec2<f32>,
|
||||
[[location(17)]] float16x4 : vec4<f32>,
|
||||
[[location(18)]] float32 : f32,
|
||||
[[location(19)]] float32x2 : vec2<f32>,
|
||||
[[location(20)]] float32x3 : vec3<f32>,
|
||||
[[location(21)]] float32x4 : vec4<f32>,
|
||||
[[location(22)]] uint32 : u32,
|
||||
[[location(23)]] uint32x2 : vec2<u32>,
|
||||
[[location(24)]] uint32x3 : vec3<u32>,
|
||||
[[location(25)]] uint32x4 : vec4<u32>,
|
||||
[[location(26)]] sint32 : i32,
|
||||
[[location(27)]] sint32x2 : vec2<i32>,
|
||||
[[location(28)]] sint32x3 : vec3<i32>,
|
||||
[[location(29)]] sint32x4 : vec4<i32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@location(0) uint8x2 : vec2<u32>,
|
||||
@location(1) uint8x4 : vec4<u32>,
|
||||
@location(2) sint8x2 : vec2<i32>,
|
||||
@location(3) sint8x4 : vec4<i32>,
|
||||
@location(4) unorm8x2 : vec2<f32>,
|
||||
@location(5) unorm8x4 : vec4<f32>,
|
||||
@location(6) snorm8x2 : vec2<f32>,
|
||||
@location(7) snorm8x4 : vec4<f32>,
|
||||
@location(8) uint16x2 : vec2<u32>,
|
||||
@location(9) uint16x4 : vec4<u32>,
|
||||
@location(10) sint16x2 : vec2<i32>,
|
||||
@location(11) sint16x4 : vec4<i32>,
|
||||
@location(12) unorm16x2 : vec2<f32>,
|
||||
@location(13) unorm16x4 : vec4<f32>,
|
||||
@location(14) snorm16x2 : vec2<f32>,
|
||||
@location(15) snorm16x4 : vec4<f32>,
|
||||
@location(16) float16x2 : vec2<f32>,
|
||||
@location(17) float16x4 : vec4<f32>,
|
||||
@location(18) float32 : f32,
|
||||
@location(19) float32x2 : vec2<f32>,
|
||||
@location(20) float32x3 : vec3<f32>,
|
||||
@location(21) float32x4 : vec4<f32>,
|
||||
@location(22) uint32 : u32,
|
||||
@location(23) uint32x2 : vec2<u32>,
|
||||
@location(24) uint32x3 : vec3<u32>,
|
||||
@location(25) uint32x4 : vec4<u32>,
|
||||
@location(26) sint32 : i32,
|
||||
@location(27) sint32x2 : vec2<i32>,
|
||||
@location(28) sint32x3 : vec3<i32>,
|
||||
@location(29) sint32x4 : vec4<i32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
@ -851,13 +851,13 @@ fn main(
|
|||
auto* expect =
|
||||
R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var uint8x2 : vec2<u32>;
|
||||
var uint8x4 : vec4<u32>;
|
||||
var sint8x2 : vec2<i32>;
|
||||
|
@ -971,52 +971,52 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
|
|||
|
||||
TEST_F(VertexPullingTest, FormatsWithVectorsResized) {
|
||||
auto* src = R"(
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(
|
||||
[[location(0)]] uint8x2 : vec3<u32>,
|
||||
[[location(1)]] uint8x4 : vec2<u32>,
|
||||
[[location(2)]] sint8x2 : i32,
|
||||
[[location(3)]] sint8x4 : vec2<i32>,
|
||||
[[location(4)]] unorm8x2 : vec4<f32>,
|
||||
[[location(5)]] unorm8x4 : f32,
|
||||
[[location(6)]] snorm8x2 : vec3<f32>,
|
||||
[[location(7)]] snorm8x4 : f32,
|
||||
[[location(8)]] uint16x2 : vec3<u32>,
|
||||
[[location(9)]] uint16x4 : vec2<u32>,
|
||||
[[location(10)]] sint16x2 : vec4<i32>,
|
||||
[[location(11)]] sint16x4 : i32,
|
||||
[[location(12)]] unorm16x2 : vec3<f32>,
|
||||
[[location(13)]] unorm16x4 : f32,
|
||||
[[location(14)]] snorm16x2 : vec4<f32>,
|
||||
[[location(15)]] snorm16x4 : vec3<f32>,
|
||||
[[location(16)]] float16x2 : vec4<f32>,
|
||||
[[location(17)]] float16x4 : f32,
|
||||
[[location(18)]] float32 : vec4<f32>,
|
||||
[[location(19)]] float32x2 : vec4<f32>,
|
||||
[[location(20)]] float32x3 : vec2<f32>,
|
||||
[[location(21)]] float32x4 : vec3<f32>,
|
||||
[[location(22)]] uint32 : vec3<u32>,
|
||||
[[location(23)]] uint32x2 : vec4<u32>,
|
||||
[[location(24)]] uint32x3 : vec4<u32>,
|
||||
[[location(25)]] uint32x4 : vec2<u32>,
|
||||
[[location(26)]] sint32 : vec4<i32>,
|
||||
[[location(27)]] sint32x2 : vec3<i32>,
|
||||
[[location(28)]] sint32x3 : i32,
|
||||
[[location(29)]] sint32x4 : vec2<i32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@location(0) uint8x2 : vec3<u32>,
|
||||
@location(1) uint8x4 : vec2<u32>,
|
||||
@location(2) sint8x2 : i32,
|
||||
@location(3) sint8x4 : vec2<i32>,
|
||||
@location(4) unorm8x2 : vec4<f32>,
|
||||
@location(5) unorm8x4 : f32,
|
||||
@location(6) snorm8x2 : vec3<f32>,
|
||||
@location(7) snorm8x4 : f32,
|
||||
@location(8) uint16x2 : vec3<u32>,
|
||||
@location(9) uint16x4 : vec2<u32>,
|
||||
@location(10) sint16x2 : vec4<i32>,
|
||||
@location(11) sint16x4 : i32,
|
||||
@location(12) unorm16x2 : vec3<f32>,
|
||||
@location(13) unorm16x4 : f32,
|
||||
@location(14) snorm16x2 : vec4<f32>,
|
||||
@location(15) snorm16x4 : vec3<f32>,
|
||||
@location(16) float16x2 : vec4<f32>,
|
||||
@location(17) float16x4 : f32,
|
||||
@location(18) float32 : vec4<f32>,
|
||||
@location(19) float32x2 : vec4<f32>,
|
||||
@location(20) float32x3 : vec2<f32>,
|
||||
@location(21) float32x4 : vec3<f32>,
|
||||
@location(22) uint32 : vec3<u32>,
|
||||
@location(23) uint32x2 : vec4<u32>,
|
||||
@location(24) uint32x3 : vec4<u32>,
|
||||
@location(25) uint32x4 : vec2<u32>,
|
||||
@location(26) sint32 : vec4<i32>,
|
||||
@location(27) sint32x2 : vec3<i32>,
|
||||
@location(28) sint32x3 : i32,
|
||||
@location(29) sint32x4 : vec2<i32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct TintVertexData {
|
||||
tint_vertex_data : [[stride(4)]] array<u32>;
|
||||
tint_vertex_data : @stride(4) array<u32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(4)]] var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
@binding(0) @group(4) var<storage, read> tint_pulling_vertex_buffer_0 : TintVertexData;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
var uint8x2 : vec3<u32>;
|
||||
var uint8x4 : vec2<u32>;
|
||||
var sint8x2 : i32;
|
||||
|
|
|
@ -60,7 +60,7 @@ fn unreferenced() {
|
|||
b = c;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
}
|
||||
)";
|
||||
|
@ -75,16 +75,16 @@ TEST_F(ZeroInitWorkgroupMemoryTest, SingleWorkgroupVar_ExistingLocalIndex) {
|
|||
auto* src = R"(
|
||||
var<workgroup> v : i32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
ignore(v); // Initialization should be inserted above this statement
|
||||
}
|
||||
)";
|
||||
auto* expect = R"(
|
||||
var<workgroup> v : i32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
{
|
||||
v = i32();
|
||||
}
|
||||
|
@ -104,10 +104,10 @@ TEST_F(ZeroInitWorkgroupMemoryTest,
|
|||
var<workgroup> v : i32;
|
||||
|
||||
struct Params {
|
||||
[[builtin(local_invocation_index)]] local_idx : u32;
|
||||
@builtin(local_invocation_index) local_idx : u32;
|
||||
};
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(params : Params) {
|
||||
ignore(v); // Initialization should be inserted above this statement
|
||||
}
|
||||
|
@ -116,11 +116,11 @@ fn f(params : Params) {
|
|||
var<workgroup> v : i32;
|
||||
|
||||
struct Params {
|
||||
[[builtin(local_invocation_index)]]
|
||||
@builtin(local_invocation_index)
|
||||
local_idx : u32;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(params : Params) {
|
||||
{
|
||||
v = i32();
|
||||
|
@ -139,7 +139,7 @@ TEST_F(ZeroInitWorkgroupMemoryTest, SingleWorkgroupVar_InjectedLocalIndex) {
|
|||
auto* src = R"(
|
||||
var<workgroup> v : i32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
ignore(v); // Initialization should be inserted above this statement
|
||||
}
|
||||
|
@ -147,8 +147,8 @@ fn f() {
|
|||
auto* expect = R"(
|
||||
var<workgroup> v : i32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_invocation_index : u32) {
|
||||
{
|
||||
v = i32();
|
||||
}
|
||||
|
@ -176,8 +176,8 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
ignore(a); // Initialization should be inserted above this statement
|
||||
ignore(b);
|
||||
ignore(c);
|
||||
|
@ -195,8 +195,8 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
{
|
||||
a = i32();
|
||||
b.x = i32();
|
||||
|
@ -240,8 +240,8 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(2, 3)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(2, 3)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
ignore(a); // Initialization should be inserted above this statement
|
||||
ignore(b);
|
||||
ignore(c);
|
||||
|
@ -259,8 +259,8 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(2, 3)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(2, 3)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
if ((local_idx < 1u)) {
|
||||
a = i32();
|
||||
b.x = i32();
|
||||
|
@ -304,10 +304,10 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[override(1)]] let X : i32;
|
||||
@override(1) let X : i32;
|
||||
|
||||
[[stage(compute), workgroup_size(2, 3, X)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(2, 3, X)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
ignore(a); // Initialization should be inserted above this statement
|
||||
ignore(b);
|
||||
ignore(c);
|
||||
|
@ -326,10 +326,10 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[override(1)]] let X : i32;
|
||||
@override(1) let X : i32;
|
||||
|
||||
[[stage(compute), workgroup_size(2, 3, X)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(2, 3, X)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
for(var idx : u32 = local_idx; (idx < 1u); idx = (idx + (u32(X) * 6u))) {
|
||||
a = i32();
|
||||
b.x = i32();
|
||||
|
@ -374,10 +374,10 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[override(1)]] let X : u32;
|
||||
@override(1) let X : u32;
|
||||
|
||||
[[stage(compute), workgroup_size(5u, X, 10u)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(5u, X, 10u)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
ignore(a); // Initialization should be inserted above this statement
|
||||
ignore(b);
|
||||
ignore(c);
|
||||
|
@ -397,10 +397,10 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[override(1)]] let X : u32;
|
||||
@override(1) let X : u32;
|
||||
|
||||
[[stage(compute), workgroup_size(5u, X, 10u)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(5u, X, 10u)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
for(var idx : u32 = local_idx; (idx < 1u); idx = (idx + (X * 50u))) {
|
||||
a = i32();
|
||||
}
|
||||
|
@ -462,8 +462,8 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_id)]] local_invocation_id : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_id) local_invocation_id : vec3<u32>) {
|
||||
ignore(a); // Initialization should be inserted above this statement
|
||||
ignore(b);
|
||||
ignore(c);
|
||||
|
@ -481,8 +481,8 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_id)]] local_invocation_id : vec3<u32>, [[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_id) local_invocation_id : vec3<u32>, @builtin(local_invocation_index) local_invocation_index : u32) {
|
||||
{
|
||||
a = i32();
|
||||
b.x = i32();
|
||||
|
@ -525,18 +525,18 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f1() {
|
||||
ignore(a); // Initialization should be inserted above this statement
|
||||
ignore(c);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1, 2, 3)]]
|
||||
fn f2([[builtin(local_invocation_id)]] local_invocation_id : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1, 2, 3)
|
||||
fn f2(@builtin(local_invocation_id) local_invocation_id : vec3<u32>) {
|
||||
ignore(b); // Initialization should be inserted above this statement
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(4, 5, 6)]]
|
||||
@stage(compute) @workgroup_size(4, 5, 6)
|
||||
fn f3() {
|
||||
ignore(c); // Initialization should be inserted above this statement
|
||||
ignore(a);
|
||||
|
@ -554,8 +554,8 @@ var<workgroup> b : S;
|
|||
|
||||
var<workgroup> c : array<S, 32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f1([[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f1(@builtin(local_invocation_index) local_invocation_index : u32) {
|
||||
{
|
||||
a = i32();
|
||||
}
|
||||
|
@ -573,8 +573,8 @@ fn f1([[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
|||
ignore(c);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1, 2, 3)]]
|
||||
fn f2([[builtin(local_invocation_id)]] local_invocation_id : vec3<u32>, [[builtin(local_invocation_index)]] local_invocation_index_1 : u32) {
|
||||
@stage(compute) @workgroup_size(1, 2, 3)
|
||||
fn f2(@builtin(local_invocation_id) local_invocation_id : vec3<u32>, @builtin(local_invocation_index) local_invocation_index_1 : u32) {
|
||||
if ((local_invocation_index_1 < 1u)) {
|
||||
b.x = i32();
|
||||
}
|
||||
|
@ -586,8 +586,8 @@ fn f2([[builtin(local_invocation_id)]] local_invocation_id : vec3<u32>, [[builti
|
|||
ignore(b);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(4, 5, 6)]]
|
||||
fn f3([[builtin(local_invocation_index)]] local_invocation_index_2 : u32) {
|
||||
@stage(compute) @workgroup_size(4, 5, 6)
|
||||
fn f3(@builtin(local_invocation_index) local_invocation_index_2 : u32) {
|
||||
if ((local_invocation_index_2 < 1u)) {
|
||||
a = i32();
|
||||
}
|
||||
|
@ -623,8 +623,8 @@ fn call_use_v() {
|
|||
use_v();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
call_use_v(); // Initialization should be inserted above this statement
|
||||
}
|
||||
)";
|
||||
|
@ -639,8 +639,8 @@ fn call_use_v() {
|
|||
use_v();
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_idx : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_idx : u32) {
|
||||
{
|
||||
v = i32();
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ TEST_F(ZeroInitWorkgroupMemoryTest, WorkgroupAtomics) {
|
|||
var<workgroup> i : atomic<i32>;
|
||||
var<workgroup> u : atomic<u32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
ignore(i); // Initialization should be inserted above this statement
|
||||
ignore(u);
|
||||
|
@ -670,8 +670,8 @@ var<workgroup> i : atomic<i32>;
|
|||
|
||||
var<workgroup> u : atomic<u32>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_invocation_index : u32) {
|
||||
{
|
||||
atomicStore(&(i), i32());
|
||||
atomicStore(&(u), u32());
|
||||
|
@ -699,7 +699,7 @@ struct S {
|
|||
|
||||
var<workgroup> w : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
ignore(w); // Initialization should be inserted above this statement
|
||||
}
|
||||
|
@ -715,8 +715,8 @@ struct S {
|
|||
|
||||
var<workgroup> w : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_invocation_index : u32) {
|
||||
{
|
||||
w.a = i32();
|
||||
atomicStore(&(w.i), i32());
|
||||
|
@ -738,7 +738,7 @@ TEST_F(ZeroInitWorkgroupMemoryTest, WorkgroupArrayOfAtomics) {
|
|||
auto* src = R"(
|
||||
var<workgroup> w : array<atomic<u32>, 4>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
ignore(w); // Initialization should be inserted above this statement
|
||||
}
|
||||
|
@ -746,8 +746,8 @@ fn f() {
|
|||
auto* expect = R"(
|
||||
var<workgroup> w : array<atomic<u32>, 4>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_invocation_index : u32) {
|
||||
for(var idx : u32 = local_invocation_index; (idx < 4u); idx = (idx + 1u)) {
|
||||
let i : u32 = idx;
|
||||
atomicStore(&(w[i]), u32());
|
||||
|
@ -774,7 +774,7 @@ struct S {
|
|||
|
||||
var<workgroup> w : array<S, 4>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f() {
|
||||
ignore(w); // Initialization should be inserted above this statement
|
||||
}
|
||||
|
@ -790,8 +790,8 @@ struct S {
|
|||
|
||||
var<workgroup> w : array<S, 4>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn f([[builtin(local_invocation_index)]] local_invocation_index : u32) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn f(@builtin(local_invocation_index) local_invocation_index : u32) {
|
||||
for(var idx : u32 = local_invocation_index; (idx < 4u); idx = (idx + 1u)) {
|
||||
let i_1 : u32 = idx;
|
||||
w[i_1].a = i32();
|
||||
|
|
|
@ -127,7 +127,7 @@ TEST_F(GlslGeneratorImplTest_Function, PtrParameter) {
|
|||
|
||||
TEST_F(GlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_WithInOutVars) {
|
||||
// fn frag_main([[location(0)]] foo : f32) -> [[location(1)]] f32 {
|
||||
// fn frag_main(@location(0) foo : f32) -> @location(1) f32 {
|
||||
// return foo;
|
||||
// }
|
||||
auto* foo_in = Param("foo", ty.f32(), {Location(0)});
|
||||
|
@ -173,7 +173,7 @@ void main() {
|
|||
|
||||
TEST_F(GlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_WithInOut_Builtins) {
|
||||
// fn frag_main([[position(0)]] coord : vec4<f32>) -> [[frag_depth]] f32 {
|
||||
// fn frag_main(@position(0) coord : vec4<f32>) -> @frag_depth f32 {
|
||||
// return coord.x;
|
||||
// }
|
||||
auto* coord_in =
|
||||
|
@ -221,9 +221,9 @@ void main() {
|
|||
TEST_F(GlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_SharedStruct_DifferentStages) {
|
||||
// struct Interface {
|
||||
// [[builtin(position)]] pos : vec4<f32>;
|
||||
// [[location(1)]] col1 : f32;
|
||||
// [[location(2)]] col2 : f32;
|
||||
// @builtin(position) pos : vec4<f32>;
|
||||
// @location(1) col1 : f32;
|
||||
// @location(2) col2 : f32;
|
||||
// };
|
||||
// fn vert_main() -> Interface {
|
||||
// return Interface(vec4<f32>(), 0.4, 0.6);
|
||||
|
@ -332,7 +332,7 @@ void main() {
|
|||
TEST_F(GlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_SharedStruct_HelperFunction) {
|
||||
// struct VertexOutput {
|
||||
// [[builtin(position)]] pos : vec4<f32>;
|
||||
// @builtin(position) pos : vec4<f32>;
|
||||
// };
|
||||
// fn foo(x : f32) -> VertexOutput {
|
||||
// return VertexOutput(vec4<f32>(x, x, x, 1.0));
|
||||
|
@ -1032,15 +1032,15 @@ TEST_F(GlslGeneratorImplTest_Function,
|
|||
// [[block]] struct Data {
|
||||
// d : f32;
|
||||
// };
|
||||
// [[binding(0), group(0)]] var<storage> data : Data;
|
||||
// @binding(0) @group(0) var<storage> data : Data;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn a() {
|
||||
// var v = data.d;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn b() {
|
||||
// var v = data.d;
|
||||
// return;
|
||||
|
|
|
@ -372,7 +372,7 @@ void main() {
|
|||
TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray) {
|
||||
// struct Data {
|
||||
// a : [[stride(4)]] array<i32, 5>;
|
||||
// a : @stride(4) array<i32, 5>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[2];
|
||||
|
@ -420,7 +420,7 @@ void main() {
|
|||
TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
||||
EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
|
||||
// struct Data {
|
||||
// a : [[stride(4)]] array<i32, 5>;
|
||||
// a : @stride(4) array<i32, 5>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[(2 + 4) - 3];
|
||||
|
@ -468,7 +468,7 @@ void main() {
|
|||
|
||||
TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
|
||||
// struct Data {
|
||||
// a : [[stride(4)]] array<i32, 5>;
|
||||
// a : @stride(4) array<i32, 5>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[2] = 2;
|
||||
|
@ -518,7 +518,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -578,7 +578,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -640,7 +640,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -702,7 +702,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -763,7 +763,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -822,7 +822,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
|
|
@ -113,7 +113,7 @@ TEST_F(HlslGeneratorImplTest_Function, PtrParameter) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_WithInOutVars) {
|
||||
// fn frag_main([[location(0)]] foo : f32) -> [[location(1)]] f32 {
|
||||
// fn frag_main(@location(0) foo : f32) -> @location(1) f32 {
|
||||
// return foo;
|
||||
// }
|
||||
auto* foo_in = Param("foo", ty.f32(), {Location(0)});
|
||||
|
@ -145,7 +145,7 @@ tint_symbol_2 frag_main(tint_symbol_1 tint_symbol) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_WithInOut_Builtins) {
|
||||
// fn frag_main([[position(0)]] coord : vec4<f32>) -> [[frag_depth]] f32 {
|
||||
// fn frag_main(@position(0) coord : vec4<f32>) -> @frag_depth f32 {
|
||||
// return coord.x;
|
||||
// }
|
||||
auto* coord_in =
|
||||
|
@ -181,9 +181,9 @@ tint_symbol_2 frag_main(tint_symbol_1 tint_symbol) {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_SharedStruct_DifferentStages) {
|
||||
// struct Interface {
|
||||
// [[builtin(position)]] pos : vec4<f32>;
|
||||
// [[location(1)]] col1 : f32;
|
||||
// [[location(2)]] col2 : f32;
|
||||
// @builtin(position) pos : vec4<f32>;
|
||||
// @location(1) col1 : f32;
|
||||
// @location(2) col2 : f32;
|
||||
// };
|
||||
// fn vert_main() -> Interface {
|
||||
// return Interface(vec4<f32>(), 0.4, 0.6);
|
||||
|
@ -265,7 +265,7 @@ void frag_main(tint_symbol_2 tint_symbol_1) {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_Decoration_EntryPoint_SharedStruct_HelperFunction) {
|
||||
// struct VertexOutput {
|
||||
// [[builtin(position)]] pos : vec4<f32>;
|
||||
// @builtin(position) pos : vec4<f32>;
|
||||
// };
|
||||
// fn foo(x : f32) -> VertexOutput {
|
||||
// return VertexOutput(vec4<f32>(x, x, x, 1.0));
|
||||
|
@ -860,15 +860,15 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
// [[block]] struct Data {
|
||||
// d : f32;
|
||||
// };
|
||||
// [[binding(0), group(0)]] var<storage> data : Data;
|
||||
// @binding(0) @group(0) var<storage> data : Data;
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn a() {
|
||||
// var v = data.d;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// [[stage(compute), workgroup_size(1)]]
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn b() {
|
||||
// var v = data.d;
|
||||
// return;
|
||||
|
|
|
@ -393,7 +393,7 @@ void main() {
|
|||
TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||
EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray) {
|
||||
// struct Data {
|
||||
// a : [[stride(4)]] array<i32, 5>;
|
||||
// a : @stride(4) array<i32, 5>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[2];
|
||||
|
@ -425,7 +425,7 @@ void main() {
|
|||
TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||
EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
|
||||
// struct Data {
|
||||
// a : [[stride(4)]] array<i32, 5>;
|
||||
// a : @stride(4) array<i32, 5>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[(2 + 4) - 3];
|
||||
|
@ -457,7 +457,7 @@ void main() {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
|
||||
// struct Data {
|
||||
// a : [[stride(4)]] array<i32, 5>;
|
||||
// a : @stride(4) array<i32, 5>;
|
||||
// };
|
||||
// var<storage> data : Data;
|
||||
// data.a[2] = 2;
|
||||
|
@ -491,7 +491,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -533,7 +533,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -577,7 +577,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -621,7 +621,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -664,7 +664,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
@ -705,7 +705,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// b : vec3<f32>;
|
||||
// };
|
||||
// struct Data {
|
||||
// var c : [[stride(32)]] array<Inner, 4>;
|
||||
// var c : @stride(32) array<Inner, 4>;
|
||||
// };
|
||||
//
|
||||
// var<storage> data : Pre;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue