dawn-cmake/test/array/assign_to_private_var.wgsl
Ben Clayton 01e4b6fc18 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>
2022-01-19 22:46:57 +00:00

53 lines
1.1 KiB
WebGPU Shading Language

type ArrayType = @stride(16) array<i32, 4>;
struct S {
arr : ArrayType;
};
var<private> src_private : ArrayType;
var<workgroup> src_workgroup : ArrayType;
@group(0) @binding(0) var<uniform> src_uniform : S;
@group(0) @binding(1) var<storage, read_write> src_storage : S;
var<private> dst : ArrayType;
var<private> dst_nested : array<array<array<i32, 2>, 3>, 4>;
fn ret_arr() -> ArrayType {
return ArrayType();
}
fn ret_struct_arr() -> S {
return S();
}
fn foo(src_param : ArrayType) {
var src_function : ArrayType;
// Assign from type constructor.
dst = ArrayType(1, 2, 3, 3);
// Assign from parameter.
dst = src_param;
// Assign from function call.
dst = ret_arr();
// Assign from constant.
let src_let : ArrayType = ArrayType();
dst = src_let;
// Assign from var, various storage classes.
dst = src_function;
dst = src_private;
dst = src_workgroup;
// Assign from struct.arr, various storage classes.
dst = ret_struct_arr().arr;
dst = src_uniform.arr;
dst = src_storage.arr;
// Nested assignment.
var src_nested : array<array<array<i32, 2>, 3>, 4>;
dst_nested = src_nested;
}