wgsl: Replace use of [[attribute]] with @attribute

Bug: tint:1382
Change-Id: I58ad2c88fde1e7c96f2ae8257e6df924b94b61db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77660
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-01-25 16:29:04 +00:00
committed by Dawn LUCI CQ
parent facbc82d6c
commit a9ca8cb4ab
101 changed files with 1307 additions and 1312 deletions

View File

@@ -1415,7 +1415,7 @@ class SetBindGroupValidationTest : public ValidationTest {
wgpu::RenderPipeline CreateRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
@@ -1424,12 +1424,12 @@ class SetBindGroupValidationTest : public ValidationTest {
value : vec2<f32>;
};
[[group(0), binding(0)]] var<uniform> uBufferDynamic : S;
[[group(0), binding(1)]] var<uniform> uBuffer : S;
[[group(0), binding(2)]] var<storage, read_write> sBufferDynamic : S;
[[group(0), binding(3)]] var<storage, read> sReadonlyBufferDynamic : S;
@group(0) @binding(0) var<uniform> uBufferDynamic : S;
@group(0) @binding(1) var<uniform> uBuffer : S;
@group(0) @binding(2) var<storage, read_write> sBufferDynamic : S;
@group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
@@ -1448,12 +1448,12 @@ class SetBindGroupValidationTest : public ValidationTest {
value : vec2<f32>;
};
[[group(0), binding(0)]] var<uniform> uBufferDynamic : S;
[[group(0), binding(1)]] var<uniform> uBuffer : S;
[[group(0), binding(2)]] var<storage, read_write> sBufferDynamic : S;
[[group(0), binding(3)]] var<storage, read> sReadonlyBufferDynamic : S;
@group(0) @binding(0) var<uniform> uBufferDynamic : S;
@group(0) @binding(1) var<uniform> uBuffer : S;
@group(0) @binding(2) var<storage, read_write> sBufferDynamic : S;
@group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S;
[[stage(compute), workgroup_size(4, 4, 1)]] fn main() {
@stage(compute) @workgroup_size(4, 4, 1) fn main() {
})");
wgpu::PipelineLayout pipelineLayout =
@@ -1824,7 +1824,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
ValidationTest::SetUp();
mVsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
@@ -1880,7 +1880,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
for (uint32_t b = 0; b < layout.size(); ++b) {
wgpu::BufferBindingType binding = layout[b];
ss << "[[group(" << l << "), binding(" << b << ")]] ";
ss << "@group(" << l << ") @binding(" << b << ") ";
switch (binding) {
case wgpu::BufferBindingType::Storage:
ss << "var<storage, read_write> set" << l << "_binding" << b << " : S;";
@@ -1894,7 +1894,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
}
}
ss << "[[stage(fragment)]] fn main() {}";
ss << "@stage(fragment) fn main() {}";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, ss.str().c_str());
@@ -2026,7 +2026,7 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
const char* fsShader,
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
@@ -2050,10 +2050,10 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
value : vec2<f32>;
};
[[group(0), binding(0)]] var<storage, read_write> sBufferDynamic : S;
[[group(1), binding(0)]] var<storage, read> sReadonlyBufferDynamic : S;
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
var val : vec2<f32> = sBufferDynamic.value;
val = sReadonlyBufferDynamic.value;
})",
@@ -2085,10 +2085,10 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
value : vec2<f32>;
};
[[group(0), binding(0)]] var<storage, read_write> sBufferDynamic : S;
[[group(1), binding(0)]] var<storage, read> sReadonlyBufferDynamic : S;
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
[[stage(compute), workgroup_size(4, 4, 1)]] fn main() {
@stage(compute) @workgroup_size(4, 4, 1) fn main() {
var val : vec2<f32> = sBufferDynamic.value;
val = sReadonlyBufferDynamic.value;
})",
@@ -2130,13 +2130,13 @@ TEST_F(BindGroupLayoutCompatibilityTest, ROStorageInBGLWithRWStorageInShader) {
TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
constexpr char kTexture2DShaderFS[] = R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@stage(fragment) fn main() {
textureDimensions(myTexture);
})";
constexpr char kTexture2DShaderCS[] = R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(compute), workgroup_size(1)]] fn main() {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@stage(compute) @workgroup_size(1) fn main() {
textureDimensions(myTexture);
})";
@@ -2169,13 +2169,13 @@ TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
wgpu::TextureViewDimension::e2DArray}})}));
constexpr char kTexture2DArrayShaderFS[] = R"(
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var myTexture : texture_2d_array<f32>;
@stage(fragment) fn main() {
textureDimensions(myTexture);
})";
constexpr char kTexture2DArrayShaderCS[] = R"(
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
[[stage(compute), workgroup_size(1)]] fn main() {
@group(0) @binding(0) var myTexture : texture_2d_array<f32>;
@stage(compute) @workgroup_size(1) fn main() {
textureDimensions(myTexture);
})";
@@ -2216,16 +2216,16 @@ TEST_F(BindGroupLayoutCompatibilityTest, ExternalTextureBindGroupLayoutCompatibi
// Test that an external texture binding works with a texture_external in the shader.
CreateFSRenderPipeline(R"(
[[group(0), binding(0)]] var myExternalTexture: texture_external;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var myExternalTexture: texture_external;
@stage(fragment) fn main() {
_ = myExternalTexture;
})",
{bgl});
// Test that an external texture binding doesn't work with a texture_2d<f32> in the shader.
ASSERT_DEVICE_ERROR(CreateFSRenderPipeline(R"(
[[group(0), binding(0)]] var myTexture: texture_2d<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() {
_ = myTexture;
})",
{bgl}));
@@ -2429,7 +2429,7 @@ class SamplerTypeBindingTest : public ValidationTest {
wgpu::RenderPipeline CreateFragmentPipeline(wgpu::BindGroupLayout* bindGroupLayout,
const char* fragmentSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
@@ -2455,8 +2455,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() {
_ = mySampler;
})");
}
@@ -2467,8 +2467,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::NonFiltering}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() {
_ = mySampler;
})");
}
@@ -2479,8 +2479,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler_comparison;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler_comparison;
@stage(fragment) fn main() {
_ = mySampler;
})");
}
@@ -2491,8 +2491,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler_comparison;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler_comparison;
@stage(fragment) fn main() {
_ = mySampler;
})"));
}
@@ -2503,8 +2503,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::NonFiltering}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler_comparison;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler_comparison;
@stage(fragment) fn main() {
_ = mySampler;
})"));
}
@@ -2515,8 +2515,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() {
_ = mySampler;
})"));
}
@@ -2528,9 +2528,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})");
}
@@ -2542,9 +2542,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})");
}
@@ -2556,9 +2556,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture: texture_depth_2d;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_depth_2d;
@stage(fragment) fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})");
}
@@ -2570,9 +2570,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture: texture_depth_2d;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_depth_2d;
@stage(fragment) fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})");
}
@@ -2584,9 +2584,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler_comparison;
[[group(0), binding(1)]] var myTexture: texture_depth_2d;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler_comparison;
@group(0) @binding(1) var myTexture: texture_depth_2d;
@stage(fragment) fn main() {
textureSampleCompare(myTexture, mySampler, vec2<f32>(0.0, 0.0), 0.0);
})");
}
@@ -2598,9 +2598,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::UnfilterableFloat}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})"));
}
@@ -2612,9 +2612,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::UnfilterableFloat}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})");
}

View File

@@ -23,7 +23,7 @@ class ComputeIndirectValidationTest : public ValidationTest {
ValidationTest::SetUp();
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
})");
// Set up compute pipeline

View File

@@ -25,7 +25,7 @@ class ComputeValidationTest : public ValidationTest {
ValidationTest::SetUp();
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
})");
// Set up compute pipeline

View File

@@ -24,12 +24,12 @@ class DrawIndirectValidationTest : public ValidationTest {
ValidationTest::SetUp();
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32>{
@stage(fragment) fn main() -> @location(0) vec4<f32>{
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})");

View File

@@ -82,7 +82,7 @@ namespace {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
}
@@ -107,8 +107,8 @@ namespace {
for (auto buffer : bufferDescList) {
for (auto attr : buffer.attributes) {
// [[location({shaderLocation})]] var_{id} : {typeString},
inputStringStream << "[[location(" << attr.shaderLocation << ")]] var_"
// @location({shaderLocation}) var_{id} : {typeString},
inputStringStream << "@location(" << attr.shaderLocation << ") var_"
<< attributeCount << " : vec4<f32>,";
attributeCount++;
}
@@ -117,9 +117,9 @@ namespace {
std::stringstream shaderStringStream;
shaderStringStream << R"(
[[stage(vertex)]]
@stage(vertex)
fn main()" << inputStringStream.str()
<< R"() -> [[builtin(position)]] vec4<f32> {
<< R"() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})";

View File

@@ -21,7 +21,7 @@ class GetBindGroupLayoutTests : public ValidationTest {
protected:
wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
@@ -49,10 +49,10 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
struct S {
pos : vec4<f32>;
};
[[group(0), binding(0)]] var<uniform> uniform0 : S;
[[group(1), binding(0)]] var<uniform> uniform1 : S;
@group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniform0.pos;
pos = uniform1.pos;
return vec4<f32>();
@@ -62,14 +62,14 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
struct S2 {
pos : vec4<f32>;
};
[[group(2), binding(0)]] var<uniform> uniform2 : S2;
@group(2) @binding(0) var<uniform> uniform2 : S2;
struct S3 {
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() {
var pos_u : vec4<f32> = uniform2.pos;
var pos_s : mat4x4<f32> = storage3.pos;
})");
@@ -101,9 +101,9 @@ TEST_F(GetBindGroupLayoutTests, DefaultBindGroupLayoutPipelineCompatibility) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
@@ -123,9 +123,9 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
@@ -176,51 +176,51 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::SamplerBindingType::Filtering}});
wgpu::ShaderModule emptyVertexModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[group(0), binding(1)]] var mySampler : sampler;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
_ = myTexture;
_ = mySampler;
return vec4<f32>();
})");
wgpu::ShaderModule textureLoadVertexModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[group(0), binding(1)]] var mySampler : sampler;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
textureLoad(myTexture, vec2<i32>(), 0);
_ = mySampler;
return vec4<f32>();
})");
wgpu::ShaderModule textureSampleVertexModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[group(0), binding(1)]] var mySampler : sampler;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
textureSampleLevel(myTexture, mySampler, vec2<f32>(), 0.0);
return vec4<f32>();
})");
wgpu::ShaderModule unusedTextureFragmentModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[group(0), binding(1)]] var mySampler : sampler;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@stage(fragment) fn main() {
_ = myTexture;
_ = mySampler;
})");
wgpu::ShaderModule textureLoadFragmentModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[group(0), binding(1)]] var mySampler : sampler;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@stage(fragment) fn main() {
textureLoad(myTexture, vec2<i32>(), 0);
_ = mySampler;
})");
wgpu::ShaderModule textureSampleFragmentModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[group(0), binding(1)]] var mySampler : sampler;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@stage(fragment) fn main() {
textureSample(myTexture, mySampler, vec2<f32>());
})");
@@ -293,9 +293,9 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
@@ -346,9 +346,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
struct S {
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() {
var pos : vec4<f32> = ssbo.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -360,9 +360,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -375,9 +375,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
struct S {
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() {
var pos : vec4<f32> = ssbo.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -389,9 +389,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::UnfilterableFloat;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
@group(0) @binding(0) var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -401,9 +401,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{
binding.texture.multisampled = true;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_multisampled_2d<f32>;
@group(0) @binding(0) var myTexture : texture_multisampled_2d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -414,9 +414,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{
binding.sampler.type = wgpu::SamplerBindingType::Filtering;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var mySampler: sampler;
@group(0) @binding(0) var mySampler: sampler;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
_ = mySampler;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -442,9 +442,9 @@ TEST_F(GetBindGroupLayoutTests, ExternalTextureBindingType) {
binding.nextInChain = &utils::kExternalTextureBindingLayout;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myExternalTexture: texture_external;
@group(0) @binding(0) var myExternalTexture: texture_external;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
_ = myExternalTexture;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -470,9 +470,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e1D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_1d<f32>;
@group(0) @binding(0) var myTexture : texture_1d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -482,9 +482,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e2D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
@group(0) @binding(0) var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -494,9 +494,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e2DArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
@group(0) @binding(0) var myTexture : texture_2d_array<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -506,9 +506,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e3D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_3d<f32>;
@group(0) @binding(0) var myTexture : texture_3d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -518,9 +518,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::Cube;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_cube<f32>;
@group(0) @binding(0) var myTexture : texture_cube<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -530,9 +530,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::CubeArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_cube_array<f32>;
@group(0) @binding(0) var myTexture : texture_cube_array<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -558,9 +558,9 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::UnfilterableFloat;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
@group(0) @binding(0) var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -570,9 +570,9 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::Sint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_2d<i32>;
@group(0) @binding(0) var myTexture : texture_2d<i32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -582,9 +582,9 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::Uint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var myTexture : texture_2d<u32>;
@group(0) @binding(0) var myTexture : texture_2d<u32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -615,9 +615,9 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -630,9 +630,9 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -645,9 +645,9 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@@ -661,10 +661,10 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
struct S {
pos : vec4<f32>;
};
[[group(0), binding(0)]] var<uniform> uniform0 : S;
[[group(1), binding(0)]] var<uniform> uniform1 : S;
@group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniform0.pos;
pos = uniform1.pos;
return vec4<f32>();
@@ -674,9 +674,9 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
struct S {
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() {
var pos : vec4<f32> = uniforms.pos;
})");
@@ -700,9 +700,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
struct S {
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> {
var pos : f32 = uniforms.pos;
return vec4<f32>();
})");
@@ -711,9 +711,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
struct S {
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> {
var pos : mat4x4<f32> = uniforms.pos;
return vec4<f32>();
})");
@@ -722,9 +722,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
struct S {
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() {
var pos : f32 = uniforms.pos;
})");
@@ -732,9 +732,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
struct S {
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() {
var pos : mat4x4<f32> = uniforms.pos;
})");
@@ -793,24 +793,24 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@group(0) @binding(0) var mySampler: sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
_ = mySampler;
return vec4<f32>();
})");
wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
})");
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() {
_ = mySampler;
})");
@@ -867,9 +867,9 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
struct S {
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> {
var pos : vec4<f32> = ubo.pos;
return vec4<f32>();
})");
@@ -878,9 +878,9 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
struct S {
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() {
var pos : vec4<f32> = ssbo.pos;
})");
@@ -895,17 +895,17 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
// Test it is invalid to have conflicting binding texture multisampling in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
@group(0) @binding(0) var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
textureDimensions(myTexture);
return vec4<f32>();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_multisampled_2d<f32>;
@group(0) @binding(0) var myTexture : texture_multisampled_2d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
@@ -920,17 +920,17 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
// Test it is invalid to have conflicting binding texture dimension in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
@group(0) @binding(0) var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
textureDimensions(myTexture);
return vec4<f32>();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_3d<f32>;
@group(0) @binding(0) var myTexture : texture_3d<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
@@ -945,17 +945,17 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
// Test it is invalid to have conflicting binding texture component type in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
@group(0) @binding(0) var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
textureDimensions(myTexture);
return vec4<f32>();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<i32>;
@group(0) @binding(0) var myTexture : texture_2d<i32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})");
@@ -970,12 +970,12 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
// Test it is an error to query an out of range bind group layout.
TEST_F(GetBindGroupLayoutTests, OutOfRangeIndex) {
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
})")
.GetBindGroupLayout(kMaxBindGroups));
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
})")
.GetBindGroupLayout(kMaxBindGroups + 1));
}
@@ -991,10 +991,10 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
struct S {
pos : vec4<f32>;
};
[[group(0), binding(0)]] var<uniform> uniforms0 : S;
[[group(2), binding(0)]] var<uniform> uniforms2 : S;
@group(0) @binding(0) var<uniform> uniforms0 : S;
@group(2) @binding(0) var<uniform> uniforms2 : S;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
var pos : vec4<f32> = uniforms0.pos;
pos = uniforms2.pos;
})");
@@ -1044,15 +1044,15 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
struct S {
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> {
var pos : vec4<f32> = uniforms.pos;
return vec4<f32>();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
})");
utils::ComboRenderPipelineDescriptor pipelineDesc;
@@ -1085,14 +1085,14 @@ TEST_F(GetBindGroupLayoutTests, FromCorrectEntryPoint) {
struct Data {
data : f32;
};
[[group(0), binding(0)]] var<storage, read_write> data0 : Data;
[[group(0), binding(1)]] var<storage, read_write> data1 : Data;
@group(0) @binding(0) var<storage, read_write> data0 : Data;
@group(0) @binding(1) var<storage, read_write> data1 : Data;
[[stage(compute), workgroup_size(1)]] fn compute0() {
@stage(compute) @workgroup_size(1) fn compute0() {
data0.data = 0.0;
}
[[stage(compute), workgroup_size(1)]] fn compute1() {
@stage(compute) @workgroup_size(1) fn compute1() {
data1.data = 0.0;
}
)");

View File

@@ -19,16 +19,16 @@
#include "utils/WGPUHelpers.h"
class IndexBufferValidationTest : public ValidationTest {
protected:
protected:
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format,
wgpu::PrimitiveTopology primitiveTopology) {
wgpu::PrimitiveTopology primitiveTopology) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
@@ -151,10 +151,10 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
// Test that formats given when setting an index buffers must match the format specified on the
// pipeline for strip primitive topologies.
TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
wgpu::RenderPipeline pipeline32 = MakeTestPipeline(wgpu::IndexFormat::Uint32,
wgpu::PrimitiveTopology::TriangleStrip);
wgpu::RenderPipeline pipeline16 = MakeTestPipeline(wgpu::IndexFormat::Uint16,
wgpu::PrimitiveTopology::LineStrip);
wgpu::RenderPipeline pipeline32 =
MakeTestPipeline(wgpu::IndexFormat::Uint32, wgpu::PrimitiveTopology::TriangleStrip);
wgpu::RenderPipeline pipeline16 =
MakeTestPipeline(wgpu::IndexFormat::Uint16, wgpu::PrimitiveTopology::LineStrip);
wgpu::RenderPipeline pipelineUndef =
MakeTestPipeline(wgpu::IndexFormat::Undefined, wgpu::PrimitiveTopology::LineStrip);

View File

@@ -502,12 +502,12 @@ TEST_F(LabelTest, RenderPipeline) {
std::string label = "test";
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
@@ -544,7 +544,7 @@ TEST_F(LabelTest, ComputePipeline) {
std::string label = "test";
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
})");
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr);
wgpu::ComputePipelineDescriptor descriptor;
@@ -581,7 +581,7 @@ TEST_F(LabelTest, ShaderModule) {
std::string label = "test";
const char* source = R"(
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
})";
wgpu::ShaderModuleWGSLDescriptor wgslDesc;
@@ -611,4 +611,4 @@ TEST_F(LabelTest, ShaderModule) {
std::string readbackLabel = dawn::native::GetObjectLabelForTesting(shaderModule.Get());
ASSERT_EQ(label, readbackLabel);
}
}
}

View File

@@ -74,7 +74,7 @@ namespace {
size_t index = 0;
for (const BindingDescriptor& b : bindings) {
ostream << "struct S" << index << " { " << b.decl << "};\n";
ostream << "[[group(" << b.group << "), binding(" << b.binding << ")]] ";
ostream << "@group(" << b.group << ") @binding(" << b.binding << ") ";
switch (b.type) {
case wgpu::BufferBindingType::Uniform:
ostream << "var<uniform> b" << index << " : S" << index << ";\n";
@@ -115,21 +115,21 @@ namespace {
// Creates a compute shader with given bindings
std::string CreateComputeShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
return kStructs + GenerateBindingString(bindings) +
"[[stage(compute), workgroup_size(1,1,1)]] fn main() {\n" +
"@stage(compute) @workgroup_size(1,1,1) fn main() {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Compute) + "}";
}
// Creates a vertex shader with given bindings
std::string CreateVertexShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
return kStructs + GenerateBindingString(bindings) +
"[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {\n" +
"@stage(vertex) fn main() -> @builtin(position) vec4<f32> {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Vertex) +
"\n return vec4<f32>(); " + "}";
}
// Creates a fragment shader with given bindings
std::string CreateFragmentShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
return kStructs + GenerateBindingString(bindings) + "[[stage(fragment)]] fn main() {\n" +
return kStructs + GenerateBindingString(bindings) + "@stage(fragment) fn main() {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Fragment) + "}";
}
@@ -565,11 +565,10 @@ TEST_F(MinBufferSizeDefaultLayoutTests, MultipleBindGroups) {
// Test the minimum size computations with manual size/align/stride decorations.
TEST_F(MinBufferSizeDefaultLayoutTests, NonDefaultLayout) {
CheckShaderBindingSizeReflection(
{{{0, 0, "[[size(256)]] a : u32; b : u32;", "u32", "a", 260},
{0, 1, "c : u32; [[align(16)]] d : u32;", "u32", "c", 20},
{0, 2, "d : [[stride(40)]] array<u32, 3>;", "u32", "d[0]", 120},
{0, 3, "e : [[stride(40)]] array<u32>;", "u32", "e[0]", 40}}});
CheckShaderBindingSizeReflection({{{0, 0, "@size(256) a : u32; b : u32;", "u32", "a", 260},
{0, 1, "c : u32; @align(16) d : u32;", "u32", "c", 20},
{0, 2, "d : @stride(40) array<u32, 3>;", "u32", "d[0]", 120},
{0, 3, "e : @stride(40) array<u32>;", "u32", "e[0]", 40}}});
}
// Minimum size should be the max requirement of both vertex and fragment stages.

View File

@@ -33,7 +33,7 @@ TEST_F(MultipleDeviceTest, ValidatesSameDevice) {
TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreatePipelineAsync) {
wgpu::ShaderModuleWGSLDescriptor wgslDesc = {};
wgslDesc.source = R"(
[[stage(compute), workgroup_size(1, 1, 1)]] fn main() {
@stage(compute) @workgroup_size(1, 1, 1) fn main() {
}
)";

View File

@@ -20,19 +20,19 @@ class ComputePipelineOverridableConstantsValidationTest : public ValidationTest
protected:
void SetUpShadersWithDefaultValueConstants() {
computeModule = utils::CreateShaderModule(device, R"(
[[override]] let c0: bool = true; // type: bool
[[override]] let c1: bool = false; // default override
[[override]] let c2: f32 = 0.0; // type: float32
[[override]] let c3: f32 = 0.0; // default override
[[override]] let c4: f32 = 4.0; // default
[[override]] let c5: i32 = 0; // type: int32
[[override]] let c6: i32 = 0; // default override
[[override]] let c7: i32 = 7; // default
[[override]] let c8: u32 = 0u; // type: uint32
[[override]] let c9: u32 = 0u; // default override
[[override(1000)]] let c10: u32 = 10u; // default
@override let c0: bool = true; // type: bool
@override let c1: bool = false; // default override
@override let c2: f32 = 0.0; // type: float32
@override let c3: f32 = 0.0; // default override
@override let c4: f32 = 4.0; // default
@override let c5: i32 = 0; // type: int32
@override let c6: i32 = 0; // default override
@override let c7: i32 = 7; // default
@override let c8: u32 = 0u; // type: uint32
@override let c9: u32 = 0u; // default override
@override(1000) let c10: u32 = 10u; // default
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
// make sure the overridable constants are not optimized out
_ = u32(c0);
_ = u32(c1);
@@ -50,19 +50,19 @@ class ComputePipelineOverridableConstantsValidationTest : public ValidationTest
void SetUpShadersWithUninitializedConstants() {
computeModule = utils::CreateShaderModule(device, R"(
[[override]] let c0: bool; // type: bool
[[override]] let c1: bool = false; // default override
[[override]] let c2: f32; // type: float32
[[override]] let c3: f32 = 0.0; // default override
[[override]] let c4: f32 = 4.0; // default
[[override]] let c5: i32; // type: int32
[[override]] let c6: i32 = 0; // default override
[[override]] let c7: i32 = 7; // default
[[override]] let c8: u32; // type: uint32
[[override]] let c9: u32 = 0u; // default override
[[override(1000)]] let c10: u32 = 10u; // default
@override let c0: bool; // type: bool
@override let c1: bool = false; // default override
@override let c2: f32; // type: float32
@override let c3: f32 = 0.0; // default override
@override let c4: f32 = 4.0; // default
@override let c5: i32; // type: int32
@override let c6: i32 = 0; // default override
@override let c7: i32 = 7; // default
@override let c8: u32; // type: uint32
@override let c9: u32 = 0u; // default override
@override(1000) let c10: u32 = 10u; // default
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
// make sure the overridable constants are not optimized out
_ = u32(c0);
_ = u32(c1);
@@ -209,4 +209,4 @@ TEST_F(ComputePipelineOverridableConstantsValidationTest, ConstantsIdentifierUni
std::vector<wgpu::ConstantEntry> constants{{nullptr, "c10", 0}};
ASSERT_DEVICE_ERROR(TestCreatePipeline(constants));
}
}
}

View File

@@ -33,11 +33,11 @@ namespace {
// Create a NoOp pipeline
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
})");
pipelineDescriptor.cFragment.targets = nullptr;
pipelineDescriptor.cFragment.targetCount = 0;

View File

@@ -175,12 +175,12 @@ namespace {
};
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
@@ -211,7 +211,7 @@ namespace {
wgpu::ComputePipelineDescriptor descriptor;
descriptor.compute.module = utils::CreateShaderModule(device, R"(
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
})");
descriptor.compute.entryPoint = "main";
device.CreateComputePipelineAsync(&descriptor, callback, &callbackData);
@@ -236,7 +236,7 @@ namespace {
cpDesc.layout = utils::MakePipelineLayout(device, {emptyBGL, testBGL});
cpDesc.compute.entryPoint = "main";
cpDesc.compute.module =
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&cpDesc);
wgpu::BufferDescriptor bufDesc;
@@ -304,7 +304,7 @@ namespace {
cpDesc.layout = utils::MakePipelineLayout(device, {emptyBGL, emptyBGL, testBGL});
cpDesc.compute.entryPoint = "main";
cpDesc.compute.module =
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&cpDesc);
wgpu::TextureDescriptor texDesc;

View File

@@ -31,9 +31,9 @@ namespace {
struct S {
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> {
return vec4<f32>();
})");
@@ -41,14 +41,14 @@ namespace {
struct Uniforms {
color : vec4<f32>;
};
[[group(1), binding(0)]] var<uniform> uniforms : Uniforms;
@group(1) @binding(0) var<uniform> uniforms : Uniforms;
struct Storage {
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() {
})");
wgpu::BindGroupLayout bgls[] = {

View File

@@ -27,17 +27,17 @@ class RenderPipelineValidationTest : public ValidationTest {
ValidationTest::SetUp();
vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
fsModuleUint = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<u32> {
@stage(fragment) fn main() -> @location(0) vec4<u32> {
return vec4<u32>(0u, 255u, 0u, 255u);
})");
}
@@ -288,7 +288,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
descriptor.vertex.module = vsModule;
std::ostringstream stream;
stream << R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<)"
@stage(fragment) fn main() -> @location(0) vec4<)"
<< kScalarTypes[i] << R"(> {
var result : vec4<)"
<< kScalarTypes[i] << R"(>;
@@ -329,7 +329,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputComponentCountCompatibility)
std::ostringstream stream;
stream << R"(
[[stage(fragment)]] fn main() -> [[location(0)]] )";
@stage(fragment) fn main() -> @location(0) )";
switch (componentCount) {
case 1:
stream << R"(f32 {
@@ -737,10 +737,10 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
std::ostringstream stream;
stream << R"(
[[group(0), binding(0)]] var myTexture : texture_2d<)"
@group(0) @binding(0) var myTexture : texture_2d<)"
<< kScalarTypes[i] << R"(>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})";
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
@@ -787,9 +787,9 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
std::ostringstream stream;
stream << R"(
[[group(0), binding(0)]] var myTexture : )"
@group(0) @binding(0) var myTexture : )"
<< kTextureKeywords[i] << R"(<f32>;
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
textureDimensions(myTexture);
})";
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
@@ -816,8 +816,8 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
struct Dst {
data : array<u32, 100>;
};
[[group(0), binding(0)]] var<storage, read_write> dst : Dst;
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
@group(0) @binding(0) var<storage, read_write> dst : Dst;
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
dst.data[VertexIndex] = 0x1234u;
return vec4<f32>();
})");
@@ -918,11 +918,11 @@ TEST_F(RenderPipelineValidationTest, DepthCompareUndefinedIsError) {
// Test that the entryPoint names must be present for the correct stage in the shader module.
TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn vertex_main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
}
[[stage(fragment)]] fn fragment_main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}
)");
@@ -964,12 +964,12 @@ TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
// Test that vertex attrib validation is for the correct entryPoint
TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn vertex0([[location(0)]] attrib0 : vec4<f32>)
-> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn vertex0(@location(0) attrib0 : vec4<f32>)
-> @builtin(position) vec4<f32> {
return attrib0;
}
[[stage(vertex)]] fn vertex1([[location(1)]] attrib1 : vec4<f32>)
-> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn vertex1(@location(1) attrib1 : vec4<f32>)
-> @builtin(position) vec4<f32> {
return attrib1;
}
)");
@@ -1006,10 +1006,10 @@ TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
// Test that fragment output validation is for the correct entryPoint
TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn fragmentFloat() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn fragmentFloat() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}
[[stage(fragment)]] fn fragmentUint() -> [[location(0)]] vec4<u32> {
@stage(fragment) fn fragmentUint() -> @location(0) vec4<u32> {
return vec4<u32>(0u, 0u, 0u, 0u);
}
)");
@@ -1040,33 +1040,33 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
// Test that unwritten fragment outputs must have a write mask of 0.
TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
}
)");
wgpu::ShaderModule fsModuleWriteNone = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() {}
@stage(fragment) fn main() {}
)");
wgpu::ShaderModule fsModuleWrite0 = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>();
}
)");
wgpu::ShaderModule fsModuleWrite1 = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(1)]] vec4<f32> {
@stage(fragment) fn main() -> @location(1) vec4<f32> {
return vec4<f32>();
}
)");
wgpu::ShaderModule fsModuleWriteBoth = utils::CreateShaderModule(device, R"(
struct FragmentOut {
[[location(0)]] target0 : vec4<f32>;
[[location(1)]] target1 : vec4<f32>;
@location(0) target0 : vec4<f32>;
@location(1) target1 : vec4<f32>;
};
[[stage(fragment)]] fn main() -> FragmentOut {
@stage(fragment) fn main() -> FragmentOut {
var out : FragmentOut;
return out;
}
@@ -1175,13 +1175,13 @@ TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
struct Uniforms {
data : vec4<f32>;
};
[[group(0), binding(0)]] var<uniform> var0 : Uniforms;
[[group(0), binding(1)]] var<uniform> var1 : Uniforms;
@group(0) @binding(0) var<uniform> var0 : Uniforms;
@group(0) @binding(1) var<uniform> var1 : Uniforms;
[[stage(vertex)]] fn vertex0() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn vertex0() -> @builtin(position) vec4<f32> {
return var0.data;
}
[[stage(vertex)]] fn vertex1() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn vertex1() -> @builtin(position) vec4<f32> {
return var1.data;
}
)");
@@ -1272,34 +1272,34 @@ class InterStageVariableMatchingValidationTest : public RenderPipelineValidation
TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocation) {
wgpu::ShaderModule vertexModuleOutputAtLocation0 = utils::CreateShaderModule(device, R"(
struct A {
[[location(0)]] vout: f32;
[[builtin(position)]] pos: vec4<f32>;
@location(0) vout: f32;
@builtin(position) pos: vec4<f32>;
};
[[stage(vertex)]] fn main() -> A {
@stage(vertex) fn main() -> A {
var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vertexOut;
})");
wgpu::ShaderModule fragmentModuleAtLocation0 = utils::CreateShaderModule(device, R"(
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);
})");
wgpu::ShaderModule fragmentModuleInputAtLocation1 = utils::CreateShaderModule(device, R"(
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);
})");
wgpu::ShaderModule vertexModuleOutputAtLocation1 = utils::CreateShaderModule(device, R"(
struct B {
[[location(1)]] fin: f32;
[[builtin(position)]] pos: vec4<f32>;
@location(1) fin: f32;
@builtin(position) pos: vec4<f32>;
};
[[stage(vertex)]] fn main() -> B {
@stage(vertex) fn main() -> B {
var fragmentIn: B;
fragmentIn.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return fragmentIn;
@@ -1334,15 +1334,15 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
std::string interfaceDeclaration;
{
std::ostringstream sstream;
sstream << "struct A { [[location(0)]] a: " << kTypes[i] << ";" << std::endl;
sstream << "struct A { @location(0) a: " << kTypes[i] << ";" << std::endl;
interfaceDeclaration = sstream.str();
}
{
std::ostringstream vertexStream;
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;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vertexOut;
@@ -1353,7 +1353,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
std::ostringstream fragmentStream;
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);
})";
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());
@@ -1420,9 +1420,9 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
{
const auto& interpolationAttribute = validInterpolationAttributes[i];
std::ostringstream sstream;
sstream << "struct A { [[location(0)";
sstream << "struct A { @location(0)";
if (interpolationAttribute.interpolationType != InterpolationType::None) {
sstream << ", interpolate("
sstream << " @interpolate("
<< kInterpolationTypeString[static_cast<uint8_t>(
interpolationAttribute.interpolationType)];
if (interpolationAttribute.interpolationSampling != InterpolationSampling::None) {
@@ -1432,15 +1432,15 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
}
sstream << ")";
}
sstream << " ]] a : vec4<f32>;" << std::endl;
sstream << " a : vec4<f32>;" << std::endl;
interfaceDeclaration = sstream.str();
}
{
std::ostringstream vertexStream;
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;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vertexOut;
@@ -1451,7 +1451,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
std::ostringstream fragmentStream;
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;
})";
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());
@@ -1463,7 +1463,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
attribute.interpolationSampling};
switch (attribute.interpolationType) {
// If the interpolation attribute is not specified, then
// [[interpolate(perspective, center)]] or [[interpolate(perspective)]] is assumed.
// @interpolate(perspective, center) or @interpolate(perspective) is assumed.
case InterpolationType::None:
appliedAttribute.interpolationType = InterpolationType::Perspective;
appliedAttribute.interpolationSampling = InterpolationSampling::Center;

View File

@@ -48,12 +48,12 @@ namespace {
// pipeline. But those bind groups in caller can be used for validation for other purposes.
wgpu::RenderPipeline CreateNoOpRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() {
@stage(fragment) fn main() {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
@@ -65,7 +65,7 @@ namespace {
wgpu::ComputePipeline CreateNoOpComputePipeline(std::vector<wgpu::BindGroupLayout> bgls) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
})");
wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.layout = utils::MakePipelineLayout(device, std::move(bgls));
@@ -756,7 +756,7 @@ namespace {
// Create a passthrough render pipeline with a readonly buffer
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
@@ -764,8 +764,8 @@ namespace {
struct RBuffer {
value : f32;
};
[[group(0), binding(0)]] var<storage, read> rBuffer : RBuffer;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var<storage, read> rBuffer : RBuffer;
@stage(fragment) fn main() {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
@@ -1573,13 +1573,13 @@ namespace {
{
// Create a passthrough render pipeline with a sampled storage texture
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var tex : texture_2d<f32>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var tex : texture_2d<f32>;
@stage(fragment) fn main() {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;

View File

@@ -60,8 +60,7 @@ TEST_F(ShaderModuleValidationTest, CreationSuccess) {
// be compiled.
TEST_F(ShaderModuleValidationTest, FragmentOutputLocationExceedsMaxColorAttachments) {
std::ostringstream stream;
stream << "[[stage(fragment)]] fn main() -> [[location(" << kMaxColorAttachments
<< R"()]] vec4<f32> {
stream << "@stage(fragment) fn main() -> @location(" << kMaxColorAttachments << R"() vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})";
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, stream.str().c_str()));
@@ -163,7 +162,7 @@ TEST_F(ShaderModuleValidationTest, GetCompilationMessages) {
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
@@ -219,14 +218,14 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
std::ostringstream stream;
stream << "struct ShaderIO {" << std::endl;
for (uint32_t location = 1; location <= maximumOutputLocation; ++location) {
stream << "[[location(" << location << ")]] var" << location << ": f32;" << std::endl;
stream << "@location(" << location << ") var" << location << ": f32;" << std::endl;
}
switch (shaderStage) {
case wgpu::ShaderStage::Vertex: {
stream << R"(
[[builtin(position)]] pos: vec4<f32>;
@builtin(position) pos: vec4<f32>;
};
[[stage(vertex)]] fn main() -> ShaderIO {
@stage(vertex) fn main() -> ShaderIO {
var shaderIO : ShaderIO;
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return shaderIO;
@@ -236,7 +235,7 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
case wgpu::ShaderStage::Fragment: {
stream << R"(
};
[[stage(fragment)]] fn main(shaderIO: ShaderIO) -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main(shaderIO: ShaderIO) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})";
} break;
@@ -293,14 +292,13 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
uint32_t vec4InputLocations = totalUserDefinedInterStageShaderComponentCount / 4;
for (uint32_t location = 0; location < vec4InputLocations; ++location) {
stream << "[[location(" << location << ")]] var" << location << ": vec4<f32>;"
stream << "@location(" << location << ") var" << location << ": vec4<f32>;"
<< std::endl;
}
uint32_t lastComponentCount = totalUserDefinedInterStageShaderComponentCount % 4;
if (lastComponentCount > 0) {
stream << "[[location(" << vec4InputLocations << ")]] var" << vec4InputLocations
<< ": ";
stream << "@location(" << vec4InputLocations << ") var" << vec4InputLocations << ": ";
if (lastComponentCount == 1) {
stream << "f32;";
} else {
@@ -312,9 +310,9 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
switch (shaderStage) {
case wgpu::ShaderStage::Vertex: {
stream << R"(
[[builtin(position)]] pos: vec4<f32>;
@builtin(position) pos: vec4<f32>;
};
[[stage(vertex)]] fn main() -> ShaderIO {
@stage(vertex) fn main() -> ShaderIO {
var shaderIO : ShaderIO;
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return shaderIO;
@@ -324,7 +322,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
case wgpu::ShaderStage::Fragment: {
stream << R"(
};
[[stage(fragment)]] fn main(shaderIO: ShaderIO) -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main(shaderIO: ShaderIO) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})";
} break;
@@ -350,8 +348,8 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, errorFragmentShader.c_str()));
}
// [[position]] should be counted into the maximum inter-stage component count.
// Note that in vertex shader we always have [[position]] so we don't need to specify it
// @position should be counted into the maximum inter-stage component count.
// Note that in vertex shader we always have @position so we don't need to specify it
// again in the parameter "builtInDeclarations" of generateShaderForTest().
{
constexpr uint32_t kInterStageShaderComponentCount = kMaxInterStageShaderComponents - 4;
@@ -361,7 +359,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
std::string fragmentShader =
generateShaderForTest(kInterStageShaderComponentCount, wgpu::ShaderStage::Fragment,
"[[builtin(position)]] fragCoord: vec4<f32>;");
"@builtin(position) fragCoord: vec4<f32>;");
utils::CreateShaderModule(device, fragmentShader.c_str());
}
@@ -373,13 +371,13 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
std::string fragmentShader =
generateShaderForTest(kInterStageShaderComponentCount, wgpu::ShaderStage::Fragment,
"[[builtin(position)]] fragCoord: vec4<f32>;");
"@builtin(position) fragCoord: vec4<f32>;");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, fragmentShader.c_str()));
}
// [[front_facing]] should be counted into the maximum inter-stage component count.
// front_facing should be counted into the maximum inter-stage component count.
{
const char* builtinDeclaration = "[[builtin(front_facing)]] frontFacing : bool;";
const char* builtinDeclaration = "@builtin(front_facing) frontFacing : bool;";
{
std::string fragmentShader =
@@ -395,9 +393,9 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
}
}
// [[sample_index]] should be counted into the maximum inter-stage component count.
// @sample_index should be counted into the maximum inter-stage component count.
{
const char* builtinDeclaration = "[[builtin(sample_index)]] sampleIndex: u32;";
const char* builtinDeclaration = "@builtin(sample_index) sampleIndex: u32;";
{
std::string fragmentShader =
@@ -413,9 +411,9 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
}
}
// [[sample_mask]] should be counted into the maximum inter-stage component count.
// @sample_mask should be counted into the maximum inter-stage component count.
{
const char* builtinDeclaration = "[[builtin(front_facing)]] frontFacing : bool;";
const char* builtinDeclaration = "@builtin(front_facing) frontFacing : bool;";
{
std::string fragmentShader =
@@ -436,8 +434,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
TEST_F(ShaderModuleValidationTest, ComputeWorkgroupSizeLimits) {
auto MakeShaderWithWorkgroupSize = [this](uint32_t x, uint32_t y, uint32_t z) {
std::ostringstream ss;
ss << "[[stage(compute), workgroup_size(" << x << "," << y << "," << z
<< ")]] fn main() {}";
ss << "@stage(compute) @workgroup_size(" << x << "," << y << "," << z << ") fn main() {}";
utils::CreateShaderModule(device, ss.str().c_str());
};
@@ -482,7 +479,7 @@ TEST_F(ShaderModuleValidationTest, ComputeWorkgroupStorageSizeLimits) {
ss << "var<workgroup> mat4_data: array<mat4x4<f32>, " << mat4_count << ">;";
body << "_ = mat4_data;";
}
ss << "[[stage(compute), workgroup_size(1)]] fn main() { " << body.str() << " }";
ss << "@stage(compute) @workgroup_size(1) fn main() { " << body.str() << " }";
utils::CreateShaderModule(device, ss.str().c_str());
};
@@ -500,16 +497,16 @@ TEST_F(ShaderModuleValidationTest, ComputeWorkgroupStorageSizeLimits) {
// Test that numeric ID must be unique
TEST_F(ShaderModuleValidationTest, OverridableConstantsNumericIDConflicts) {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[override(1234)]] let c0: u32;
[[override(1234)]] let c1: u32;
@override(1234) let c0: u32;
@override(1234) let c1: u32;
struct Buf {
data : array<u32, 2>;
};
[[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() {
// make sure the overridable constants are not optimized out
buf.data[0] = c0;
buf.data[1] = c1;

View File

@@ -24,11 +24,11 @@ class StorageTextureValidationTests : public ValidationTest {
ValidationTest::SetUp();
mDefaultVSModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
mDefaultFSModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
})");
}
@@ -79,10 +79,10 @@ class StorageTextureValidationTests : public ValidationTest {
}
std::ostringstream ostream;
ostream << "[[group(0), binding(0)]] var image0 : " << imageTypeDeclaration << "<"
ostream << "@group(0) @binding(0) var image0 : " << imageTypeDeclaration << "<"
<< imageFormatQualifier << ", " << access
<< ">;\n"
"[[stage(compute), workgroup_size(1)]] fn main() {\n"
"@stage(compute) @workgroup_size(1) fn main() {\n"
" textureDimensions(image0);\n"
"}\n";
@@ -117,9 +117,9 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Write-only storage textures cannot be declared in a vertex shader.
{
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
@stage(vertex)
fn main(@builtin(vertex_index) vertex_index : u32) -> @builtin(position) vec4<f32> {
textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
return vec4<f32>(0.0);
})");
@@ -134,8 +134,8 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Write-only storage textures can be declared in a fragment shader.
{
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
[[stage(fragment)]] fn main([[builtin(position)]] position : vec4<f32>) {
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
@stage(fragment) fn main(@builtin(position) position : vec4<f32>) {
textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})");
@@ -154,9 +154,9 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Write-only storage textures can be declared in a compute shader.
{
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
[[stage(compute), workgroup_size(1)]] fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3<u32>) {
@stage(compute) @workgroup_size(1) fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
textureStore(image0, vec2<i32>(LocalInvocationID.xy), vec4<f32>(0.0, 0.0, 0.0, 0.0));
})");
@@ -174,8 +174,8 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a vertex shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
[[stage(vertex)]] fn main() {
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
@stage(vertex) fn main() {
textureDimensions(image0);
})"));
}
@@ -183,8 +183,8 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a fragment shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
[[stage(fragment)]] fn main() {
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
@stage(fragment) fn main() {
textureDimensions(image0);
})"));
}
@@ -192,8 +192,8 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a compute shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
[[stage(compute), workgroup_size(1)]] fn main() {
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
@stage(compute) @workgroup_size(1) fn main() {
textureDimensions(image0);
})"));
}

View File

@@ -70,7 +70,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
{
wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase;
pipelineDesc.compute.module =
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
device.CreateComputePipeline(&pipelineDesc);
}
@@ -78,10 +78,10 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
// Error case: shader with overridable constant with default value
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[override(1000)]] let c0: u32 = 1u;
[[override(1000)]] let c1: u32;
@override(1000) let c0: u32 = 1u;
@override(1000) let c1: u32;
[[stage(compute), workgroup_size(1)]] fn main() {
@stage(compute) @workgroup_size(1) fn main() {
_ = c0;
_ = c1;
})"));
@@ -91,7 +91,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
{
wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase;
pipelineDesc.compute.module =
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
std::vector<wgpu::ConstantEntry> constants{{nullptr, "c", 1u}};
pipelineDesc.compute.constants = constants.data();
pipelineDesc.compute.constantCount = constants.size();

View File

@@ -26,7 +26,7 @@ class VertexBufferValidationTest : public ValidationTest {
ValidationTest::SetUp();
fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
}
@@ -41,16 +41,16 @@ class VertexBufferValidationTest : public ValidationTest {
wgpu::ShaderModule MakeVertexShader(unsigned int bufferCount) {
std::ostringstream vs;
vs << "[[stage(vertex)]] fn main(\n";
vs << "@stage(vertex) fn main(\n";
for (unsigned int i = 0; i < bufferCount; ++i) {
// TODO(cwallez@chromium.org): remove this special handling of 0 once Tint supports
// trailing commas in argument lists.
if (i != 0) {
vs << ", ";
}
vs << "[[location(" << i << ")]] a_position" << i << " : vec3<f32>\n";
vs << "@location(" << i << ") a_position" << i << " : vec3<f32>\n";
}
vs << ") -> [[builtin(position)]] vec4<f32> {";
vs << ") -> @builtin(position) vec4<f32> {";
vs << "return vec4<f32>(";
for (unsigned int i = 0; i < bufferCount; ++i) {

View File

@@ -24,7 +24,7 @@ class VertexStateTest : public ValidationTest {
const char* vertexSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexSource);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment) fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}
)");
@@ -44,7 +44,7 @@ class VertexStateTest : public ValidationTest {
}
const char* kDummyVertexShader = R"(
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}
)";
@@ -97,28 +97,28 @@ TEST_F(VertexStateTest, PipelineCompatibility) {
// Control case: pipeline with one input per attribute
CreatePipeline(true, state, R"(
[[stage(vertex)]] fn main(
[[location(0)]] a : vec4<f32>,
[[location(1)]] b : vec4<f32>
) -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main(
@location(0) a : vec4<f32>,
@location(1) b : vec4<f32>
) -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}
)");
// Check it is valid for the pipeline to use a subset of the VertexState
CreatePipeline(true, state, R"(
[[stage(vertex)]] fn main(
[[location(0)]] a : vec4<f32>
) -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main(
@location(0) a : vec4<f32>
) -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}
)");
// Check for an error when the pipeline uses an attribute not in the vertex input
CreatePipeline(false, state, R"(
[[stage(vertex)]] fn main(
[[location(2)]] a : vec4<f32>
) -> [[builtin(position)]] vec4<f32> {
@stage(vertex) fn main(
@location(2) a : vec4<f32>
) -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}
)");
@@ -359,8 +359,8 @@ TEST_F(VertexStateTest, BaseTypeMatching) {
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].format = format;
std::string shader = "[[stage(vertex)]] fn main([[location(0)]] attrib : " + shaderType +
R"() -> [[builtin(position)]] vec4<f32> {
std::string shader = "@stage(vertex) fn main(@location(0) attrib : " + shaderType +
R"() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})";
@@ -413,7 +413,7 @@ TEST_F(VertexStateTest, BaseTypeMatchingForInexistentInput) {
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].format = format;
std::string shader = R"([[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
std::string shader = R"(@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})";