Migrate all tests over to using Default Struct Layout
The WGSL spec has been updated with 'Default Struct Layouts':
https://github.com/gpuweb/gpuweb/pull/1447
This removes the `[[offset(n)]]` decoration, and replaces it with two optional decorations: `[[size(n)]]` and `[[align(n)]]`, and a sensible set of sizes and alignments for each type.
Most `[[stride(n)]]` decorations have also been removed from arrays.
Bug: tint:626
Bug: tint:629
Change-Id: Ib0d2741f61ea943e6fb99d00cbb5cab2f97ae7be
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/44280
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/tests/end2end/GpuMemorySynchronizationTests.cpp b/src/tests/end2end/GpuMemorySynchronizationTests.cpp
index b7182f9..7dd4850 100644
--- a/src/tests/end2end/GpuMemorySynchronizationTests.cpp
+++ b/src/tests/end2end/GpuMemorySynchronizationTests.cpp
@@ -37,7 +37,7 @@
const wgpu::Buffer& buffer) {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Data {
- [[offset(0)]] a : i32;
+ a : i32;
};
[[group(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data;
[[stage(compute)]] fn main() -> void {
@@ -65,7 +65,7 @@
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Data {
- [[offset(0)]] i : i32;
+ i : i32;
};
[[group(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data;
[[location(0)]] var<out> fragColor : vec4<f32>;
@@ -254,8 +254,8 @@
pipelineDesc.computeStage.entryPoint = "main";
pipelineDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Output {
- [[offset(0)]] sampledOut: u32;
- [[offset(4)]] storageOut: u32;
+ sampledOut: u32;
+ storageOut: u32;
};
[[group(0), binding(0)]] var<storage_buffer> output : [[access(write)]] Output;
[[group(0), binding(1)]] var sampledTex : texture_2d<u32>;
@@ -315,7 +315,7 @@
std::tuple<wgpu::ComputePipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForCompute() {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Data {
- [[offset(0)]] a : f32;
+ a : f32;
};
[[group(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data;
[[stage(compute)]] fn main() -> void {
@@ -342,7 +342,7 @@
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Contents {
- [[offset(0)]] color : f32;
+ color : f32;
};
[[group(0), binding(0)]] var<uniform> contents : Contents;
@@ -514,21 +514,21 @@
// Create pipeline, bind group, and different buffers for compute pass.
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct VBContents {
- [[offset(0)]] pos : [[stride(16)]] array<vec4<f32>, 4>;
+ pos : array<vec4<f32>, 4>;
};
[[group(0), binding(0)]] var<storage_buffer> vbContents : [[access(read_write)]] VBContents;
[[block]] struct IBContents {
- [[offset(0)]] indices : [[stride(16)]] array<vec4<i32>, 2>;
+ indices : array<vec4<i32>, 2>;
};
[[group(0), binding(1)]] var<storage_buffer> ibContents : [[access(read_write)]] IBContents;
// TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct ColorContents1 {
- [[offset(0)]] color : f32;
+ color : f32;
};
[[block]] struct ColorContents2 {
- [[offset(0)]] color : f32;
+ color : f32;
};
[[group(0), binding(2)]] var<storage_buffer> uniformContents : [[access(read_write)]] ColorContents1;
[[group(0), binding(3)]] var<storage_buffer> storageContents : [[access(read_write)]] ColorContents2;
@@ -582,7 +582,7 @@
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Buf {
- [[offset(0)]] color : f32;
+ color : f32;
};
[[group(0), binding(0)]] var<uniform> uniformBuffer : Buf;
@@ -642,10 +642,10 @@
// Create pipeline, bind group, and a complex buffer for compute pass.
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Contents {
- [[offset(0)]] pos : [[stride(16)]] array<vec4<f32>, 4>;
- [[offset(256)]] indices : [[stride(16)]] array<vec4<i32>, 2>;
- [[offset(512)]] color0 : f32;
- [[offset(768)]] color1 : f32;
+ [[align(256)]] pos : array<vec4<f32>, 4>;
+ [[align(256)]] indices : array<vec4<i32>, 2>;
+ [[align(256)]] color0 : f32;
+ [[align(256)]] color1 : f32;
};
[[group(0), binding(0)]] var<storage_buffer> contents : [[access(read_write)]] Contents;
@@ -700,7 +700,7 @@
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Buf {
- [[offset(0)]] color : f32;
+ color : f32;
};
[[group(0), binding(0)]] var<uniform> uniformBuffer : Buf;
[[group(0), binding(1)]] var<storage_buffer> storageBuffer : [[access(read)]] Buf;