Update Dawn tests to use group instead of set.

This Cl updates the WGSL used by Dawn to use the new `group` decoration
instead of the deprecated `set` decoration.

Change-Id: I145aaff7721dfafff986ddc429c9cdc9389c2110
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38141
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair 2021-01-19 14:18:51 +00:00 committed by Commit Bot service account
parent e45593cb08
commit 0f9c2d7b78
35 changed files with 214 additions and 212 deletions

View File

@ -167,9 +167,9 @@ void initSim() {
[[block]] struct Particles { [[block]] struct Particles {
[[offset(0)]] particles : [[stride(16)]] array<Particle>; [[offset(0)]] particles : [[stride(16)]] array<Particle>;
}; };
[[binding(0), set(0)]] var<uniform> params : SimParams; [[binding(0), group(0)]] var<uniform> params : SimParams;
[[binding(1), set(0)]] var<storage_buffer> particlesA : [[access(read)]] Particles; [[binding(1), group(0)]] var<storage_buffer> particlesA : [[access(read)]] Particles;
[[binding(2), set(0)]] var<storage_buffer> particlesB : [[access(read_write)]] Particles; [[binding(2), group(0)]] var<storage_buffer> particlesB : [[access(read_write)]] Particles;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp // https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp

View File

@ -105,8 +105,8 @@ void init() {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[set(0), binding(1)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(1)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[location(0)]] var<out> FragColor : vec4<f32>; [[location(0)]] var<out> FragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {

View File

@ -106,12 +106,12 @@ void init() {
[[offset(0)]] view : mat4x4<f32>; [[offset(0)]] view : mat4x4<f32>;
[[offset(64)]] proj : mat4x4<f32>; [[offset(64)]] proj : mat4x4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> camera : Camera; [[group(0), binding(0)]] var<uniform> camera : Camera;
[[block]] struct Model { [[block]] struct Model {
[[offset(0)]] matrix : mat4x4<f32>; [[offset(0)]] matrix : mat4x4<f32>;
}; };
[[set(0), binding(1)]] var<uniform> model : Model; [[group(0), binding(1)]] var<uniform> model : Model;
[[location(0)]] var<in> pos : vec3<f32>; [[location(0)]] var<in> pos : vec3<f32>;
[[location(1)]] var<in> col : vec3<f32>; [[location(1)]] var<in> col : vec3<f32>;

View File

@ -45,7 +45,7 @@ namespace dawn_native {
[[location(0)]] var<out> v_texcoord: vec2<f32>; [[location(0)]] var<out> v_texcoord: vec2<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[builtin(vertex_idx)]] var<in> VertexIndex : u32; [[builtin(vertex_idx)]] var<in> VertexIndex : u32;
[[binding(0), set(0)]] var<uniform> uniforms : Uniforms; [[binding(0), group(0)]] var<uniform> uniforms : Uniforms;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>((texcoord[VertexIndex] * 2.0 - vec2<f32>(1.0, 1.0)), 0.0, 1.0); Position = vec4<f32>((texcoord[VertexIndex] * 2.0 - vec2<f32>(1.0, 1.0)), 0.0, 1.0);
@ -57,8 +57,8 @@ namespace dawn_native {
)"; )";
static const char sPassthrough2D4ChannelFrag[] = R"( static const char sPassthrough2D4ChannelFrag[] = R"(
[[binding(1), set(0)]] var<uniform_constant> mySampler: sampler; [[binding(1), group(0)]] var<uniform_constant> mySampler: sampler;
[[binding(2), set(0)]] var<uniform_constant> myTexture: texture_2d<f32>; [[binding(2), group(0)]] var<uniform_constant> myTexture: texture_2d<f32>;
[[location(0)]] var<in> v_texcoord : vec2<f32>; [[location(0)]] var<in> v_texcoord : vec2<f32>;
[[location(0)]] var<out> rgbaColor : vec4<f32>; [[location(0)]] var<out> rgbaColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {

View File

@ -52,11 +52,11 @@ namespace dawn_native {
[[offset(8)]] period : f32; [[offset(8)]] period : f32;
}; };
[[set(0), binding(0)]] [[group(0), binding(0)]]
var<storage_buffer> timestamps : [[access(read_write)]] TimestampArr; var<storage_buffer> timestamps : [[access(read_write)]] TimestampArr;
[[set(0), binding(1)]] [[group(0), binding(1)]]
var<storage_buffer> availability : [[access(read)]] AvailabilityArr; var<storage_buffer> availability : [[access(read)]] AvailabilityArr;
[[set(0), binding(2)]] var<uniform> params : TimestampParams; [[group(0), binding(2)]] var<uniform> params : TimestampParams;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;

View File

@ -72,11 +72,11 @@ class BindGroupTests : public DawnTest {
switch (bindingTypes[i]) { switch (bindingTypes[i]) {
case wgpu::BufferBindingType::Uniform: case wgpu::BufferBindingType::Uniform:
fs << "\n[[set(" << i << "), binding(0)]] var<uniform> buffer" << i fs << "\n[[group(" << i << "), binding(0)]] var<uniform> buffer" << i
<< " : Buffer" << i << ";"; << " : Buffer" << i << ";";
break; break;
case wgpu::BufferBindingType::Storage: case wgpu::BufferBindingType::Storage:
fs << "\n[[set(" << i << "), binding(0)]] var<storage_buffer> buffer" << i fs << "\n[[group(" << i << "), binding(0)]] var<storage_buffer> buffer" << i
<< " : [[access(read)]] Buffer" << i << ";"; << " : [[access(read)]] Buffer" << i << ";";
break; break;
default: default:
@ -123,7 +123,7 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
[[block]] struct Contents { [[block]] struct Contents {
[[offset(0)]] f : f32; [[offset(0)]] f : f32;
}; };
[[set(0), binding(0)]] var <uniform> contents: Contents; [[group(0), binding(0)]] var <uniform> contents: Contents;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
})"); })");
@ -162,7 +162,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
[[offset(0)]] transform : vec4<f32>; [[offset(0)]] transform : vec4<f32>;
}; };
[[set(0), binding(0)]] var <uniform> vertexUbo : VertexUniformBuffer; [[group(0), binding(0)]] var <uniform> vertexUbo : VertexUniformBuffer;
[[builtin(vertex_idx)]] var<in> VertexIndex : u32; [[builtin(vertex_idx)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
@ -183,7 +183,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
[[block]] struct FragmentUniformBuffer { [[block]] struct FragmentUniformBuffer {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
[[set(0), binding(1)]] var <uniform> fragmentUbo : FragmentUniformBuffer; [[group(0), binding(1)]] var <uniform> fragmentUbo : FragmentUniformBuffer;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
@ -249,7 +249,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
[[block]] struct VertexUniformBuffer { [[block]] struct VertexUniformBuffer {
[[offset(0)]] transform : vec4<f32>; [[offset(0)]] transform : vec4<f32>;
}; };
[[set(0), binding(0)]] var <uniform> vertexUbo : VertexUniformBuffer; [[group(0), binding(0)]] var <uniform> vertexUbo : VertexUniformBuffer;
[[builtin(vertex_idx)]] var<in> VertexIndex : u32; [[builtin(vertex_idx)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
@ -267,8 +267,8 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(1)]] var <uniform_constant> samp : sampler; [[group(0), binding(1)]] var <uniform_constant> samp : sampler;
[[set(0), binding(2)]] var <uniform_constant> tex : texture_2d<f32>; [[group(0), binding(2)]] var <uniform_constant> tex : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
@ -371,8 +371,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
}; };
// TODO(crbug.com/tint/386): Use the same struct definition. // TODO(crbug.com/tint/386): Use the same struct definition.
[[set(0), binding(0)]] var <uniform> vertexUbo1 : VertexUniformBuffer1; [[group(0), binding(0)]] var <uniform> vertexUbo1 : VertexUniformBuffer1;
[[set(1), binding(0)]] var <uniform> vertexUbo2 : VertexUniformBuffer2; [[group(1), binding(0)]] var <uniform> vertexUbo2 : VertexUniformBuffer2;
[[builtin(vertex_idx)]] var<in> VertexIndex : u32; [[builtin(vertex_idx)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
@ -400,8 +400,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
}; };
// TODO(crbug.com/tint/386): Use the same struct definition. // TODO(crbug.com/tint/386): Use the same struct definition.
[[set(0), binding(1)]] var <uniform> fragmentUbo1 : FragmentUniformBuffer1; [[group(0), binding(1)]] var <uniform> fragmentUbo1 : FragmentUniformBuffer1;
[[set(1), binding(1)]] var <uniform> fragmentUbo2 : FragmentUniformBuffer2; [[group(1), binding(1)]] var <uniform> fragmentUbo2 : FragmentUniformBuffer2;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
@ -863,10 +863,10 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
[[offset(0)]] value : vec3<u32>; [[offset(0)]] value : vec3<u32>;
}; };
[[set(0), binding(2)]] var<uniform> buffer2 : Buffer2; [[group(0), binding(2)]] var<uniform> buffer2 : Buffer2;
[[set(0), binding(3)]] var<storage_buffer> buffer3 : [[access(read)]] Buffer3; [[group(0), binding(3)]] var<storage_buffer> buffer3 : [[access(read)]] Buffer3;
[[set(0), binding(0)]] var<storage_buffer> buffer0 : [[access(read)]] Buffer0; [[group(0), binding(0)]] var<storage_buffer> buffer0 : [[access(read)]] Buffer0;
[[set(0), binding(4)]] var<storage_buffer> outputBuffer : [[access(read_write)]] OutputBuffer; [[group(0), binding(4)]] var<storage_buffer> outputBuffer : [[access(read_write)]] OutputBuffer;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
outputBuffer.value = vec3<u32>(buffer0.value, buffer2.value, buffer3.value); outputBuffer.value = vec3<u32>(buffer0.value, buffer2.value, buffer3.value);
@ -988,9 +988,9 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
}; };
// TODO(crbug.com/tint/386): Use the same struct definition. // TODO(crbug.com/tint/386): Use the same struct definition.
[[set(0), binding(953)]] var <uniform> ubo1 : Ubo1; [[group(0), binding(953)]] var <uniform> ubo1 : Ubo1;
[[set(0), binding(47)]] var <uniform> ubo2 : Ubo2; [[group(0), binding(47)]] var <uniform> ubo2 : Ubo2;
[[set(0), binding(111)]] var <uniform> ubo3 : Ubo3; [[group(0), binding(111)]] var <uniform> ubo3 : Ubo3;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
@ -1133,7 +1133,7 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
[[block]] struct Buffer0 { [[block]] struct Buffer0 {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
[[set(0), binding(0)]] var<storage_buffer> buffer0 : [[access(read)]] Buffer0; [[group(0), binding(0)]] var<storage_buffer> buffer0 : [[access(read)]] Buffer0;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
@ -1216,13 +1216,13 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
wgpu::TextureFormat::R8Unorm, expectedValue, wgpu::TextureUsage::Sampled); wgpu::TextureFormat::R8Unorm, expectedValue, wgpu::TextureUsage::Sampled);
bgEntries.push_back({binding, nullptr, 0, 0, nullptr, texture.CreateView()}); bgEntries.push_back({binding, nullptr, 0, 0, nullptr, texture.CreateView()});
interface << "[[set(0), binding(" << binding++ << ")]] " interface << "[[group(0), binding(" << binding++ << ")]] "
<< "var<uniform_constant> tex" << i << " : texture_2d<f32>;\n"; << "var<uniform_constant> tex" << i << " : texture_2d<f32>;\n";
wgpu::SamplerDescriptor samplerDesc = {}; wgpu::SamplerDescriptor samplerDesc = {};
bgEntries.push_back({binding, nullptr, 0, 0, device.CreateSampler(&samplerDesc), nullptr}); bgEntries.push_back({binding, nullptr, 0, 0, device.CreateSampler(&samplerDesc), nullptr});
interface << "[[set(0), binding(" << binding++ << ")]]" interface << "[[group(0), binding(" << binding++ << ")]]"
<< "var<uniform_constant> samp" << i << " : sampler;\n"; << "var<uniform_constant> samp" << i << " : sampler;\n";
body << "if (abs(textureSampleLevel(tex" << i << ", samp" << i body << "if (abs(textureSampleLevel(tex" << i << ", samp" << i
@ -1236,7 +1236,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
wgpu::TextureFormat::R32Uint, expectedValue, wgpu::TextureUsage::Storage); wgpu::TextureFormat::R32Uint, expectedValue, wgpu::TextureUsage::Storage);
bgEntries.push_back({binding, nullptr, 0, 0, nullptr, texture.CreateView()}); bgEntries.push_back({binding, nullptr, 0, 0, nullptr, texture.CreateView()});
interface << "[[set(0), binding(" << binding++ << ")]] " interface << "[[group(0), binding(" << binding++ << ")]] "
<< "var<uniform_constant> image" << i << "var<uniform_constant> image" << i
<< " : [[access(read)]] texture_storage_2d<r32uint>;\n"; << " : [[access(read)]] texture_storage_2d<r32uint>;\n";
@ -1255,7 +1255,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
[[offset(0)]] value : u32; [[offset(0)]] value : u32;
}; };
)"; )";
interface << "[[set(0), binding(" << binding++ << ")]] " interface << "[[group(0), binding(" << binding++ << ")]] "
<< "var<uniform> ubuf" << i << " : UniformBuffer" << i << ";\n"; << "var<uniform> ubuf" << i << " : UniformBuffer" << i << ";\n";
body << "if (ubuf" << i << ".value != " << expectedValue++ << "u) {\n"; body << "if (ubuf" << i << ".value != " << expectedValue++ << "u) {\n";
@ -1272,7 +1272,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
[[offset(0)]] value : u32; [[offset(0)]] value : u32;
}; };
)"; )";
interface << "[[set(0), binding(" << binding++ << ")]] " interface << "[[group(0), binding(" << binding++ << ")]] "
<< "var<storage_buffer> sbuf" << i << " : [[access(read)]] ReadOnlyStorageBuffer" << "var<storage_buffer> sbuf" << i << " : [[access(read)]] ReadOnlyStorageBuffer"
<< i << ";\n"; << i << ";\n";
@ -1289,7 +1289,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
[[offset(0)]] value : u32; [[offset(0)]] value : u32;
}; };
)"; )";
interface << "[[set(0), binding(" << binding++ << ")]] " interface << "[[group(0), binding(" << binding++ << ")]] "
<< "var<storage_buffer> result : [[access(read_write)]] ReadWriteStorageBuffer;\n"; << "var<storage_buffer> result : [[access(read_write)]] ReadWriteStorageBuffer;\n";
body << "result.value = 1u;\n"; body << "result.value = 1u;\n";

View File

@ -60,7 +60,7 @@ class ColorStateTest : public DawnTest {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> myUbo : MyBlock; [[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
@ -777,7 +777,7 @@ TEST_P(ColorStateTest, IndependentColorState) {
[[offset(48)]] color3 : vec4<f32>; [[offset(48)]] color3 : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> myUbo : MyBlock; [[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
[[location(0)]] var<out> fragColor0 : vec4<f32>; [[location(0)]] var<out> fragColor0 : vec4<f32>;
[[location(1)]] var<out> fragColor1 : vec4<f32>; [[location(1)]] var<out> fragColor1 : vec4<f32>;
@ -884,7 +884,7 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> myUbo : MyBlock; [[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
@ -1007,7 +1007,7 @@ TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> myUbo : MyBlock; [[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;

View File

@ -156,8 +156,8 @@ class CompressedTextureBCFormatTest : public DawnTest {
return; return;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> sampler0 : sampler; [[group(0), binding(0)]] var<uniform_constant> sampler0 : sampler;
[[set(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>; [[group(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>;
[[location(0)]] var<in> texCoord : vec2<f32>; [[location(0)]] var<in> texCoord : vec2<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;

View File

@ -38,8 +38,8 @@ void ComputeIndirectTests::BasicTest(std::initializer_list<uint32_t> bufferList,
[[offset(0)]] workGroups : vec3<u32>; [[offset(0)]] workGroups : vec3<u32>;
}; };
[[set(0), binding(0)]] var<uniform> input : InputBuf; [[group(0), binding(0)]] var<uniform> input : InputBuf;
[[set(0), binding(1)]] var<storage_buffer> output : OutputBuf; [[group(0), binding(1)]] var<storage_buffer> output : OutputBuf;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;

View File

@ -36,7 +36,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddIncrement) {
[[offset(0)]] data : [[stride(4)]] array<u32, 100>; [[offset(0)]] data : [[stride(4)]] array<u32, 100>;
}; };
[[set(0), binding(0)]] var<storage_buffer> buf : [[access(read_write)]] Buf; [[group(0), binding(0)]] var<storage_buffer> buf : [[access(read_write)]] Buf;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
@ -92,8 +92,8 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
[[offset(0)]] data : [[stride(4)]] array<u32, 100>; [[offset(0)]] data : [[stride(4)]] array<u32, 100>;
}; };
[[set(0), binding(0)]] var<storage_buffer> src : [[access(read_write)]] Src; [[group(0), binding(0)]] var<storage_buffer> src : [[access(read_write)]] Src;
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Dst; [[group(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Dst;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
@ -163,8 +163,8 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
[[offset(0)]] data : [[stride(4)]] array<u32, 100>; [[offset(0)]] data : [[stride(4)]] array<u32, 100>;
}; };
[[set(0), binding(0)]] var<storage_buffer> src : [[access(read)]] Src; [[group(0), binding(0)]] var<storage_buffer> src : [[access(read)]] Src;
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Dst; [[group(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Dst;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
@ -232,8 +232,8 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPong) {
[[offset(0)]] data : [[stride(16)]] array<vec4<u32>, 25>; [[offset(0)]] data : [[stride(16)]] array<vec4<u32>, 25>;
}; };
[[set(0), binding(0)]] var<uniform> src : Buf; [[group(0), binding(0)]] var<uniform> src : Buf;
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Buf; [[group(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Buf;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
@ -300,8 +300,8 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPongInOnePass) {
[[offset(0)]] data : [[stride(16)]] array<vec4<u32>, 25>; [[offset(0)]] data : [[stride(16)]] array<vec4<u32>, 25>;
}; };
[[set(0), binding(0)]] var<uniform> src : Buf; [[group(0), binding(0)]] var<uniform> src : Buf;
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Buf; [[group(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Buf;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {

View File

@ -38,7 +38,7 @@ TEST_P(CreateReadyPipelineTest, BasicUseOfCreateReadyComputePipeline) {
[[block]] struct SSBO { [[block]] struct SSBO {
[[offset(0)]] value : u32; [[offset(0)]] value : u32;
}; };
[[set(0), binding(0)]] var<storage_buffer> ssbo : SSBO; [[group(0), binding(0)]] var<storage_buffer> ssbo : SSBO;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
ssbo.value = 1u; ssbo.value = 1u;
@ -105,7 +105,7 @@ TEST_P(CreateReadyPipelineTest, CreateComputePipelineFailed) {
[[block]] struct SSBO { [[block]] struct SSBO {
[[offset(0)]] value : u32; [[offset(0)]] value : u32;
}; };
[[set(0), binding(0)]] var<storage_buffer> ssbo : SSBO; [[group(0), binding(0)]] var<storage_buffer> ssbo : SSBO;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
ssbo.value = 1u; ssbo.value = 1u;

View File

@ -229,7 +229,7 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPoints) {
[[block]] struct Data { [[block]] struct Data {
[[offset(0)]] data : u32; [[offset(0)]] data : u32;
}; };
[[binding(0), set(0)]] var<storage_buffer> data : Data; [[binding(0), group(0)]] var<storage_buffer> data : Data;
[[stage(compute)]] fn write1() -> void { [[stage(compute)]] fn write1() -> void {
data.data = 1u; data.data = 1u;

View File

@ -253,7 +253,7 @@ class DepthStencilCopyTests : public DawnTest {
// Sample the input texture and write out depth. |result| will only be set to 1 if we // Sample the input texture and write out depth. |result| will only be set to 1 if we
// pass the depth test. // pass the depth test.
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> texture0 : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> texture0 : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[location(0)]] var<out> result : u32; [[location(0)]] var<out> result : u32;

View File

@ -83,8 +83,9 @@ class DepthStencilSamplingTest : public DawnTest {
for (TestAspect aspect : aspects) { for (TestAspect aspect : aspects) {
switch (aspect) { switch (aspect) {
case TestAspect::Depth: case TestAspect::Depth:
shaderSource << "[[set(0), binding(" << index << ")]] var<uniform_constant> tex" shaderSource << "[[group(0), binding(" << index
<< index << " : texture_2d<f32>;\n"; << ")]] var<uniform_constant> tex" << index
<< " : texture_2d<f32>;\n";
shaderSource << "[[location(" << index << ")]] var<out> result" << index shaderSource << "[[location(" << index << ")]] var<out> result" << index
<< " : f32;\n"; << " : f32;\n";
@ -94,8 +95,9 @@ class DepthStencilSamplingTest : public DawnTest {
pipelineDescriptor.cColorStates[index].format = wgpu::TextureFormat::R32Float; pipelineDescriptor.cColorStates[index].format = wgpu::TextureFormat::R32Float;
break; break;
case TestAspect::Stencil: case TestAspect::Stencil:
shaderSource << "[[set(0), binding(" << index << ")]] var<uniform_constant> tex" shaderSource << "[[group(0), binding(" << index
<< index << " : texture_2d<u32>;\n"; << ")]] var<uniform_constant> tex" << index
<< " : texture_2d<u32>;\n";
shaderSource << "[[location(" << index << ")]] var<out> result" << index shaderSource << "[[location(" << index << ")]] var<out> result" << index
<< " : u32;\n"; << " : u32;\n";
@ -138,11 +140,11 @@ class DepthStencilSamplingTest : public DawnTest {
for (TestAspect aspect : aspects) { for (TestAspect aspect : aspects) {
switch (aspect) { switch (aspect) {
case TestAspect::Depth: case TestAspect::Depth:
shaderSource << "[[set(0), binding(" << 2 * index shaderSource << "[[group(0), binding(" << 2 * index
<< ")]] var<uniform_constant> tex" << index << ")]] var<uniform_constant> tex" << index
<< " : texture_2d<f32>;\n"; << " : texture_2d<f32>;\n";
shaderSource << "[[set(0), binding(" << 2 * index + 1 shaderSource << "[[group(0), binding(" << 2 * index + 1
<< ")]] var<storage_buffer> result" << index << ")]] var<storage_buffer> result" << index
<< " : DepthResult;\n"; << " : DepthResult;\n";
@ -150,11 +152,11 @@ class DepthStencilSamplingTest : public DawnTest {
<< ", vec2<i32>(0, 0), 0)[" << componentIndex << "];"; << ", vec2<i32>(0, 0), 0)[" << componentIndex << "];";
break; break;
case TestAspect::Stencil: case TestAspect::Stencil:
shaderSource << "[[set(0), binding(" << 2 * index shaderSource << "[[group(0), binding(" << 2 * index
<< ")]] var<uniform_constant> tex" << index << ")]] var<uniform_constant> tex" << index
<< " : texture_2d<u32>;\n"; << " : texture_2d<u32>;\n";
shaderSource << "[[set(0), binding(" << 2 * index + 1 shaderSource << "[[group(0), binding(" << 2 * index + 1
<< ")]] var<storage_buffer> result" << index << ")]] var<storage_buffer> result" << index
<< " : StencilResult;\n"; << " : StencilResult;\n";
@ -186,12 +188,12 @@ class DepthStencilSamplingTest : public DawnTest {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> samp : sampler_comparison; [[group(0), binding(0)]] var<uniform_constant> samp : sampler_comparison;
[[set(0), binding(1)]] var<uniform_constant> tex : texture_depth_2d; [[group(0), binding(1)]] var<uniform_constant> tex : texture_depth_2d;
[[block]] struct Uniforms { [[block]] struct Uniforms {
[[offset(0)]] compareRef : f32; [[offset(0)]] compareRef : f32;
}; };
[[set(0), binding(2)]] var<uniform> uniforms : Uniforms; [[group(0), binding(2)]] var<uniform> uniforms : Uniforms;
[[location(0)]] var<out> samplerResult : f32; [[location(0)]] var<out> samplerResult : f32;
@ -218,17 +220,17 @@ class DepthStencilSamplingTest : public DawnTest {
wgpu::ComputePipeline CreateComparisonComputePipeline() { wgpu::ComputePipeline CreateComparisonComputePipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> samp : sampler_comparison; [[group(0), binding(0)]] var<uniform_constant> samp : sampler_comparison;
[[set(0), binding(1)]] var<uniform_constant> tex : texture_depth_2d; [[group(0), binding(1)]] var<uniform_constant> tex : texture_depth_2d;
[[block]] struct Uniforms { [[block]] struct Uniforms {
[[offset(0)]] compareRef : f32; [[offset(0)]] compareRef : f32;
}; };
[[set(0), binding(2)]] var<uniform> uniforms : Uniforms; [[group(0), binding(2)]] var<uniform> uniforms : Uniforms;
[[block]] struct SamplerResult { [[block]] struct SamplerResult {
[[offset(0)]] value : f32; [[offset(0)]] value : f32;
}; };
[[set(0), binding(3)]] var<storage_buffer> samplerResult : SamplerResult; [[group(0), binding(3)]] var<storage_buffer> samplerResult : SamplerResult;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
samplerResult.value = textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef); samplerResult.value = textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef);

View File

@ -57,7 +57,7 @@ class DepthStencilStateTest : public DawnTest {
[[offset(0)]] color : vec3<f32>; [[offset(0)]] color : vec3<f32>;
[[offset(12)]] depth : f32; [[offset(12)]] depth : f32;
}; };
[[set(0), binding(0)]] var<uniform> ubo : UBO; [[group(0), binding(0)]] var<uniform> ubo : UBO;
[[builtin(vertex_idx)]] var<in> VertexIndex : u32; [[builtin(vertex_idx)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
@ -77,7 +77,7 @@ class DepthStencilStateTest : public DawnTest {
[[offset(0)]] color : vec3<f32>; [[offset(0)]] color : vec3<f32>;
[[offset(12)]] depth : f32; [[offset(12)]] depth : f32;
}; };
[[set(0), binding(0)]] var<uniform> ubo : UBO; [[group(0), binding(0)]] var<uniform> ubo : UBO;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;

View File

@ -116,7 +116,7 @@ TEST_P(DeviceLostTest, GetBindGroupLayoutFails) {
[[block]] struct UniformBuffer { [[block]] struct UniformBuffer {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> ubo : UniformBuffer; [[group(0), binding(0)]] var<uniform> ubo : UniformBuffer;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
})"); })");

View File

@ -125,10 +125,10 @@ class DynamicBufferOffsetTests : public DawnTest {
[[offset(0)]] value : vec2<u32>; [[offset(0)]] value : vec2<u32>;
}; };
[[set(0), binding(0)]] var<uniform> uBufferNotDynamic : Buffer1; [[group(0), binding(0)]] var<uniform> uBufferNotDynamic : Buffer1;
[[set(0), binding(1)]] var<storage_buffer> sBufferNotDynamic : [[access(read_write)]] Buffer2; [[group(0), binding(1)]] var<storage_buffer> sBufferNotDynamic : [[access(read_write)]] Buffer2;
[[set(0), binding(3)]] var<uniform> uBuffer : Buffer3; [[group(0), binding(3)]] var<uniform> uBuffer : Buffer3;
[[set(0), binding(4)]] var<storage_buffer> sBuffer : [[access(read_write)]] Buffer4; [[group(0), binding(4)]] var<storage_buffer> sBuffer : [[access(read_write)]] Buffer4;
)"; )";
if (isInheritedPipeline) { if (isInheritedPipeline) {
@ -137,7 +137,7 @@ class DynamicBufferOffsetTests : public DawnTest {
[[offset(0)]] value : vec2<u32>; [[offset(0)]] value : vec2<u32>;
}; };
[[set(1), binding(0)]] var<uniform> paddingBlock : Buffer5; [[group(1), binding(0)]] var<uniform> paddingBlock : Buffer5;
)"; )";
} }
@ -194,10 +194,10 @@ class DynamicBufferOffsetTests : public DawnTest {
[[offset(0)]] value : vec2<u32>; [[offset(0)]] value : vec2<u32>;
}; };
[[set(0), binding(0)]] var<uniform> uBufferNotDynamic : Buffer1; [[group(0), binding(0)]] var<uniform> uBufferNotDynamic : Buffer1;
[[set(0), binding(1)]] var<storage_buffer> sBufferNotDynamic : [[access(read_write)]] Buffer2; [[group(0), binding(1)]] var<storage_buffer> sBufferNotDynamic : [[access(read_write)]] Buffer2;
[[set(0), binding(3)]] var<uniform> uBuffer : Buffer3; [[group(0), binding(3)]] var<uniform> uBuffer : Buffer3;
[[set(0), binding(4)]] var<storage_buffer> sBuffer : [[access(read_write)]] Buffer4; [[group(0), binding(4)]] var<storage_buffer> sBuffer : [[access(read_write)]] Buffer4;
)"; )";
if (isInheritedPipeline) { if (isInheritedPipeline) {
@ -206,7 +206,7 @@ class DynamicBufferOffsetTests : public DawnTest {
[[offset(0)]] value : vec2<u32>; [[offset(0)]] value : vec2<u32>;
}; };
[[set(1), binding(0)]] var<uniform> paddingBlock : Buffer5; [[group(1), binding(0)]] var<uniform> paddingBlock : Buffer5;
)"; )";
} }

View File

@ -78,7 +78,7 @@ TEST_P(EntryPointTests, TwoComputeInModule) {
[[block]] struct Data { [[block]] struct Data {
[[offset(0)]] data : u32; [[offset(0)]] data : u32;
}; };
[[binding(0), set(0)]] var<storage_buffer> data : Data; [[binding(0), group(0)]] var<storage_buffer> data : Data;
[[stage(compute)]] fn write1() -> void { [[stage(compute)]] fn write1() -> void {
data.data = 1u; data.data = 1u;

View File

@ -46,7 +46,7 @@ class GpuMemorySyncTests : public DawnTest {
[[block]] struct Data { [[block]] struct Data {
[[offset(0)]] a : i32; [[offset(0)]] a : i32;
}; };
[[set(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data; [[group(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
data.a = data.a + 1; data.a = data.a + 1;
})"); })");
@ -74,7 +74,7 @@ class GpuMemorySyncTests : public DawnTest {
[[block]] struct Data { [[block]] struct Data {
[[offset(0)]] i : i32; [[offset(0)]] i : i32;
}; };
[[set(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data; [[group(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
data.i = data.i + 1; data.i = data.i + 1;
@ -262,7 +262,7 @@ class StorageToUniformSyncTests : public DawnTest {
[[block]] struct Data { [[block]] struct Data {
[[offset(0)]] a : f32; [[offset(0)]] a : f32;
}; };
[[set(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data; [[group(0), binding(0)]] var<storage_buffer> data : [[access(read_write)]] Data;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
data.a = 1.0; data.a = 1.0;
})"); })");
@ -289,7 +289,7 @@ class StorageToUniformSyncTests : public DawnTest {
[[block]] struct Contents { [[block]] struct Contents {
[[offset(0)]] color : f32; [[offset(0)]] color : f32;
}; };
[[set(0), binding(0)]] var<uniform> contents : Contents; [[group(0), binding(0)]] var<uniform> contents : Contents;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
@ -461,12 +461,12 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
[[block]] struct VBContents { [[block]] struct VBContents {
[[offset(0)]] pos : [[stride(16)]] array<vec4<f32>, 4>; [[offset(0)]] pos : [[stride(16)]] array<vec4<f32>, 4>;
}; };
[[set(0), binding(0)]] var<storage_buffer> vbContents : [[access(read_write)]] VBContents; [[group(0), binding(0)]] var<storage_buffer> vbContents : [[access(read_write)]] VBContents;
[[block]] struct IBContents { [[block]] struct IBContents {
[[offset(0)]] indices : [[stride(16)]] array<vec4<i32>, 2>; [[offset(0)]] indices : [[stride(16)]] array<vec4<i32>, 2>;
}; };
[[set(0), binding(1)]] var<storage_buffer> ibContents : [[access(read_write)]] IBContents; [[group(0), binding(1)]] var<storage_buffer> ibContents : [[access(read_write)]] IBContents;
// TODO(crbug.com/tint/386): Use the same struct. // TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct ColorContents1 { [[block]] struct ColorContents1 {
@ -475,8 +475,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
[[block]] struct ColorContents2 { [[block]] struct ColorContents2 {
[[offset(0)]] color : f32; [[offset(0)]] color : f32;
}; };
[[set(0), binding(2)]] var<storage_buffer> uniformContents : [[access(read_write)]] ColorContents1; [[group(0), binding(2)]] var<storage_buffer> uniformContents : [[access(read_write)]] ColorContents1;
[[set(0), binding(3)]] var<storage_buffer> storageContents : [[access(read_write)]] ColorContents2; [[group(0), binding(3)]] var<storage_buffer> storageContents : [[access(read_write)]] ColorContents2;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
vbContents.pos[0] = vec4<f32>(-1.0, 1.0, 0.0, 1.0); vbContents.pos[0] = vec4<f32>(-1.0, 1.0, 0.0, 1.0);
@ -530,8 +530,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
[[offset(0)]] color : f32; [[offset(0)]] color : f32;
}; };
[[set(0), binding(0)]] var<uniform> uniformBuffer : Buf; [[group(0), binding(0)]] var<uniform> uniformBuffer : Buf;
[[set(0), binding(1)]] var<storage_buffer> storageBuffer : [[access(read)]] Buf; [[group(0), binding(1)]] var<storage_buffer> storageBuffer : [[access(read)]] Buf;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
@ -588,7 +588,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
[[offset(768)]] color1 : f32; [[offset(768)]] color1 : f32;
}; };
[[set(0), binding(0)]] var<storage_buffer> contents : [[access(read_write)]] Contents; [[group(0), binding(0)]] var<storage_buffer> contents : [[access(read_write)]] Contents;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
contents.pos[0] = vec4<f32>(-1.0, 1.0, 0.0, 1.0); contents.pos[0] = vec4<f32>(-1.0, 1.0, 0.0, 1.0);
@ -642,8 +642,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
[[block]] struct Buf { [[block]] struct Buf {
[[offset(0)]] color : f32; [[offset(0)]] color : f32;
}; };
[[set(0), binding(0)]] var<uniform> uniformBuffer : Buf; [[group(0), binding(0)]] var<uniform> uniformBuffer : Buf;
[[set(0), binding(1)]] var<storage_buffer> storageBuffer : [[access(read)]] Buf; [[group(0), binding(1)]] var<storage_buffer> storageBuffer : [[access(read)]] Buf;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {

View File

@ -274,8 +274,8 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
} }
)"); )");
wgpu::ShaderModule fs = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fs = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> sampler0 : sampler; [[group(0), binding(0)]] var<uniform_constant> sampler0 : sampler;
[[set(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>; [[group(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>;
[[location(0)]] var<in> texCoord : vec2<f32>; [[location(0)]] var<in> texCoord : vec2<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;

View File

@ -90,14 +90,14 @@ class MultisampledSamplingTest : public DawnTest {
wgpu::ComputePipelineDescriptor desc = {}; wgpu::ComputePipelineDescriptor desc = {};
desc.computeStage.entryPoint = "main"; desc.computeStage.entryPoint = "main";
desc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> texture0 : texture_multisampled_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> texture0 : texture_multisampled_2d<f32>;
[[set(0), binding(1)]] var<uniform_constant> texture1 : texture_multisampled_2d<f32>; [[group(0), binding(1)]] var<uniform_constant> texture1 : texture_multisampled_2d<f32>;
[[block]] struct Results { [[block]] struct Results {
[[offset(0)]] colorSamples : [[stride(4)]] array<f32, 4>; [[offset(0)]] colorSamples : [[stride(4)]] array<f32, 4>;
[[offset(16)]] depthSamples : [[stride(4)]] array<f32, 4>; [[offset(16)]] depthSamples : [[stride(4)]] array<f32, 4>;
}; };
[[set(0), binding(2)]] var<storage_buffer> results : [[access(read_write)]] Results; [[group(0), binding(2)]] var<storage_buffer> results : [[access(read_write)]] Results;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
for (var i : i32 = 0; i < 4; i = i + 1) { for (var i : i32 = 0; i < 4; i = i + 1) {

View File

@ -66,10 +66,10 @@ class OpArrayLengthTest : public DawnTest {
}; };
// The length should be 1 because the buffer is 4-byte long. // The length should be 1 because the buffer is 4-byte long.
[[set(0), binding(0)]] var<storage_buffer> buffer1 : [[access(read)]] DataBuffer1; [[group(0), binding(0)]] var<storage_buffer> buffer1 : [[access(read)]] DataBuffer1;
// The length should be 64 because the buffer is 256 bytes long. // The length should be 64 because the buffer is 256 bytes long.
[[set(0), binding(1)]] var<storage_buffer> buffer2 : [[access(read)]] DataBuffer2; [[group(0), binding(1)]] var<storage_buffer> buffer2 : [[access(read)]] DataBuffer2;
// 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.
@ -82,7 +82,7 @@ class OpArrayLengthTest : public DawnTest {
[[offset(0)]] garbage : mat4x4<f32>; [[offset(0)]] garbage : mat4x4<f32>;
[[offset(64)]] data : [[stride(8)]] array<Buffer3Data>; [[offset(64)]] data : [[stride(8)]] array<Buffer3Data>;
}; };
[[set(0), binding(2)]] var<storage_buffer> buffer3 : [[access(read)]] Buffer3; [[group(0), binding(2)]] var<storage_buffer> buffer3 : [[access(read)]] Buffer3;
)"; )";
// See comments in the shader for an explanation of these values // See comments in the shader for an explanation of these values
@ -132,7 +132,7 @@ TEST_P(OpArrayLengthTest, Compute) {
[[block]] struct ResultBuffer { [[block]] struct ResultBuffer {
[[offset(0)]] data : [[stride(4)]] array<u32, 3>; [[offset(0)]] data : [[stride(4)]] array<u32, 3>;
}; };
[[set(1), binding(0)]] var<storage_buffer> result : [[access(read_write)]] ResultBuffer; [[group(1), binding(0)]] var<storage_buffer> result : [[access(read_write)]] ResultBuffer;
)" + mShaderInterface + R"( )" + mShaderInterface + R"(
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
result.data[0] = arrayLength(buffer1.data); result.data[0] = arrayLength(buffer1.data);

View File

@ -43,7 +43,7 @@ class RenderBundleTest : public DawnTest {
[[block]] struct Ubo { [[block]] struct Ubo {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> fragmentUniformBuffer : Ubo; [[group(0), binding(0)]] var<uniform> fragmentUniformBuffer : Ubo;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
fragColor = fragmentUniformBuffer.color; fragColor = fragmentUniformBuffer.color;

View File

@ -45,7 +45,7 @@ class SamplerFilterAnisotropicTest : public DawnTest {
[[location(0)]] var<in> position : vec4<f32>; [[location(0)]] var<in> position : vec4<f32>;
[[location(1)]] var<in> uv : vec2<f32>; [[location(1)]] var<in> uv : vec2<f32>;
[[set(0), binding(2)]] var<uniform> uniforms : Uniforms; [[group(0), binding(2)]] var<uniform> uniforms : Uniforms;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[location(0)]] var<out> fragUV : vec2<f32>; [[location(0)]] var<out> fragUV : vec2<f32>;
@ -56,8 +56,8 @@ class SamplerFilterAnisotropicTest : public DawnTest {
} }
)"); )");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> sampler0 : sampler; [[group(0), binding(0)]] var<uniform_constant> sampler0 : sampler;
[[set(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>; [[group(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;

View File

@ -70,8 +70,8 @@ class SamplerTest : public DawnTest {
} }
)"); )");
auto fsModule = utils::CreateShaderModuleFromWGSL(device, R"( auto fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> sampler0 : sampler; [[group(0), binding(0)]] var<uniform_constant> sampler0 : sampler;
[[set(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>; [[group(0), binding(1)]] var<uniform_constant> texture0 : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;

View File

@ -165,7 +165,7 @@ class StorageTextureTests : public DawnTest {
bool is2DArray, bool is2DArray,
uint32_t binding) { uint32_t binding) {
std::ostringstream ostream; std::ostringstream ostream;
ostream << "[[set(0), binding(" << binding << ")]] " ostream << "[[group(0), binding(" << binding << ")]] "
<< "var<uniform_constant> storageImage" << binding << " : " << "var<uniform_constant> storageImage" << binding << " : "
<< "[[access(" << accessQualifier << ")]] " << "[[access(" << accessQualifier << ")]] "
<< "texture_storage_2d"; << "texture_storage_2d";
@ -712,7 +712,7 @@ TEST_P(StorageTextureTests, ReadonlyStorageTextureInComputeShader) {
[[offset(0)]] result : u32; [[offset(0)]] result : u32;
}; };
[[set(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer; [[group(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer;
)" << CommonReadOnlyTestCode(format) )" << CommonReadOnlyTestCode(format)
<< R"( << R"(
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
@ -917,7 +917,7 @@ TEST_P(StorageTextureTests, Readonly2DArrayStorageTexture) {
[[offset(0)]] result : u32; [[offset(0)]] result : u32;
}; };
[[set(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer; [[group(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer;
)" << CommonReadOnlyTestCode(kTextureFormat, true) )" << CommonReadOnlyTestCode(kTextureFormat, true)
<< R"( << R"(
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
@ -964,8 +964,8 @@ TEST_P(StorageTextureTests, ReadonlyAndWriteonlyStorageTexturePingPong) {
kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, 1u, 1u); kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, 1u, 1u);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> Src : [[access(read)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var<uniform_constant> Src : [[access(read)]] texture_storage_2d<r32uint>;
[[set(0), binding(1)]] var<uniform_constant> Dst : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(1)]] var<uniform_constant> Dst : [[access(write)]] texture_storage_2d<r32uint>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0)); var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0));
srcValue.x = srcValue.x + 1u; srcValue.x = srcValue.x + 1u;
@ -1040,8 +1040,8 @@ TEST_P(StorageTextureTests, SampledAndWriteonlyStorageTexturePingPong) {
wgpu::Texture storageTexture2 = CreateTexture( wgpu::Texture storageTexture2 = CreateTexture(
kTextureFormat, wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Storage, 1u, 1u); kTextureFormat, wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Storage, 1u, 1u);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> Src : texture_2d<u32>; [[group(0), binding(0)]] var<uniform_constant> Src : texture_2d<u32>;
[[set(0), binding(1)]] var<uniform_constant> Dst : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(1)]] var<uniform_constant> Dst : [[access(write)]] texture_storage_2d<r32uint>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0)); var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0));
srcValue.x = srcValue.x + 1u; srcValue.x = srcValue.x + 1u;
@ -1139,13 +1139,13 @@ fn doTest() -> bool {
})"; })";
const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"( const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"(
[[set(0), binding(0)]] var<uniform_constant> dstImage : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var<uniform_constant> dstImage : [[access(write)]] texture_storage_2d<r32uint>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u)); textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
})"; })";
const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"( const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"(
[[set(0), binding(0)]] var<uniform_constant> dstImage : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var<uniform_constant> dstImage : [[access(write)]] texture_storage_2d<r32uint>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u)); textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
@ -1162,7 +1162,7 @@ TEST_P(StorageTextureZeroInitTests, ReadonlyStorageTextureClearsToZeroInRenderPa
// green as the output color, otherwise uses red instead. // green as the output color, otherwise uses red instead.
const char* kVertexShader = kSimpleVertexShader; const char* kVertexShader = kSimpleVertexShader;
const std::string kFragmentShader = std::string(R"( const std::string kFragmentShader = std::string(R"(
[[set(0), binding(0)]] var<uniform_constant> srcImage : [[access(read)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var<uniform_constant> srcImage : [[access(read)]] texture_storage_2d<r32uint>;
[[location(0)]] var<out> o_color : vec4<f32>; [[location(0)]] var<out> o_color : vec4<f32>;
)") + kCommonReadOnlyZeroInitTestCode + )") + kCommonReadOnlyZeroInitTestCode +
R"( R"(
@ -1189,8 +1189,8 @@ TEST_P(StorageTextureZeroInitTests, ReadonlyStorageTextureClearsToZeroInComputeP
[[offset(0)]] result : u32; [[offset(0)]] result : u32;
}; };
[[set(0), binding(0)]] var<uniform_constant> srcImage : [[access(read)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var<uniform_constant> srcImage : [[access(read)]] texture_storage_2d<r32uint>;
[[set(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer; [[group(0), binding(1)]] var<storage_buffer> dstBuffer : DstBuffer;
)") + kCommonReadOnlyZeroInitTestCode + R"( )") + kCommonReadOnlyZeroInitTestCode + R"(
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
if (doTest()) { if (doTest()) {

View File

@ -163,7 +163,7 @@ class TextureFormatTest : public DawnTest {
const char* type = utils::GetColorTextureComponentWGSLType(sampleFormatInfo.format); const char* type = utils::GetColorTextureComponentWGSLType(sampleFormatInfo.format);
std::ostringstream fsSource; std::ostringstream fsSource;
fsSource << "[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<" << type fsSource << "[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<" << type
<< ">;\n"; << ">;\n";
fsSource << "[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;\n"; fsSource << "[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;\n";
fsSource << "[[location(0)]] var<out> fragColor : vec4<" << type << ">;\n"; fsSource << "[[location(0)]] var<out> fragColor : vec4<" << type << ">;\n";

View File

@ -106,8 +106,8 @@ class TextureSubresourceTest : public DawnTest {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> samp : sampler; [[group(0), binding(0)]] var<uniform_constant> samp : sampler;
[[set(0), binding(1)]] var<uniform_constant> tex : texture_2d<f32>; [[group(0), binding(1)]] var<uniform_constant> tex : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;

View File

@ -78,7 +78,7 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams<SubresourceTrackin
)"); )");
pipelineDesc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>; [[location(0)]] var<out> FragColor : vec4<f32>;
[[set(0), binding(0)]] var<uniform_constant> materials : texture_sampled_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> materials : texture_sampled_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
FragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0); FragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }

View File

@ -1094,10 +1094,10 @@ class SetBindGroupValidationTest : public ValidationTest {
[[offset(0)]] value : vec2<f32>; [[offset(0)]] value : vec2<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uBufferDynamic : S; [[group(0), binding(0)]] var<uniform> uBufferDynamic : S;
[[set(0), binding(1)]] var<uniform> uBuffer : S; [[group(0), binding(1)]] var<uniform> uBuffer : S;
[[set(0), binding(2)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S; [[group(0), binding(2)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S;
[[set(0), binding(3)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S; [[group(0), binding(3)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -1117,10 +1117,10 @@ class SetBindGroupValidationTest : public ValidationTest {
[[offset(0)]] value : vec2<f32>; [[offset(0)]] value : vec2<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uBufferDynamic : S; [[group(0), binding(0)]] var<uniform> uBufferDynamic : S;
[[set(0), binding(1)]] var<uniform> uBuffer : S; [[group(0), binding(1)]] var<uniform> uBuffer : S;
[[set(0), binding(2)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S; [[group(0), binding(2)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S;
[[set(0), binding(3)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S; [[group(0), binding(3)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S;
[[stage(compute), workgroup_size(4, 4, 1)]] fn main() -> void { [[stage(compute), workgroup_size(4, 4, 1)]] fn main() -> void {
})"); })");
@ -1542,7 +1542,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
for (uint32_t b = 0; b < layout.size(); ++b) { for (uint32_t b = 0; b < layout.size(); ++b) {
wgpu::BufferBindingType binding = layout[b]; wgpu::BufferBindingType binding = layout[b];
ss << "[[set(" << l << "), binding(" << b << ")]] "; ss << "[[group(" << l << "), binding(" << b << ")]] ";
switch (binding) { switch (binding) {
case wgpu::BufferBindingType::Storage: case wgpu::BufferBindingType::Storage:
ss << "var<storage_buffer> set" << l << "_binding" << b ss << "var<storage_buffer> set" << l << "_binding" << b
@ -1713,8 +1713,8 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
[[offset(0)]] value : vec2<f32>; [[offset(0)]] value : vec2<f32>;
}; };
[[set(0), binding(0)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S; [[group(0), binding(0)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S;
[[set(1), binding(0)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S; [[group(1), binding(0)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})", })",
@ -1746,8 +1746,8 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
[[offset(0)]] value : vec2<f32>; [[offset(0)]] value : vec2<f32>;
}; };
[[set(0), binding(0)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S; [[group(0), binding(0)]] var<storage_buffer> sBufferDynamic : [[access(read_write)]] S;
[[set(1), binding(0)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S; [[group(1), binding(0)]] var<storage_buffer> sReadonlyBufferDynamic : [[access(read)]] S;
[[stage(compute), workgroup_size(4, 4, 1)]] fn main() -> void { [[stage(compute), workgroup_size(4, 4, 1)]] fn main() -> void {
})", })",
@ -1789,11 +1789,11 @@ TEST_F(BindGroupLayoutCompatibilityTest, ROStorageInBGLWithRWStorageInShader) {
TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) { TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
constexpr char kTexture2DShaderFS[] = R"( constexpr char kTexture2DShaderFS[] = R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"; })";
constexpr char kTexture2DShaderCS[] = R"( constexpr char kTexture2DShaderCS[] = R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
})"; })";
@ -1826,11 +1826,11 @@ TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
wgpu::TextureViewDimension::e2DArray}})})); wgpu::TextureViewDimension::e2DArray}})}));
constexpr char kTexture2DArrayShaderFS[] = R"( constexpr char kTexture2DArrayShaderFS[] = R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"; })";
constexpr char kTexture2DArrayShaderCS[] = R"( constexpr char kTexture2DArrayShaderCS[] = R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
})"; })";
@ -2079,7 +2079,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
} }
@ -2090,7 +2090,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
} }
@ -2101,7 +2101,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})")); })"));
} }
@ -2112,7 +2112,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})")); })"));
} }

View File

@ -42,8 +42,8 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniform0 : S; [[group(0), binding(0)]] var<uniform> uniform0 : S;
[[set(1), binding(0)]] var<uniform> uniform1 : S; [[group(1), binding(0)]] var<uniform> uniform1 : S;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
@ -52,12 +52,12 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
[[block]] struct S2 { [[block]] struct S2 {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(2), binding(0)]] var<uniform> uniform2 : S2; [[group(2), binding(0)]] var<uniform> uniform2 : S2;
[[block]] struct S3 { [[block]] struct S3 {
[[offset(0)]] pos : mat4x4<f32>; [[offset(0)]] pos : mat4x4<f32>;
}; };
[[set(3), binding(0)]] var<storage_buffer> storage3 : S3; [[group(3), binding(0)]] var<storage_buffer> storage3 : S3;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -90,7 +90,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -128,7 +128,7 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
})"); })");
@ -174,7 +174,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<storage_buffer> ssbo : S; [[group(0), binding(0)]] var<storage_buffer> ssbo : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -186,7 +186,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -199,7 +199,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<storage_buffer> ssbo : [[access(read)]] S; [[group(0), binding(0)]] var<storage_buffer> ssbo : [[access(read)]] S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -211,7 +211,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{ {
binding.texture.sampleType = wgpu::TextureSampleType::Float; binding.texture.sampleType = wgpu::TextureSampleType::Float;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -221,7 +221,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{ {
binding.texture.multisampled = true; binding.texture.multisampled = true;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -232,7 +232,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{ {
binding.sampler.type = wgpu::SamplerBindingType::Filtering; binding.sampler.type = wgpu::SamplerBindingType::Filtering;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -254,7 +254,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{ {
binding.texture.viewDimension = wgpu::TextureViewDimension::e1D; binding.texture.viewDimension = wgpu::TextureViewDimension::e1D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_1d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_1d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -264,7 +264,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{ {
binding.texture.viewDimension = wgpu::TextureViewDimension::e2D; binding.texture.viewDimension = wgpu::TextureViewDimension::e2D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -274,7 +274,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{ {
binding.texture.viewDimension = wgpu::TextureViewDimension::e2DArray; binding.texture.viewDimension = wgpu::TextureViewDimension::e2DArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -284,7 +284,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{ {
binding.texture.viewDimension = wgpu::TextureViewDimension::e3D; binding.texture.viewDimension = wgpu::TextureViewDimension::e3D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_3d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_3d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -294,7 +294,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{ {
binding.texture.viewDimension = wgpu::TextureViewDimension::Cube; binding.texture.viewDimension = wgpu::TextureViewDimension::Cube;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_cube<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_cube<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -304,7 +304,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{ {
binding.texture.viewDimension = wgpu::TextureViewDimension::CubeArray; binding.texture.viewDimension = wgpu::TextureViewDimension::CubeArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_cube_array<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_cube_array<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -325,7 +325,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{ {
binding.texture.sampleType = wgpu::TextureSampleType::Float; binding.texture.sampleType = wgpu::TextureSampleType::Float;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -335,7 +335,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{ {
binding.texture.sampleType = wgpu::TextureSampleType::Sint; binding.texture.sampleType = wgpu::TextureSampleType::Sint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<i32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<i32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -345,7 +345,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{ {
binding.texture.sampleType = wgpu::TextureSampleType::Uint; binding.texture.sampleType = wgpu::TextureSampleType::Uint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<u32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<u32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -371,7 +371,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -384,7 +384,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(1)]] var<uniform> uniforms : S; [[group(0), binding(1)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -397,7 +397,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(1)]] var<uniform> uniforms : S; [[group(0), binding(1)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -411,8 +411,8 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniform0 : S; [[group(0), binding(0)]] var<uniform> uniform0 : S;
[[set(1), binding(0)]] var<uniform> uniform1 : S; [[group(1), binding(0)]] var<uniform> uniform1 : S;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
@ -421,7 +421,7 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(1), binding(0)]] var<uniform> uniforms : S; [[group(1), binding(0)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -440,7 +440,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : f32; [[offset(0)]] pos : f32;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
@ -449,7 +449,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : mat4x4<f32>; [[offset(0)]] pos : mat4x4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
@ -458,7 +458,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : f32; [[offset(0)]] pos : f32;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -467,7 +467,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : mat4x4<f32>; [[offset(0)]] pos : mat4x4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -522,7 +522,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
})"); })");
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
@ -531,7 +531,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
})"); })");
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -584,7 +584,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> ubo : S; [[group(0), binding(0)]] var<uniform> ubo : S;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
@ -593,7 +593,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<storage_buffer> ssbo : S; [[group(0), binding(0)]] var<storage_buffer> ssbo : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -609,13 +609,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
// Test it is invalid to have conflicting binding texture multisampling in the shaders. // Test it is invalid to have conflicting binding texture multisampling in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) { TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -631,13 +631,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
// Test it is invalid to have conflicting binding texture dimension in the shaders. // Test it is invalid to have conflicting binding texture dimension in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) { TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_3d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_3d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -653,13 +653,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
// Test it is invalid to have conflicting binding texture component type in the shaders. // Test it is invalid to have conflicting binding texture component type in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) { TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<i32>; [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<i32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -691,8 +691,8 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms0 : S; [[group(0), binding(0)]] var<uniform> uniforms0 : S;
[[set(2), binding(0)]] var<uniform> uniforms2 : S; [[group(2), binding(0)]] var<uniform> uniforms2 : S;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
@ -733,7 +733,7 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] pos : vec4<f32>; [[offset(0)]] pos : vec4<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");

View File

@ -33,7 +33,7 @@ namespace {
[[block]] struct S { [[block]] struct S {
[[offset(0)]] transform : mat2x2<f32>; [[offset(0)]] transform : mat2x2<f32>;
}; };
[[set(0), binding(0)]] var<uniform> uniforms : S; [[group(0), binding(0)]] var<uniform> uniforms : S;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
})"); })");
@ -42,12 +42,12 @@ namespace {
[[block]] struct Uniforms { [[block]] struct Uniforms {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
[[set(1), binding(0)]] var<uniform> uniforms : Uniforms; [[group(1), binding(0)]] var<uniform> uniforms : Uniforms;
[[block]] struct Storage { [[block]] struct Storage {
[[offset(0)]] dummy : [[stride(4)]] array<f32>; [[offset(0)]] dummy : [[stride(4)]] array<f32>;
}; };
[[set(1), binding(1)]] var<storage_buffer> ssbo : [[access(read_write)]] Storage; [[group(1), binding(1)]] var<storage_buffer> ssbo : [[access(read_write)]] Storage;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");

View File

@ -397,7 +397,7 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
std::ostringstream stream; std::ostringstream stream;
stream << R"( stream << R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<)" [[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<)"
<< kScalarTypes[i] << R"(>; << kScalarTypes[i] << R"(>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
@ -446,7 +446,7 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
std::ostringstream stream; std::ostringstream stream;
stream << R"( stream << R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : )" [[group(0), binding(0)]] var<uniform_constant> myTexture : )"
<< kTextureKeywords[i] << R"(<f32>; << kTextureKeywords[i] << R"(<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"; })";
@ -474,7 +474,7 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
[[block]] struct Dst { [[block]] struct Dst {
[[offset(0)]] data : [[stride(4)]] array<u32, 100>; [[offset(0)]] data : [[stride(4)]] array<u32, 100>;
}; };
[[set(0), binding(0)]] var<storage_buffer> dst : [[access(read_write)]] Dst; [[group(0), binding(0)]] var<storage_buffer> dst : [[access(read_write)]] Dst;
[[builtin(vertex_idx)]] var<in> VertexIndex : u32; [[builtin(vertex_idx)]] var<in> VertexIndex : u32;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
dst.data[VertexIndex] = 0x1234u; dst.data[VertexIndex] = 0x1234u;

View File

@ -779,7 +779,7 @@ namespace {
[[block]] struct RBuffer { [[block]] struct RBuffer {
[[offset(0)]] value : f32; [[offset(0)]] value : f32;
}; };
[[set(0), binding(0)]] var<storage_buffer> rBuffer : [[access(read)]] RBuffer; [[group(0), binding(0)]] var<storage_buffer> rBuffer : [[access(read)]] RBuffer;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
@ -819,7 +819,7 @@ namespace {
[[block]] struct RBuffer { [[block]] struct RBuffer {
[[offset(0)]] value : f32; [[offset(0)]] value : f32;
}; };
[[set(0), binding(0)]] var<storage_buffer> rBuffer : [[access(read)]] RBuffer; [[group(0), binding(0)]] var<storage_buffer> rBuffer : [[access(read)]] RBuffer;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
})"); })");
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
@ -1554,7 +1554,7 @@ namespace {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> tex : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var<uniform_constant> tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
@ -1580,7 +1580,7 @@ namespace {
{ {
// Create a passthrough compute pipeline with a readonly storage texture // Create a passthrough compute pipeline with a readonly storage texture
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> tex : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var<uniform_constant> tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
})"); })");
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;

View File

@ -125,7 +125,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Readonly storage texture can be declared in a vertex shader. // Readonly storage texture can be declared in a vertex shader.
{ {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(vertex_idx)]] var<in> VertexIndex : u32; [[builtin(vertex_idx)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
@ -142,7 +142,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Read-only storage textures can be declared in a fragment shader. // Read-only storage textures can be declared in a fragment shader.
{ {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
@ -197,13 +197,13 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Read-only storage textures can be declared in a compute shader. // Read-only storage textures can be declared in a compute shader.
{ {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(local_invocation_id)]] var<in> LocalInvocationID : vec3<u32>; [[builtin(local_invocation_id)]] var<in> LocalInvocationID : vec3<u32>;
[[block]] struct Buf { [[block]] struct Buf {
[[offset(0)]] data : f32; [[offset(0)]] data : f32;
}; };
[[set(0), binding(1)]] var<storage_buffer> buf : [[access(read_write)]] Buf; [[group(0), binding(1)]] var<storage_buffer> buf : [[access(read_write)]] Buf;
[[stage(compute)]] fn main() -> void { [[stage(compute)]] fn main() -> void {
buf.data = textureLoad(image0, vec2<i32>(LocalInvocationID.xy)).x; buf.data = textureLoad(image0, vec2<i32>(LocalInvocationID.xy)).x;