Updated the syntax for WGSL structs in all tests.

Change-Id: Ia80b1bed84aa7d16421d432d5da861e55175b335
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85841
Commit-Queue: Brandon Jones <bajones@chromium.org>
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Brandon Jones 2022-04-05 18:41:23 +00:00 committed by Dawn LUCI CQ
parent 40b4ece211
commit 29b72c87e9
51 changed files with 571 additions and 571 deletions

View File

@ -1166,8 +1166,8 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t
shaderSource << "@group(0) @binding(0) var tex : " << wgslTextureType << ";\n"; shaderSource << "@group(0) @binding(0) var tex : " << wgslTextureType << ";\n";
shaderSource << R"( shaderSource << R"(
struct Result { struct Result {
values : array<f32>; values : array<f32>
}; }
@group(0) @binding(1) var<storage, read_write> result : Result; @group(0) @binding(1) var<storage, read_write> result : Result;
)"; )";
shaderSource << "let componentCount : u32 = " << componentCount << "u;\n"; shaderSource << "let componentCount : u32 = " << componentCount << "u;\n";
@ -1352,9 +1352,9 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
@group(0) @binding(0) var texture0 : texture_2d<f32>; @group(0) @binding(0) var texture0 : texture_2d<f32>;
struct FragmentOut { struct FragmentOut {
@location(0) result : u32; @location(0) result : u32,
@builtin(frag_depth) fragDepth : f32; @builtin(frag_depth) fragDepth : f32,
}; }
@stage(fragment) @stage(fragment)
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut { fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {

View File

@ -68,8 +68,8 @@ class BindGroupTests : public DawnTest {
std::ostringstream fs; std::ostringstream fs;
for (size_t i = 0; i < bindingTypes.size(); ++i) { for (size_t i = 0; i < bindingTypes.size(); ++i) {
fs << "struct Buffer" << i << R"( { fs << "struct Buffer" << i << R"( {
color : vec4<f32>; color : vec4<f32>
};)"; })";
switch (bindingTypes[i]) { switch (bindingTypes[i]) {
case wgpu::BufferBindingType::Uniform: case wgpu::BufferBindingType::Uniform:
@ -130,8 +130,8 @@ class BindGroupTests : public DawnTest {
TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) { TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Contents { struct Contents {
f : f32; f : f32
}; }
@group(0) @binding(0) var <uniform> contents: Contents; @group(0) @binding(0) var <uniform> contents: Contents;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -165,8 +165,8 @@ TEST_P(BindGroupTests, ReusedUBO) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. // TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
struct VertexUniformBuffer { struct VertexUniformBuffer {
transform : vec4<f32>; transform : vec4<f32>
}; }
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer; @group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
@ -183,8 +183,8 @@ TEST_P(BindGroupTests, ReusedUBO) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct FragmentUniformBuffer { struct FragmentUniformBuffer {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(1) var <uniform> fragmentUbo : FragmentUniformBuffer; @group(0) @binding(1) var <uniform> fragmentUbo : FragmentUniformBuffer;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
@ -243,8 +243,8 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. // TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
struct VertexUniformBuffer { struct VertexUniformBuffer {
transform : vec4<f32>; transform : vec4<f32>
}; }
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer; @group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
@stage(vertex) @stage(vertex)
@ -346,8 +346,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. // TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
struct VertexUniformBuffer { struct VertexUniformBuffer {
transform : vec4<f32>; transform : vec4<f32>
}; }
@group(0) @binding(0) var <uniform> vertexUbo1 : VertexUniformBuffer; @group(0) @binding(0) var <uniform> vertexUbo1 : VertexUniformBuffer;
@group(1) @binding(0) var <uniform> vertexUbo2 : VertexUniformBuffer; @group(1) @binding(0) var <uniform> vertexUbo2 : VertexUniformBuffer;
@ -367,8 +367,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct FragmentUniformBuffer { struct FragmentUniformBuffer {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(1) var <uniform> fragmentUbo1 : FragmentUniformBuffer; @group(0) @binding(1) var <uniform> fragmentUbo1 : FragmentUniformBuffer;
@group(1) @binding(1) var <uniform> fragmentUbo2 : FragmentUniformBuffer; @group(1) @binding(1) var <uniform> fragmentUbo2 : FragmentUniformBuffer;
@ -436,8 +436,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
TEST_P(BindGroupTests, MultipleEntryPointsWithMultipleNonZeroGroups) { TEST_P(BindGroupTests, MultipleEntryPointsWithMultipleNonZeroGroups) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Contents { struct Contents {
f : f32; f : f32
}; }
@group(0) @binding(0) var <uniform> contents0: Contents; @group(0) @binding(0) var <uniform> contents0: Contents;
@group(1) @binding(0) var <uniform> contents1: Contents; @group(1) @binding(0) var <uniform> contents1: Contents;
@group(2) @binding(0) var <uniform> contents2: Contents; @group(2) @binding(0) var <uniform> contents2: Contents;
@ -1036,12 +1036,12 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.compute.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.compute.module = utils::CreateShaderModule(device, R"(
struct Buffer { struct Buffer {
value : u32; value : u32
}; }
struct OutputBuffer { struct OutputBuffer {
value : vec3<u32>; value : vec3<u32>
}; }
@group(0) @binding(2) var<uniform> buffer2 : Buffer; @group(0) @binding(2) var<uniform> buffer2 : Buffer;
@group(0) @binding(3) var<storage, read> buffer3 : Buffer; @group(0) @binding(3) var<storage, read> buffer3 : Buffer;
@ -1119,12 +1119,12 @@ TEST_P(BindGroupTests, DynamicAndNonDynamicBindingsDoNotConflictAfterRemapping)
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.compute.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.compute.module = utils::CreateShaderModule(device, R"(
struct Buffer { struct Buffer {
value : u32; value : u32
}; }
struct OutputBuffer { struct OutputBuffer {
value : vec2<u32>; value : vec2<u32>
}; }
@group(0) @binding(0) var<uniform> buffer0 : Buffer; @group(0) @binding(0) var<uniform> buffer0 : Buffer;
@group(0) @binding(1) var<uniform> buffer1 : Buffer; @group(0) @binding(1) var<uniform> buffer1 : Buffer;
@ -1245,8 +1245,8 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Ubo { struct Ubo {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(953) var <uniform> ubo1 : Ubo; @group(0) @binding(953) var <uniform> ubo1 : Ubo;
@group(0) @binding(47) var <uniform> ubo2 : Ubo; @group(0) @binding(47) var <uniform> ubo2 : Ubo;
@ -1387,8 +1387,8 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
struct Buffer0 { struct Buffer0 {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<storage, read> buffer0 : Buffer0; @group(0) @binding(0) var<storage, read> buffer0 : Buffer0;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
@ -1502,8 +1502,8 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
bgEntries.push_back({nullptr, binding, buffer, 0, 4 * sizeof(uint32_t), nullptr, nullptr}); bgEntries.push_back({nullptr, binding, buffer, 0, 4 * sizeof(uint32_t), nullptr, nullptr});
interface << "struct UniformBuffer" << i << R"({ interface << "struct UniformBuffer" << i << R"({
value : u32; value : u32
}; }
)"; )";
interface << "@group(0) @binding(" << binding++ << ") " interface << "@group(0) @binding(" << binding++ << ") "
<< "var<uniform> ubuf" << i << " : UniformBuffer" << i << ";\n"; << "var<uniform> ubuf" << i << " : UniformBuffer" << i << ";\n";
@ -1519,8 +1519,8 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
bgEntries.push_back({nullptr, binding, buffer, 0, sizeof(uint32_t), nullptr, nullptr}); bgEntries.push_back({nullptr, binding, buffer, 0, sizeof(uint32_t), nullptr, nullptr});
interface << "struct ReadOnlyStorageBuffer" << i << R"({ interface << "struct ReadOnlyStorageBuffer" << i << R"({
value : u32; value : u32
}; }
)"; )";
interface << "@group(0) @binding(" << binding++ << ") " interface << "@group(0) @binding(" << binding++ << ") "
<< "var<storage, read> sbuf" << i << " : ReadOnlyStorageBuffer" << i << ";\n"; << "var<storage, read> sbuf" << i << " : ReadOnlyStorageBuffer" << i << ";\n";
@ -1535,8 +1535,8 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
bgEntries.push_back({nullptr, binding, result, 0, sizeof(uint32_t), nullptr, nullptr}); bgEntries.push_back({nullptr, binding, result, 0, sizeof(uint32_t), nullptr, nullptr});
interface << R"(struct ReadWriteStorageBuffer{ interface << R"(struct ReadWriteStorageBuffer{
value : u32; value : u32
}; }
)"; )";
interface << "@group(0) @binding(" << binding++ << ") " interface << "@group(0) @binding(" << binding++ << ") "
<< "var<storage, read_write> result : ReadWriteStorageBuffer;\n"; << "var<storage, read_write> result : ReadWriteStorageBuffer;\n";

View File

@ -251,9 +251,9 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline = CreateRenderPipelineForTest(R"( wgpu::RenderPipeline renderPipeline = CreateRenderPipelineForTest(R"(
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) fn main(@location(0) pos : vec4<f32>) -> VertexOut { @stage(vertex) fn main(@location(0) pos : vec4<f32>) -> VertexOut {
var output : VertexOut; var output : VertexOut;
@ -295,9 +295,9 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline = wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"( CreateRenderPipelineForTest(R"(
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
@ -345,9 +345,9 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline = wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"( CreateRenderPipelineForTest(R"(
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) fn main() -> VertexOut { @stage(vertex) fn main() -> VertexOut {
var output : VertexOut; var output : VertexOut;
@ -386,9 +386,9 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline = wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"( CreateRenderPipelineForTest(R"(
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) fn main() -> VertexOut { @stage(vertex) fn main() -> VertexOut {
var output : VertexOut; var output : VertexOut;
@ -998,8 +998,8 @@ TEST_P(BufferZeroInitTest, BoundAsUniformBuffer) {
constexpr uint32_t kBoundBufferSize = 16u; constexpr uint32_t kBoundBufferSize = 16u;
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct UBO { struct UBO {
value : vec4<u32>; value : vec4<u32>
}; }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>; @group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@ -1037,8 +1037,8 @@ TEST_P(BufferZeroInitTest, BoundAsReadonlyStorageBuffer) {
constexpr uint32_t kBoundBufferSize = 16u; constexpr uint32_t kBoundBufferSize = 16u;
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct SSBO { struct SSBO {
value : vec4<u32>; value : vec4<u32>
}; }
@group(0) @binding(0) var<storage, read> ssbo : SSBO; @group(0) @binding(0) var<storage, read> ssbo : SSBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>; @group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@ -1076,8 +1076,8 @@ TEST_P(BufferZeroInitTest, BoundAsStorageBuffer) {
constexpr uint32_t kBoundBufferSize = 32u; constexpr uint32_t kBoundBufferSize = 32u;
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct SSBO { struct SSBO {
value : array<vec4<u32>, 2>; value : array<vec4<u32>, 2>
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>; @group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@ -1150,9 +1150,9 @@ TEST_P(BufferZeroInitTest, PaddingInitialized) {
wgpu::RenderPipeline renderPipeline = wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"( CreateRenderPipelineForTest(R"(
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) fn main(@location(0) pos : vec2<f32>) -> VertexOut { @stage(vertex) fn main(@location(0) pos : vec2<f32>) -> VertexOut {
var output : VertexOut; var output : VertexOut;

View File

@ -62,8 +62,8 @@ class ColorStateTest : public DawnTest {
void SetupSingleSourcePipelines(wgpu::ColorTargetState colorTargetState) { void SetupSingleSourcePipelines(wgpu::ColorTargetState colorTargetState) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock { struct MyBlock {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> myUbo : MyBlock; @group(0) @binding(0) var<uniform> myUbo : MyBlock;
@ -792,20 +792,20 @@ TEST_P(ColorStateTest, IndependentColorState) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock { struct MyBlock {
color0 : vec4<f32>; color0 : vec4<f32>,
color1 : vec4<f32>; color1 : vec4<f32>,
color2 : vec4<f32>; color2 : vec4<f32>,
color3 : vec4<f32>; color3 : vec4<f32>,
}; }
@group(0) @binding(0) var<uniform> myUbo : MyBlock; @group(0) @binding(0) var<uniform> myUbo : MyBlock;
struct FragmentOut { struct FragmentOut {
@location(0) fragColor0 : vec4<f32>; @location(0) fragColor0 : vec4<f32>,
@location(1) fragColor1 : vec4<f32>; @location(1) fragColor1 : vec4<f32>,
@location(2) fragColor2 : vec4<f32>; @location(2) fragColor2 : vec4<f32>,
@location(3) fragColor3 : vec4<f32>; @location(3) fragColor3 : vec4<f32>,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
@ -916,8 +916,8 @@ TEST_P(ColorStateTest, IndependentColorState) {
TEST_P(ColorStateTest, DefaultBlendColor) { TEST_P(ColorStateTest, DefaultBlendColor) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock { struct MyBlock {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> myUbo : MyBlock; @group(0) @binding(0) var<uniform> myUbo : MyBlock;
@ -1042,8 +1042,8 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) { TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock { struct MyBlock {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> myUbo : MyBlock; @group(0) @binding(0) var<uniform> myUbo : MyBlock;
@ -1100,8 +1100,8 @@ TEST_P(ColorStateTest, SparseAttachmentsDifferentColorMask) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Outputs { struct Outputs {
@location(1) o1 : vec4<f32>; @location(1) o1 : vec4<f32>,
@location(3) o3 : vec4<f32>; @location(3) o3 : vec4<f32>,
} }
@stage(fragment) fn main() -> Outputs { @stage(fragment) fn main() -> Outputs {

View File

@ -165,9 +165,9 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct VertexOut { struct VertexOut {
@location(0) texCoord : vec2 <f32>; @location(0) texCoord : vec2 <f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {

View File

@ -89,8 +89,8 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) { TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) {
BasicTest(R"( BasicTest(R"(
struct Buf { struct Buf {
s : array<vec4<u32>, 4>; s : array<vec4<u32>, 4>
}; }
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@ -107,13 +107,13 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) {
TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) { TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
BasicTest(R"( BasicTest(R"(
struct S { struct S {
a : vec2<u32>; a : vec2<u32>,
b : vec2<u32>; b : vec2<u32>,
}; }
struct Buf { struct Buf {
s : array<S, 4>; s : array<S, 4>
}; }
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@ -130,8 +130,8 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
TEST_P(ComputeCopyStorageBufferTests, UnsizedArrayOfBasic) { TEST_P(ComputeCopyStorageBufferTests, UnsizedArrayOfBasic) {
BasicTest(R"( BasicTest(R"(
struct Buf { struct Buf {
s : array<vec4<u32>>; s : array<vec4<u32>>
}; }
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;

View File

@ -29,8 +29,8 @@ class ComputeDispatchTests : public DawnTest {
// To make sure the dispatch was not called, write maximum u32 value for 0 dispatches // To make sure the dispatch was not called, write maximum u32 value for 0 dispatches
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct OutputBuf { struct OutputBuf {
workGroups : vec3<u32>; workGroups : vec3<u32>
}; }
@group(0) @binding(0) var<storage, read_write> output : OutputBuf; @group(0) @binding(0) var<storage, read_write> output : OutputBuf;
@ -55,11 +55,11 @@ class ComputeDispatchTests : public DawnTest {
// Test the use of the compute pipelines without using @num_workgroups // Test the use of the compute pipelines without using @num_workgroups
wgpu::ShaderModule moduleWithoutNumWorkgroups = utils::CreateShaderModule(device, R"( wgpu::ShaderModule moduleWithoutNumWorkgroups = utils::CreateShaderModule(device, R"(
struct InputBuf { struct InputBuf {
expectedDispatch : vec3<u32>; expectedDispatch : vec3<u32>
}; }
struct OutputBuf { struct OutputBuf {
workGroups : vec3<u32>; workGroups : vec3<u32>
}; }
@group(0) @binding(0) var<uniform> input : InputBuf; @group(0) @binding(0) var<uniform> input : InputBuf;
@group(0) @binding(1) var<storage, read_write> output : OutputBuf; @group(0) @binding(1) var<storage, read_write> output : OutputBuf;

View File

@ -169,24 +169,24 @@ TEST_P(ComputeLayoutMemoryBufferTests, Fields) {
std::string shader = R"( std::string shader = R"(
struct Data { struct Data {
header : u32; header : u32,
@align({field_align}) @size({field_size}) field : {field_type}; @align({field_align}) @size({field_size}) field : {field_type},
footer : u32; footer : u32,
}; }
struct Input { struct Input {
header : u32; header : u32,
{data_align}data : Data; {data_align}data : Data,
{footer_align}footer : u32; {footer_align}footer : u32,
}; }
struct Output { struct Output {
data : {field_type}; data : {field_type}
}; }
struct Status { struct Status {
code : u32; code : u32
}; }
@group(0) @binding(0) var<{input_qualifiers}> input : Input; @group(0) @binding(0) var<{input_qualifiers}> input : Input;
@group(0) @binding(1) var<storage, read_write> output : Output; @group(0) @binding(1) var<storage, read_write> output : Output;

View File

@ -75,8 +75,8 @@ TEST_P(ComputeSharedMemoryTests, Basic) {
let kInstances : u32 = 11u; let kInstances : u32 = 11u;
struct Dst { struct Dst {
x : u32; x : u32
}; }
@group(0) @binding(0) var<storage, write> dst : Dst; @group(0) @binding(0) var<storage, write> dst : Dst;
var<workgroup> tmp : u32; var<workgroup> tmp : u32;
@ -107,15 +107,15 @@ TEST_P(ComputeSharedMemoryTests, AssortedTypes) {
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
struct StructValues { struct StructValues {
m: mat2x2<f32>; m: mat2x2<f32>
}; }
struct Dst { struct Dst {
d_struct : StructValues; d_struct : StructValues,
d_matrix : mat2x2<f32>; d_matrix : mat2x2<f32>,
d_array : array<u32, 4>; d_array : array<u32, 4>,
d_vector : vec4<f32>; d_vector : vec4<f32>,
}; }
@group(0) @binding(0) var<storage, write> dst : Dst; @group(0) @binding(0) var<storage, write> dst : Dst;

View File

@ -33,8 +33,8 @@ TEST_P(ComputeStorageBufferBarrierTests, AddIncrement) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<u32, 100>; data : array<u32, 100>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;
@ -83,8 +83,8 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<u32, 100>; data : array<u32, 100>
}; }
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@ -149,8 +149,8 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<u32, 100>; data : array<u32, 100>
}; }
@group(0) @binding(0) var<storage, read> src : Buf; @group(0) @binding(0) var<storage, read> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@ -217,8 +217,8 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPong) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<vec4<u32>, 25>; data : array<vec4<u32>, 25>
}; }
@group(0) @binding(0) var<uniform> src : Buf; @group(0) @binding(0) var<uniform> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@ -285,8 +285,8 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPongInOnePass) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<vec4<u32>, 25>; data : array<vec4<u32>, 25>
}; }
@group(0) @binding(0) var<uniform> src : Buf; @group(0) @binding(0) var<uniform> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@ -343,8 +343,8 @@ TEST_P(ComputeStorageBufferBarrierTests, IndirectBufferCorrectBarrier) {
step2PipelineDesc.compute.entryPoint = "main"; step2PipelineDesc.compute.entryPoint = "main";
step2PipelineDesc.compute.module = utils::CreateShaderModule(device, R"( step2PipelineDesc.compute.module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<u32, 3>; data : array<u32, 3>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -357,13 +357,13 @@ TEST_P(ComputeStorageBufferBarrierTests, IndirectBufferCorrectBarrier) {
step3PipelineDesc.compute.entryPoint = "main"; step3PipelineDesc.compute.entryPoint = "main";
step3PipelineDesc.compute.module = utils::CreateShaderModule(device, R"( step3PipelineDesc.compute.module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<u32, 3>; data : array<u32, 3>
}; }
@group(0) @binding(0) var<storage, read> buf : Buf; @group(0) @binding(0) var<storage, read> buf : Buf;
struct Result { struct Result {
data : u32; data : u32
}; }
@group(0) @binding(1) var<storage, read_write> result : Result; @group(0) @binding(1) var<storage, read_write> result : Result;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {

View File

@ -247,17 +247,17 @@ class CopyTextureForBrowserTests : public Parent {
wgpu::ComputePipeline MakeTestPipeline() { wgpu::ComputePipeline MakeTestPipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModule(this->device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(this->device, R"(
struct Uniforms { struct Uniforms {
dstTextureFlipY : u32; dstTextureFlipY : u32,
channelCount : u32; channelCount : u32,
srcCopyOrigin : vec2<u32>; srcCopyOrigin : vec2<u32>,
dstCopyOrigin : vec2<u32>; dstCopyOrigin : vec2<u32>,
copySize : vec2<u32>; copySize : vec2<u32>,
srcAlphaMode : u32; srcAlphaMode : u32,
dstAlphaMode : u32; dstAlphaMode : u32,
}; }
struct OutputBuf { struct OutputBuf {
result : array<u32>; result : array<u32>
}; }
@group(0) @binding(0) var src : texture_2d<f32>; @group(0) @binding(0) var src : texture_2d<f32>;
@group(0) @binding(1) var dst : texture_2d<f32>; @group(0) @binding(1) var dst : texture_2d<f32>;
@group(0) @binding(2) var<storage, read_write> output : OutputBuf; @group(0) @binding(2) var<storage, read_write> output : OutputBuf;

View File

@ -134,8 +134,8 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateComputePipelineAsync) {
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
struct SSBO { struct SSBO {
value : u32; value : u32
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -164,8 +164,8 @@ TEST_P(CreatePipelineAsyncTest, ReleaseEntryPointAfterCreatComputePipelineAsync)
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
struct SSBO { struct SSBO {
value : u32; value : u32
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -203,8 +203,8 @@ TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
struct SSBO { struct SSBO {
value : u32; value : u32
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -483,8 +483,8 @@ TEST_P(CreatePipelineAsyncTest, CreateSameComputePipelineTwice) {
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
struct SSBO { struct SSBO {
value : u32; value : u32
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -542,8 +542,8 @@ TEST_P(CreatePipelineAsyncTest, CreateSameComputePipelineTwiceAtSameTime) {
csDesc.layout = pipelineLayout; csDesc.layout = pipelineLayout;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
struct SSBO { struct SSBO {
value : u32; value : u32
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -635,14 +635,14 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithVertexBufferLayouts
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
struct VertexInput { struct VertexInput {
@location(0) input0: u32; @location(0) input0: u32,
@location(1) input1: u32; @location(1) input1: u32,
}; }
struct VertexOutput { struct VertexOutput {
@location(0) vertexColorOut: vec4<f32>; @location(0) vertexColorOut: vec4<f32>,
@builtin(position) position: vec4<f32>; @builtin(position) position: vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(vertexInput : VertexInput) -> VertexOutput { fn main(vertexInput : VertexInput) -> VertexOutput {
@ -886,9 +886,9 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithBlendState) {
})"); })");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
struct FragmentOut { struct FragmentOut {
@location(0) fragColor0 : vec4<f32>; @location(0) fragColor0 : vec4<f32>,
@location(1) fragColor1 : vec4<f32>; @location(1) fragColor1 : vec4<f32>,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;

View File

@ -209,8 +209,8 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPoints) { TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPoints) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Data { struct Data {
data : u32; data : u32
}; }
@binding(0) @group(0) var<storage, read_write> data : Data; @binding(0) @group(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn write1() { @stage(compute) @workgroup_size(1) fn write1() {

View File

@ -84,11 +84,11 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
shaderSource << "type StencilValues = array<u32, " << components.size() << ">;\n"; shaderSource << "type StencilValues = array<u32, " << components.size() << ">;\n";
shaderSource << R"( shaderSource << R"(
struct DepthResult { struct DepthResult {
value : f32; value : f32
}; }
struct StencilResult { struct StencilResult {
values : StencilValues; values : StencilValues
};)"; })";
shaderSource << "\n"; shaderSource << "\n";
uint32_t index = 0; uint32_t index = 0;
@ -195,8 +195,8 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
@group(0) @binding(0) var samp : sampler_comparison; @group(0) @binding(0) var samp : sampler_comparison;
@group(0) @binding(1) var tex : texture_depth_2d; @group(0) @binding(1) var tex : texture_depth_2d;
struct Uniforms { struct Uniforms {
compareRef : f32; compareRef : f32
}; }
@group(0) @binding(2) var<uniform> uniforms : Uniforms; @group(0) @binding(2) var<uniform> uniforms : Uniforms;
@stage(fragment) fn main() -> @location(0) f32 { @stage(fragment) fn main() -> @location(0) f32 {
@ -217,13 +217,13 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
@group(0) @binding(0) var samp : sampler_comparison; @group(0) @binding(0) var samp : sampler_comparison;
@group(0) @binding(1) var tex : texture_depth_2d; @group(0) @binding(1) var tex : texture_depth_2d;
struct Uniforms { struct Uniforms {
compareRef : f32; compareRef : f32
}; }
@group(0) @binding(2) var<uniform> uniforms : Uniforms; @group(0) @binding(2) var<uniform> uniforms : Uniforms;
struct SamplerResult { struct SamplerResult {
value : f32; value : f32
}; }
@group(0) @binding(3) var<storage, read_write> samplerResult : SamplerResult; @group(0) @binding(3) var<storage, read_write> samplerResult : SamplerResult;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {

View File

@ -57,9 +57,9 @@ class DepthStencilStateTest : public DawnTest {
vsModule = utils::CreateShaderModule(device, R"( vsModule = utils::CreateShaderModule(device, R"(
struct UBO { struct UBO {
color : vec3<f32>; color : vec3<f32>,
depth : f32; depth : f32,
}; }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(vertex) @stage(vertex)
@ -76,9 +76,9 @@ class DepthStencilStateTest : public DawnTest {
fsModule = utils::CreateShaderModule(device, R"( fsModule = utils::CreateShaderModule(device, R"(
struct UBO { struct UBO {
color : vec3<f32>; color : vec3<f32>,
depth : f32; depth : f32,
}; }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {

View File

@ -113,8 +113,8 @@ TEST_P(DeviceLostTest, CreateBindGroupLayoutFails) {
TEST_P(DeviceLostTest, GetBindGroupLayoutFails) { TEST_P(DeviceLostTest, GetBindGroupLayoutFails) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct UniformBuffer { struct UniformBuffer {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> ubo : UniformBuffer; @group(0) @binding(0) var<uniform> ubo : UniformBuffer;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
})"); })");

View File

@ -647,12 +647,12 @@ TEST_P(DrawIndexedIndirectTest, ValidateReusedBundleWithChangingParams) {
wgpu::ShaderModule paramWriterModule = utils::CreateShaderModule(device, wgpu::ShaderModule paramWriterModule = utils::CreateShaderModule(device,
R"( R"(
struct Input { firstIndex: u32; }; struct Input { firstIndex: u32 }
struct Params { struct Params {
indexCount: u32; indexCount: u32,
instanceCount: u32; instanceCount: u32,
firstIndex: u32; firstIndex: u32,
}; }
@group(0) @binding(0) var<uniform> input: Input; @group(0) @binding(0) var<uniform> input: Input;
@group(0) @binding(1) var<storage, write> params: Params; @group(0) @binding(1) var<storage, write> params: Params;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {

View File

@ -116,8 +116,8 @@ class DynamicBufferOffsetTests : public DawnTest {
std::string multipleNumber = isInheritedPipeline ? "2" : "1"; std::string multipleNumber = isInheritedPipeline ? "2" : "1";
fs << R"( fs << R"(
struct Buf { struct Buf {
value : vec2<u32>; value : vec2<u32>
}; }
@group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf; @group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf;
@group(0) @binding(1) var<storage, read_write> sBufferNotDynamic : Buf; @group(0) @binding(1) var<storage, read_write> sBufferNotDynamic : Buf;
@ -166,8 +166,8 @@ class DynamicBufferOffsetTests : public DawnTest {
std::string multipleNumber = isInheritedPipeline ? "2" : "1"; std::string multipleNumber = isInheritedPipeline ? "2" : "1";
cs << R"( cs << R"(
struct Buf { struct Buf {
value : vec2<u32>; value : vec2<u32>
}; }
@group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf; @group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf;
@group(0) @binding(1) var<storage, read_write> sBufferNotDynamic : Buf; @group(0) @binding(1) var<storage, read_write> sBufferNotDynamic : Buf;
@ -454,16 +454,16 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
case wgpu::BufferUsage::Uniform: case wgpu::BufferUsage::Uniform:
shader << R"( shader << R"(
struct Src { struct Src {
values : array<vec4<u32>, kArrayLength>; values : array<vec4<u32>, kArrayLength>
}; }
@group(0) @binding(0) var<uniform> src : Src; @group(0) @binding(0) var<uniform> src : Src;
)"; )";
break; break;
case wgpu::BufferUsage::Storage: case wgpu::BufferUsage::Storage:
shader << R"( shader << R"(
struct Src { struct Src {
values : array<vec4<u32>>; values : array<vec4<u32>>
}; }
@group(0) @binding(0) var<storage, read> src : Src; @group(0) @binding(0) var<storage, read> src : Src;
)"; )";
break; break;
@ -473,8 +473,8 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
shader << R"( shader << R"(
struct Dst { struct Dst {
values : array<vec4<u32>>; values : array<vec4<u32>>
}; }
@group(0) @binding(1) var<storage, read_write> dst : Dst; @group(0) @binding(1) var<storage, read_write> dst : Dst;
)"; )";
shader << R"( shader << R"(

View File

@ -79,8 +79,8 @@ TEST_P(EntryPointTests, TwoComputeInModule) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Data { struct Data {
data : u32; data : u32
}; }
@binding(0) @group(0) var<storage, read_write> data : Data; @binding(0) @group(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn write1() { @stage(compute) @workgroup_size(1) fn write1() {

View File

@ -92,33 +92,33 @@ void FirstIndexOffsetTests::TestImpl(DrawMode mode,
std::stringstream fragmentInputs; std::stringstream fragmentInputs;
std::stringstream fragmentBody; std::stringstream fragmentBody;
vertexInputs << " @location(0) position : vec4<f32>;\n"; vertexInputs << " @location(0) position : vec4<f32>,\n";
vertexOutputs << " @builtin(position) position : vec4<f32>;\n"; vertexOutputs << " @builtin(position) position : vec4<f32>,\n";
if ((checkIndex & CheckIndex::Vertex) != 0) { if ((checkIndex & CheckIndex::Vertex) != 0) {
vertexInputs << " @builtin(vertex_index) vertex_index : u32;\n"; vertexInputs << " @builtin(vertex_index) vertex_index : u32,\n";
vertexOutputs << " @location(1) @interpolate(flat) vertex_index : u32;\n"; vertexOutputs << " @location(1) @interpolate(flat) vertex_index : u32,\n";
vertexBody << " output.vertex_index = input.vertex_index;\n"; vertexBody << " output.vertex_index = input.vertex_index;\n";
fragmentInputs << " @location(1) @interpolate(flat) vertex_index : u32;\n"; fragmentInputs << " @location(1) @interpolate(flat) vertex_index : u32,\n";
fragmentBody << " _ = atomicMin(&idx_vals.vertex_index, input.vertex_index);\n"; fragmentBody << " _ = atomicMin(&idx_vals.vertex_index, input.vertex_index);\n";
} }
if ((checkIndex & CheckIndex::Instance) != 0) { if ((checkIndex & CheckIndex::Instance) != 0) {
vertexInputs << " @builtin(instance_index) instance_index : u32;\n"; vertexInputs << " @builtin(instance_index) instance_index : u32,\n";
vertexOutputs << " @location(2) @interpolate(flat) instance_index : u32;\n"; vertexOutputs << " @location(2) @interpolate(flat) instance_index : u32,\n";
vertexBody << " output.instance_index = input.instance_index;\n"; vertexBody << " output.instance_index = input.instance_index;\n";
fragmentInputs << " @location(2) @interpolate(flat) instance_index : u32;\n"; fragmentInputs << " @location(2) @interpolate(flat) instance_index : u32,\n";
fragmentBody << " _ = atomicMin(&idx_vals.instance_index, input.instance_index);\n"; fragmentBody << " _ = atomicMin(&idx_vals.instance_index, input.instance_index);\n";
} }
std::string vertexShader = R"( std::string vertexShader = R"(
struct VertexInputs { struct VertexInputs {
)" + vertexInputs.str() + R"( )" + vertexInputs.str() + R"(
}; }
struct VertexOutputs { struct VertexOutputs {
)" + vertexOutputs.str() + R"( )" + vertexOutputs.str() + R"(
}; }
@stage(vertex) fn main(input : VertexInputs) -> VertexOutputs { @stage(vertex) fn main(input : VertexInputs) -> VertexOutputs {
var output : VertexOutputs; var output : VertexOutputs;
)" + vertexBody.str() + R"( )" + vertexBody.str() + R"(
@ -128,14 +128,14 @@ struct VertexOutputs {
std::string fragmentShader = R"( std::string fragmentShader = R"(
struct IndexVals { struct IndexVals {
vertex_index : atomic<u32>; vertex_index : atomic<u32>,
instance_index : atomic<u32>; instance_index : atomic<u32>,
}; }
@group(0) @binding(0) var<storage, read_write> idx_vals : IndexVals; @group(0) @binding(0) var<storage, read_write> idx_vals : IndexVals;
struct FragInputs { struct FragInputs {
)" + fragmentInputs.str() + R"( )" + fragmentInputs.str() + R"(
}; }
@stage(fragment) fn main(input : FragInputs) { @stage(fragment) fn main(input : FragInputs) {
)" + fragmentBody.str() + R"( )" + fragmentBody.str() + R"(
})"; })";

View File

@ -37,8 +37,8 @@ class GpuMemorySyncTests : public DawnTest {
const wgpu::Buffer& buffer) { const wgpu::Buffer& buffer) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct Data { struct Data {
a : i32; a : i32
}; }
@group(0) @binding(0) var<storage, read_write> data : Data; @group(0) @binding(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
data.a = data.a + 1; data.a = data.a + 1;
@ -64,8 +64,8 @@ class GpuMemorySyncTests : public DawnTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Data { struct Data {
i : i32; i : i32
}; }
@group(0) @binding(0) var<storage, read_write> data : Data; @group(0) @binding(0) var<storage, read_write> data : Data;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
data.i = data.i + 1; data.i = data.i + 1;
@ -229,8 +229,8 @@ class StorageToUniformSyncTests : public DawnTest {
std::tuple<wgpu::ComputePipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForCompute() { std::tuple<wgpu::ComputePipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForCompute() {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct Data { struct Data {
a : f32; a : f32
}; }
@group(0) @binding(0) var<storage, read_write> data : Data; @group(0) @binding(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
data.a = 1.0; data.a = 1.0;
@ -255,8 +255,8 @@ class StorageToUniformSyncTests : public DawnTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Contents { struct Contents {
color : f32; color : f32
}; }
@group(0) @binding(0) var<uniform> contents : Contents; @group(0) @binding(0) var<uniform> contents : Contents;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
@ -414,18 +414,18 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
// Create pipeline, bind group, and different buffers for compute pass. // Create pipeline, bind group, and different buffers for compute pass.
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct VBContents { struct VBContents {
pos : array<vec4<f32>, 4>; pos : array<vec4<f32>, 4>
}; }
@group(0) @binding(0) var<storage, read_write> vbContents : VBContents; @group(0) @binding(0) var<storage, read_write> vbContents : VBContents;
struct IBContents { struct IBContents {
indices : array<vec4<i32>, 2>; indices : array<vec4<i32>, 2>
}; }
@group(0) @binding(1) var<storage, read_write> ibContents : IBContents; @group(0) @binding(1) var<storage, read_write> ibContents : IBContents;
struct ColorContents { struct ColorContents {
color : f32; color : f32
}; }
@group(0) @binding(2) var<storage, read_write> uniformContents : ColorContents; @group(0) @binding(2) var<storage, read_write> uniformContents : ColorContents;
@group(0) @binding(3) var<storage, read_write> storageContents : ColorContents; @group(0) @binding(3) var<storage, read_write> storageContents : ColorContents;
@ -477,8 +477,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
color : f32; color : f32
}; }
@group(0) @binding(0) var<uniform> uniformBuffer : Buf; @group(0) @binding(0) var<uniform> uniformBuffer : Buf;
@group(0) @binding(1) var<storage, read> storageBuffer : Buf; @group(0) @binding(1) var<storage, read> storageBuffer : Buf;
@ -536,11 +536,11 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
// Create pipeline, bind group, and a complex buffer for compute pass. // Create pipeline, bind group, and a complex buffer for compute pass.
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct Contents { struct Contents {
@align(256) pos : array<vec4<f32>, 4>; @align(256) pos : array<vec4<f32>, 4>,
@align(256) indices : array<vec4<i32>, 2>; @align(256) indices : array<vec4<i32>, 2>,
@align(256) color0 : f32; @align(256) color0 : f32,
@align(256) color1 : f32; @align(256) color1 : f32,
}; }
@group(0) @binding(0) var<storage, read_write> contents : Contents; @group(0) @binding(0) var<storage, read_write> contents : Contents;
@ -594,8 +594,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
color : f32; color : f32
}; }
@group(0) @binding(0) var<uniform> uniformBuffer : Buf; @group(0) @binding(0) var<uniform> uniformBuffer : Buf;
@group(0) @binding(1) var<storage, read> storageBuffer : Buf; @group(0) @binding(1) var<storage, read> storageBuffer : Buf;

View File

@ -231,9 +231,9 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
{ {
wgpu::ShaderModule vs = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vs = utils::CreateShaderModule(device, R"(
struct VertexOut { struct VertexOut {
@location(0) texCoord : vec2<f32>; @location(0) texCoord : vec2<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {

View File

@ -35,9 +35,9 @@ class IndexFormatTest : public DawnTest {
wgpu::PrimitiveTopology primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip) { wgpu::PrimitiveTopology primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct VertexIn { struct VertexIn {
@location(0) pos : vec4<f32>; @location(0) pos : vec4<f32>,
@builtin(vertex_index) idx : u32; @builtin(vertex_index) idx : u32,
}; }
@stage(vertex) fn main(input : VertexIn) -> @builtin(position) vec4<f32> { @stage(vertex) fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
// 0xFFFFFFFE is a designated invalid index used by some tests. // 0xFFFFFFFE is a designated invalid index used by some tests.

View File

@ -34,19 +34,19 @@ TEST_P(MaxLimitTests, MaxComputeWorkgroupStorageSize) {
std::string shader = R"( std::string shader = R"(
struct Dst { struct Dst {
value0 : u32; value0 : u32,
value1 : u32; value1 : u32,
}; }
@group(0) @binding(0) var<storage, write> dst : Dst; @group(0) @binding(0) var<storage, write> dst : Dst;
struct WGData { struct WGData {
value0 : u32; value0 : u32,
// padding such that value0 and value1 are the first and last bytes of the memory. // padding such that value0 and value1 are the first and last bytes of the memory.
@size()" + std::to_string(maxComputeWorkgroupStorageSize / 4 - 2) + @size()" + std::to_string(maxComputeWorkgroupStorageSize / 4 - 2) +
R"() padding : u32; R"() padding : u32,
value1 : u32; value1 : u32,
}; }
var<workgroup> wg_data : WGData; var<workgroup> wg_data : WGData;
@stage(compute) @workgroup_size(2,1,1) @stage(compute) @workgroup_size(2,1,1)
@ -130,13 +130,13 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
} }
shader = R"( shader = R"(
struct Buf { struct Buf {
values : array<u32>; values : array<u32>
}; }
struct Result { struct Result {
value0 : u32; value0 : u32,
value1 : u32; value1 : u32,
}; }
@group(0) @binding(0) var<storage, read> buf : Buf; @group(0) @binding(0) var<storage, read> buf : Buf;
@group(0) @binding(1) var<storage, write> result : Result; @group(0) @binding(1) var<storage, write> result : Result;
@ -157,17 +157,17 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
shader = R"( shader = R"(
struct Buf { struct Buf {
value0 : u32; value0 : u32,
// padding such that value0 and value1 are the first and last bytes of the memory. // padding such that value0 and value1 are the first and last bytes of the memory.
@size()" + @size()" +
std::to_string(maxBufferBindingSize - 8) + R"() padding : u32; std::to_string(maxBufferBindingSize - 8) + R"() padding : u32,
value1 : u32; value1 : u32,
}; }
struct Result { struct Result {
value0 : u32; value0 : u32,
value1 : u32; value1 : u32,
}; }
@group(0) @binding(0) var<uniform> buf : Buf; @group(0) @binding(0) var<uniform> buf : Buf;
@group(0) @binding(1) var<storage, write> result : Result; @group(0) @binding(1) var<storage, write> result : Result;

View File

@ -46,15 +46,15 @@ class MultisampledRenderingTest : public DawnTest {
bool flipTriangle = false) { bool flipTriangle = false) {
const char* kFsOneOutputWithDepth = R"( const char* kFsOneOutputWithDepth = R"(
struct U { struct U {
color : vec4<f32>; color : vec4<f32>,
depth : f32; depth : f32,
}; }
@group(0) @binding(0) var<uniform> uBuffer : U; @group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut { struct FragmentOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(frag_depth) depth : f32; @builtin(frag_depth) depth : f32,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
@ -65,8 +65,8 @@ class MultisampledRenderingTest : public DawnTest {
const char* kFsOneOutputWithoutDepth = R"( const char* kFsOneOutputWithoutDepth = R"(
struct U { struct U {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uBuffer : U; @group(0) @binding(0) var<uniform> uBuffer : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
@ -84,15 +84,15 @@ class MultisampledRenderingTest : public DawnTest {
bool alphaToCoverageEnabled = false) { bool alphaToCoverageEnabled = false) {
const char* kFsTwoOutputs = R"( const char* kFsTwoOutputs = R"(
struct U { struct U {
color0 : vec4<f32>; color0 : vec4<f32>,
color1 : vec4<f32>; color1 : vec4<f32>,
}; }
@group(0) @binding(0) var<uniform> uBuffer : U; @group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut { struct FragmentOut {
@location(0) color0 : vec4<f32>; @location(0) color0 : vec4<f32>,
@location(1) color1 : vec4<f32>; @location(1) color1 : vec4<f32>,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
@ -751,14 +751,14 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOut
constexpr uint32_t kSampleMask = kFirstSampleMaskBit | kThirdSampleMaskBit; constexpr uint32_t kSampleMask = kFirstSampleMaskBit | kThirdSampleMaskBit;
const char* fs = R"( const char* fs = R"(
struct U { struct U {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uBuffer : U; @group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut { struct FragmentOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(sample_mask) sampleMask : u32; @builtin(sample_mask) sampleMask : u32,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
@ -812,16 +812,16 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOut
constexpr float kMSAACoverage = 0.25f; constexpr float kMSAACoverage = 0.25f;
const char* fs = R"( const char* fs = R"(
struct U { struct U {
color0 : vec4<f32>; color0 : vec4<f32>,
color1 : vec4<f32>; color1 : vec4<f32>,
}; }
@group(0) @binding(0) var<uniform> uBuffer : U; @group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut { struct FragmentOut {
@location(0) color0 : vec4<f32>; @location(0) color0 : vec4<f32>,
@location(1) color1 : vec4<f32>; @location(1) color1 : vec4<f32>,
@builtin(sample_mask) sampleMask : u32; @builtin(sample_mask) sampleMask : u32,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;

View File

@ -64,9 +64,9 @@ class MultisampledSamplingTest : public DawnTest {
desc.cFragment.module = utils::CreateShaderModule(device, R"( desc.cFragment.module = utils::CreateShaderModule(device, R"(
struct FragmentOut { struct FragmentOut {
@location(0) color : f32; @location(0) color : f32,
@builtin(frag_depth) depth : f32; @builtin(frag_depth) depth : f32,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
@ -100,9 +100,9 @@ class MultisampledSamplingTest : public DawnTest {
@group(0) @binding(1) var texture1 : texture_depth_multisampled_2d; @group(0) @binding(1) var texture1 : texture_depth_multisampled_2d;
struct Results { struct Results {
colorSamples : array<f32, 4>; colorSamples : array<f32, 4>,
depthSamples : array<f32, 4>; depthSamples : array<f32, 4>,
}; }
@group(0) @binding(2) var<storage, read_write> results : Results; @group(0) @binding(2) var<storage, read_write> results : Results;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {

View File

@ -54,8 +54,8 @@ class OpArrayLengthTest : public DawnTest {
// 0. // 0.
mShaderInterface = R"( mShaderInterface = R"(
struct DataBuffer { struct DataBuffer {
data : array<f32>; data : array<f32>
}; }
// The length should be 1 because the buffer is 4-byte long. // The length should be 1 because the buffer is 4-byte long.
@group(0) @binding(0) var<storage, read> buffer1 : DataBuffer; @group(0) @binding(0) var<storage, read> buffer1 : DataBuffer;
@ -66,14 +66,14 @@ class OpArrayLengthTest : public DawnTest {
// The length should be (512 - 16*4) / 8 = 56 because the buffer is 512 bytes long // The length should be (512 - 16*4) / 8 = 56 because the buffer is 512 bytes long
// and the structure is 8 bytes big. // and the structure is 8 bytes big.
struct Buffer3Data { struct Buffer3Data {
a : f32; a : f32,
b : i32; b : i32,
}; }
struct Buffer3 { struct Buffer3 {
@size(64) garbage : mat4x4<f32>; @size(64) garbage : mat4x4<f32>,
data : array<Buffer3Data>; data : array<Buffer3Data>,
}; }
@group(0) @binding(2) var<storage, read> buffer3 : Buffer3; @group(0) @binding(2) var<storage, read> buffer3 : Buffer3;
)"; )";
@ -125,8 +125,8 @@ TEST_P(OpArrayLengthTest, Compute) {
pipelineDesc.compute.entryPoint = "main"; pipelineDesc.compute.entryPoint = "main";
pipelineDesc.compute.module = utils::CreateShaderModule(device, (R"( pipelineDesc.compute.module = utils::CreateShaderModule(device, (R"(
struct ResultBuffer { struct ResultBuffer {
data : array<u32, 3>; data : array<u32, 3>
}; }
@group(1) @binding(0) var<storage, read_write> result : ResultBuffer; @group(1) @binding(0) var<storage, read_write> result : ResultBuffer;
)" + mShaderInterface + R"( )" + mShaderInterface + R"(
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -224,9 +224,9 @@ TEST_P(OpArrayLengthTest, Vertex) {
// pass pixel. // pass pixel.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, (mShaderInterface + R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, (mShaderInterface + R"(
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) fn main() -> VertexOut { @stage(vertex) fn main() -> VertexOut {
var output : VertexOut; var output : VertexOut;

View File

@ -46,9 +46,9 @@ class DepthClampingTest : public DawnTest {
vsModule = utils::CreateShaderModule(device, R"( vsModule = utils::CreateShaderModule(device, R"(
struct UBO { struct UBO {
color : vec3<f32>; color : vec3<f32>,
depth : f32; depth : f32,
}; }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @stage(vertex) fn main() -> @builtin(position) vec4<f32> {
@ -57,9 +57,9 @@ class DepthClampingTest : public DawnTest {
fsModule = utils::CreateShaderModule(device, R"( fsModule = utils::CreateShaderModule(device, R"(
struct UBO { struct UBO {
color : vec3<f32>; color : vec3<f32>,
depth : f32; depth : f32,
}; }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {

View File

@ -30,11 +30,11 @@ TEST_P(RenderAttachmentTest, MoreFragmentOutputsThanAttachments) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Output { struct Output {
@location(0) color0 : vec4<f32>; @location(0) color0 : vec4<f32>,
@location(1) color1 : vec4<f32>; @location(1) color1 : vec4<f32>,
@location(2) color2 : vec4<f32>; @location(2) color2 : vec4<f32>,
@location(3) color3 : vec4<f32>; @location(3) color3 : vec4<f32>,
}; }
@stage(fragment) @stage(fragment)
fn main() -> Output { fn main() -> Output {

View File

@ -39,8 +39,8 @@ class RenderBundleTest : public DawnTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Ubo { struct Ubo {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> fragmentUniformBuffer : Ubo; @group(0) @binding(0) var<uniform> fragmentUniformBuffer : Ubo;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {

View File

@ -39,20 +39,20 @@ class SamplerFilterAnisotropicTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct Uniforms { struct Uniforms {
matrix : mat4x4<f32>; matrix : mat4x4<f32>
}; }
struct VertexIn { struct VertexIn {
@location(0) position : vec4<f32>; @location(0) position : vec4<f32>,
@location(1) uv : vec2<f32>; @location(1) uv : vec2<f32>,
}; }
@group(0) @binding(2) var<uniform> uniforms : Uniforms; @group(0) @binding(2) var<uniform> uniforms : Uniforms;
struct VertexOut { struct VertexOut {
@location(0) uv : vec2<f32>; @location(0) uv : vec2<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
@ -67,9 +67,9 @@ class SamplerFilterAnisotropicTest : public DawnTest {
@group(0) @binding(1) var texture0 : texture_2d<f32>; @group(0) @binding(1) var texture0 : texture_2d<f32>;
struct FragmentIn { struct FragmentIn {
@location(0) uv: vec2<f32>; @location(0) uv: vec2<f32>,
@builtin(position) fragCoord : vec4<f32>; @builtin(position) fragCoord : vec4<f32>,
}; }
@stage(fragment) @stage(fragment)
fn main(input : FragmentIn) -> @location(0) vec4<f32> { fn main(input : FragmentIn) -> @location(0) vec4<f32> {

View File

@ -51,8 +51,8 @@ TEST_P(ShaderTests, ComputeLog2) {
std::string shader = R"( std::string shader = R"(
struct Buf { struct Buf {
data : array<u32, 19>; data : array<u32, 19>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;
@ -143,14 +143,14 @@ fn main(@builtin(position) fragCoord : vec4<f32>) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLMixedStructParamIO) { TEST_P(ShaderTests, WGSLMixedStructParamIO) {
std::string vertexShader = R"( std::string vertexShader = R"(
struct VertexIn { struct VertexIn {
@location(0) position : vec3<f32>; @location(0) position : vec3<f32>,
@location(1) color : vec4<f32>; @location(1) color : vec4<f32>,
}; }
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
@ -186,14 +186,14 @@ fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLStructIO) { TEST_P(ShaderTests, WGSLStructIO) {
std::string vertexShader = R"( std::string vertexShader = R"(
struct VertexIn { struct VertexIn {
@location(0) position : vec3<f32>; @location(0) position : vec3<f32>,
@location(1) color : vec4<f32>; @location(1) color : vec4<f32>,
}; }
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
@ -206,9 +206,9 @@ fn main(input : VertexIn) -> VertexOut {
std::string fragmentShader = R"( std::string fragmentShader = R"(
struct FragmentIn { struct FragmentIn {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) fragCoord : vec4<f32>; @builtin(position) fragCoord : vec4<f32>,
}; }
@stage(fragment) @stage(fragment)
fn main(input : FragmentIn) -> @location(0) vec4<f32> { fn main(input : FragmentIn) -> @location(0) vec4<f32> {
@ -233,14 +233,14 @@ fn main(input : FragmentIn) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLUnsortedStructIO) { TEST_P(ShaderTests, WGSLUnsortedStructIO) {
std::string vertexShader = R"( std::string vertexShader = R"(
struct VertexIn { struct VertexIn {
@location(0) position : vec3<f32>; @location(0) position : vec3<f32>,
@location(1) color : vec4<f32>; @location(1) color : vec4<f32>,
}; }
struct VertexOut { struct VertexOut {
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
@ -253,9 +253,9 @@ fn main(input : VertexIn) -> VertexOut {
std::string fragmentShader = R"( std::string fragmentShader = R"(
struct FragmentIn { struct FragmentIn {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) fragCoord : vec4<f32>; @builtin(position) fragCoord : vec4<f32>,
}; }
@stage(fragment) @stage(fragment)
fn main(input : FragmentIn) -> @location(0) vec4<f32> { fn main(input : FragmentIn) -> @location(0) vec4<f32> {
@ -280,14 +280,14 @@ fn main(input : FragmentIn) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLSharedStructIO) { TEST_P(ShaderTests, WGSLSharedStructIO) {
std::string shader = R"( std::string shader = R"(
struct VertexIn { struct VertexIn {
@location(0) position : vec3<f32>; @location(0) position : vec3<f32>,
@location(1) color : vec4<f32>; @location(1) color : vec4<f32>,
}; }
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn vertexMain(input : VertexIn) -> VertexOut { fn vertexMain(input : VertexIn) -> VertexOut {
@ -329,13 +329,13 @@ TEST_P(ShaderTests, FirstIndexOffsetRegisterConflictInHLSLTransforms) {
// Dumped WGSL: // Dumped WGSL:
struct Inputs { struct Inputs {
@location(1) attrib1 : u32; @location(1) attrib1 : u32,
// The extra register added to handle base_vertex for vertex_index conflicts with [1] // The extra register added to handle base_vertex for vertex_index conflicts with [1]
@builtin(vertex_index) vertexIndex: u32; @builtin(vertex_index) vertexIndex: u32,
}; }
// [1] a binding point that conflicts with the regitster // [1] a binding point that conflicts with the regitster
struct S1 { data : array<vec4<u32>, 20>; }; struct S1 { data : array<vec4<u32>, 20> }
@group(0) @binding(1) var<uniform> providedData1 : S1; @group(0) @binding(1) var<uniform> providedData1 : S1;
@stage(vertex) fn vsMain(input : Inputs) -> @builtin(position) vec4<f32> { @stage(vertex) fn vsMain(input : Inputs) -> @builtin(position) vec4<f32> {
@ -413,8 +413,8 @@ override c9: u32 = 0u; // default override
override c10: u32 = 10u; // default override c10: u32 = 10u; // default
struct Buf { struct Buf {
data : array<u32, 11>; data : array<u32, 11>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;
@ -483,8 +483,8 @@ TEST_P(ShaderTests, OverridableConstantsNumericIdentifiers) {
@id(1004) override c4: u32; // default unspecified @id(1004) override c4: u32; // default unspecified
struct Buf { struct Buf {
data : array<u32, 4>; data : array<u32, 4>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;
@ -540,8 +540,8 @@ TEST_P(ShaderTests, OverridableConstantsPrecision) {
@id(1002) override c2: f32; @id(1002) override c2: f32;
struct Buf { struct Buf {
data : array<f32, 2>; data : array<f32, 2>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;
@ -594,8 +594,8 @@ TEST_P(ShaderTests, OverridableConstantsMultipleEntryPoints) {
@id(1002) override c2: u32; @id(1002) override c2: u32;
struct Buf { struct Buf {
data : array<u32, 1>; data : array<u32, 1>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;

View File

@ -228,9 +228,9 @@ TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
})"); })");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
struct FragmentOut { struct FragmentOut {
@location(0) target0 : vec4<f32>; @location(0) target0 : vec4<f32>,
@location(1) target1 : f32; @location(1) target1 : f32,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var out : FragmentOut; var out : FragmentOut;
out.target0 = vec4<f32>(0.0, 1.0, 0.0, 1.0); out.target0 = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -159,8 +159,8 @@ class TextureFormatTest : public DawnTest {
std::ostringstream fsSource; std::ostringstream fsSource;
fsSource << "@group(0) @binding(0) var myTexture : texture_2d<" << type << ">;\n"; fsSource << "@group(0) @binding(0) var myTexture : texture_2d<" << type << ">;\n";
fsSource << "struct FragmentOut {\n"; fsSource << "struct FragmentOut {\n";
fsSource << " @location(0) color : vec4<" << type << ">;\n"; fsSource << " @location(0) color : vec4<" << type << ">\n";
fsSource << R"(}; fsSource << R"(}
@stage(fragment) @stage(fragment)
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut { fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;

View File

@ -62,9 +62,9 @@ namespace {
wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) { wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) {
return utils::CreateShaderModule(device, R"( return utils::CreateShaderModule(device, R"(
struct VertexOut { struct VertexOut {
@location(0) texCoord : vec2<f32>; @location(0) texCoord : vec2<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {

View File

@ -102,8 +102,8 @@ class TextureZeroInitTest : public DawnTest {
return utils::CreateShaderModule(device, R"( return utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture0 : texture_2d<f32>; @group(0) @binding(0) var texture0 : texture_2d<f32>;
struct FragmentOut { struct FragmentOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>
}; }
@stage(fragment) @stage(fragment)
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut { fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
@ -981,8 +981,8 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
const char* cs = R"( const char* cs = R"(
@group(0) @binding(0) var tex : texture_2d<f32>; @group(0) @binding(0) var tex : texture_2d<f32>;
struct Result { struct Result {
value : vec4<f32>; value : vec4<f32>
}; }
@group(0) @binding(1) var<storage, read_write> result : Result; @group(0) @binding(1) var<storage, read_write> result : Result;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
result.value = textureLoad(tex, vec2<i32>(0,0), 0); result.value = textureLoad(tex, vec2<i32>(0,0), 0);

View File

@ -236,9 +236,9 @@ class VertexFormatTest : public DawnTest {
std::ostringstream vs; std::ostringstream vs;
vs << "struct VertexIn {\n"; vs << "struct VertexIn {\n";
vs << " @location(0) test : " << variableType << ";\n"; vs << " @location(0) test : " << variableType << ",\n";
vs << " @builtin(vertex_index) VertexIndex : u32;\n"; vs << " @builtin(vertex_index) VertexIndex : u32,\n";
vs << "};\n"; vs << "}\n";
// Because x86 CPU using "extended // Because x86 CPU using "extended
// precision"(https://en.wikipedia.org/wiki/Extended_precision) during float // precision"(https://en.wikipedia.org/wiki/Extended_precision) during float
@ -270,9 +270,9 @@ class VertexFormatTest : public DawnTest {
} }
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {

View File

@ -77,18 +77,18 @@ class VertexStateTest : public DawnTest {
// @location(1) input1 : vec4<f32>; // @location(1) input1 : vec4<f32>;
for (const auto& input : testSpec) { for (const auto& input : testSpec) {
vs << "@location(" << input.location << ") input" << input.location vs << "@location(" << input.location << ") input" << input.location
<< " : vec4<f32>;\n"; << " : vec4<f32>,\n";
} }
vs << R"( vs << R"(
@builtin(vertex_index) VertexIndex : u32; @builtin(vertex_index) VertexIndex : u32,
@builtin(instance_index) InstanceIndex : u32; @builtin(instance_index) InstanceIndex : u32,
}; }
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) fn main(input : VertexIn) -> VertexOut { @stage(vertex) fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
@ -586,16 +586,16 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
struct VertexIn { struct VertexIn {
@location(0) attr0 : vec4<f32>; @location(0) attr0 : vec4<f32>,
@location(1) attr1 : vec2<u32>; @location(1) attr1 : vec2<u32>,
@location(2) attr2 : vec4<f32>; @location(2) attr2 : vec4<f32>,
@location(3) attr3 : f32; @location(3) attr3 : f32,
}; }
struct VertexOut { struct VertexOut {
@location(0) color : vec4<f32>; @location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) fn main(input : VertexIn) -> VertexOut { @stage(vertex) fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;

View File

@ -173,9 +173,9 @@ std::vector<uint8_t> VideoViewsTests::GetTestTextureDataWithPlaneIndex(size_t pl
wgpu::ShaderModule VideoViewsTests::GetTestVertexShaderModule() const { wgpu::ShaderModule VideoViewsTests::GetTestVertexShaderModule() const {
return utils::CreateShaderModule(device, R"( return utils::CreateShaderModule(device, R"(
struct VertexOut { struct VertexOut {
@location(0) texCoord : vec2 <f32>; @location(0) texCoord : vec2 <f32>,
@builtin(position) position : vec4<f32>; @builtin(position) position : vec4<f32>,
}; }
@stage(vertex) @stage(vertex)
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {

View File

@ -40,8 +40,8 @@ namespace {
constexpr char kFragmentShaderA[] = R"( constexpr char kFragmentShaderA[] = R"(
struct Uniforms { struct Uniforms {
color : vec3<f32>; color : vec3<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : Uniforms; @group(0) @binding(0) var<uniform> uniforms : Uniforms;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uniforms.color * (1.0 / 5000.0), 1.0); return vec4<f32>(uniforms.color * (1.0 / 5000.0), 1.0);
@ -49,11 +49,11 @@ namespace {
constexpr char kFragmentShaderB[] = R"( constexpr char kFragmentShaderB[] = R"(
struct Constants { struct Constants {
color : vec3<f32>; color : vec3<f32>
}; }
struct Uniforms { struct Uniforms {
color : vec3<f32>; color : vec3<f32>
}; }
@group(0) @binding(0) var<uniform> constants : Constants; @group(0) @binding(0) var<uniform> constants : Constants;
@group(1) @binding(0) var<uniform> uniforms : Uniforms; @group(1) @binding(0) var<uniform> uniforms : Uniforms;

View File

@ -21,13 +21,13 @@ namespace {
const std::string& kMatMulFloatHeader = R"( const std::string& kMatMulFloatHeader = R"(
struct Uniforms { struct Uniforms {
dimAOuter : u32; dimAOuter : u32,
dimInner : u32; dimInner : u32,
dimBOuter : u32; dimBOuter : u32,
}; }
struct Matrix { struct Matrix {
numbers: array<f32>; numbers: array<f32>
}; }
@group(0) @binding(0) var<storage, read> firstMatrix : Matrix; @group(0) @binding(0) var<storage, read> firstMatrix : Matrix;
@group(0) @binding(1) var<storage, read> secondMatrix : Matrix; @group(0) @binding(1) var<storage, read> secondMatrix : Matrix;
@ -188,13 +188,13 @@ namespace {
// The vec4 version requires that dimInner and dimBOuter are divisible by 4. // The vec4 version requires that dimInner and dimBOuter are divisible by 4.
const std::string& kMatMulVec4Header = R"( const std::string& kMatMulVec4Header = R"(
struct Uniforms { struct Uniforms {
dimAOuter : u32; dimAOuter : u32,
dimInner : u32; dimInner : u32,
dimBOuter : u32; dimBOuter : u32,
}; }
struct Matrix { struct Matrix {
numbers: array<vec4<f32>>; numbers: array<vec4<f32>>
}; }
@group(0) @binding(0) var<storage, read> firstMatrix : Matrix; @group(0) @binding(0) var<storage, read> firstMatrix : Matrix;
@group(0) @binding(1) var<storage, read> secondMatrix : Matrix; @group(0) @binding(1) var<storage, read> secondMatrix : Matrix;

View File

@ -1448,8 +1448,8 @@ class SetBindGroupValidationTest : public ValidationTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
value : vec2<f32>; value : vec2<f32>
}; }
@group(0) @binding(0) var<uniform> uBufferDynamic : S; @group(0) @binding(0) var<uniform> uBufferDynamic : S;
@group(0) @binding(1) var<uniform> uBuffer : S; @group(0) @binding(1) var<uniform> uBuffer : S;
@ -1472,8 +1472,8 @@ class SetBindGroupValidationTest : public ValidationTest {
wgpu::ComputePipeline CreateComputePipeline() { wgpu::ComputePipeline CreateComputePipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
value : vec2<f32>; value : vec2<f32>
}; }
@group(0) @binding(0) var<uniform> uBufferDynamic : S; @group(0) @binding(0) var<uniform> uBufferDynamic : S;
@group(0) @binding(1) var<uniform> uBuffer : S; @group(0) @binding(1) var<uniform> uBuffer : S;
@ -1899,7 +1899,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
device.CreatePipelineLayout(&pipelineLayoutDescriptor); device.CreatePipelineLayout(&pipelineLayoutDescriptor);
std::stringstream ss; std::stringstream ss;
ss << "struct S { value : vec2<f32>; };"; ss << "struct S { value : vec2<f32> }";
// Build a shader which has bindings that match the pipeline layout. // Build a shader which has bindings that match the pipeline layout.
for (uint32_t l = 0; l < layouts.size(); ++l) { for (uint32_t l = 0; l < layouts.size(); ++l) {
@ -2074,8 +2074,8 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
wgpu::RenderPipeline CreateRenderPipeline(std::vector<wgpu::BindGroupLayout> bindGroupLayouts) { wgpu::RenderPipeline CreateRenderPipeline(std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
return CreateFSRenderPipeline(R"( return CreateFSRenderPipeline(R"(
struct S { struct S {
value : vec2<f32>; value : vec2<f32>
}; }
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S; @group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S; @group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
@ -2109,8 +2109,8 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
std::vector<wgpu::BindGroupLayout> bindGroupLayouts) { std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
return CreateComputePipeline(R"( return CreateComputePipeline(R"(
struct S { struct S {
value : vec2<f32>; value : vec2<f32>
}; }
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S; @group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S; @group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;

View File

@ -47,8 +47,8 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniform0 : S; @group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S; @group(1) @binding(0) var<uniform> uniform1 : S;
@ -60,13 +60,13 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S2 { struct S2 {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(2) @binding(0) var<uniform> uniform2 : S2; @group(2) @binding(0) var<uniform> uniform2 : S2;
struct S3 { struct S3 {
pos : mat4x4<f32>; pos : mat4x4<f32>
}; }
@group(3) @binding(0) var<storage, read_write> storage3 : S3; @group(3) @binding(0) var<storage, read_write> storage3 : S3;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -99,8 +99,8 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
TEST_F(GetBindGroupLayoutTests, DefaultBindGroupLayoutPipelineCompatibility) { TEST_F(GetBindGroupLayoutTests, DefaultBindGroupLayoutPipelineCompatibility) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -121,8 +121,8 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -291,8 +291,8 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(compute) @workgroup_size(1) fn main() { @stage(compute) @workgroup_size(1) fn main() {
@ -344,8 +344,8 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
binding.buffer.type = wgpu::BufferBindingType::Storage; binding.buffer.type = wgpu::BufferBindingType::Storage;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : S; @group(0) @binding(0) var<storage, read_write> ssbo : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -358,8 +358,8 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
binding.buffer.type = wgpu::BufferBindingType::Uniform; binding.buffer.type = wgpu::BufferBindingType::Uniform;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -373,8 +373,8 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
binding.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage; binding.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<storage, read> ssbo : S; @group(0) @binding(0) var<storage, read> ssbo : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -613,8 +613,8 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
binding.binding = 0; binding.binding = 0;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -628,8 +628,8 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
binding.binding = 1; binding.binding = 1;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(1) var<uniform> uniforms : S; @group(0) @binding(1) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -643,8 +643,8 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
binding.binding = 2; binding.binding = 2;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(1) var<uniform> uniforms : S; @group(0) @binding(1) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -659,8 +659,8 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
TEST_F(GetBindGroupLayoutTests, DuplicateBinding) { TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniform0 : S; @group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S; @group(1) @binding(0) var<uniform> uniform1 : S;
@ -672,8 +672,8 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(1) @binding(0) var<uniform> uniforms : S; @group(1) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -698,8 +698,8 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
wgpu::ShaderModule vsModule4 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule4 = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : f32; pos : f32
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @stage(vertex) fn main() -> @builtin(position) vec4<f32> {
@ -709,8 +709,8 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
wgpu::ShaderModule vsModule64 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule64 = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : mat4x4<f32>; pos : mat4x4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @stage(vertex) fn main() -> @builtin(position) vec4<f32> {
@ -720,8 +720,8 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
wgpu::ShaderModule fsModule4 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule4 = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : f32; pos : f32
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -730,8 +730,8 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
wgpu::ShaderModule fsModule64 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule64 = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : mat4x4<f32>; pos : mat4x4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -865,8 +865,8 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) { TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> ubo : S; @group(0) @binding(0) var<uniform> ubo : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @stage(vertex) fn main() -> @builtin(position) vec4<f32> {
@ -876,8 +876,8 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<storage, read_write> ssbo : S; @group(0) @binding(0) var<storage, read_write> ssbo : S;
@stage(fragment) fn main() { @stage(fragment) fn main() {
@ -989,8 +989,8 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms0 : S; @group(0) @binding(0) var<uniform> uniforms0 : S;
@group(2) @binding(0) var<uniform> uniforms2 : S; @group(2) @binding(0) var<uniform> uniforms2 : S;
@ -1042,8 +1042,8 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
pos : vec4<f32>; pos : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @stage(vertex) fn main() -> @builtin(position) vec4<f32> {
@ -1083,8 +1083,8 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
TEST_F(GetBindGroupLayoutTests, FromCorrectEntryPoint) { TEST_F(GetBindGroupLayoutTests, FromCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Data { struct Data {
data : f32; data : f32
}; }
@group(0) @binding(0) var<storage, read_write> data0 : Data; @group(0) @binding(0) var<storage, read_write> data0 : Data;
@group(0) @binding(1) var<storage, read_write> data1 : Data; @group(0) @binding(1) var<storage, read_write> data1 : Data;

View File

@ -73,7 +73,7 @@ namespace {
std::ostringstream ostream; std::ostringstream ostream;
size_t index = 0; size_t index = 0;
for (const BindingDescriptor& b : bindings) { for (const BindingDescriptor& b : bindings) {
ostream << "struct S" << index << " { " << b.decl << "};\n"; ostream << "struct S" << index << " { " << b.decl << "}\n";
ostream << "@group(" << b.group << ") @binding(" << b.binding << ") "; ostream << "@group(" << b.group << ") @binding(" << b.binding << ") ";
switch (b.type) { switch (b.type) {
case wgpu::BufferBindingType::Uniform: case wgpu::BufferBindingType::Uniform:
@ -110,7 +110,7 @@ namespace {
} }
// Used for adding custom types available throughout the tests // Used for adding custom types available throughout the tests
static const std::string kStructs = "struct ThreeFloats {f1 : f32; f2 : f32; f3 : f32;};\n"; static const std::string kStructs = "struct ThreeFloats {f1 : f32, f2 : f32, f3 : f32,}\n";
// Creates a compute shader with given bindings // Creates a compute shader with given bindings
std::string CreateComputeShaderWithBindings(const std::vector<BindingDescriptor>& bindings) { std::string CreateComputeShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
@ -323,8 +323,8 @@ class MinBufferSizePipelineCreationTests : public MinBufferSizeTestsBase {};
// Pipeline can be created if minimum buffer size in layout is specified as 0 // Pipeline can be created if minimum buffer size in layout is specified as 0
TEST_F(MinBufferSizePipelineCreationTests, ZeroMinBufferSize) { TEST_F(MinBufferSizePipelineCreationTests, ZeroMinBufferSize) {
std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32; b : f32;", "f32", "a", 8}, std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32, b : f32,", "f32", "a", 8},
{0, 1, "c : f32;", "f32", "c", 4}}; {0, 1, "c : f32,", "f32", "c", 4}};
std::string computeShader = CreateComputeShaderWithBindings(bindings); std::string computeShader = CreateComputeShaderWithBindings(bindings);
std::string vertexShader = CreateVertexShaderWithBindings({}); std::string vertexShader = CreateVertexShaderWithBindings({});
@ -337,8 +337,8 @@ TEST_F(MinBufferSizePipelineCreationTests, ZeroMinBufferSize) {
// Fail if layout given has non-zero minimum sizes smaller than shader requirements // Fail if layout given has non-zero minimum sizes smaller than shader requirements
TEST_F(MinBufferSizePipelineCreationTests, LayoutSizesTooSmall) { TEST_F(MinBufferSizePipelineCreationTests, LayoutSizesTooSmall) {
std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32; b : f32;", "f32", "a", 8}, std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32, b : f32,", "f32", "a", 8},
{0, 1, "c : f32;", "f32", "c", 4}}; {0, 1, "c : f32,", "f32", "c", 4}};
std::string computeShader = CreateComputeShaderWithBindings(bindings); std::string computeShader = CreateComputeShaderWithBindings(bindings);
std::string vertexShader = CreateVertexShaderWithBindings({}); std::string vertexShader = CreateVertexShaderWithBindings({});
@ -358,11 +358,11 @@ TEST_F(MinBufferSizePipelineCreationTests, LayoutSizesTooSmall) {
// Fail if layout given has non-zero minimum sizes smaller than shader requirements // Fail if layout given has non-zero minimum sizes smaller than shader requirements
TEST_F(MinBufferSizePipelineCreationTests, LayoutSizesTooSmallMultipleGroups) { TEST_F(MinBufferSizePipelineCreationTests, LayoutSizesTooSmallMultipleGroups) {
std::vector<BindingDescriptor> bg0Bindings = {{0, 0, "a : f32; b : f32;", "f32", "a", 8}, std::vector<BindingDescriptor> bg0Bindings = {{0, 0, "a : f32, b : f32,", "f32", "a", 8},
{0, 1, "c : f32;", "f32", "c", 4}}; {0, 1, "c : f32,", "f32", "c", 4}};
std::vector<BindingDescriptor> bg1Bindings = { std::vector<BindingDescriptor> bg1Bindings = {
{1, 0, "d : f32; e : f32; f : f32;", "f32", "e", 12}, {1, 0, "d : f32, e : f32, f : f32,", "f32", "e", 12},
{1, 1, "g : mat2x2<f32>;", "mat2x2<f32>", "g", 16}}; {1, 1, "g : mat2x2<f32>,", "mat2x2<f32>", "g", 16}};
std::vector<BindingDescriptor> bindings = CombineBindings({bg0Bindings, bg1Bindings}); std::vector<BindingDescriptor> bindings = CombineBindings({bg0Bindings, bg1Bindings});
std::string computeShader = CreateComputeShaderWithBindings(bindings); std::string computeShader = CreateComputeShaderWithBindings(bindings);
@ -387,8 +387,8 @@ class MinBufferSizeBindGroupCreationTests : public MinBufferSizeTestsBase {};
// Fail if a binding is smaller than minimum buffer size // Fail if a binding is smaller than minimum buffer size
TEST_F(MinBufferSizeBindGroupCreationTests, BindingTooSmall) { TEST_F(MinBufferSizeBindGroupCreationTests, BindingTooSmall) {
std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32; b : f32;", "f32", "a", 8}, std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32, b : f32,", "f32", "a", 8},
{0, 1, "c : f32;", "f32", "c", 4}}; {0, 1, "c : f32,", "f32", "c", 4}};
wgpu::BindGroupLayout layout = CreateBindGroupLayout(bindings, {8, 4}); wgpu::BindGroupLayout layout = CreateBindGroupLayout(bindings, {8, 4});
CheckSizeBounds({8, 4}, [&](const std::vector<uint64_t>& sizes, bool expectation) { CheckSizeBounds({8, 4}, [&](const std::vector<uint64_t>& sizes, bool expectation) {
@ -421,8 +421,8 @@ class MinBufferSizeDrawTimeValidationTests : public MinBufferSizeTestsBase {};
// Fail if binding sizes are too small at draw time // Fail if binding sizes are too small at draw time
TEST_F(MinBufferSizeDrawTimeValidationTests, ZeroMinSizeAndTooSmallBinding) { TEST_F(MinBufferSizeDrawTimeValidationTests, ZeroMinSizeAndTooSmallBinding) {
std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32; b : f32;", "f32", "a", 8}, std::vector<BindingDescriptor> bindings = {{0, 0, "a : f32, b : f32,", "f32", "a", 8},
{0, 1, "c : f32;", "f32", "c", 4}}; {0, 1, "c : f32,", "f32", "c", 4}};
std::string computeShader = CreateComputeShaderWithBindings(bindings); std::string computeShader = CreateComputeShaderWithBindings(bindings);
std::string vertexShader = CreateVertexShaderWithBindings({}); std::string vertexShader = CreateVertexShaderWithBindings({});
@ -443,9 +443,9 @@ TEST_F(MinBufferSizeDrawTimeValidationTests, ZeroMinSizeAndTooSmallBinding) {
// Draw time validation works for non-contiguous bindings // Draw time validation works for non-contiguous bindings
TEST_F(MinBufferSizeDrawTimeValidationTests, UnorderedBindings) { TEST_F(MinBufferSizeDrawTimeValidationTests, UnorderedBindings) {
std::vector<BindingDescriptor> bindings = { std::vector<BindingDescriptor> bindings = {
{0, 2, "a : f32; b : f32;", "f32", "a", 8}, {0, 2, "a : f32, b : f32,", "f32", "a", 8},
{0, 0, "c : f32;", "f32", "c", 4}, {0, 0, "c : f32,", "f32", "c", 4},
{0, 4, "d : f32; e : f32; f : f32;", "f32", "e", 12}}; {0, 4, "d : f32, e : f32, f : f32,", "f32", "e", 12}};
std::string computeShader = CreateComputeShaderWithBindings(bindings); std::string computeShader = CreateComputeShaderWithBindings(bindings);
std::string vertexShader = CreateVertexShaderWithBindings({}); std::string vertexShader = CreateVertexShaderWithBindings({});
@ -465,11 +465,11 @@ TEST_F(MinBufferSizeDrawTimeValidationTests, UnorderedBindings) {
// Draw time validation works for multiple bind groups // Draw time validation works for multiple bind groups
TEST_F(MinBufferSizeDrawTimeValidationTests, MultipleGroups) { TEST_F(MinBufferSizeDrawTimeValidationTests, MultipleGroups) {
std::vector<BindingDescriptor> bg0Bindings = {{0, 0, "a : f32; b : f32;", "f32", "a", 8}, std::vector<BindingDescriptor> bg0Bindings = {{0, 0, "a : f32, b : f32,", "f32", "a", 8},
{0, 1, "c : f32;", "f32", "c", 4}}; {0, 1, "c : f32,", "f32", "c", 4}};
std::vector<BindingDescriptor> bg1Bindings = { std::vector<BindingDescriptor> bg1Bindings = {
{1, 0, "d : f32; e : f32; f : f32;", "f32", "e", 12}, {1, 0, "d : f32, e : f32, f : f32,", "f32", "e", 12},
{1, 1, "g : mat2x2<f32>;", "mat2x2<f32>", "g", 16}}; {1, 1, "g : mat2x2<f32>,", "mat2x2<f32>", "g", 16}};
std::vector<BindingDescriptor> bindings = CombineBindings({bg0Bindings, bg1Bindings}); std::vector<BindingDescriptor> bindings = CombineBindings({bg0Bindings, bg1Bindings});
std::string computeShader = CreateComputeShaderWithBindings(bindings); std::string computeShader = CreateComputeShaderWithBindings(bindings);
@ -537,52 +537,52 @@ class MinBufferSizeDefaultLayoutTests : public MinBufferSizeTestsBase {
// Test the minimum size computations for various WGSL types. // Test the minimum size computations for various WGSL types.
TEST_F(MinBufferSizeDefaultLayoutTests, DefaultLayoutVariousWGSLTypes) { TEST_F(MinBufferSizeDefaultLayoutTests, DefaultLayoutVariousWGSLTypes) {
CheckShaderBindingSizeReflection({{{0, 0, "a : f32;", "f32", "a", 4}, CheckShaderBindingSizeReflection({{{0, 0, "a : f32,", "f32", "a", 4},
{0, 1, "b : array<f32>;", "f32", "b[0]", 4}, {0, 1, "b : array<f32>,", "f32", "b[0]", 4},
{0, 2, "c : mat2x2<f32>;", "mat2x2<f32>", "c", 16}}}); {0, 2, "c : mat2x2<f32>,", "mat2x2<f32>", "c", 16}}});
CheckShaderBindingSizeReflection({{{0, 3, "d : u32; e : array<f32>;", "u32", "d", 8}, CheckShaderBindingSizeReflection({{{0, 3, "d : u32; e : array<f32>,", "u32", "d", 8},
{0, 4, "f : ThreeFloats;", "f32", "f.f1", 12}, {0, 4, "f : ThreeFloats,", "f32", "f.f1", 12},
{0, 5, "g : array<ThreeFloats>;", "f32", "g[0].f1", 12}}}); {0, 5, "g : array<ThreeFloats>,", "f32", "g[0].f1", 12}}});
} }
// Test the minimum size computations for various buffer binding types. // Test the minimum size computations for various buffer binding types.
TEST_F(MinBufferSizeDefaultLayoutTests, DefaultLayoutVariousBindingTypes) { TEST_F(MinBufferSizeDefaultLayoutTests, DefaultLayoutVariousBindingTypes) {
CheckShaderBindingSizeReflection( CheckShaderBindingSizeReflection(
{{{0, 0, "a : f32;", "f32", "a", 4, wgpu::BufferBindingType::Uniform}, {{{0, 0, "a : f32,", "f32", "a", 4, wgpu::BufferBindingType::Uniform},
{0, 1, "a : f32; b : f32;", "f32", "a", 8, wgpu::BufferBindingType::Storage}, {0, 1, "a : f32, b : f32,", "f32", "a", 8, wgpu::BufferBindingType::Storage},
{0, 2, "a : f32; b : f32; c: f32;", "f32", "a", 12, {0, 2, "a : f32, b : f32, c: f32,", "f32", "a", 12,
wgpu::BufferBindingType::ReadOnlyStorage}}}); wgpu::BufferBindingType::ReadOnlyStorage}}});
} }
// Test the minimum size computations works with multiple bind groups. // Test the minimum size computations works with multiple bind groups.
TEST_F(MinBufferSizeDefaultLayoutTests, MultipleBindGroups) { TEST_F(MinBufferSizeDefaultLayoutTests, MultipleBindGroups) {
CheckShaderBindingSizeReflection( CheckShaderBindingSizeReflection(
{{{0, 0, "a : f32;", "f32", "a", 4, wgpu::BufferBindingType::Uniform}}, {{{0, 0, "a : f32,", "f32", "a", 4, wgpu::BufferBindingType::Uniform}},
{{1, 0, "a : f32; b : f32;", "f32", "a", 8, wgpu::BufferBindingType::Storage}}, {{1, 0, "a : f32, b : f32,", "f32", "a", 8, wgpu::BufferBindingType::Storage}},
{{2, 0, "a : f32; b : f32; c : f32;", "f32", "a", 12, {{2, 0, "a : f32, b : f32, c : f32,", "f32", "a", 12,
wgpu::BufferBindingType::ReadOnlyStorage}}}); wgpu::BufferBindingType::ReadOnlyStorage}}});
} }
// Test the minimum size computations with manual size/align attributes. // Test the minimum size computations with manual size/align attributes.
TEST_F(MinBufferSizeDefaultLayoutTests, NonDefaultLayout) { TEST_F(MinBufferSizeDefaultLayoutTests, NonDefaultLayout) {
CheckShaderBindingSizeReflection( CheckShaderBindingSizeReflection(
{{{0, 0, "@size(256) a : u32; b : u32;", "u32", "a", 260}, {{{0, 0, "@size(256) a : u32, b : u32,", "u32", "a", 260},
{0, 1, "c : u32; @align(16) d : u32;", "u32", "c", 20}, {0, 1, "c : u32, @align(16) d : u32,", "u32", "c", 20},
{0, 2, "d : array<array<u32, 10>, 3>;", "u32", "d[0][0]", 120}, {0, 2, "d : array<array<u32, 10>, 3>,", "u32", "d[0][0]", 120},
{0, 3, "e : array<array<u32, 10>>;", "u32", "e[0][0]", 40}}}); {0, 3, "e : array<array<u32, 10>>,", "u32", "e[0][0]", 40}}});
} }
// Minimum size should be the max requirement of both vertex and fragment stages. // Minimum size should be the max requirement of both vertex and fragment stages.
TEST_F(MinBufferSizeDefaultLayoutTests, RenderPassConsidersBothStages) { TEST_F(MinBufferSizeDefaultLayoutTests, RenderPassConsidersBothStages) {
std::string vertexShader = CreateVertexShaderWithBindings( std::string vertexShader = CreateVertexShaderWithBindings(
{{0, 0, "a : f32; b : f32;", "f32", "a", 8, wgpu::BufferBindingType::Uniform, {{0, 0, "a : f32, b : f32,", "f32", "a", 8, wgpu::BufferBindingType::Uniform,
wgpu::ShaderStage::Vertex}, wgpu::ShaderStage::Vertex},
{0, 1, "c : vec4<f32>;", "vec4<f32>", "c", 16, wgpu::BufferBindingType::Uniform, {0, 1, "c : vec4<f32>,", "vec4<f32>", "c", 16, wgpu::BufferBindingType::Uniform,
wgpu::ShaderStage::Vertex}}); wgpu::ShaderStage::Vertex}});
std::string fragShader = CreateFragmentShaderWithBindings( std::string fragShader = CreateFragmentShaderWithBindings(
{{0, 0, "a : f32;", "f32", "a", 4, wgpu::BufferBindingType::Uniform, {{0, 0, "a : f32,", "f32", "a", 4, wgpu::BufferBindingType::Uniform,
wgpu::ShaderStage::Fragment}, wgpu::ShaderStage::Fragment},
{0, 1, "b : f32; c : f32;", "f32", "b", 8, wgpu::BufferBindingType::Uniform, {0, 1, "b : f32, c : f32,", "f32", "b", 8, wgpu::BufferBindingType::Uniform,
wgpu::ShaderStage::Fragment}}); wgpu::ShaderStage::Fragment}});
wgpu::BindGroupLayout renderLayout = GetBGLFromRenderShaders(vertexShader, fragShader, 0); wgpu::BindGroupLayout renderLayout = GetBGLFromRenderShaders(vertexShader, fragShader, 0);

View File

@ -29,8 +29,8 @@ namespace {
vsModule = utils::CreateShaderModule(device, R"( vsModule = utils::CreateShaderModule(device, R"(
struct S { struct S {
transform : mat2x2<f32>; transform : mat2x2<f32>
}; }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(vertex) fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> { @stage(vertex) fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> {
@ -39,13 +39,13 @@ namespace {
fsModule = utils::CreateShaderModule(device, R"( fsModule = utils::CreateShaderModule(device, R"(
struct Uniforms { struct Uniforms {
color : vec4<f32>; color : vec4<f32>
}; }
@group(1) @binding(0) var<uniform> uniforms : Uniforms; @group(1) @binding(0) var<uniform> uniforms : Uniforms;
struct Storage { struct Storage {
dummy : array<f32>; dummy : array<f32>
}; }
@group(1) @binding(1) var<storage, read_write> ssbo : Storage; @group(1) @binding(1) var<storage, read_write> ssbo : Storage;
@stage(fragment) fn main() { @stage(fragment) fn main() {

View File

@ -856,8 +856,8 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) { TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
wgpu::ShaderModule vsModuleWithStorageBuffer = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModuleWithStorageBuffer = utils::CreateShaderModule(device, R"(
struct Dst { struct Dst {
data : array<u32, 100>; data : array<u32, 100>
}; }
@group(0) @binding(0) var<storage, read_write> dst : Dst; @group(0) @binding(0) var<storage, read_write> dst : Dst;
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { @stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
dst.data[VertexIndex] = 0x1234u; dst.data[VertexIndex] = 0x1234u;
@ -1105,9 +1105,9 @@ TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
wgpu::ShaderModule fsModuleWriteBoth = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModuleWriteBoth = utils::CreateShaderModule(device, R"(
struct FragmentOut { struct FragmentOut {
@location(0) target0 : vec4<f32>; @location(0) target0 : vec4<f32>,
@location(1) target1 : vec4<f32>; @location(1) target1 : vec4<f32>,
}; }
@stage(fragment) fn main() -> FragmentOut { @stage(fragment) fn main() -> FragmentOut {
var out : FragmentOut; var out : FragmentOut;
return out; return out;
@ -1215,8 +1215,8 @@ TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) { TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Uniforms { struct Uniforms {
data : vec4<f32>; data : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> var0 : Uniforms; @group(0) @binding(0) var<uniform> var0 : Uniforms;
@group(0) @binding(1) var<uniform> var1 : Uniforms; @group(0) @binding(1) var<uniform> var1 : Uniforms;
@ -1314,9 +1314,9 @@ class InterStageVariableMatchingValidationTest : public RenderPipelineValidation
TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocation) { TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocation) {
wgpu::ShaderModule vertexModuleOutputAtLocation0 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vertexModuleOutputAtLocation0 = utils::CreateShaderModule(device, R"(
struct A { struct A {
@location(0) vout: f32; @location(0) vout: f32,
@builtin(position) pos: vec4<f32>; @builtin(position) pos: vec4<f32>,
}; }
@stage(vertex) fn main() -> A { @stage(vertex) fn main() -> A {
var vertexOut: A; var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -1324,23 +1324,23 @@ TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocatio
})"); })");
wgpu::ShaderModule fragmentModuleAtLocation0 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fragmentModuleAtLocation0 = utils::CreateShaderModule(device, R"(
struct B { struct B {
@location(0) fin: f32; @location(0) fin: f32
}; }
@stage(fragment) fn main(fragmentIn: B) -> @location(0) vec4<f32> { @stage(fragment) fn main(fragmentIn: B) -> @location(0) vec4<f32> {
return vec4<f32>(fragmentIn.fin, 0.0, 0.0, 1.0); return vec4<f32>(fragmentIn.fin, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fragmentModuleInputAtLocation1 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fragmentModuleInputAtLocation1 = utils::CreateShaderModule(device, R"(
struct A { struct A {
@location(1) vout: f32; @location(1) vout: f32
}; }
@stage(fragment) fn main(vertexOut: A) -> @location(0) vec4<f32> { @stage(fragment) fn main(vertexOut: A) -> @location(0) vec4<f32> {
return vec4<f32>(vertexOut.vout, 0.0, 0.0, 1.0); return vec4<f32>(vertexOut.vout, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule vertexModuleOutputAtLocation1 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vertexModuleOutputAtLocation1 = utils::CreateShaderModule(device, R"(
struct B { struct B {
@location(1) fin: f32; @location(1) fin: f32,
@builtin(position) pos: vec4<f32>; @builtin(position) pos: vec4<f32>,
}; }
@stage(vertex) fn main() -> B { @stage(vertex) fn main() -> B {
var fragmentIn: B; var fragmentIn: B;
fragmentIn.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); fragmentIn.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -1376,15 +1376,15 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
std::string interfaceDeclaration; std::string interfaceDeclaration;
{ {
std::ostringstream sstream; std::ostringstream sstream;
sstream << "struct A { @location(0) @interpolate(flat) a: " << kTypes[i] << ";" sstream << "struct A { @location(0) @interpolate(flat) a: " << kTypes[i] << ","
<< std::endl; << std::endl;
interfaceDeclaration = sstream.str(); interfaceDeclaration = sstream.str();
} }
{ {
std::ostringstream vertexStream; std::ostringstream vertexStream;
vertexStream << interfaceDeclaration << R"( vertexStream << interfaceDeclaration << R"(
@builtin(position) pos: vec4<f32>; @builtin(position) pos: vec4<f32>,
}; }
@stage(vertex) fn main() -> A { @stage(vertex) fn main() -> A {
var vertexOut: A; var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -1395,7 +1395,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
{ {
std::ostringstream fragmentStream; std::ostringstream fragmentStream;
fragmentStream << interfaceDeclaration << R"( fragmentStream << interfaceDeclaration << R"(
}; }
@stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> { @stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"; })";
@ -1475,14 +1475,14 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
} }
sstream << ")"; sstream << ")";
} }
sstream << " a : vec4<f32>;" << std::endl; sstream << " a : vec4<f32>," << std::endl;
interfaceDeclaration = sstream.str(); interfaceDeclaration = sstream.str();
} }
{ {
std::ostringstream vertexStream; std::ostringstream vertexStream;
vertexStream << interfaceDeclaration << R"( vertexStream << interfaceDeclaration << R"(
@builtin(position) pos: vec4<f32>; @builtin(position) pos: vec4<f32>,
}; }
@stage(vertex) fn main() -> A { @stage(vertex) fn main() -> A {
var vertexOut: A; var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -1493,7 +1493,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
{ {
std::ostringstream fragmentStream; std::ostringstream fragmentStream;
fragmentStream << interfaceDeclaration << R"( fragmentStream << interfaceDeclaration << R"(
}; }
@stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> { @stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> {
return fragmentIn.a; return fragmentIn.a;
})"; })";

View File

@ -762,8 +762,8 @@ namespace {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct RBuffer { struct RBuffer {
value : f32; value : f32
}; }
@group(0) @binding(0) var<storage, read> rBuffer : RBuffer; @group(0) @binding(0) var<storage, read> rBuffer : RBuffer;
@stage(fragment) fn main() { @stage(fragment) fn main() {
})"); })");

View File

@ -538,8 +538,8 @@ TEST_F(ShaderModuleValidationTest, OverridableConstantsNumericIDConflicts) {
@id(1234) override c1: u32; @id(1234) override c1: u32;
struct Buf { struct Buf {
data : array<u32, 2>; data : array<u32, 2>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;

View File

@ -54,8 +54,8 @@ class D3D12DescriptorHeapTests : public DawnTest {
mSimpleFSModule = utils::CreateShaderModule(device, R"( mSimpleFSModule = utils::CreateShaderModule(device, R"(
struct U { struct U {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> colorBuffer : U; @group(0) @binding(0) var<uniform> colorBuffer : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
@ -445,8 +445,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
struct U { struct U {
heapSize : f32; heapSize : f32
}; }
@group(0) @binding(0) var<uniform> buffer0 : U; @group(0) @binding(0) var<uniform> buffer0 : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {
@ -778,8 +778,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
struct U { struct U {
transform : mat2x2<f32>; transform : mat2x2<f32>
}; }
@group(0) @binding(0) var<uniform> buffer0 : U; @group(0) @binding(0) var<uniform> buffer0 : U;
@stage(vertex) fn main( @stage(vertex) fn main(
@ -794,8 +794,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
})"); })");
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
struct U { struct U {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(1) var sampler0 : sampler; @group(0) @binding(1) var sampler0 : sampler;
@group(0) @binding(2) var texture0 : texture_2d<f32>; @group(0) @binding(2) var texture0 : texture_2d<f32>;
@group(0) @binding(3) var<uniform> buffer0 : U; @group(0) @binding(3) var<uniform> buffer0 : U;

View File

@ -354,8 +354,8 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
struct U { struct U {
color : vec4<f32>; color : vec4<f32>
}; }
@group(0) @binding(0) var<uniform> colorBuffer : U; @group(0) @binding(0) var<uniform> colorBuffer : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @stage(fragment) fn main() -> @location(0) vec4<f32> {

View File

@ -32,8 +32,8 @@ class InternalStorageBufferBindingTests : public DawnTest {
wgpu::ComputePipeline CreateComputePipelineWithInternalStorage() { wgpu::ComputePipeline CreateComputePipelineWithInternalStorage() {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf { struct Buf {
data : array<u32, 4>; data : array<u32, 4>
}; }
@group(0) @binding(0) var<storage, read_write> buf : Buf; @group(0) @binding(0) var<storage, read_write> buf : Buf;