Convert @stage to short form in src/dawn/test

This CL converts the @stage(...) in src/dawn/test to use the new
@compute, @vertex, or @fragment syntax.

Bug: tint:1503
Change-Id: I51feaceebe8b3ba03a95ddd93367c76d2b24a4ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92482
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
dan sinclair 2022-06-07 15:23:04 +00:00 committed by Dawn LUCI CQ
parent b29892be09
commit 825b95b7c1
96 changed files with 533 additions and 534 deletions

View File

@ -1285,7 +1285,7 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t
} }
} }
shaderSource << R"( shaderSource << R"(
@stage(compute) @workgroup_size(1) fn main( @compute @workgroup_size(1) fn main(
@builtin(global_invocation_id) GlobalInvocationId : vec3<u32> @builtin(global_invocation_id) GlobalInvocationId : vec3<u32>
) { ) {
let baseOutIndex = GlobalInvocationId.y * width + GlobalInvocationId.x; let baseOutIndex = GlobalInvocationId.y * width + GlobalInvocationId.x;
@ -1429,7 +1429,7 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
utils::ComboRenderPipelineDescriptor pipelineDescriptor; utils::ComboRenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -1449,7 +1449,7 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
@builtin(frag_depth) fragDepth : f32, @builtin(frag_depth) fragDepth : f32,
} }
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut { fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.result = 1u; output.result = 1u;
@ -1458,7 +1458,7 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
})"); })");
} else { } else {
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main() -> @location(0) u32 { fn main() -> @location(0) u32 {
return 1u; return 1u;
})"); })");

View File

@ -54,7 +54,7 @@ class BindGroupTests : public DawnTest {
wgpu::ShaderModule MakeSimpleVSModule() const { wgpu::ShaderModule MakeSimpleVSModule() const {
return utils::CreateShaderModule(device, R"( return utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -88,7 +88,7 @@ class BindGroupTests : public DawnTest {
} }
} }
fs << "\n@stage(fragment) fn main() -> @location(0) vec4<f32>{\n"; fs << "\n@fragment fn main() -> @location(0) vec4<f32>{\n";
fs << "var fragColor : vec4<f32> = vec4<f32>();\n"; fs << "var fragColor : vec4<f32> = vec4<f32>();\n";
for (size_t i = 0; i < bindingTypes.size(); ++i) { for (size_t i = 0; i < bindingTypes.size(); ++i) {
fs << "fragColor = fragColor + buffer" << i << ".color;\n"; fs << "fragColor = fragColor + buffer" << i << ".color;\n";
@ -137,7 +137,7 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
} }
@group(0) @binding(0) var <uniform> contents: Contents; @group(0) @binding(0) var <uniform> contents: Contents;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
var f : f32 = contents.f; var f : f32 = contents.f;
})"); })");
@ -173,7 +173,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer; @group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -190,7 +190,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
} }
@group(0) @binding(1) var <uniform> fragmentUbo : FragmentUniformBuffer; @group(0) @binding(1) var <uniform> fragmentUbo : FragmentUniformBuffer;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return fragmentUbo.color; return fragmentUbo.color;
})"); })");
@ -250,7 +250,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
} }
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer; @group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -265,7 +265,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
@group(0) @binding(1) var samp : sampler; @group(0) @binding(1) var samp : sampler;
@group(0) @binding(2) var tex : texture_2d<f32>; @group(0) @binding(2) var tex : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return textureSample(tex, samp, FragCoord.xy); return textureSample(tex, samp, FragCoord.xy);
})"); })");
@ -355,7 +355,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
@group(0) @binding(0) var <uniform> vertexUbo1 : VertexUniformBuffer; @group(0) @binding(0) var <uniform> vertexUbo1 : VertexUniformBuffer;
@group(1) @binding(0) var <uniform> vertexUbo2 : VertexUniformBuffer; @group(1) @binding(0) var <uniform> vertexUbo2 : VertexUniformBuffer;
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -376,7 +376,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
@group(0) @binding(1) var <uniform> fragmentUbo1 : FragmentUniformBuffer; @group(0) @binding(1) var <uniform> fragmentUbo1 : FragmentUniformBuffer;
@group(1) @binding(1) var <uniform> fragmentUbo2 : FragmentUniformBuffer; @group(1) @binding(1) var <uniform> fragmentUbo2 : FragmentUniformBuffer;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return fragmentUbo1.color + fragmentUbo2.color; return fragmentUbo1.color + fragmentUbo2.color;
})"); })");
@ -445,16 +445,16 @@ TEST_P(BindGroupTests, MultipleEntryPointsWithMultipleNonZeroGroups) {
@group(1) @binding(0) var <uniform> contents1: Contents; @group(1) @binding(0) var <uniform> contents1: Contents;
@group(2) @binding(0) var <uniform> contents2: Contents; @group(2) @binding(0) var <uniform> contents2: Contents;
@stage(compute) @workgroup_size(1) fn main0() { @compute @workgroup_size(1) fn main0() {
var a : f32 = contents0.f; var a : f32 = contents0.f;
} }
@stage(compute) @workgroup_size(1) fn main1() { @compute @workgroup_size(1) fn main1() {
var a : f32 = contents1.f; var a : f32 = contents1.f;
var b : f32 = contents2.f; var b : f32 = contents2.f;
} }
@stage(compute) @workgroup_size(1) fn main2() { @compute @workgroup_size(1) fn main2() {
var a : f32 = contents0.f; var a : f32 = contents0.f;
var b : f32 = contents1.f; var b : f32 = contents1.f;
var c : f32 = contents2.f; var c : f32 = contents2.f;
@ -1054,7 +1054,7 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
@group(0) @binding(0) var<storage, read> buffer0 : Buffer; @group(0) @binding(0) var<storage, read> buffer0 : Buffer;
@group(0) @binding(4) var<storage, read_write> outputBuffer : OutputBuffer; @group(0) @binding(4) var<storage, read_write> outputBuffer : OutputBuffer;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
outputBuffer.value = vec3<u32>(buffer0.value, buffer2.value, buffer3.value); outputBuffer.value = vec3<u32>(buffer0.value, buffer2.value, buffer3.value);
})"); })");
pipelineDescriptor.compute.entryPoint = "main"; pipelineDescriptor.compute.entryPoint = "main";
@ -1136,7 +1136,7 @@ TEST_P(BindGroupTests, DynamicAndNonDynamicBindingsDoNotConflictAfterRemapping)
@group(0) @binding(1) var<uniform> buffer1 : Buffer; @group(0) @binding(1) var<uniform> buffer1 : Buffer;
@group(0) @binding(2) var<storage, read_write> outputBuffer : OutputBuffer; @group(0) @binding(2) var<storage, read_write> outputBuffer : OutputBuffer;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
outputBuffer.value = vec2<u32>(buffer0.value, buffer1.value); outputBuffer.value = vec2<u32>(buffer0.value, buffer1.value);
})"); })");
pipelineDescriptor.compute.entryPoint = "main"; pipelineDescriptor.compute.entryPoint = "main";
@ -1239,7 +1239,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -1258,7 +1258,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
@group(0) @binding(47) var <uniform> ubo2 : Ubo; @group(0) @binding(47) var <uniform> ubo2 : Ubo;
@group(0) @binding(111) var <uniform> ubo3 : Ubo; @group(0) @binding(111) var <uniform> ubo3 : Ubo;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return ubo1.color + 2.0 * ubo2.color + 4.0 * ubo3.color; return ubo1.color + 2.0 * ubo2.color + 4.0 * ubo3.color;
})"); })");
@ -1358,7 +1358,7 @@ TEST_P(BindGroupTests, EmptyLayout) {
pipelineDesc.layout = utils::MakeBasicPipelineLayout(device, &bgl); pipelineDesc.layout = utils::MakeBasicPipelineLayout(device, &bgl);
pipelineDesc.compute.entryPoint = "main"; pipelineDesc.compute.entryPoint = "main";
pipelineDesc.compute.module = utils::CreateShaderModule(device, R"( pipelineDesc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc); wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
@ -1381,7 +1381,7 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor; utils::ComboRenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -1397,7 +1397,7 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
} }
@group(0) @binding(0) var<storage, read> buffer0 : Buffer0; @group(0) @binding(0) var<storage, read> buffer0 : Buffer0;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return buffer0.color; return buffer0.color;
})"); })");
@ -1550,7 +1550,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
body << "result.value = 1u;\n"; body << "result.value = 1u;\n";
std::string shader = std::string shader =
interface.str() + "@stage(compute) @workgroup_size(1) fn main() {\n" + body.str() + "}\n"; interface.str() + "@compute @workgroup_size(1) fn main() {\n" + body.str() + "}\n";
wgpu::ComputePipelineDescriptor cpDesc; wgpu::ComputePipelineDescriptor cpDesc;
cpDesc.compute.module = utils::CreateShaderModule(device, shader.c_str()); cpDesc.compute.module = utils::CreateShaderModule(device, shader.c_str());
cpDesc.compute.entryPoint = "main"; cpDesc.compute.entryPoint = "main";

View File

@ -212,7 +212,7 @@ class BufferZeroInitTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader); wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@location(0) i_color : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) i_color : vec4<f32>) -> @location(0) vec4<f32> {
return i_color; return i_color;
})"); })");
@ -256,7 +256,7 @@ class BufferZeroInitTest : public DawnTest {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) fn main(@location(0) pos : vec4<f32>) -> VertexOut { @vertex fn main(@location(0) pos : vec4<f32>) -> VertexOut {
var output : VertexOut; var output : VertexOut;
if (all(pos == vec4<f32>(0.0, 0.0, 0.0, 0.0))) { if (all(pos == vec4<f32>(0.0, 0.0, 0.0, 0.0))) {
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0); output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
@ -300,7 +300,7 @@ class BufferZeroInitTest : public DawnTest {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
var output : VertexOut; var output : VertexOut;
if (VertexIndex == 0u) { if (VertexIndex == 0u) {
@ -350,7 +350,7 @@ class BufferZeroInitTest : public DawnTest {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) fn main() -> VertexOut { @vertex fn main() -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0); output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0); output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -391,7 +391,7 @@ class BufferZeroInitTest : public DawnTest {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) fn main() -> VertexOut { @vertex fn main() -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0); output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0); output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -432,7 +432,7 @@ class BufferZeroInitTest : public DawnTest {
const char* computeShader = R"( const char* computeShader = R"(
@group(0) @binding(0) var outImage : texture_storage_2d<rgba8unorm, write>; @group(0) @binding(0) var outImage : texture_storage_2d<rgba8unorm, write>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0)); textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})"; })";
@ -1001,7 +1001,7 @@ TEST_P(BufferZeroInitTest, BoundAsUniformBuffer) {
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>; @group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
if (all(ubo.value == vec4<u32>(0u, 0u, 0u, 0u))) { if (all(ubo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0)); textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0));
} else { } else {
@ -1040,7 +1040,7 @@ TEST_P(BufferZeroInitTest, BoundAsReadonlyStorageBuffer) {
@group(0) @binding(0) var<storage, read> ssbo : SSBO; @group(0) @binding(0) var<storage, read> ssbo : SSBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>; @group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
if (all(ssbo.value == vec4<u32>(0u, 0u, 0u, 0u))) { if (all(ssbo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0)); textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0));
} else { } else {
@ -1079,7 +1079,7 @@ TEST_P(BufferZeroInitTest, BoundAsStorageBuffer) {
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>; @group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
if (all(ssbo.value[0] == vec4<u32>(0u, 0u, 0u, 0u)) && if (all(ssbo.value[0] == vec4<u32>(0u, 0u, 0u, 0u)) &&
all(ssbo.value[1] == vec4<u32>(0u, 0u, 0u, 0u))) { all(ssbo.value[1] == vec4<u32>(0u, 0u, 0u, 0u))) {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0)); textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0));
@ -1152,7 +1152,7 @@ TEST_P(BufferZeroInitTest, PaddingInitialized) {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) fn main(@location(0) pos : vec2<f32>) -> VertexOut { @vertex fn main(@location(0) pos : vec2<f32>) -> VertexOut {
var output : VertexOut; var output : VertexOut;
if (all(pos == vec2<f32>(0.0, 0.0))) { if (all(pos == vec2<f32>(0.0, 0.0))) {
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0); output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -26,7 +26,7 @@ class ClipSpaceTest : public DawnTest {
// 1. The depth value of the top-left one is >= 0.5 // 1. The depth value of the top-left one is >= 0.5
// 2. The depth value of the bottom-right one is <= 0.5 // 2. The depth value of the bottom-right one is <= 0.5
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec3<f32>, 6>( var pos = array<vec3<f32>, 6>(
vec3<f32>(-1.0, 1.0, 1.0), vec3<f32>(-1.0, 1.0, 1.0),
@ -39,7 +39,7 @@ class ClipSpaceTest : public DawnTest {
})"); })");
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
})"); })");

View File

@ -40,7 +40,7 @@ class ColorStateTest : public DawnTest {
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsWARP()); DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsWARP());
vsModule = utils::CreateShaderModule(device, R"( vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -68,7 +68,7 @@ class ColorStateTest : public DawnTest {
@group(0) @binding(0) var<uniform> myUbo : MyBlock; @group(0) @binding(0) var<uniform> myUbo : MyBlock;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return myUbo.color; return myUbo.color;
} }
)"); )");
@ -808,7 +808,7 @@ TEST_P(ColorStateTest, IndependentColorState) {
@location(3) fragColor3 : vec4<f32>, @location(3) fragColor3 : vec4<f32>,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.fragColor0 = myUbo.color0; output.fragColor0 = myUbo.color0;
output.fragColor1 = myUbo.color1; output.fragColor1 = myUbo.color1;
@ -922,7 +922,7 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
@group(0) @binding(0) var<uniform> myUbo : MyBlock; @group(0) @binding(0) var<uniform> myUbo : MyBlock;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return myUbo.color; return myUbo.color;
} }
)"); )");
@ -1048,7 +1048,7 @@ TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
@group(0) @binding(0) var<uniform> myUbo : MyBlock; @group(0) @binding(0) var<uniform> myUbo : MyBlock;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return myUbo.color; return myUbo.color;
} }
)"); )");
@ -1105,7 +1105,7 @@ TEST_P(ColorStateTest, SparseAttachmentsDifferentColorMask) {
@location(3) o3 : vec4<f32>, @location(3) o3 : vec4<f32>,
} }
@stage(fragment) fn main() -> Outputs { @fragment fn main() -> Outputs {
return Outputs(vec4<f32>(1.0), vec4<f32>(0.0, 1.0, 1.0, 1.0)); return Outputs(vec4<f32>(1.0), vec4<f32>(0.0, 1.0, 1.0, 1.0));
} }
)"); )");

View File

@ -168,7 +168,7 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-3.0, 1.0), vec2<f32>(-3.0, 1.0),
@ -184,7 +184,7 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d<f32>; @group(0) @binding(1) var texture0 : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, texCoord); return textureSample(texture0, sampler0, texCoord);
})"); })");

View File

@ -95,7 +95,7 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) {
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@stage(compute) @workgroup_size(1) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
let index : u32 = GlobalInvocationID.x; let index : u32 = GlobalInvocationID.x;
if (index >= 4u) { return; } if (index >= 4u) { return; }
@ -118,7 +118,7 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@stage(compute) @workgroup_size(1) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
let index : u32 = GlobalInvocationID.x; let index : u32 = GlobalInvocationID.x;
if (index >= 4u) { return; } if (index >= 4u) { return; }
@ -136,7 +136,7 @@ TEST_P(ComputeCopyStorageBufferTests, UnsizedArrayOfBasic) {
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@stage(compute) @workgroup_size(1) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
let index : u32 = GlobalInvocationID.x; let index : u32 = GlobalInvocationID.x;
if (index >= 4u) { return; } if (index >= 4u) { return; }

View File

@ -34,7 +34,7 @@ class ComputeDispatchTests : public DawnTest {
@group(0) @binding(0) var<storage, read_write> output : OutputBuf; @group(0) @binding(0) var<storage, read_write> output : OutputBuf;
@stage(compute) @workgroup_size(1, 1, 1) @compute @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>, fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>,
@builtin(num_workgroups) dispatch : vec3<u32>) { @builtin(num_workgroups) dispatch : vec3<u32>) {
if (dispatch.x == 0u || dispatch.y == 0u || dispatch.z == 0u) { if (dispatch.x == 0u || dispatch.y == 0u || dispatch.z == 0u) {
@ -64,7 +64,7 @@ class ComputeDispatchTests : public DawnTest {
@group(0) @binding(0) var<uniform> input : InputBuf; @group(0) @binding(0) var<uniform> input : InputBuf;
@group(0) @binding(1) var<storage, read_write> output : OutputBuf; @group(0) @binding(1) var<storage, read_write> output : OutputBuf;
@stage(compute) @workgroup_size(1, 1, 1) @compute @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
let dispatch : vec3<u32> = input.expectedDispatch; let dispatch : vec3<u32> = input.expectedDispatch;

View File

@ -190,7 +190,7 @@ struct Status {
@group(0) @binding(1) var<storage, read_write> output : Output; @group(0) @binding(1) var<storage, read_write> output : Output;
@group(0) @binding(2) var<storage, read_write> status : Status; @group(0) @binding(2) var<storage, read_write> status : Status;
@stage(compute) @workgroup_size(1,1,1) @compute @workgroup_size(1,1,1)
fn main() { fn main() {
if (input.header != {input_header_code}u) { if (input.header != {input_header_code}u) {
status.code = {status_bad_input_header}u; status.code = {status_bad_input_header}u;

View File

@ -81,7 +81,7 @@ TEST_P(ComputeSharedMemoryTests, Basic) {
@group(0) @binding(0) var<storage, write> dst : Dst; @group(0) @binding(0) var<storage, write> dst : Dst;
var<workgroup> tmp : u32; var<workgroup> tmp : u32;
@stage(compute) @workgroup_size(4,4,1) @compute @workgroup_size(4,4,1)
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) { fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
let index : u32 = LocalInvocationID.y * kTileSize + LocalInvocationID.x; let index : u32 = LocalInvocationID.y * kTileSize + LocalInvocationID.x;
if (index == 0u) { if (index == 0u) {
@ -124,7 +124,7 @@ TEST_P(ComputeSharedMemoryTests, AssortedTypes) {
var<workgroup> wg_array : array<u32, 4>; var<workgroup> wg_array : array<u32, 4>;
var<workgroup> wg_vector : vec4<f32>; var<workgroup> wg_vector : vec4<f32>;
@stage(compute) @workgroup_size(4,1,1) @compute @workgroup_size(4,1,1)
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) { fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
let i = 4u * LocalInvocationID.x; let i = 4u * LocalInvocationID.x;

View File

@ -39,7 +39,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddIncrement) {
@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) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234u; buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234u;
} }
@ -90,7 +90,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
@group(0) @binding(0) var<storage, read_write> src : Buf; @group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@stage(compute) @workgroup_size(1) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u; dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u;
} }
@ -156,7 +156,7 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
@group(0) @binding(0) var<storage, read> src : Buf; @group(0) @binding(0) var<storage, read> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@stage(compute) @workgroup_size(1) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u; dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u;
} }
@ -224,7 +224,7 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPong) {
@group(0) @binding(0) var<uniform> src : Buf; @group(0) @binding(0) var<uniform> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@stage(compute) @workgroup_size(1) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u); vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u);
@ -292,7 +292,7 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPongInOnePass) {
@group(0) @binding(0) var<uniform> src : Buf; @group(0) @binding(0) var<uniform> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf; @group(0) @binding(1) var<storage, read_write> dst : Buf;
@stage(compute) @workgroup_size(1) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u); vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u);
@ -348,7 +348,7 @@ TEST_P(ComputeStorageBufferBarrierTests, IndirectBufferCorrectBarrier) {
} }
@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() { @compute @workgroup_size(1) fn main() {
buf.data = array<u32, 3>(1u, 1u, 1u); buf.data = array<u32, 3>(1u, 1u, 1u);
} }
)"); )");
@ -367,7 +367,7 @@ TEST_P(ComputeStorageBufferBarrierTests, IndirectBufferCorrectBarrier) {
} }
@group(0) @binding(1) var<storage, read_write> result : Result; @group(0) @binding(1) var<storage, read_write> result : Result;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
result.data = 2u; result.data = 2u;
if (buf.data[0] == 1u && buf.data[1] == 1u && buf.data[2] == 1u) { if (buf.data[0] == 1u && buf.data[1] == 1u && buf.data[2] == 1u) {
result.data = 1u; result.data = 1u;

View File

@ -267,7 +267,7 @@ class CopyTextureForBrowserTests : public Parent {
// The value diff should be smaller than the hard coded tolerance. // The value diff should be smaller than the hard coded tolerance.
return abs(value - expect) < 0.01; return abs(value - expect) < 0.01;
} }
@stage(compute) @workgroup_size(1, 1, 1) @compute @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
let srcSize = textureDimensions(src); let srcSize = textureDimensions(src);
let dstSize = textureDimensions(dst); let dstSize = textureDimensions(dst);

View File

@ -135,7 +135,7 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateComputePipelineAsync) {
} }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
ssbo.value = 1u; ssbo.value = 1u;
})"); })");
csDesc.compute.entryPoint = "main"; csDesc.compute.entryPoint = "main";
@ -165,7 +165,7 @@ TEST_P(CreatePipelineAsyncTest, ReleaseEntryPointAfterCreatComputePipelineAsync)
} }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
ssbo.value = 1u; ssbo.value = 1u;
})"); })");
@ -204,7 +204,7 @@ TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
} }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
ssbo.value = 1u; ssbo.value = 1u;
})"); })");
csDesc.compute.entryPoint = "main0"; csDesc.compute.entryPoint = "main0";
@ -236,11 +236,11 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertex.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
@ -260,11 +260,11 @@ TEST_P(CreatePipelineAsyncTest, ReleaseEntryPointsAfterCreateRenderPipelineAsync
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertex.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
@ -325,11 +325,11 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertex.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
@ -363,7 +363,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipelineAsync) { TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipelineAsync) {
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
csDesc.compute.entryPoint = "main"; csDesc.compute.entryPoint = "main";
@ -387,11 +387,11 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipeli
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) { TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertex.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
@ -419,7 +419,7 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelin
TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateComputePipelineAsync) { TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateComputePipelineAsync) {
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
csDesc.compute.entryPoint = "main"; csDesc.compute.entryPoint = "main";
@ -444,11 +444,11 @@ TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateComputePipeli
TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateRenderPipelineAsync) { TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertex.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
@ -482,7 +482,7 @@ TEST_P(CreatePipelineAsyncTest, CreateSameComputePipelineTwice) {
} }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
ssbo.value = 1u; ssbo.value = 1u;
})"); })");
csDesc.compute.entryPoint = "main"; csDesc.compute.entryPoint = "main";
@ -541,7 +541,7 @@ TEST_P(CreatePipelineAsyncTest, CreateSameComputePipelineTwiceAtSameTime) {
} }
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO; @group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
ssbo.value = 1u; ssbo.value = 1u;
})"); })");
csDesc.compute.entryPoint = "main"; csDesc.compute.entryPoint = "main";
@ -578,11 +578,11 @@ TEST_P(CreatePipelineAsyncTest, CreateSameRenderPipelineTwiceAtSameTime) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.vertex.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
@ -639,7 +639,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithVertexBufferLayouts
@builtin(position) position: vec4<f32>, @builtin(position) position: vec4<f32>,
} }
@stage(vertex) @vertex
fn main(vertexInput : VertexInput) -> VertexOutput { fn main(vertexInput : VertexInput) -> VertexOutput {
var vertexOutput : VertexOutput; var vertexOutput : VertexOutput;
vertexOutput.position = vec4<f32>(0.0, 0.0, 0.0, 1.0); vertexOutput.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -651,7 +651,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithVertexBufferLayouts
return vertexOutput; return vertexOutput;
})"); })");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@location(0) fragColorIn : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) fragColorIn : vec4<f32>) -> @location(0) vec4<f32> {
return fragColorIn; return fragColorIn;
})"); })");
@ -731,12 +731,12 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithDepthStencilState)
{ {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main() -> @builtin(position) vec4<f32> { fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main() -> @location(0) vec4<f32> { fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
})"); })");
@ -803,12 +803,12 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineWithMultisampleState) {
{ {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main() -> @builtin(position) vec4<f32> { fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main() -> @location(0) vec4<f32> { fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
@ -875,7 +875,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithBlendState) {
{ {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor; utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main() -> @builtin(position) vec4<f32> { fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
@ -885,7 +885,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithBlendState) {
@location(1) fragColor1 : vec4<f32>, @location(1) fragColor1 : vec4<f32>,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.fragColor0 = vec4<f32>(0.4, 0.0, 0.0, 0.4); output.fragColor0 = vec4<f32>(0.4, 0.0, 0.0, 0.4);
output.fragColor1 = vec4<f32>(0.0, 1.0, 0.0, 1.0); output.fragColor1 = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -26,7 +26,7 @@ class CullingTest : public DawnTest {
// 1. The top-left one is counterclockwise (CCW) // 1. The top-left one is counterclockwise (CCW)
// 2. The bottom-right one is clockwise (CW) // 2. The bottom-right one is clockwise (CW)
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -42,7 +42,7 @@ class CullingTest : public DawnTest {
// RGBA8 format for the back buffer. So (FragCoord.xy - vec2(0.5)) / 255 in shader code // RGBA8 format for the back buffer. So (FragCoord.xy - vec2(0.5)) / 255 in shader code
// will make the pixel's R and G channels exactly equal to the pixel's x and y coordinates. // will make the pixel's R and G channels exactly equal to the pixel's x and y coordinates.
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return vec4<f32>( return vec4<f32>(
(FragCoord.xy - vec2<f32>(0.5, 0.5)) / vec2<f32>(255.0, 255.0), (FragCoord.xy - vec2<f32>(0.5, 0.5)) / vec2<f32>(255.0, 255.0),

View File

@ -45,11 +45,11 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
mMockCache.Disable(); mMockCache.Disable();
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> { @vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
} }
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> { @fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
@ -82,11 +82,11 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
// entrypoints) // entrypoints)
TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) { TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> { @vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
} }
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> { @fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
@ -115,11 +115,11 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
// Modify the WGSL shader functions and make sure it doesn't hit. // Modify the WGSL shader functions and make sure it doesn't hit.
wgpu::ShaderModule newModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule newModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> { @vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0); return vec4<f32>(1.0, 1.0, 1.0, 1.0);
} }
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> { @fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0); return vec4<f32>(1.0, 1.0, 1.0, 1.0);
} }
)"); )");
@ -144,11 +144,11 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPoints) {
} }
@binding(0) @group(0) var<storage, read_write> data : Data; @binding(0) @group(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn write1() { @compute @workgroup_size(1) fn write1() {
data.data = 1u; data.data = 1u;
} }
@stage(compute) @workgroup_size(1) fn write42() { @compute @workgroup_size(1) fn write42() {
data.data = 42u; data.data = 42u;
} }
)"); )");

View File

@ -142,7 +142,7 @@ TEST_P(DeprecationTests, EndPass) {
// Test that dispatch() and dispatchIndirect() is deprecated. // Test that dispatch() and dispatchIndirect() is deprecated.
TEST_P(DeprecationTests, Dispatch) { TEST_P(DeprecationTests, Dispatch) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1, 1, 1) @compute @workgroup_size(1, 1, 1)
fn main() { fn main() {
})"); })");

View File

@ -39,7 +39,7 @@ class DepthBiasTests : public DawnTest {
case QuadAngle::Flat: case QuadAngle::Flat:
// Draw a square at z = 0.25 // Draw a square at z = 0.25
vertexSource = R"( vertexSource = R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -55,7 +55,7 @@ class DepthBiasTests : public DawnTest {
case QuadAngle::TiltedX: case QuadAngle::TiltedX:
// Draw a square ranging from 0 to 0.5, bottom to top // Draw a square ranging from 0 to 0.5, bottom to top
vertexSource = R"( vertexSource = R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec3<f32>, 6>( var pos = array<vec3<f32>, 6>(
vec3<f32>(-1.0, -1.0, 0.0), vec3<f32>(-1.0, -1.0, 0.0),
@ -72,7 +72,7 @@ class DepthBiasTests : public DawnTest {
wgpu::ShaderModule vertexModule = utils::CreateShaderModule(device, vertexSource); wgpu::ShaderModule vertexModule = utils::CreateShaderModule(device, vertexSource);
wgpu::ShaderModule fragmentModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fragmentModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
})"); })");

View File

@ -48,7 +48,7 @@ class DepthStencilCopyTests : public DawnTestWithParams<DepthStencilCopyTestPara
// Draw a square in the bottom left quarter of the screen. // Draw a square in the bottom left quarter of the screen.
mVertexModule = utils::CreateShaderModule(device, R"( mVertexModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -148,12 +148,12 @@ class DepthStencilCopyTests : public DawnTestWithParams<DepthStencilCopyTestPara
if (utils::IsStencilOnlyFormat(format)) { if (utils::IsStencilOnlyFormat(format)) {
depthStencil->depthCompare = wgpu::CompareFunction::Always; depthStencil->depthCompare = wgpu::CompareFunction::Always;
renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() {} @fragment fn main() {}
)"); )");
} else { } else {
depthStencil->depthWriteEnabled = true; depthStencil->depthWriteEnabled = true;
renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, std::string(R"( renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, std::string(R"(
@stage(fragment) fn main() -> @builtin(frag_depth) f32 { @fragment fn main() -> @builtin(frag_depth) f32 {
return )" + std::to_string(regionDepth) + R"(; return )" + std::to_string(regionDepth) + R"(;
})") })")
.c_str()); .c_str());
@ -704,7 +704,7 @@ TEST_P(StencilCopyTests, ToStencilAspect) {
utils::ComboRenderPipelineDescriptor renderPipelineDesc; utils::ComboRenderPipelineDescriptor renderPipelineDesc;
renderPipelineDesc.vertex.module = mVertexModule; renderPipelineDesc.vertex.module = mVertexModule;
renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
renderPipelineDesc.cFragment.targetCount = 0; renderPipelineDesc.cFragment.targetCount = 0;
wgpu::DepthStencilState* depthStencil = wgpu::DepthStencilState* depthStencil =

View File

@ -134,7 +134,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
wgpu::RenderPipeline CreateSamplingRenderPipeline(std::vector<TestAspect> aspects, wgpu::RenderPipeline CreateSamplingRenderPipeline(std::vector<TestAspect> aspects,
std::vector<uint32_t> components) { std::vector<uint32_t> components) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
@ -146,7 +146,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
GenerateSamplingShader(aspects, components, shaderSource, shaderBody); GenerateSamplingShader(aspects, components, shaderSource, shaderBody);
shaderSource << "@stage(fragment) fn main() -> @location(0) vec4<f32> {\n"; shaderSource << "@fragment fn main() -> @location(0) vec4<f32> {\n";
shaderSource << shaderBody.str() << "return vec4<f32>();\n }"; shaderSource << shaderBody.str() << "return vec4<f32>();\n }";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, shaderSource.str().c_str()); wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, shaderSource.str().c_str());
@ -164,8 +164,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
std::ostringstream shaderBody; std::ostringstream shaderBody;
GenerateSamplingShader(aspects, components, shaderSource, shaderBody); GenerateSamplingShader(aspects, components, shaderSource, shaderBody);
shaderSource << "@stage(compute) @workgroup_size(1) fn main() { " << shaderBody.str() shaderSource << "@compute @workgroup_size(1) fn main() { " << shaderBody.str() << "\n}";
<< "\n}";
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, shaderSource.str().c_str()); wgpu::ShaderModule csModule = utils::CreateShaderModule(device, shaderSource.str().c_str());
@ -190,7 +189,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
wgpu::RenderPipeline CreateComparisonRenderPipeline() { wgpu::RenderPipeline CreateComparisonRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
@ -202,7 +201,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
} }
@group(0) @binding(2) var<uniform> uniforms : Uniforms; @group(0) @binding(2) var<uniform> uniforms : Uniforms;
@stage(fragment) fn main() -> @location(0) f32 { @fragment fn main() -> @location(0) f32 {
return textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef); return textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef);
})"); })");
@ -229,7 +228,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
} }
@group(0) @binding(3) var<storage, read_write> samplerResult : SamplerResult; @group(0) @binding(3) var<storage, read_write> samplerResult : SamplerResult;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
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

@ -63,7 +63,7 @@ class DepthStencilStateTest : public DawnTest {
} }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -82,7 +82,7 @@ class DepthStencilStateTest : public DawnTest {
} }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(ubo.color, 1.0); return vec4<f32>(ubo.color, 1.0);
})"); })");
} }

View File

@ -31,13 +31,13 @@ class DestroyTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -286,7 +286,7 @@ TEST_P(DeviceLifetimeTests, DroppedWhileWriteBufferAndSubmit) {
TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsync) { TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsync) {
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
@ -306,7 +306,7 @@ TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsync) {
TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsync) { TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsync) {
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
@ -343,7 +343,7 @@ TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsync) {
TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsyncAlreadyCached) { TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsyncAlreadyCached) {
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
@ -372,7 +372,7 @@ TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsyncAlreadyCached) {
TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsyncAlreadyCached) { TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsyncAlreadyCached) {
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
@ -413,7 +413,7 @@ TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsyncAlreadyCached) {
TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsyncRaceCache) { TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsyncRaceCache) {
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
@ -437,7 +437,7 @@ TEST_P(DeviceLifetimeTests, DroppedWhileCreatePipelineAsyncRaceCache) {
TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsyncRaceCache) { TEST_P(DeviceLifetimeTests, DroppedInsideCreatePipelineAsyncRaceCache) {
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";

View File

@ -93,7 +93,7 @@ TEST_P(DeviceLostTest, GetBindGroupLayoutFails) {
pos : vec4<f32> pos : vec4<f32>
} }
@group(0) @binding(0) var<uniform> ubo : UniformBuffer; @group(0) @binding(0) var<uniform> ubo : UniformBuffer;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
wgpu::ComputePipelineDescriptor descriptor; wgpu::ComputePipelineDescriptor descriptor;
@ -176,7 +176,7 @@ TEST_P(DeviceLostTest, CreateShaderModuleFails) {
LoseDeviceForTesting(); LoseDeviceForTesting();
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
return color; return color;
})")); })"));
@ -423,7 +423,7 @@ TEST_P(DeviceLostTest, DeviceLostDoesntCallUncapturedError) {
// before the callback of Create*PipelineAsync() is called. // before the callback of Create*PipelineAsync() is called.
TEST_P(DeviceLostTest, DeviceLostBeforeCreatePipelineAsyncCallback) { TEST_P(DeviceLostTest, DeviceLostBeforeCreatePipelineAsyncCallback) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
wgpu::ComputePipelineDescriptor descriptor; wgpu::ComputePipelineDescriptor descriptor;

View File

@ -37,13 +37,13 @@ class DrawIndexedIndirectTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
@ -664,7 +664,7 @@ TEST_P(DrawIndexedIndirectTest, ValidateReusedBundleWithChangingParams) {
} }
@group(0) @binding(0) var<uniform> input: Input; @group(0) @binding(0) var<uniform> input: Input;
@group(0) @binding(1) var<storage, write> params: Params; @group(0) @binding(1) var<storage, write> params: Params;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
params.indexCount = 3u; params.indexCount = 3u;
params.instanceCount = 1u; params.instanceCount = 1u;
params.firstIndex = input.firstIndex; params.firstIndex = input.firstIndex;

View File

@ -27,13 +27,13 @@ class DrawIndexedTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -27,13 +27,13 @@ class DrawIndirectTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -27,13 +27,13 @@ class DrawTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -104,7 +104,7 @@ class DynamicBufferOffsetTests : public DawnTest {
wgpu::RenderPipeline CreateRenderPipeline(bool isInheritedPipeline = false) { wgpu::RenderPipeline CreateRenderPipeline(bool isInheritedPipeline = false) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 0.0), vec2<f32>(-1.0, 0.0),
@ -135,7 +135,7 @@ class DynamicBufferOffsetTests : public DawnTest {
fs << "let multipleNumber : u32 = " << multipleNumber << "u;\n"; fs << "let multipleNumber : u32 = " << multipleNumber << "u;\n";
fs << R"( fs << R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
sBufferNotDynamic.value = uBufferNotDynamic.value.xy; sBufferNotDynamic.value = uBufferNotDynamic.value.xy;
sBuffer.value = vec2<u32>(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy); sBuffer.value = vec2<u32>(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy);
return vec4<f32>(f32(uBuffer.value.x) / 255.0, f32(uBuffer.value.y) / 255.0, return vec4<f32>(f32(uBuffer.value.x) / 255.0, f32(uBuffer.value.y) / 255.0,
@ -185,7 +185,7 @@ class DynamicBufferOffsetTests : public DawnTest {
cs << "let multipleNumber : u32 = " << multipleNumber << "u;\n"; cs << "let multipleNumber : u32 = " << multipleNumber << "u;\n";
cs << R"( cs << R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
sBufferNotDynamic.value = uBufferNotDynamic.value.xy; sBufferNotDynamic.value = uBufferNotDynamic.value.xy;
sBuffer.value = vec2<u32>(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy); sBuffer.value = vec2<u32>(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy);
} }
@ -480,7 +480,7 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
@group(0) @binding(1) var<storage, read_write> dst : Dst; @group(0) @binding(1) var<storage, read_write> dst : Dst;
)"; )";
shader << R"( shader << R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
for (var i: u32 = 0u; i < kArrayLength; i = i + 1u) { for (var i: u32 = 0u; i < kArrayLength; i = i + 1u) {
dst.values[i + kWriteOffset] = src.values[i + kReadOffset]; dst.values[i + kWriteOffset] = src.values[i + kReadOffset];
} }

View File

@ -24,11 +24,11 @@ TEST_P(EntryPointTests, FragAndVertexSameModule) {
// TODO(crbug.com/dawn/658): Crashes on bots // TODO(crbug.com/dawn/658): Crashes on bots
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES()); DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> { @vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
} }
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> { @fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
@ -83,12 +83,12 @@ TEST_P(EntryPointTests, TwoComputeInModule) {
} }
@binding(0) @group(0) var<storage, read_write> data : Data; @binding(0) @group(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn write1() { @compute @workgroup_size(1) fn write1() {
data.data = 1u; data.data = 1u;
return; return;
} }
@stage(compute) @workgroup_size(1) fn write42() { @compute @workgroup_size(1) fn write42() {
data.data = 42u; data.data = 42u;
return; return;
} }

View File

@ -56,7 +56,7 @@ TEST_P(ExperimentalDP4aTests, BasicDP4aFeaturesTest) {
} }
@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) @compute @workgroup_size(1)
fn main() { fn main() {
var a = 0xFFFFFFFFu; var a = 0xFFFFFFFFu;
var b = 0xFFFFFFFEu; var b = 0xFFFFFFFEu;

View File

@ -84,7 +84,7 @@ TEST_P(ExternalTextureTests, SampleExternalTexture) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES()); DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
const wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( const wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var positions = array<vec4<f32>, 3>( var positions = array<vec4<f32>, 3>(
vec4<f32>(-1.0, 1.0, 0.0, 1.0), vec4<f32>(-1.0, 1.0, 0.0, 1.0),
vec4<f32>(-1.0, -1.0, 0.0, 1.0), vec4<f32>(-1.0, -1.0, 0.0, 1.0),
@ -97,7 +97,7 @@ TEST_P(ExternalTextureTests, SampleExternalTexture) {
@group(0) @binding(0) var s : sampler; @group(0) @binding(0) var s : sampler;
@group(0) @binding(1) var t : texture_external; @group(0) @binding(1) var t : texture_external;
@stage(fragment) fn main(@builtin(position) FragCoord : vec4<f32>) @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> { -> @location(0) vec4<f32> {
return textureSampleLevel(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0)); return textureSampleLevel(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0));
})"); })");
@ -169,7 +169,7 @@ TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES()); DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
const wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( const wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var positions = array<vec4<f32>, 3>( var positions = array<vec4<f32>, 3>(
vec4<f32>(-1.0, 1.0, 0.0, 1.0), vec4<f32>(-1.0, 1.0, 0.0, 1.0),
vec4<f32>(-1.0, -1.0, 0.0, 1.0), vec4<f32>(-1.0, -1.0, 0.0, 1.0),
@ -182,7 +182,7 @@ TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) {
@group(0) @binding(0) var s : sampler; @group(0) @binding(0) var s : sampler;
@group(0) @binding(1) var t : texture_external; @group(0) @binding(1) var t : texture_external;
@stage(fragment) fn main(@builtin(position) FragCoord : vec4<f32>) @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> { -> @location(0) vec4<f32> {
return textureSampleLevel(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0)); return textureSampleLevel(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0));
})"); })");

View File

@ -135,7 +135,7 @@ struct VertexInputs {
struct VertexOutputs { struct VertexOutputs {
)" + vertexOutputs.str() + R"( )" + vertexOutputs.str() + R"(
} }
@stage(vertex) fn main(input : VertexInputs) -> VertexOutputs { @vertex fn main(input : VertexInputs) -> VertexOutputs {
var output : VertexOutputs; var output : VertexOutputs;
)" + vertexBody.str() + R"( )" + vertexBody.str() + R"(
output.position = input.position; output.position = input.position;
@ -152,7 +152,7 @@ struct IndexVals {
struct FragInputs { struct FragInputs {
)" + fragmentInputs.str() + R"( )" + fragmentInputs.str() + R"(
} }
@stage(fragment) fn main(input : FragInputs) { @fragment fn main(input : FragInputs) {
)" + fragmentBody.str() + R"( )" + fragmentBody.str() + R"(
})"; })";

View File

@ -43,7 +43,7 @@ class GpuMemorySyncTests : public DawnTest {
a : i32 a : i32
} }
@group(0) @binding(0) var<storage, read_write> data : Data; @group(0) @binding(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
data.a = data.a + 1; data.a = data.a + 1;
})"); })");
@ -61,7 +61,7 @@ class GpuMemorySyncTests : public DawnTest {
const wgpu::Buffer& buffer, const wgpu::Buffer& buffer,
wgpu::TextureFormat colorFormat) { wgpu::TextureFormat colorFormat) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
@ -70,7 +70,7 @@ class GpuMemorySyncTests : public DawnTest {
i : i32 i : i32
} }
@group(0) @binding(0) var<storage, read_write> data : Data; @group(0) @binding(0) var<storage, read_write> data : Data;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
data.i = data.i + 1; data.i = data.i + 1;
return vec4<f32>(f32(data.i) / 255.0, 0.0, 0.0, 1.0); return vec4<f32>(f32(data.i) / 255.0, 0.0, 0.0, 1.0);
})"); })");
@ -235,7 +235,7 @@ class StorageToUniformSyncTests : public DawnTest {
a : f32 a : f32
} }
@group(0) @binding(0) var<storage, read_write> data : Data; @group(0) @binding(0) var<storage, read_write> data : Data;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
data.a = 1.0; data.a = 1.0;
})"); })");
@ -252,7 +252,7 @@ class StorageToUniformSyncTests : public DawnTest {
std::tuple<wgpu::RenderPipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForRender( std::tuple<wgpu::RenderPipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForRender(
wgpu::TextureFormat colorFormat) { wgpu::TextureFormat colorFormat) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
@ -262,7 +262,7 @@ class StorageToUniformSyncTests : public DawnTest {
} }
@group(0) @binding(0) var<uniform> contents : Contents; @group(0) @binding(0) var<uniform> contents : Contents;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(contents.color, 0.0, 0.0, 1.0); return vec4<f32>(contents.color, 0.0, 0.0, 1.0);
})"); })");
@ -432,7 +432,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
@group(0) @binding(2) var<storage, read_write> uniformContents : ColorContents; @group(0) @binding(2) var<storage, read_write> uniformContents : ColorContents;
@group(0) @binding(3) var<storage, read_write> storageContents : ColorContents; @group(0) @binding(3) var<storage, read_write> storageContents : ColorContents;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
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);
vbContents.pos[1] = vec4<f32>(1.0, 1.0, 0.0, 1.0); vbContents.pos[1] = vec4<f32>(1.0, 1.0, 0.0, 1.0);
vbContents.pos[2] = vec4<f32>(1.0, -1.0, 0.0, 1.0); vbContents.pos[2] = vec4<f32>(1.0, -1.0, 0.0, 1.0);
@ -473,7 +473,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
// Create pipeline, bind group, and reuse buffers in render pass. // Create pipeline, bind group, and reuse buffers in render pass.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
@ -486,7 +486,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
@group(0) @binding(0) var<uniform> uniformBuffer : Buf; @group(0) @binding(0) var<uniform> uniformBuffer : Buf;
@group(0) @binding(1) var<storage, read> storageBuffer : Buf; @group(0) @binding(1) var<storage, read> storageBuffer : Buf;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0); return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
})"); })");
@ -547,7 +547,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
@group(0) @binding(0) var<storage, read_write> contents : Contents; @group(0) @binding(0) var<storage, read_write> contents : Contents;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
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);
contents.pos[1] = vec4<f32>(1.0, 1.0, 0.0, 1.0); contents.pos[1] = vec4<f32>(1.0, 1.0, 0.0, 1.0);
contents.pos[2] = vec4<f32>(1.0, -1.0, 0.0, 1.0); contents.pos[2] = vec4<f32>(1.0, -1.0, 0.0, 1.0);
@ -590,7 +590,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
// Create pipeline, bind group, and reuse the buffer in render pass. // Create pipeline, bind group, and reuse the buffer in render pass.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
@ -602,7 +602,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
@group(0) @binding(0) var<uniform> uniformBuffer : Buf; @group(0) @binding(0) var<uniform> uniformBuffer : Buf;
@group(0) @binding(1) var<storage, read> storageBuffer : Buf; @group(0) @binding(1) var<storage, read> storageBuffer : Buf;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0); return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
})"); })");

View File

@ -229,7 +229,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-2.0, -2.0), vec2<f32>(-2.0, -2.0),
@ -257,7 +257,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d<f32>; @group(0) @binding(1) var texture0 : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, texCoord); return textureSample(texture0, sampler0, texCoord);
} }

View File

@ -39,7 +39,7 @@ class IndexFormatTest : public DawnTest {
@builtin(vertex_index) idx : u32, @builtin(vertex_index) idx : u32,
} }
@stage(vertex) fn main(input : VertexIn) -> @builtin(position) vec4<f32> { @vertex fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
// 0xFFFFFFFE is a designated invalid index used by some tests. // 0xFFFFFFFE is a designated invalid index used by some tests.
if (input.idx == 0xFFFFFFFEu) { if (input.idx == 0xFFFFFFFEu) {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -48,7 +48,7 @@ class IndexFormatTest : public DawnTest {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -52,7 +52,7 @@ TEST_P(MaxLimitTests, MaxComputeWorkgroupStorageSize) {
} }
var<workgroup> wg_data : WGData; var<workgroup> wg_data : WGData;
@stage(compute) @workgroup_size(2,1,1) @compute @workgroup_size(2,1,1)
fn main(@builtin(local_invocation_index) LocalInvocationIndex : u32) { fn main(@builtin(local_invocation_index) LocalInvocationIndex : u32) {
if (LocalInvocationIndex == 0u) { if (LocalInvocationIndex == 0u) {
// Put data into the first and last byte of workgroup memory. // Put data into the first and last byte of workgroup memory.
@ -144,7 +144,7 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
@group(0) @binding(0) var<storage, read> buf : Buf; @group(0) @binding(0) var<storage, read> buf : Buf;
@group(0) @binding(1) var<storage, write> result : Result; @group(0) @binding(1) var<storage, write> result : Result;
@stage(compute) @workgroup_size(1,1,1) @compute @workgroup_size(1,1,1)
fn main() { fn main() {
result.value0 = buf.values[0]; result.value0 = buf.values[0];
result.value1 = buf.values[arrayLength(&buf.values) - 1u]; result.value1 = buf.values[arrayLength(&buf.values) - 1u];
@ -175,7 +175,7 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
@group(0) @binding(0) var<uniform> buf : Buf; @group(0) @binding(0) var<uniform> buf : Buf;
@group(0) @binding(1) var<storage, write> result : Result; @group(0) @binding(1) var<storage, write> result : Result;
@stage(compute) @workgroup_size(1,1,1) @compute @workgroup_size(1,1,1)
fn main() { fn main() {
result.value0 = buf.value0; result.value0 = buf.value0;
result.value1 = buf.value1; result.value1 = buf.value1;

View File

@ -57,7 +57,7 @@ class MultisampledRenderingTest : public DawnTest {
@builtin(frag_depth) depth : f32, @builtin(frag_depth) depth : f32,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.color = uBuffer.color; output.color = uBuffer.color;
output.depth = uBuffer.depth; output.depth = uBuffer.depth;
@ -70,7 +70,7 @@ class MultisampledRenderingTest : public DawnTest {
} }
@group(0) @binding(0) var<uniform> uBuffer : U; @group(0) @binding(0) var<uniform> uBuffer : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return uBuffer.color; return uBuffer.color;
})"; })";
@ -95,7 +95,7 @@ class MultisampledRenderingTest : public DawnTest {
@location(1) color1 : vec4<f32>, @location(1) color1 : vec4<f32>,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.color0 = uBuffer.color0; output.color0 = uBuffer.color0;
output.color1 = uBuffer.color1; output.color1 = uBuffer.color1;
@ -224,7 +224,7 @@ class MultisampledRenderingTest : public DawnTest {
// Draw a bottom-right triangle. In standard 4xMSAA pattern, for the pixels on diagonal, // Draw a bottom-right triangle. In standard 4xMSAA pattern, for the pixels on diagonal,
// only two of the samples will be touched. // only two of the samples will be touched.
const char* vs = R"( const char* vs = R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -236,7 +236,7 @@ class MultisampledRenderingTest : public DawnTest {
// Draw a bottom-left triangle. // Draw a bottom-left triangle.
const char* vsFlipped = R"( const char* vsFlipped = R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -753,7 +753,7 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOut
@builtin(sample_mask) sampleMask : u32, @builtin(sample_mask) sampleMask : u32,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.color = uBuffer.color; output.color = uBuffer.color;
output.sampleMask = 6u; output.sampleMask = 6u;
@ -808,7 +808,7 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOut
@builtin(sample_mask) sampleMask : u32, @builtin(sample_mask) sampleMask : u32,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.color0 = uBuffer.color0; output.color0 = uBuffer.color0;
output.color1 = uBuffer.color1; output.color1 = uBuffer.color1;

View File

@ -55,7 +55,7 @@ class MultisampledSamplingTest : public DawnTest {
utils::ComboRenderPipelineDescriptor desc; utils::ComboRenderPipelineDescriptor desc;
desc.vertex.module = utils::CreateShaderModule(device, R"( desc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> {
return vec4<f32>(pos, 0.0, 1.0); return vec4<f32>(pos, 0.0, 1.0);
})"); })");
@ -66,7 +66,7 @@ class MultisampledSamplingTest : public DawnTest {
@builtin(frag_depth) depth : f32, @builtin(frag_depth) depth : f32,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.color = 1.0; output.color = 1.0;
output.depth = 0.7; output.depth = 0.7;
@ -103,7 +103,7 @@ class MultisampledSamplingTest : public DawnTest {
} }
@group(0) @binding(2) var<storage, read_write> results : Results; @group(0) @binding(2) var<storage, read_write> results : Results;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
for (var i : i32 = 0; i < 4; i = i + 1) { for (var i : i32 = 0; i < 4; i = i + 1) {
results.colorSamples[i] = textureLoad(texture0, vec2<i32>(0, 0), i).x; results.colorSamples[i] = textureLoad(texture0, vec2<i32>(0, 0), i).x;
results.depthSamples[i] = textureLoad(texture1, vec2<i32>(0, 0), i); results.depthSamples[i] = textureLoad(texture1, vec2<i32>(0, 0), i);

View File

@ -104,15 +104,15 @@ TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
// Test that ShaderModules are correctly deduplicated. // Test that ShaderModules are correctly deduplicated.
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) { TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
@ -124,16 +124,16 @@ TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) { TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
var<workgroup> i : u32; var<workgroup> i : u32;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
i = 0u; i = 0u;
})"); })");
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
var<workgroup> i : u32; var<workgroup> i : u32;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
i = 0u; i = 0u;
})"); })");
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
EXPECT_NE(module.Get(), otherModule.Get()); EXPECT_NE(module.Get(), otherModule.Get());
@ -176,7 +176,7 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
var<workgroup> i : u32; var<workgroup> i : u32;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
i = 0u; i = 0u;
})"); })");
@ -210,11 +210,11 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
utils::ComboRenderPipelineDescriptor desc; utils::ComboRenderPipelineDescriptor desc;
desc.cTargets[0].writeMask = wgpu::ColorWriteMask::None; desc.cTargets[0].writeMask = wgpu::ColorWriteMask::None;
desc.vertex.module = utils::CreateShaderModule(device, R"( desc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
desc.cFragment.module = utils::CreateShaderModule(device, R"( desc.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
desc.layout = pl; desc.layout = pl;
@ -233,15 +233,15 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
// Test that RenderPipelines are correctly deduplicated wrt. their vertex module // Test that RenderPipelines are correctly deduplicated wrt. their vertex module
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) { TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0); return vec4<f32>(1.0, 1.0, 1.0, 1.0);
})"); })");
@ -251,7 +251,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
utils::ComboRenderPipelineDescriptor desc; utils::ComboRenderPipelineDescriptor desc;
desc.cTargets[0].writeMask = wgpu::ColorWriteMask::None; desc.cTargets[0].writeMask = wgpu::ColorWriteMask::None;
desc.cFragment.module = utils::CreateShaderModule(device, R"( desc.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
desc.vertex.module = module; desc.vertex.module = module;
@ -270,13 +270,13 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
// Test that RenderPipelines are correctly deduplicated wrt. their fragment module // Test that RenderPipelines are correctly deduplicated wrt. their fragment module
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) { TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
@ -285,7 +285,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
utils::ComboRenderPipelineDescriptor desc; utils::ComboRenderPipelineDescriptor desc;
desc.vertex.module = utils::CreateShaderModule(device, R"( desc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");

View File

@ -130,7 +130,7 @@ TEST_P(OpArrayLengthTest, Compute) {
} }
@group(1) @binding(0) var<storage, read_write> result : ResultBuffer; @group(1) @binding(0) var<storage, read_write> result : ResultBuffer;
)" + mShaderInterface + R"( )" + mShaderInterface + R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
result.data[0] = arrayLength(&buffer1.data); result.data[0] = arrayLength(&buffer1.data);
result.data[1] = arrayLength(&buffer2.data); result.data[1] = arrayLength(&buffer2.data);
result.data[2] = arrayLength(&buffer3.data); result.data[2] = arrayLength(&buffer3.data);
@ -168,12 +168,12 @@ TEST_P(OpArrayLengthTest, Fragment) {
// Create the pipeline that computes the length of the buffers and writes it to the only render // Create the pipeline that computes the length of the buffers and writes it to the only render
// pass pixel. // pass pixel.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, (mShaderInterface + R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, (mShaderInterface + R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
var fragColor : vec4<f32>; var fragColor : vec4<f32>;
fragColor.r = f32(arrayLength(&buffer1.data)) / 255.0; fragColor.r = f32(arrayLength(&buffer1.data)) / 255.0;
fragColor.g = f32(arrayLength(&buffer2.data)) / 255.0; fragColor.g = f32(arrayLength(&buffer2.data)) / 255.0;
@ -229,7 +229,7 @@ TEST_P(OpArrayLengthTest, Vertex) {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) fn main() -> VertexOut { @vertex fn main() -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.color.r = f32(arrayLength(&buffer1.data)) / 255.0; output.color.r = f32(arrayLength(&buffer1.data)) / 255.0;
output.color.g = f32(arrayLength(&buffer2.data)) / 255.0; output.color.g = f32(arrayLength(&buffer2.data)) / 255.0;
@ -242,7 +242,7 @@ TEST_P(OpArrayLengthTest, Vertex) {
.c_str()); .c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
return color; return color;
})"); })");

View File

@ -27,32 +27,32 @@ using ::testing::NiceMock;
// TODO(dawn:549) Add some sort of pipeline descriptor repository to test more caching. // TODO(dawn:549) Add some sort of pipeline descriptor repository to test more caching.
static constexpr std::string_view kComputeShaderDefault = R"( static constexpr std::string_view kComputeShaderDefault = R"(
@stage(compute) @workgroup_size(1) fn main() {} @compute @workgroup_size(1) fn main() {}
)"; )";
static constexpr std::string_view kComputeShaderMultipleEntryPoints = R"( static constexpr std::string_view kComputeShaderMultipleEntryPoints = R"(
@stage(compute) @workgroup_size(16) fn main() {} @compute @workgroup_size(16) fn main() {}
@stage(compute) @workgroup_size(64) fn main2() {} @compute @workgroup_size(64) fn main2() {}
)"; )";
static constexpr std::string_view kVertexShaderDefault = R"( static constexpr std::string_view kVertexShaderDefault = R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
} }
)"; )";
static constexpr std::string_view kVertexShaderMultipleEntryPoints = R"( static constexpr std::string_view kVertexShaderMultipleEntryPoints = R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
@stage(vertex) fn main2() -> @builtin(position) vec4<f32> { @vertex fn main2() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.5, 0.5, 0.5, 1.0); return vec4<f32>(0.5, 0.5, 0.5, 1.0);
} }
)"; )";
static constexpr std::string_view kFragmentShaderDefault = R"( static constexpr std::string_view kFragmentShaderDefault = R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.1, 0.2, 0.3, 0.4); return vec4<f32>(0.1, 0.2, 0.3, 0.4);
} }
)"; )";
@ -63,7 +63,7 @@ static constexpr std::string_view kFragmentShaderMultipleOutput = R"(
@location(1) fragColor1 : vec4<f32>, @location(1) fragColor1 : vec4<f32>,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.fragColor0 = vec4<f32>(0.1, 0.2, 0.3, 0.4); output.fragColor0 = vec4<f32>(0.1, 0.2, 0.3, 0.4);
output.fragColor1 = vec4<f32>(0.5, 0.6, 0.7, 0.8); output.fragColor1 = vec4<f32>(0.5, 0.6, 0.7, 0.8);

View File

@ -52,7 +52,7 @@ class DepthClampingTest : public DawnTest {
} }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, ubo.depth, 1.0); return vec4<f32>(0.0, 0.0, ubo.depth, 1.0);
})"); })");
@ -63,7 +63,7 @@ class DepthClampingTest : public DawnTest {
} }
@group(0) @binding(0) var<uniform> ubo : UBO; @group(0) @binding(0) var<uniform> ubo : UBO;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(ubo.color, 1.0); return vec4<f32>(ubo.color, 1.0);
})"); })");
} }

View File

@ -155,13 +155,13 @@ class PrimitiveTopologyTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
vsModule = utils::CreateShaderModule(device, R"( vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
fsModule = utils::CreateShaderModule(device, R"( fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -77,7 +77,7 @@ class OcclusionQueryTests : public QueryTests {
// Create basic render pipeline // Create basic render pipeline
vsModule = utils::CreateShaderModule(device, R"( vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>( 1.0, 1.0), vec2<f32>( 1.0, 1.0),
@ -87,7 +87,7 @@ class OcclusionQueryTests : public QueryTests {
})"); })");
fsModule = utils::CreateShaderModule(device, R"( fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -71,7 +71,7 @@ class ReadOnlyDepthStencilAttachmentTests
// and pass the depth test, and sample from the depth buffer in fragment shader in the same // and pass the depth test, and sample from the depth buffer in fragment shader in the same
// pipeline. // pipeline.
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec3<f32>, 6>( var pos = array<vec3<f32>, 6>(
vec3<f32>(-1.0, 1.0, 0.4), vec3<f32>(-1.0, 1.0, 0.4),
@ -86,7 +86,7 @@ class ReadOnlyDepthStencilAttachmentTests
if (!sampleFromAttachment) { if (!sampleFromAttachment) {
// Draw a solid blue into color buffer if not sample from depth/stencil attachment. // Draw a solid blue into color buffer if not sample from depth/stencil attachment.
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 1.0, 0.0); return vec4<f32>(0.0, 0.0, 1.0, 0.0);
})"); })");
} else { } else {
@ -96,7 +96,7 @@ class ReadOnlyDepthStencilAttachmentTests
@group(0) @binding(0) var samp : sampler; @group(0) @binding(0) var samp : sampler;
@group(0) @binding(1) var tex : texture_depth_2d; @group(0) @binding(1) var tex : texture_depth_2d;
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return vec4<f32>(textureSample(tex, samp, FragCoord.xy), 0.0, 0.0, 0.0); return vec4<f32>(textureSample(tex, samp, FragCoord.xy), 0.0, 0.0, 0.0);
})"); })");
@ -105,7 +105,7 @@ class ReadOnlyDepthStencilAttachmentTests
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var tex : texture_2d<u32>; @group(0) @binding(0) var tex : texture_2d<u32>;
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
var texel = textureLoad(tex, vec2<i32>(FragCoord.xy), 0); var texel = textureLoad(tex, vec2<i32>(FragCoord.xy), 0);
return vec4<f32>(f32(texel[0]) / 255.0, 0.0, 0.0, 0.0); return vec4<f32>(f32(texel[0]) / 255.0, 0.0, 0.0, 0.0);

View File

@ -23,7 +23,7 @@ class RenderAttachmentTest : public DawnTest {};
// There should be no backend validation errors or indexing out-of-bounds. // There should be no backend validation errors or indexing out-of-bounds.
TEST_P(RenderAttachmentTest, MoreFragmentOutputsThanAttachments) { TEST_P(RenderAttachmentTest, MoreFragmentOutputsThanAttachments) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main() -> @builtin(position) vec4<f32> { fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
@ -36,7 +36,7 @@ TEST_P(RenderAttachmentTest, MoreFragmentOutputsThanAttachments) {
@location(3) color3 : vec4<f32>, @location(3) color3 : vec4<f32>,
} }
@stage(fragment) @fragment
fn main() -> Output { fn main() -> Output {
var output : Output; var output : Output;
output.color0 = vec4<f32>(1.0, 0.0, 0.0, 1.0); output.color0 = vec4<f32>(1.0, 0.0, 0.0, 1.0);

View File

@ -32,7 +32,7 @@ class RenderBundleTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
@ -43,7 +43,7 @@ class RenderBundleTest : public DawnTest {
} }
@group(0) @binding(0) var<uniform> fragmentUniformBuffer : Ubo; @group(0) @binding(0) var<uniform> fragmentUniformBuffer : Ubo;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return fragmentUniformBuffer.color; return fragmentUniformBuffer.color;
})"); })");

View File

@ -76,7 +76,7 @@ class RenderPassLoadOpTests : public DawnTest {
// draws a blue quad on the right half of the screen // draws a blue quad on the right half of the screen
const char* vsSource = R"( const char* vsSource = R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>( 0.0, -1.0), vec2<f32>( 0.0, -1.0),
@ -90,7 +90,7 @@ class RenderPassLoadOpTests : public DawnTest {
})"; })";
const char* fsSource = R"( const char* fsSource = R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 1.0, 1.0); return vec4<f32>(0.0, 0.0, 1.0, 1.0);
})"; })";
blueQuad = DrawQuad(device, vsSource, fsSource); blueQuad = DrawQuad(device, vsSource, fsSource);

View File

@ -27,7 +27,7 @@ class RenderPassTest : public DawnTest {
// Shaders to draw a bottom-left triangle in blue. // Shaders to draw a bottom-left triangle in blue.
mVSModule = utils::CreateShaderModule(device, R"( mVSModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -38,7 +38,7 @@ class RenderPassTest : public DawnTest {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 1.0, 1.0); return vec4<f32>(0.0, 0.0, 1.0, 1.0);
})"); })");
@ -138,7 +138,7 @@ TEST_P(RenderPassTest, NoCorrespondingFragmentShaderOutputs) {
{ {
// Next we use a pipeline whose fragment shader has no outputs. // Next we use a pipeline whose fragment shader has no outputs.
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
utils::ComboRenderPipelineDescriptor descriptor; utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = mVSModule; descriptor.vertex.module = mVSModule;

View File

@ -54,7 +54,7 @@ class SamplerFilterAnisotropicTest : public DawnTest {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.uv = input.uv; output.uv = input.uv;
@ -71,7 +71,7 @@ class SamplerFilterAnisotropicTest : public DawnTest {
@builtin(position) fragCoord : vec4<f32>, @builtin(position) fragCoord : vec4<f32>,
} }
@stage(fragment) @fragment
fn main(input : FragmentIn) -> @location(0) vec4<f32> { fn main(input : FragmentIn) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, input.uv); return textureSample(texture0, sampler0, input.uv);
})"); })");

View File

@ -56,7 +56,7 @@ class SamplerTest : public DawnTest {
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
auto vsModule = utils::CreateShaderModule(device, R"( auto vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-2.0, -2.0), vec2<f32>(-2.0, -2.0),
@ -72,7 +72,7 @@ class SamplerTest : public DawnTest {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d<f32>; @group(0) @binding(1) var texture0 : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, FragCoord.xy / vec2<f32>(2.0, 2.0)); return textureSample(texture0, sampler0, FragCoord.xy / vec2<f32>(2.0, 2.0));
})"); })");

View File

@ -21,7 +21,7 @@ class ScissorTest : public DawnTest {
protected: protected:
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) { wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -34,7 +34,7 @@ class ScissorTest : public DawnTest {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -56,7 +56,7 @@ struct Buf {
@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() { @compute @workgroup_size(1) fn main() {
let factor : f32 = 1.0001; let factor : f32 = 1.0001;
buf.data[0] = u32(log2(1.0 * factor)); buf.data[0] = u32(log2(1.0 * factor));
@ -115,7 +115,7 @@ I am an invalid shader and should never pass validation!
// can compile and link successfully. // can compile and link successfully.
TEST_P(ShaderTests, WGSLParamIO) { TEST_P(ShaderTests, WGSLParamIO) {
std::string vertexShader = R"( std::string vertexShader = R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -126,7 +126,7 @@ fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str()); wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str());
std::string fragmentShader = R"( std::string fragmentShader = R"(
@stage(fragment) @fragment
fn main(@builtin(position) fragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) fragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return vec4<f32>(fragCoord.xy, 0.0, 1.0); return vec4<f32>(fragCoord.xy, 0.0, 1.0);
})"; })";
@ -152,7 +152,7 @@ struct VertexOut {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0); output.position = vec4<f32>(input.position, 1.0);
@ -162,7 +162,7 @@ fn main(input : VertexIn) -> VertexOut {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str()); wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str());
std::string fragmentShader = R"( std::string fragmentShader = R"(
@stage(fragment) @fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
return color; return color;
})"; })";
@ -195,7 +195,7 @@ struct VertexOut {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0); output.position = vec4<f32>(input.position, 1.0);
@ -210,7 +210,7 @@ struct FragmentIn {
@builtin(position) fragCoord : vec4<f32>, @builtin(position) fragCoord : vec4<f32>,
} }
@stage(fragment) @fragment
fn main(input : FragmentIn) -> @location(0) vec4<f32> { fn main(input : FragmentIn) -> @location(0) vec4<f32> {
return input.color * input.fragCoord; return input.color * input.fragCoord;
})"; })";
@ -242,7 +242,7 @@ struct VertexOut {
@location(0) color : vec4<f32>, @location(0) color : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0); output.position = vec4<f32>(input.position, 1.0);
@ -257,7 +257,7 @@ struct FragmentIn {
@builtin(position) fragCoord : vec4<f32>, @builtin(position) fragCoord : vec4<f32>,
} }
@stage(fragment) @fragment
fn main(input : FragmentIn) -> @location(0) vec4<f32> { fn main(input : FragmentIn) -> @location(0) vec4<f32> {
return input.color * input.fragCoord; return input.color * input.fragCoord;
})"; })";
@ -289,7 +289,7 @@ struct VertexOut {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn vertexMain(input : VertexIn) -> VertexOut { fn vertexMain(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0); output.position = vec4<f32>(input.position, 1.0);
@ -297,7 +297,7 @@ fn vertexMain(input : VertexIn) -> VertexOut {
return output; return output;
} }
@stage(fragment) @fragment
fn fragmentMain(input : VertexOut) -> @location(0) vec4<f32> { fn fragmentMain(input : VertexOut) -> @location(0) vec4<f32> {
return input.color; return input.color;
})"; })";
@ -338,12 +338,12 @@ struct Inputs {
struct S1 { data : array<vec4<u32>, 20> } struct S1 { data : array<vec4<u32>, 20> }
@group(0) @binding(1) var<uniform> providedData1 : S1; @group(0) @binding(1) var<uniform> providedData1 : S1;
@stage(vertex) fn vsMain(input : Inputs) -> @builtin(position) vec4<f32> { @vertex fn vsMain(input : Inputs) -> @builtin(position) vec4<f32> {
_ = providedData1.data[input.vertexIndex][0]; _ = providedData1.data[input.vertexIndex][0];
return vec4<f32>(); return vec4<f32>();
} }
@stage(fragment) fn fsMain() -> @location(0) vec4<f32> { @fragment fn fsMain() -> @location(0) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
} }
)"; )";
@ -369,13 +369,13 @@ TEST_P(ShaderTests, SampleIndex) {
DAWN_TEST_UNSUPPORTED_IF(HasToggleEnabled("disable_sample_variables")); DAWN_TEST_UNSUPPORTED_IF(HasToggleEnabled("disable_sample_variables"));
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main(@builtin(sample_index) sampleIndex : u32) @fragment fn main(@builtin(sample_index) sampleIndex : u32)
-> @location(0) vec4<f32> { -> @location(0) vec4<f32> {
return vec4<f32>(f32(sampleIndex), 1.0, 0.0, 1.0); return vec4<f32>(f32(sampleIndex), 1.0, 0.0, 1.0);
})"); })");
@ -422,7 +422,7 @@ struct Buf {
@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() { @compute @workgroup_size(1) fn main() {
buf.data[0] = u32(c0); buf.data[0] = u32(c0);
buf.data[1] = u32(c1); buf.data[1] = u32(c1);
buf.data[2] = u32(c2); buf.data[2] = u32(c2);
@ -492,7 +492,7 @@ struct Buf {
@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() { @compute @workgroup_size(1) fn main() {
buf.data[0] = c1; buf.data[0] = c1;
buf.data[1] = c2; buf.data[1] = c2;
buf.data[2] = c3; buf.data[2] = c3;
@ -549,7 +549,7 @@ struct Buf {
@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() { @compute @workgroup_size(1) fn main() {
buf.data[0] = c1; buf.data[0] = c1;
buf.data[1] = c2; buf.data[1] = c2;
})"; })";
@ -603,15 +603,15 @@ struct Buf {
@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 main1() { @compute @workgroup_size(1) fn main1() {
buf.data[0] = c1; buf.data[0] = c1;
} }
@stage(compute) @workgroup_size(1) fn main2() { @compute @workgroup_size(1) fn main2() {
buf.data[0] = c2; buf.data[0] = c2;
} }
@stage(compute) @workgroup_size(1) fn main3() { @compute @workgroup_size(1) fn main3() {
buf.data[0] = 3u; buf.data[0] = 3u;
} }
)"; )";
@ -687,7 +687,7 @@ TEST_P(ShaderTests, OverridableConstantsRenderPipeline) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@id(1111) override xright: f32; @id(1111) override xright: f32;
@id(2222) override ytop: f32; @id(2222) override ytop: f32;
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) fn main(@builtin(vertex_index) VertexIndex : u32)
-> @builtin(position) vec4<f32> { -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
@ -700,7 +700,7 @@ fn main(@builtin(vertex_index) VertexIndex : u32)
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@id(1000) override intensity: f32 = 0.0; @id(1000) override intensity: f32 = 0.0;
@stage(fragment) fn main() @fragment fn main()
-> @location(0) vec4<f32> { -> @location(0) vec4<f32> {
return vec4<f32>(intensity, intensity, intensity, 1.0); return vec4<f32>(intensity, intensity, intensity, 1.0);
})"); })");
@ -744,12 +744,12 @@ TEST_P(ShaderTests, ConflictingBindingsDueToTransformOrder) {
@group(0) @binding(0) var<uniform> b0 : u32; @group(0) @binding(0) var<uniform> b0 : u32;
@group(0) @binding(1) var<uniform> b1 : u32; @group(0) @binding(1) var<uniform> b1 : u32;
@stage(vertex) fn vertex() -> @builtin(position) vec4<f32> { @vertex fn vertex() -> @builtin(position) vec4<f32> {
_ = b0; _ = b0;
return vec4<f32>(0.0); return vec4<f32>(0.0);
} }
@stage(fragment) fn fragment() -> @location(0) vec4<f32> { @fragment fn fragment() -> @location(0) vec4<f32> {
_ = b0; _ = b0;
_ = b1; _ = b1;
return vec4<f32>(0.0); return vec4<f32>(0.0);

View File

@ -648,7 +648,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
const char* kSimpleVertexShader = R"( const char* kSimpleVertexShader = R"(
; ;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"; })";
@ -799,7 +799,7 @@ TEST_P(StorageTextureTests, SampledAndWriteonlyStorageTexturePingPong) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var Src : texture_2d<u32>; @group(0) @binding(0) var Src : texture_2d<u32>;
@group(0) @binding(1) var Dst : texture_storage_2d<r32uint, write>; @group(0) @binding(1) var Dst : texture_storage_2d<r32uint, write>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0), 0); var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0), 0);
srcValue.x = srcValue.x + 1u; srcValue.x = srcValue.x + 1u;
textureStore(Dst, vec2<i32>(0, 0), srcValue); textureStore(Dst, vec2<i32>(0, 0), srcValue);
@ -898,14 +898,14 @@ fn doTest() -> bool {
const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"( const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"(
@group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>; @group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u)); textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
return vec4<f32>(); return vec4<f32>();
})"; })";
const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"( const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"(
@group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>; @group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u)); textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
})"; })";
}; };

View File

@ -228,7 +228,7 @@ TEST_P(SwapChainValidationTests, ViewDestroyedAfterPresent) {
TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) { TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@ -236,7 +236,7 @@ TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
@location(0) target0 : vec4<f32>, @location(0) target0 : vec4<f32>,
@location(1) target1 : f32, @location(1) target1 : f32,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var out : FragmentOut; var out : FragmentOut;
out.target0 = vec4<f32>(0.0, 1.0, 0.0, 1.0); out.target0 = vec4<f32>(0.0, 1.0, 0.0, 1.0);
out.target1 = 0.5; out.target1 = 0.5;

View File

@ -30,7 +30,7 @@ TEST_P(Texture3DTests, Sampling) {
// Set up pipeline. Two triangles will be drawn via the pipeline. They will fill the entire // Set up pipeline. Two triangles will be drawn via the pipeline. They will fill the entire
// color attachment with data sampled from 3D texture. // color attachment with data sampled from 3D texture.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -47,7 +47,7 @@ TEST_P(Texture3DTests, Sampling) {
@group(0) @binding(0) var samp : sampler; @group(0) @binding(0) var samp : sampler;
@group(0) @binding(1) var tex : texture_3d<f32>; @group(0) @binding(1) var tex : texture_3d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return textureSample(tex, samp, vec3<f32>(FragCoord.xy / 4.0, 1.5 / 4.0)); return textureSample(tex, samp, vec3<f32>(FragCoord.xy / 4.0, 1.5 / 4.0));
})"); })");

View File

@ -143,7 +143,7 @@ class TextureFormatTest : public DawnTest {
utils::ComboRenderPipelineDescriptor desc; utils::ComboRenderPipelineDescriptor desc;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-3.0, -1.0), vec2<f32>(-3.0, -1.0),
@ -161,7 +161,7 @@ class TextureFormatTest : public DawnTest {
fsSource << "struct FragmentOut {\n"; fsSource << "struct FragmentOut {\n";
fsSource << " @location(0) color : vec4<" << type << ">\n"; fsSource << " @location(0) color : vec4<" << type << ">\n";
fsSource << R"(} fsSource << R"(}
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut { fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.color = textureLoad(myTexture, vec2<i32>(FragCoord.xy), 0); output.color = textureLoad(myTexture, vec2<i32>(FragCoord.xy), 0);

View File

@ -50,7 +50,7 @@ class TextureSubresourceTest : public DawnTest {
void DrawTriangle(const wgpu::TextureView& view) { void DrawTriangle(const wgpu::TextureView& view) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -61,7 +61,7 @@ class TextureSubresourceTest : public DawnTest {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
})"); })");
@ -87,7 +87,7 @@ class TextureSubresourceTest : public DawnTest {
void SampleAndDraw(const wgpu::TextureView& samplerView, const wgpu::TextureView& renderView) { void SampleAndDraw(const wgpu::TextureView& samplerView, const wgpu::TextureView& renderView) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -104,7 +104,7 @@ class TextureSubresourceTest : public DawnTest {
@group(0) @binding(0) var samp : sampler; @group(0) @binding(0) var samp : sampler;
@group(0) @binding(1) var tex : texture_2d<f32>; @group(0) @binding(1) var tex : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return textureSample(tex, samp, FragCoord.xy / vec2<f32>(4.0, 4.0)); return textureSample(tex, samp, FragCoord.xy / vec2<f32>(4.0, 4.0));
})"); })");

View File

@ -68,7 +68,7 @@ wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
var output : VertexOut; var output : VertexOut;
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
@ -222,7 +222,7 @@ class TextureViewSamplingTest : public DawnTest {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d<f32>; @group(0) @binding(1) var texture0 : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, texCoord); return textureSample(texture0, sampler0, texCoord);
} }
@ -258,7 +258,7 @@ class TextureViewSamplingTest : public DawnTest {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d_array<f32>; @group(0) @binding(1) var texture0 : texture_2d_array<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, texCoord, 0) + return textureSample(texture0, sampler0, texCoord, 0) +
textureSample(texture0, sampler0, texCoord, 1) + textureSample(texture0, sampler0, texCoord, 1) +
@ -293,7 +293,7 @@ class TextureViewSamplingTest : public DawnTest {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : )" @group(0) @binding(1) var texture0 : )"
<< textureType << R"(<f32>; << textureType << R"(<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
var sc : f32 = 2.0 * texCoord.x - 1.0; var sc : f32 = 2.0 * texCoord.x - 1.0;
var tc : f32 = 2.0 * texCoord.y - 1.0; var tc : f32 = 2.0 * texCoord.y - 1.0;
@ -367,7 +367,7 @@ TEST_P(TextureViewSamplingTest, Default2DArrayTexture) {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d_array<f32>; @group(0) @binding(1) var texture0 : texture_2d_array<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, texCoord, 0) + return textureSample(texture0, sampler0, texCoord, 0) +
textureSample(texture0, sampler0, texCoord, 1) + textureSample(texture0, sampler0, texCoord, 1) +
@ -408,7 +408,7 @@ TEST_P(TextureViewSamplingTest, Texture2DArrayViewOnSingleLayer2DTexture) {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d_array<f32>; @group(0) @binding(1) var texture0 : texture_2d_array<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, texCoord, 0); return textureSample(texture0, sampler0, texCoord, 0);
} }
@ -470,7 +470,7 @@ TEST_P(TextureViewSamplingTest, SRGBReinterpretation) {
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -485,7 +485,7 @@ TEST_P(TextureViewSamplingTest, SRGBReinterpretation) {
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture : texture_2d<f32>; @group(0) @binding(0) var texture : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(texture, vec2<i32>(coord.xy), 0); return textureLoad(texture, vec2<i32>(coord.xy), 0);
} }
@ -603,7 +603,7 @@ class TextureViewRenderingTest : public DawnTest {
renderPassInfo.cColorAttachments[0].clearValue = {1.0f, 0.0f, 0.0f, 1.0f}; renderPassInfo.cColorAttachments[0].clearValue = {1.0f, 0.0f, 0.0f, 1.0f};
const char* oneColorFragmentShader = R"( const char* oneColorFragmentShader = R"(
@stage(fragment) fn main(@location(0) texCoord : vec2<f32>) -> @fragment fn main(@location(0) texCoord : vec2<f32>) ->
@location(0) vec4<f32> { @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
} }
@ -802,7 +802,7 @@ TEST_P(TextureViewRenderingTest, SRGBReinterpretationRenderAttachment) {
// Create a render pipeline to blit |sampledTexture| into |textureView|. // Create a render pipeline to blit |sampledTexture| into |textureView|.
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -817,7 +817,7 @@ TEST_P(TextureViewRenderingTest, SRGBReinterpretationRenderAttachment) {
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture : texture_2d<f32>; @group(0) @binding(0) var texture : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(texture, vec2<i32>(coord.xy), 0); return textureLoad(texture, vec2<i32>(coord.xy), 0);
} }
@ -916,7 +916,7 @@ TEST_P(TextureViewRenderingTest, SRGBReinterpretionResolveAttachment) {
// Create a render pipeline to blit |sampledTexture| into |multisampledTextureView|. // Create a render pipeline to blit |sampledTexture| into |multisampledTextureView|.
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -931,7 +931,7 @@ TEST_P(TextureViewRenderingTest, SRGBReinterpretionResolveAttachment) {
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture : texture_2d<f32>; @group(0) @binding(0) var texture : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(texture, vec2<i32>(coord.xy), 0); return textureLoad(texture, vec2<i32>(coord.xy), 0);
} }
@ -1065,7 +1065,7 @@ TEST_P(TextureView1DTest, Sampling) {
// Create a pipeline that will sample from the 1D texture and output to an attachment. // Create a pipeline that will sample from the 1D texture and output to an attachment.
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn vs(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn vs(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec4<f32>, 3>( var pos = array<vec4<f32>, 3>(
vec4<f32>( 0., 2., 0., 1.), vec4<f32>( 0., 2., 0., 1.),
@ -1076,7 +1076,7 @@ TEST_P(TextureView1DTest, Sampling) {
@group(0) @binding(0) var tex : texture_1d<f32>; @group(0) @binding(0) var tex : texture_1d<f32>;
@group(0) @binding(1) var samp : sampler; @group(0) @binding(1) var samp : sampler;
@stage(fragment) @fragment
fn fs(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> { fn fs(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
return textureSample(tex, samp, pos.x / 4.0); return textureSample(tex, samp, pos.x / 4.0);
} }

View File

@ -72,7 +72,7 @@ class TextureZeroInitTest : public DawnTest {
pipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest(depth); pipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest(depth);
const char* fs = R"( const char* fs = R"(
; ;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"; )";
@ -85,7 +85,7 @@ class TextureZeroInitTest : public DawnTest {
} }
wgpu::ShaderModule CreateBasicVertexShaderForTest(float depth = 0.f) { wgpu::ShaderModule CreateBasicVertexShaderForTest(float depth = 0.f) {
std::string source = R"( std::string source = R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -106,7 +106,7 @@ class TextureZeroInitTest : public DawnTest {
struct FragmentOut { struct FragmentOut {
@location(0) color : vec4<f32> @location(0) color : vec4<f32>
} }
@stage(fragment) @fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut { fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
var output : FragmentOut; var output : FragmentOut;
output.color = textureLoad(texture0, vec2<i32>(FragCoord.xy), 0); output.color = textureLoad(texture0, vec2<i32>(FragCoord.xy), 0);
@ -992,7 +992,7 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
value : vec4<f32> value : vec4<f32>
} }
@group(0) @binding(1) var<storage, read_write> result : Result; @group(0) @binding(1) var<storage, read_write> result : Result;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
result.value = textureLoad(tex, vec2<i32>(0,0), 0); result.value = textureLoad(tex, vec2<i32>(0,0), 0);
} }
)"; )";

View File

@ -273,7 +273,7 @@ class VertexFormatTest : public DawnTest {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(input : VertexIn) -> VertexOut { fn main(input : VertexIn) -> VertexOut {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -362,7 +362,7 @@ class VertexFormatTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str()); wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
return color; return color;
})"); })");

View File

@ -102,13 +102,13 @@ class VertexOnlyRenderPipelineTest : public DawnTest {
bool writeDepth = false, bool writeDepth = false,
bool useFragment = true) { bool useFragment = true) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> { fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
return pos; return pos;
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -91,7 +91,7 @@ class VertexStateTest : public DawnTest {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) fn main(input : VertexIn) -> VertexOut { @vertex fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
)"; )";
@ -139,7 +139,7 @@ class VertexStateTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str()); wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
return color; return color;
} }
@ -602,7 +602,7 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) fn main(input : VertexIn) -> VertexOut { @vertex fn main(input : VertexIn) -> VertexOut {
var output : VertexOut; var output : VertexOut;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0); output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -622,7 +622,7 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
return output; return output;
})"); })");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) @fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> { fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
return color; return color;
})"); })");
@ -659,12 +659,12 @@ TEST_P(OptionalVertexStateTest, Basic) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 3, 3); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 3, 3);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -177,7 +177,7 @@ wgpu::ShaderModule VideoViewsTests::GetTestVertexShaderModule() const {
@builtin(position) position : vec4<f32>, @builtin(position) position : vec4<f32>,
} }
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut { fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -230,7 +230,7 @@ TEST_P(VideoViewsTests, NV12SampleYtoR) {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture : texture_2d<f32>; @group(0) @binding(1) var texture : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
let y : f32 = textureSample(texture, sampler0, texCoord).r; let y : f32 = textureSample(texture, sampler0, texCoord).r;
return vec4<f32>(y, 0.0, 0.0, 1.0); return vec4<f32>(y, 0.0, 0.0, 1.0);
@ -289,7 +289,7 @@ TEST_P(VideoViewsTests, NV12SampleUVtoRG) {
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture : texture_2d<f32>; @group(0) @binding(1) var texture : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
let u : f32 = textureSample(texture, sampler0, texCoord).r; let u : f32 = textureSample(texture, sampler0, texCoord).r;
let v : f32 = textureSample(texture, sampler0, texCoord).g; let v : f32 = textureSample(texture, sampler0, texCoord).g;
@ -359,7 +359,7 @@ TEST_P(VideoViewsTests, NV12SampleYUVtoRGB) {
@group(0) @binding(1) var lumaTexture : texture_2d<f32>; @group(0) @binding(1) var lumaTexture : texture_2d<f32>;
@group(0) @binding(2) var chromaTexture : texture_2d<f32>; @group(0) @binding(2) var chromaTexture : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
let y : f32 = textureSample(lumaTexture, sampler0, texCoord).r; let y : f32 = textureSample(lumaTexture, sampler0, texCoord).r;
let u : f32 = textureSample(chromaTexture, sampler0, texCoord).r; let u : f32 = textureSample(chromaTexture, sampler0, texCoord).r;

View File

@ -24,12 +24,12 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(-0.5, 0.5, 0.0, 1.0); return vec4<f32>(-0.5, 0.5, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -24,7 +24,7 @@ class ViewportTest : public DawnTest {
DawnTest::SetUp(); DawnTest::SetUp();
mQuadVS = utils::CreateShaderModule(device, R"( mQuadVS = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
@ -37,7 +37,7 @@ class ViewportTest : public DawnTest {
})"); })");
mQuadFS = utils::CreateShaderModule(device, R"( mQuadFS = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0); return vec4<f32>(1.0, 1.0, 1.0, 1.0);
})"); })");
} }
@ -93,7 +93,7 @@ class ViewportTest : public DawnTest {
// Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0. // Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0.
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var points : array<vec3<f32>, 3> = array<vec3<f32>, 3>( var points : array<vec3<f32>, 3> = array<vec3<f32>, 3>(
vec3<f32>(-0.9, 0.0, 1.0), vec3<f32>(-0.9, 0.0, 1.0),

View File

@ -34,7 +34,7 @@ constexpr float kVertexData[12] = {
}; };
constexpr char kVertexShader[] = R"( constexpr char kVertexShader[] = R"(
@stage(vertex) fn main( @vertex fn main(
@location(0) pos : vec4<f32> @location(0) pos : vec4<f32>
) -> @builtin(position) vec4<f32> { ) -> @builtin(position) vec4<f32> {
return pos; return pos;
@ -45,7 +45,7 @@ constexpr char kFragmentShaderA[] = R"(
color : vec3<f32> color : vec3<f32>
} }
@group(0) @binding(0) var<uniform> uniforms : Uniforms; @group(0) @binding(0) var<uniform> uniforms : Uniforms;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uniforms.color * (1.0 / 5000.0), 1.0); return vec4<f32>(uniforms.color * (1.0 / 5000.0), 1.0);
})"; })";
@ -59,7 +59,7 @@ constexpr char kFragmentShaderB[] = R"(
@group(0) @binding(0) var<uniform> constants : Constants; @group(0) @binding(0) var<uniform> constants : Constants;
@group(1) @binding(0) var<uniform> uniforms : Uniforms; @group(1) @binding(0) var<uniform> uniforms : Uniforms;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>((constants.color + uniforms.color) * (1.0 / 5000.0), 1.0); return vec4<f32>((constants.color + uniforms.color) * (1.0 / 5000.0), 1.0);
})"; })";

View File

@ -75,7 +75,7 @@ const std::string& kMatMulFloatSharedArray2D = R"(
var<workgroup> mm_Asub : array<array<f32, 32>, 32>; var<workgroup> mm_Asub : array<array<f32, 32>, 32>;
var<workgroup> mm_Bsub : array<array<f32, 32>, 32>;)"; var<workgroup> mm_Bsub : array<array<f32, 32>, 32>;)";
const std::string& kMatMulFloatBodyPart1 = R"( const std::string& kMatMulFloatBodyPart1 = R"(
@stage(compute) @workgroup_size(8, 8, 1) @compute @workgroup_size(8, 8, 1)
fn main(@builtin(local_invocation_id) local_id : vec3<u32>, fn main(@builtin(local_invocation_id) local_id : vec3<u32>,
@builtin(global_invocation_id) global_id : vec3<u32>) { @builtin(global_invocation_id) global_id : vec3<u32>) {
let tileRow : u32 = local_id.y * RowPerThread; let tileRow : u32 = local_id.y * RowPerThread;
@ -240,7 +240,7 @@ const std::string& kMatMulVec4SharedArray2D = R"(
var<workgroup> mm_Asub : array<array<vec4<f32>, 8>, 32>; var<workgroup> mm_Asub : array<array<vec4<f32>, 8>, 32>;
var<workgroup> mm_Bsub : array<array<vec4<f32>, 8>, 32>;)"; var<workgroup> mm_Bsub : array<array<vec4<f32>, 8>, 32>;)";
const std::string& kMatMulVec4BodyPart1 = R"( const std::string& kMatMulVec4BodyPart1 = R"(
@stage(compute) @workgroup_size(8, 8, 1) @compute @workgroup_size(8, 8, 1)
fn main(@builtin(local_invocation_id) local_id : vec3<u32>, fn main(@builtin(local_invocation_id) local_id : vec3<u32>,
@builtin(global_invocation_id) global_id : vec3<u32>) { @builtin(global_invocation_id) global_id : vec3<u32>) {
let tileRow : u32 = local_id.y * RowPerThread; let tileRow : u32 = local_id.y * RowPerThread;

View File

@ -68,13 +68,13 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams<SubresourceTrackin
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var materials : texture_2d<f32>; @group(0) @binding(0) var materials : texture_2d<f32>;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
let foo : vec2<i32> = textureDimensions(materials); let foo : vec2<i32> = textureDimensions(materials);
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }

View File

@ -60,7 +60,7 @@ TEST_F(CommandBufferEncodingTests, ComputePassEncoderIndirectDispatchStateRestor
// Create a simple pipeline // Create a simple pipeline
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1, 1, 1) @compute @workgroup_size(1, 1, 1)
fn main() { fn main() {
})"); })");
csDesc.compute.entryPoint = "main"; csDesc.compute.entryPoint = "main";
@ -290,7 +290,7 @@ TEST_F(CommandBufferEncodingTests, StateNotLeakedAfterRestore) {
// Create a simple pipeline // Create a simple pipeline
wgpu::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.compute.module = utils::CreateShaderModule(device, R"( csDesc.compute.module = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1, 1, 1) @compute @workgroup_size(1, 1, 1)
fn main() { fn main() {
})"); })");
csDesc.compute.entryPoint = "main"; csDesc.compute.entryPoint = "main";

View File

@ -73,7 +73,7 @@ class DestroyObjectTests : public Test {
} }
DAWN_TRY_ASSIGN_WITH_CLEANUP( DAWN_TRY_ASSIGN_WITH_CLEANUP(
mVsModule, ShaderModuleMock::Create(&mDevice, R"( mVsModule, ShaderModuleMock::Create(&mDevice, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"), })"),
{ ASSERT(false); }, mVsModule); { ASSERT(false); }, mVsModule);
@ -87,7 +87,7 @@ class DestroyObjectTests : public Test {
} }
DAWN_TRY_ASSIGN_WITH_CLEANUP( DAWN_TRY_ASSIGN_WITH_CLEANUP(
mCsModule, ShaderModuleMock::Create(&mDevice, R"( mCsModule, ShaderModuleMock::Create(&mDevice, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"), })"),
{ ASSERT(false); }, mCsModule); { ASSERT(false); }, mCsModule);
EXPECT_CALL(*mCsModule.Get(), DestroyImpl).Times(1); EXPECT_CALL(*mCsModule.Get(), DestroyImpl).Times(1);
@ -428,7 +428,7 @@ TEST_F(DestroyObjectTests, ShaderModuleImplicit) {
{ {
ShaderModuleWGSLDescriptor wgslDesc; ShaderModuleWGSLDescriptor wgslDesc;
wgslDesc.source = R"( wgslDesc.source = R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
} }
)"; )";
ShaderModuleDescriptor desc = {}; ShaderModuleDescriptor desc = {};
@ -698,7 +698,7 @@ TEST_F(DestroyObjectTests, DestroyObjects) {
{ {
ShaderModuleWGSLDescriptor wgslDesc; ShaderModuleWGSLDescriptor wgslDesc;
wgslDesc.source = R"( wgslDesc.source = R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
} }
)"; )";
ShaderModuleDescriptor desc = {}; ShaderModuleDescriptor desc = {};
@ -755,17 +755,17 @@ TEST_F(DestroyObjectTests, DestroyObjects) {
} }
static constexpr std::string_view kComputeShader = R"( static constexpr std::string_view kComputeShader = R"(
@stage(compute) @workgroup_size(1) fn main() {} @compute @workgroup_size(1) fn main() {}
)"; )";
static constexpr std::string_view kVertexShader = R"( static constexpr std::string_view kVertexShader = R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
} }
)"; )";
static constexpr std::string_view kFragmentShader = R"( static constexpr std::string_view kFragmentShader = R"(
@stage(fragment) fn main() {} @fragment fn main() {}
)"; )";
class DestroyObjectRegressionTests : public DawnNativeTest {}; class DestroyObjectRegressionTests : public DawnNativeTest {};

View File

@ -1457,7 +1457,7 @@ class SetBindGroupValidationTest : public ValidationTest {
wgpu::RenderPipeline CreateRenderPipeline() { wgpu::RenderPipeline CreateRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -1471,7 +1471,7 @@ class SetBindGroupValidationTest : public ValidationTest {
@group(0) @binding(2) var<storage, read_write> sBufferDynamic : S; @group(0) @binding(2) var<storage, read_write> sBufferDynamic : S;
@group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S; @group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S;
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor; utils::ComboRenderPipelineDescriptor pipelineDescriptor;
@ -1495,7 +1495,7 @@ class SetBindGroupValidationTest : public ValidationTest {
@group(0) @binding(2) var<storage, read_write> sBufferDynamic : S; @group(0) @binding(2) var<storage, read_write> sBufferDynamic : S;
@group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S; @group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S;
@stage(compute) @workgroup_size(4, 4, 1) fn main() { @compute @workgroup_size(4, 4, 1) fn main() {
})"); })");
wgpu::PipelineLayout pipelineLayout = wgpu::PipelineLayout pipelineLayout =
@ -1866,7 +1866,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
ValidationTest::SetUp(); ValidationTest::SetUp();
mVsModule = utils::CreateShaderModule(device, R"( mVsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -1936,7 +1936,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
} }
} }
ss << "@stage(fragment) fn main() {}"; ss << "@fragment fn main() {}";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, ss.str().c_str()); wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, ss.str().c_str());
@ -2068,7 +2068,7 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
const char* fsShader, const char* fsShader,
std::vector<wgpu::BindGroupLayout> bindGroupLayout) { std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -2095,7 +2095,7 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S; @group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S; @group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
@stage(fragment) fn main() { @fragment fn main() {
var val : vec2<f32> = sBufferDynamic.value; var val : vec2<f32> = sBufferDynamic.value;
val = sReadonlyBufferDynamic.value; val = sReadonlyBufferDynamic.value;
})", })",
@ -2130,7 +2130,7 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S; @group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S; @group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
@stage(compute) @workgroup_size(4, 4, 1) fn main() { @compute @workgroup_size(4, 4, 1) fn main() {
var val : vec2<f32> = sBufferDynamic.value; var val : vec2<f32> = sBufferDynamic.value;
val = sReadonlyBufferDynamic.value; val = sReadonlyBufferDynamic.value;
})", })",
@ -2173,12 +2173,12 @@ TEST_F(BindGroupLayoutCompatibilityTest, ROStorageInBGLWithRWStorageInShader) {
TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) { TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
constexpr char kTexture2DShaderFS[] = R"( constexpr char kTexture2DShaderFS[] = R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@stage(fragment) fn main() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"; })";
constexpr char kTexture2DShaderCS[] = R"( constexpr char kTexture2DShaderCS[] = R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"; })";
@ -2212,12 +2212,12 @@ TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
constexpr char kTexture2DArrayShaderFS[] = R"( constexpr char kTexture2DArrayShaderFS[] = 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"; })";
constexpr char kTexture2DArrayShaderCS[] = R"( constexpr char kTexture2DArrayShaderCS[] = R"(
@group(0) @binding(0) var myTexture : texture_2d_array<f32>; @group(0) @binding(0) var myTexture : texture_2d_array<f32>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"; })";
@ -2259,7 +2259,7 @@ TEST_F(BindGroupLayoutCompatibilityTest, ExternalTextureBindGroupLayoutCompatibi
// Test that an external texture binding works with a texture_external in the shader. // Test that an external texture binding works with a texture_external in the shader.
CreateFSRenderPipeline(R"( CreateFSRenderPipeline(R"(
@group(0) @binding(0) var myExternalTexture: texture_external; @group(0) @binding(0) var myExternalTexture: texture_external;
@stage(fragment) fn main() { @fragment fn main() {
_ = myExternalTexture; _ = myExternalTexture;
})", })",
{bgl}); {bgl});
@ -2267,7 +2267,7 @@ TEST_F(BindGroupLayoutCompatibilityTest, ExternalTextureBindGroupLayoutCompatibi
// Test that an external texture binding doesn't work with a texture_2d<f32> in the shader. // Test that an external texture binding doesn't work with a texture_2d<f32> in the shader.
ASSERT_DEVICE_ERROR(CreateFSRenderPipeline(R"( ASSERT_DEVICE_ERROR(CreateFSRenderPipeline(R"(
@group(0) @binding(0) var myTexture: texture_2d<f32>; @group(0) @binding(0) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() { @fragment fn main() {
_ = myTexture; _ = myTexture;
})", })",
{bgl})); {bgl}));
@ -2473,7 +2473,7 @@ class SamplerTypeBindingTest : public ValidationTest {
wgpu::RenderPipeline CreateFragmentPipeline(wgpu::BindGroupLayout* bindGroupLayout, wgpu::RenderPipeline CreateFragmentPipeline(wgpu::BindGroupLayout* bindGroupLayout,
const char* fragmentSource) { const char* fragmentSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -2500,7 +2500,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})"); })");
} }
@ -2512,7 +2512,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})"); })");
} }
@ -2524,7 +2524,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler_comparison; @group(0) @binding(0) var mySampler: sampler_comparison;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})"); })");
} }
@ -2536,7 +2536,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler_comparison; @group(0) @binding(0) var mySampler: sampler_comparison;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})")); })"));
} }
@ -2548,7 +2548,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler_comparison; @group(0) @binding(0) var mySampler: sampler_comparison;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})")); })"));
} }
@ -2560,7 +2560,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})")); })"));
} }
@ -2574,7 +2574,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>; @group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() { @fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0)); textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})"); })");
} }
@ -2588,7 +2588,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>; @group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() { @fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0)); textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})"); })");
} }
@ -2602,7 +2602,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_depth_2d; @group(0) @binding(1) var myTexture: texture_depth_2d;
@stage(fragment) fn main() { @fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0)); textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})"); })");
} }
@ -2616,7 +2616,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_depth_2d; @group(0) @binding(1) var myTexture: texture_depth_2d;
@stage(fragment) fn main() { @fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0)); textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})"); })");
} }
@ -2630,7 +2630,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler_comparison; @group(0) @binding(0) var mySampler: sampler_comparison;
@group(0) @binding(1) var myTexture: texture_depth_2d; @group(0) @binding(1) var myTexture: texture_depth_2d;
@stage(fragment) fn main() { @fragment fn main() {
textureSampleCompare(myTexture, mySampler, vec2<f32>(0.0, 0.0), 0.0); textureSampleCompare(myTexture, mySampler, vec2<f32>(0.0, 0.0), 0.0);
})"); })");
} }
@ -2644,7 +2644,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>; @group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() { @fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0)); textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})")); })"));
} }
@ -2658,7 +2658,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>; @group(0) @binding(1) var myTexture: texture_2d<f32>;
@stage(fragment) fn main() { @fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0)); textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
})"); })");
} }

View File

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

View File

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

View File

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

View File

@ -83,7 +83,7 @@ class DrawVertexAndIndexBufferOOBValidationTests : public ValidationTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
fsModule = utils::CreateShaderModule(device, R"( fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
} }
@ -117,7 +117,7 @@ class DrawVertexAndIndexBufferOOBValidationTests : public ValidationTest {
std::stringstream shaderStringStream; std::stringstream shaderStringStream;
shaderStringStream << R"( shaderStringStream << R"(
@stage(vertex) @vertex
fn main()" << inputStringStream.str() 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); return vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -21,7 +21,7 @@ class GetBindGroupLayoutTests : public ValidationTest {
protected: protected:
wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) { wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -52,7 +52,7 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
@group(0) @binding(0) var<uniform> uniform0 : S; @group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S; @group(1) @binding(0) var<uniform> uniform1 : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniform0.pos; var pos : vec4<f32> = uniform0.pos;
pos = uniform1.pos; pos = uniform1.pos;
return vec4<f32>(); return vec4<f32>();
@ -69,7 +69,7 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
} }
@group(3) @binding(0) var<storage, read_write> storage3 : S3; @group(3) @binding(0) var<storage, read_write> storage3 : S3;
@stage(fragment) fn main() { @fragment fn main() {
var pos_u : vec4<f32> = uniform2.pos; var pos_u : vec4<f32> = uniform2.pos;
var pos_s : mat4x4<f32> = storage3.pos; var pos_s : mat4x4<f32> = storage3.pos;
})"); })");
@ -103,7 +103,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultBindGroupLayoutPipelineCompatibility) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
@ -125,7 +125,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
@ -178,7 +178,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::ShaderModule emptyVertexModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule emptyVertexModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler; @group(0) @binding(1) var mySampler : sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
_ = myTexture; _ = myTexture;
_ = mySampler; _ = mySampler;
return vec4<f32>(); return vec4<f32>();
@ -187,7 +187,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::ShaderModule textureLoadVertexModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule textureLoadVertexModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler; @group(0) @binding(1) var mySampler : sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
textureLoad(myTexture, vec2<i32>(), 0); textureLoad(myTexture, vec2<i32>(), 0);
_ = mySampler; _ = mySampler;
return vec4<f32>(); return vec4<f32>();
@ -196,7 +196,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::ShaderModule textureSampleVertexModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule textureSampleVertexModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler; @group(0) @binding(1) var mySampler : sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
textureSampleLevel(myTexture, mySampler, vec2<f32>(), 0.0); textureSampleLevel(myTexture, mySampler, vec2<f32>(), 0.0);
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -204,7 +204,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::ShaderModule unusedTextureFragmentModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule unusedTextureFragmentModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler; @group(0) @binding(1) var mySampler : sampler;
@stage(fragment) fn main() { @fragment fn main() {
_ = myTexture; _ = myTexture;
_ = mySampler; _ = mySampler;
})"); })");
@ -212,7 +212,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::ShaderModule textureLoadFragmentModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule textureLoadFragmentModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler; @group(0) @binding(1) var mySampler : sampler;
@stage(fragment) fn main() { @fragment fn main() {
textureLoad(myTexture, vec2<i32>(), 0); textureLoad(myTexture, vec2<i32>(), 0);
_ = mySampler; _ = mySampler;
})"); })");
@ -220,7 +220,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::ShaderModule textureSampleFragmentModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule textureSampleFragmentModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>; @group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler; @group(0) @binding(1) var mySampler : sampler;
@stage(fragment) fn main() { @fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>()); textureSample(myTexture, mySampler, vec2<f32>());
})"); })");
@ -295,7 +295,7 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
@ -348,7 +348,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
} }
@group(0) @binding(0) var<storage, read_write> ssbo : S; @group(0) @binding(0) var<storage, read_write> ssbo : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = ssbo.pos; var pos : vec4<f32> = ssbo.pos;
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -362,7 +362,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -377,7 +377,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
} }
@group(0) @binding(0) var<storage, read> ssbo : S; @group(0) @binding(0) var<storage, read> ssbo : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = ssbo.pos; var pos : vec4<f32> = ssbo.pos;
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -391,7 +391,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -403,7 +403,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -416,7 +416,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -444,7 +444,7 @@ TEST_F(GetBindGroupLayoutTests, ExternalTextureBindingType) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
_ = myExternalTexture; _ = myExternalTexture;
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -472,7 +472,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -484,7 +484,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -496,7 +496,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -508,7 +508,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -520,7 +520,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -532,7 +532,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -560,7 +560,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -572,7 +572,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -584,7 +584,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -617,7 +617,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -632,7 +632,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
} }
@group(0) @binding(1) var<uniform> uniforms : S; @group(0) @binding(1) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -647,7 +647,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
} }
@group(0) @binding(1) var<uniform> uniforms : S; @group(0) @binding(1) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting( EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
@ -664,7 +664,7 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
@group(0) @binding(0) var<uniform> uniform0 : S; @group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S; @group(1) @binding(0) var<uniform> uniform1 : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniform0.pos; var pos : vec4<f32> = uniform0.pos;
pos = uniform1.pos; pos = uniform1.pos;
return vec4<f32>(); return vec4<f32>();
@ -676,7 +676,7 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
} }
@group(1) @binding(0) var<uniform> uniforms : S; @group(1) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
})"); })");
@ -702,7 +702,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
var pos : f32 = uniforms.pos; var pos : f32 = uniforms.pos;
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -713,7 +713,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
var pos : mat4x4<f32> = uniforms.pos; var pos : mat4x4<f32> = uniforms.pos;
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -724,7 +724,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : f32 = uniforms.pos; var pos : f32 = uniforms.pos;
})"); })");
@ -734,7 +734,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : mat4x4<f32> = uniforms.pos; var pos : mat4x4<f32> = uniforms.pos;
})"); })");
@ -793,24 +793,24 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
DAWN_SKIP_TEST_IF(UsesWire()); DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
})"); })");
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
_ = mySampler; _ = mySampler;
return vec4<f32>(); return vec4<f32>();
})"); })");
wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var mySampler: sampler; @group(0) @binding(0) var mySampler: sampler;
@stage(fragment) fn main() { @fragment fn main() {
_ = mySampler; _ = mySampler;
})"); })");
@ -869,7 +869,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
} }
@group(0) @binding(0) var<uniform> ubo : S; @group(0) @binding(0) var<uniform> ubo : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = ubo.pos; var pos : vec4<f32> = ubo.pos;
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -880,7 +880,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
} }
@group(0) @binding(0) var<storage, read_write> ssbo : S; @group(0) @binding(0) var<storage, read_write> ssbo : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = ssbo.pos; var pos : vec4<f32> = ssbo.pos;
})"); })");
@ -897,7 +897,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( 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> { @vertex fn main() -> @builtin(position) vec4<f32> {
textureDimensions(myTexture); textureDimensions(myTexture);
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -905,7 +905,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
@ -922,7 +922,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( 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> { @vertex fn main() -> @builtin(position) vec4<f32> {
textureDimensions(myTexture); textureDimensions(myTexture);
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -930,7 +930,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( 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() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"); })");
@ -947,7 +947,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( 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> { @vertex fn main() -> @builtin(position) vec4<f32> {
textureDimensions(myTexture); textureDimensions(myTexture);
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -955,7 +955,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( 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() { @fragment fn main() {
textureDimensions(myTexture); 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 it is an error to query an out of range bind group layout.
TEST_F(GetBindGroupLayoutTests, OutOfRangeIndex) { TEST_F(GetBindGroupLayoutTests, OutOfRangeIndex) {
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"( ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
@stage(fragment) fn main() { @fragment fn main() {
})") })")
.GetBindGroupLayout(kMaxBindGroups)); .GetBindGroupLayout(kMaxBindGroups));
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"( ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
@stage(fragment) fn main() { @fragment fn main() {
})") })")
.GetBindGroupLayout(kMaxBindGroups + 1)); .GetBindGroupLayout(kMaxBindGroups + 1));
} }
@ -994,7 +994,7 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
@group(0) @binding(0) var<uniform> uniforms0 : S; @group(0) @binding(0) var<uniform> uniforms0 : S;
@group(2) @binding(0) var<uniform> uniforms2 : S; @group(2) @binding(0) var<uniform> uniforms2 : S;
@stage(fragment) fn main() { @fragment fn main() {
var pos : vec4<f32> = uniforms0.pos; var pos : vec4<f32> = uniforms0.pos;
pos = uniforms2.pos; pos = uniforms2.pos;
})"); })");
@ -1046,13 +1046,13 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
} }
@group(0) @binding(0) var<uniform> uniforms : S; @group(0) @binding(0) var<uniform> uniforms : S;
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniforms.pos; var pos : vec4<f32> = uniforms.pos;
return vec4<f32>(); return vec4<f32>();
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
@ -1088,11 +1088,11 @@ TEST_F(GetBindGroupLayoutTests, FromCorrectEntryPoint) {
@group(0) @binding(0) var<storage, read_write> data0 : Data; @group(0) @binding(0) var<storage, read_write> data0 : Data;
@group(0) @binding(1) var<storage, read_write> data1 : Data; @group(0) @binding(1) var<storage, read_write> data1 : Data;
@stage(compute) @workgroup_size(1) fn compute0() { @compute @workgroup_size(1) fn compute0() {
data0.data = 0.0; data0.data = 0.0;
} }
@stage(compute) @workgroup_size(1) fn compute1() { @compute @workgroup_size(1) fn compute1() {
data1.data = 0.0; data1.data = 0.0;
} }
)"); )");

View File

@ -23,12 +23,12 @@ class IndexBufferValidationTest : public ValidationTest {
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format, wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format,
wgpu::PrimitiveTopology primitiveTopology) { wgpu::PrimitiveTopology primitiveTopology) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");

View File

@ -533,12 +533,12 @@ TEST_F(LabelTest, RenderPipeline) {
std::string label = "test"; std::string label = "test";
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
@ -574,7 +574,7 @@ TEST_F(LabelTest, ComputePipeline) {
std::string label = "test"; std::string label = "test";
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"); })");
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr); wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr);
wgpu::ComputePipelineDescriptor descriptor; wgpu::ComputePipelineDescriptor descriptor;
@ -610,7 +610,7 @@ TEST_F(LabelTest, ShaderModule) {
std::string label = "test"; std::string label = "test";
const char* source = R"( const char* source = R"(
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
})"; })";
wgpu::ShaderModuleWGSLDescriptor wgslDesc; wgpu::ShaderModuleWGSLDescriptor wgslDesc;

View File

@ -118,21 +118,21 @@ static const std::string kStructs = "struct ThreeFloats {f1 : f32, f2 : f32, f3
// Creates a compute shader with given bindings // Creates a compute shader with given bindings
std::string CreateComputeShaderWithBindings(const std::vector<BindingDescriptor>& bindings) { std::string CreateComputeShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
return kStructs + GenerateBindingString(bindings) + return kStructs + GenerateBindingString(bindings) +
"@stage(compute) @workgroup_size(1,1,1) fn main() {\n" + "@compute @workgroup_size(1,1,1) fn main() {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Compute) + "}"; GenerateReferenceString(bindings, wgpu::ShaderStage::Compute) + "}";
} }
// Creates a vertex shader with given bindings // Creates a vertex shader with given bindings
std::string CreateVertexShaderWithBindings(const std::vector<BindingDescriptor>& bindings) { std::string CreateVertexShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
return kStructs + GenerateBindingString(bindings) + return kStructs + GenerateBindingString(bindings) +
"@stage(vertex) fn main() -> @builtin(position) vec4<f32> {\n" + "@vertex fn main() -> @builtin(position) vec4<f32> {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Vertex) + GenerateReferenceString(bindings, wgpu::ShaderStage::Vertex) +
"\n return vec4<f32>(); " + "}"; "\n return vec4<f32>(); " + "}";
} }
// Creates a fragment shader with given bindings // Creates a fragment shader with given bindings
std::string CreateFragmentShaderWithBindings(const std::vector<BindingDescriptor>& bindings) { std::string CreateFragmentShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
return kStructs + GenerateBindingString(bindings) + "@stage(fragment) fn main() {\n" + return kStructs + GenerateBindingString(bindings) + "@fragment fn main() {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Fragment) + "}"; GenerateReferenceString(bindings, wgpu::ShaderStage::Fragment) + "}";
} }

View File

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

View File

@ -34,7 +34,7 @@ override c8: u32 = 0u; // type: uint32
override c9: u32 = 0u; // default override override c9: u32 = 0u; // default override
@id(1000) override c10: u32 = 10u; // default @id(1000) override c10: u32 = 10u; // default
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
// make sure the overridable constants are not optimized out // make sure the overridable constants are not optimized out
_ = u32(c0); _ = u32(c0);
_ = u32(c1); _ = u32(c1);
@ -64,7 +64,7 @@ override c8: u32; // type: uint32
override c9: u32 = 0u; // default override override c9: u32 = 0u; // default override
@id(1000) override c10: u32 = 10u; // default @id(1000) override c10: u32 = 10u; // default
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
// make sure the overridable constants are not optimized out // make sure the overridable constants are not optimized out
_ = u32(c0); _ = u32(c0);
_ = u32(c1); _ = u32(c1);

View File

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

View File

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

View File

@ -33,7 +33,7 @@ class RenderBundleValidationTest : public ValidationTest {
} }
@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> { @vertex fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -48,7 +48,7 @@ class RenderBundleValidationTest : public ValidationTest {
} }
@group(1) @binding(1) var<storage, read_write> ssbo : Storage; @group(1) @binding(1) var<storage, read_write> ssbo : Storage;
@stage(fragment) fn main() { @fragment fn main() {
})"); })");
wgpu::BindGroupLayout bgls[] = { wgpu::BindGroupLayout bgls[] = {

View File

@ -28,17 +28,17 @@ class RenderPipelineValidationTest : public ValidationTest {
ValidationTest::SetUp(); ValidationTest::SetUp();
vsModule = utils::CreateShaderModule(device, R"( vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
fsModule = utils::CreateShaderModule(device, R"( fsModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
fsModuleUint = utils::CreateShaderModule(device, R"( fsModuleUint = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<u32> { @fragment fn main() -> @location(0) vec4<u32> {
return vec4<u32>(0u, 255u, 0u, 255u); return vec4<u32>(0u, 255u, 0u, 255u);
})"); })");
} }
@ -336,7 +336,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
descriptor.vertex.module = vsModule; descriptor.vertex.module = vsModule;
std::ostringstream stream; std::ostringstream stream;
stream << R"( stream << R"(
@stage(fragment) fn main() -> @location(0) vec4<)" @fragment fn main() -> @location(0) vec4<)"
<< kScalarTypes[i] << R"(> { << kScalarTypes[i] << R"(> {
var result : vec4<)" var result : vec4<)"
<< kScalarTypes[i] << R"(>; << kScalarTypes[i] << R"(>;
@ -377,7 +377,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputComponentCountCompatibility)
std::ostringstream stream; std::ostringstream stream;
stream << R"( stream << R"(
@stage(fragment) fn main() -> @location(0) )"; @fragment fn main() -> @location(0) )";
switch (componentCount) { switch (componentCount) {
case 1: case 1:
stream << R"(f32 { stream << R"(f32 {
@ -788,7 +788,7 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
@group(0) @binding(0) var myTexture : texture_2d<)" @group(0) @binding(0) var myTexture : texture_2d<)"
<< kScalarTypes[i] << R"(>; << kScalarTypes[i] << R"(>;
@stage(fragment) fn main() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"; })";
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str()); descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
@ -837,7 +837,7 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
stream << R"( stream << R"(
@group(0) @binding(0) var myTexture : )" @group(0) @binding(0) var myTexture : )"
<< kTextureKeywords[i] << R"(<f32>; << kTextureKeywords[i] << R"(<f32>;
@stage(fragment) fn main() { @fragment fn main() {
textureDimensions(myTexture); textureDimensions(myTexture);
})"; })";
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str()); descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
@ -865,7 +865,7 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
data : array<u32, 100> data : array<u32, 100>
} }
@group(0) @binding(0) var<storage, read_write> dst : Dst; @group(0) @binding(0) var<storage, read_write> dst : Dst;
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
dst.data[VertexIndex] = 0x1234u; dst.data[VertexIndex] = 0x1234u;
return vec4<f32>(); return vec4<f32>();
})"); })");
@ -966,11 +966,11 @@ TEST_F(RenderPipelineValidationTest, DepthCompareUndefinedIsError) {
// Test that the entryPoint names must be present for the correct stage in the shader module. // Test that the entryPoint names must be present for the correct stage in the shader module.
TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) { TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> { @vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
} }
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> { @fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
@ -1012,11 +1012,11 @@ TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
// Test that vertex attrib validation is for the correct entryPoint // Test that vertex attrib validation is for the correct entryPoint
TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) { TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn vertex0(@location(0) attrib0 : vec4<f32>) @vertex fn vertex0(@location(0) attrib0 : vec4<f32>)
-> @builtin(position) vec4<f32> { -> @builtin(position) vec4<f32> {
return attrib0; return attrib0;
} }
@stage(vertex) fn vertex1(@location(1) attrib1 : vec4<f32>) @vertex fn vertex1(@location(1) attrib1 : vec4<f32>)
-> @builtin(position) vec4<f32> { -> @builtin(position) vec4<f32> {
return attrib1; return attrib1;
} }
@ -1054,10 +1054,10 @@ TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
// Test that fragment output validation is for the correct entryPoint // Test that fragment output validation is for the correct entryPoint
TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) { TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn fragmentFloat() -> @location(0) vec4<f32> { @fragment fn fragmentFloat() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
} }
@stage(fragment) fn fragmentUint() -> @location(0) vec4<u32> { @fragment fn fragmentUint() -> @location(0) vec4<u32> {
return vec4<u32>(0u, 0u, 0u, 0u); return vec4<u32>(0u, 0u, 0u, 0u);
} }
)"); )");
@ -1088,23 +1088,23 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
// Test that unwritten fragment outputs must have a write mask of 0. // Test that unwritten fragment outputs must have a write mask of 0.
TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) { TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
} }
)"); )");
wgpu::ShaderModule fsModuleWriteNone = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModuleWriteNone = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() {} @fragment fn main() {}
)"); )");
wgpu::ShaderModule fsModuleWrite0 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModuleWrite0 = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
} }
)"); )");
wgpu::ShaderModule fsModuleWrite1 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModuleWrite1 = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(1) vec4<f32> { @fragment fn main() -> @location(1) vec4<f32> {
return vec4<f32>(); return vec4<f32>();
} }
)"); )");
@ -1114,7 +1114,7 @@ TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
@location(0) target0 : vec4<f32>, @location(0) target0 : vec4<f32>,
@location(1) target1 : vec4<f32>, @location(1) target1 : vec4<f32>,
} }
@stage(fragment) fn main() -> FragmentOut { @fragment fn main() -> FragmentOut {
var out : FragmentOut; var out : FragmentOut;
return out; return out;
} }
@ -1226,10 +1226,10 @@ TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
@group(0) @binding(0) var<uniform> var0 : Uniforms; @group(0) @binding(0) var<uniform> var0 : Uniforms;
@group(0) @binding(1) var<uniform> var1 : Uniforms; @group(0) @binding(1) var<uniform> var1 : Uniforms;
@stage(vertex) fn vertex0() -> @builtin(position) vec4<f32> { @vertex fn vertex0() -> @builtin(position) vec4<f32> {
return var0.data; return var0.data;
} }
@stage(vertex) fn vertex1() -> @builtin(position) vec4<f32> { @vertex fn vertex1() -> @builtin(position) vec4<f32> {
return var1.data; return var1.data;
} }
)"); )");
@ -1323,7 +1323,7 @@ TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocatio
@location(0) vout: f32, @location(0) vout: f32,
@builtin(position) pos: vec4<f32>, @builtin(position) pos: vec4<f32>,
} }
@stage(vertex) fn main() -> A { @vertex fn main() -> A {
var vertexOut: A; var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vertexOut; return vertexOut;
@ -1332,14 +1332,14 @@ TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocatio
struct B { struct B {
@location(0) fin: f32 @location(0) fin: f32
} }
@stage(fragment) fn main(fragmentIn: B) -> @location(0) vec4<f32> { @fragment fn main(fragmentIn: B) -> @location(0) vec4<f32> {
return vec4<f32>(fragmentIn.fin, 0.0, 0.0, 1.0); return vec4<f32>(fragmentIn.fin, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule fragmentModuleInputAtLocation1 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fragmentModuleInputAtLocation1 = utils::CreateShaderModule(device, R"(
struct A { struct A {
@location(1) vout: f32 @location(1) vout: f32
} }
@stage(fragment) fn main(vertexOut: A) -> @location(0) vec4<f32> { @fragment fn main(vertexOut: A) -> @location(0) vec4<f32> {
return vec4<f32>(vertexOut.vout, 0.0, 0.0, 1.0); return vec4<f32>(vertexOut.vout, 0.0, 0.0, 1.0);
})"); })");
wgpu::ShaderModule vertexModuleOutputAtLocation1 = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vertexModuleOutputAtLocation1 = utils::CreateShaderModule(device, R"(
@ -1347,7 +1347,7 @@ TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocatio
@location(1) fin: f32, @location(1) fin: f32,
@builtin(position) pos: vec4<f32>, @builtin(position) pos: vec4<f32>,
} }
@stage(vertex) fn main() -> B { @vertex fn main() -> B {
var fragmentIn: B; var fragmentIn: B;
fragmentIn.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); fragmentIn.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return fragmentIn; return fragmentIn;
@ -1391,7 +1391,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
vertexStream << interfaceDeclaration << R"( vertexStream << interfaceDeclaration << R"(
@builtin(position) pos: vec4<f32>, @builtin(position) pos: vec4<f32>,
} }
@stage(vertex) fn main() -> A { @vertex fn main() -> A {
var vertexOut: A; var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vertexOut; return vertexOut;
@ -1402,7 +1402,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
std::ostringstream fragmentStream; std::ostringstream fragmentStream;
fragmentStream << interfaceDeclaration << R"( fragmentStream << interfaceDeclaration << R"(
} }
@stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> { @fragment fn main(fragmentIn: A) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"; })";
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str()); fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());
@ -1489,7 +1489,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
vertexStream << interfaceDeclaration << R"( vertexStream << interfaceDeclaration << R"(
@builtin(position) pos: vec4<f32>, @builtin(position) pos: vec4<f32>,
} }
@stage(vertex) fn main() -> A { @vertex fn main() -> A {
var vertexOut: A; var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vertexOut; return vertexOut;
@ -1500,7 +1500,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
std::ostringstream fragmentStream; std::ostringstream fragmentStream;
fragmentStream << interfaceDeclaration << R"( fragmentStream << interfaceDeclaration << R"(
} }
@stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> { @fragment fn main(fragmentIn: A) -> @location(0) vec4<f32> {
return fragmentIn.a; return fragmentIn.a;
})"; })";
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str()); fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());

View File

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

View File

@ -59,7 +59,7 @@ TEST_F(ShaderModuleValidationTest, CreationSuccess) {
// be compiled. // be compiled.
TEST_F(ShaderModuleValidationTest, FragmentOutputLocationExceedsMaxColorAttachments) { TEST_F(ShaderModuleValidationTest, FragmentOutputLocationExceedsMaxColorAttachments) {
std::ostringstream stream; std::ostringstream stream;
stream << "@stage(fragment) fn main() -> @location(" << kMaxColorAttachments << R"() vec4<f32> { stream << "@fragment fn main() -> @location(" << kMaxColorAttachments << R"() vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"; })";
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, stream.str().c_str())); ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, stream.str().c_str()));
@ -161,7 +161,7 @@ TEST_F(ShaderModuleValidationTest, GetCompilationMessages) {
DAWN_SKIP_TEST_IF(UsesWire()); DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0); return vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
@ -241,7 +241,7 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
errorMatcher = "failingVertex"; errorMatcher = "failingVertex";
pDesc.vertex.entryPoint = "failingVertex"; pDesc.vertex.entryPoint = "failingVertex";
pDesc.vertex.module = utils::CreateShaderModule(device, (ioStruct + R"( pDesc.vertex.module = utils::CreateShaderModule(device, (ioStruct + R"(
@stage(vertex) fn failingVertex() -> ShaderIO { @vertex fn failingVertex() -> ShaderIO {
var shaderIO : ShaderIO; var shaderIO : ShaderIO;
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return shaderIO; return shaderIO;
@ -249,7 +249,7 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
)") )")
.c_str()); .c_str());
pDesc.cFragment.module = utils::CreateShaderModule(device, R"( pDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0); return vec4<f32>(0.0);
} }
)"); )");
@ -260,13 +260,13 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
errorMatcher = "failingFragment"; errorMatcher = "failingFragment";
pDesc.cFragment.entryPoint = "failingFragment"; pDesc.cFragment.entryPoint = "failingFragment";
pDesc.cFragment.module = utils::CreateShaderModule(device, (ioStruct + R"( pDesc.cFragment.module = utils::CreateShaderModule(device, (ioStruct + R"(
@stage(fragment) fn failingFragment(io : ShaderIO) -> @location(0) vec4<f32> { @fragment fn failingFragment(io : ShaderIO) -> @location(0) vec4<f32> {
return vec4<f32>(0.0); return vec4<f32>(0.0);
} }
)") )")
.c_str()); .c_str());
pDesc.vertex.module = utils::CreateShaderModule(device, R"( pDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0); return vec4<f32>(0.0);
} }
)"); )");
@ -354,7 +354,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
errorMatcher = "failingVertex"; errorMatcher = "failingVertex";
pDesc.vertex.entryPoint = "failingVertex"; pDesc.vertex.entryPoint = "failingVertex";
pDesc.vertex.module = utils::CreateShaderModule(device, (ioStruct + R"( pDesc.vertex.module = utils::CreateShaderModule(device, (ioStruct + R"(
@stage(vertex) fn failingVertex() -> ShaderIO { @vertex fn failingVertex() -> ShaderIO {
var shaderIO : ShaderIO; var shaderIO : ShaderIO;
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0); shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return shaderIO; return shaderIO;
@ -362,7 +362,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
)") )")
.c_str()); .c_str());
pDesc.cFragment.module = utils::CreateShaderModule(device, R"( pDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0); return vec4<f32>(0.0);
} }
)"); )");
@ -373,13 +373,13 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
errorMatcher = "failingFragment"; errorMatcher = "failingFragment";
pDesc.cFragment.entryPoint = "failingFragment"; pDesc.cFragment.entryPoint = "failingFragment";
pDesc.cFragment.module = utils::CreateShaderModule(device, (ioStruct + R"( pDesc.cFragment.module = utils::CreateShaderModule(device, (ioStruct + R"(
@stage(fragment) fn failingFragment(io : ShaderIO) -> @location(0) vec4<f32> { @fragment fn failingFragment(io : ShaderIO) -> @location(0) vec4<f32> {
return vec4<f32>(0.0); return vec4<f32>(0.0);
} }
)") )")
.c_str()); .c_str());
pDesc.vertex.module = utils::CreateShaderModule(device, R"( pDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0); return vec4<f32>(0.0);
} }
)"); )");
@ -454,7 +454,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
TEST_F(ShaderModuleValidationTest, ComputeWorkgroupSizeLimits) { TEST_F(ShaderModuleValidationTest, ComputeWorkgroupSizeLimits) {
auto CheckShaderWithWorkgroupSize = [this](bool success, uint32_t x, uint32_t y, uint32_t z) { auto CheckShaderWithWorkgroupSize = [this](bool success, uint32_t x, uint32_t y, uint32_t z) {
std::ostringstream ss; std::ostringstream ss;
ss << "@stage(compute) @workgroup_size(" << x << "," << y << "," << z << ") fn main() {}"; ss << "@compute @workgroup_size(" << x << "," << y << "," << z << ") fn main() {}";
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
@ -506,7 +506,7 @@ TEST_F(ShaderModuleValidationTest, ComputeWorkgroupStorageSizeLimits) {
ss << "var<workgroup> mat4_data: array<mat4x4<f32>, " << mat4_count << ">;"; ss << "var<workgroup> mat4_data: array<mat4x4<f32>, " << mat4_count << ">;";
body << "_ = mat4_data;"; body << "_ = mat4_data;";
} }
ss << "@stage(compute) @workgroup_size(1) fn main() { " << body.str() << " }"; ss << "@compute @workgroup_size(1) fn main() { " << body.str() << " }";
wgpu::ComputePipelineDescriptor desc; wgpu::ComputePipelineDescriptor desc;
desc.compute.entryPoint = "main"; desc.compute.entryPoint = "main";
@ -543,7 +543,7 @@ struct Buf {
@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() { @compute @workgroup_size(1) fn main() {
// make sure the overridable constants are not optimized out // make sure the overridable constants are not optimized out
buf.data[0] = c0; buf.data[0] = c0;
buf.data[1] = c1; buf.data[1] = c1;
@ -560,7 +560,7 @@ TEST_F(ShaderModuleValidationTest, MaxBindingNumber) {
// kMaxBindingNumber is valid. // kMaxBindingNumber is valid.
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(65535) var s : sampler; @group(0) @binding(65535) var s : sampler;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
_ = s; _ = s;
} }
)"); )");
@ -569,7 +569,7 @@ TEST_F(ShaderModuleValidationTest, MaxBindingNumber) {
// kMaxBindingNumber + 1 is an error // kMaxBindingNumber + 1 is an error
desc.compute.module = utils::CreateShaderModule(device, R"( desc.compute.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(65536) var s : sampler; @group(0) @binding(65536) var s : sampler;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
_ = s; _ = s;
} }
)"); )");
@ -580,12 +580,12 @@ TEST_F(ShaderModuleValidationTest, MaxBindingNumber) {
TEST_F(ShaderModuleValidationTest, MissingDecorations) { TEST_F(ShaderModuleValidationTest, MissingDecorations) {
// Vertex input. // Vertex input.
utils::CreateShaderModule(device, R"( utils::CreateShaderModule(device, R"(
@stage(vertex) fn main(@location(0) a : vec4<f32>) -> @builtin(position) vec4<f32> { @vertex fn main(@location(0) a : vec4<f32>) -> @builtin(position) vec4<f32> {
return vec4(1.0); return vec4(1.0);
} }
)"); )");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@stage(vertex) fn main(a : vec4<f32>) -> @builtin(position) vec4<f32> { @vertex fn main(a : vec4<f32>) -> @builtin(position) vec4<f32> {
return vec4(1.0); return vec4(1.0);
} }
)")); )"));
@ -596,7 +596,7 @@ TEST_F(ShaderModuleValidationTest, MissingDecorations) {
@builtin(position) pos : vec4<f32>, @builtin(position) pos : vec4<f32>,
@location(0) a : f32, @location(0) a : f32,
} }
@stage(vertex) fn main() -> Output { @vertex fn main() -> Output {
var output : Output; var output : Output;
return output; return output;
} }
@ -606,7 +606,7 @@ TEST_F(ShaderModuleValidationTest, MissingDecorations) {
@builtin(position) pos : vec4<f32>, @builtin(position) pos : vec4<f32>,
a : f32, a : f32,
} }
@stage(vertex) fn main() -> Output { @vertex fn main() -> Output {
var output : Output; var output : Output;
return output; return output;
} }
@ -614,24 +614,24 @@ TEST_F(ShaderModuleValidationTest, MissingDecorations) {
// Fragment input // Fragment input
utils::CreateShaderModule(device, R"( utils::CreateShaderModule(device, R"(
@stage(fragment) fn main(@location(0) a : vec4<f32>) -> @location(0) f32 { @fragment fn main(@location(0) a : vec4<f32>) -> @location(0) f32 {
return 1.0; return 1.0;
} }
)"); )");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@stage(fragment) fn main(a : vec4<f32>) -> @location(0) f32 { @fragment fn main(a : vec4<f32>) -> @location(0) f32 {
return 1.0; return 1.0;
} }
)")); )"));
// Fragment input // Fragment input
utils::CreateShaderModule(device, R"( utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) f32 { @fragment fn main() -> @location(0) f32 {
return 1.0; return 1.0;
} }
)"); )");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> f32 { @fragment fn main() -> f32 {
return 1.0; return 1.0;
} }
)")); )"));
@ -639,21 +639,21 @@ TEST_F(ShaderModuleValidationTest, MissingDecorations) {
// Binding decorations // Binding decorations
utils::CreateShaderModule(device, R"( utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var s : sampler; @group(0) @binding(0) var s : sampler;
@stage(fragment) fn main() -> @location(0) f32 { @fragment fn main() -> @location(0) f32 {
_ = s; _ = s;
return 1.0; return 1.0;
} }
)"); )");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@binding(0) var s : sampler; @binding(0) var s : sampler;
@stage(fragment) fn main() -> @location(0) f32 { @fragment fn main() -> @location(0) f32 {
_ = s; _ = s;
return 1.0; return 1.0;
} }
)")); )"));
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@group(0) var s : sampler; @group(0) var s : sampler;
@stage(fragment) fn main() -> @location(0) f32 { @fragment fn main() -> @location(0) f32 {
_ = s; _ = s;
return 1.0; return 1.0;
} }
@ -665,5 +665,5 @@ TEST_F(ShaderModuleValidationTest, ExtensionMustBeAllowed) {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
enable f16; enable f16;
@stage(compute) @workgroup_size(1) fn main() {})")); @compute @workgroup_size(1) fn main() {})"));
} }

View File

@ -26,11 +26,11 @@ class StorageTextureValidationTests : public ValidationTest {
ValidationTest::SetUp(); ValidationTest::SetUp();
mDefaultVSModule = utils::CreateShaderModule(device, R"( mDefaultVSModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
mDefaultFSModule = utils::CreateShaderModule(device, R"( mDefaultFSModule = utils::CreateShaderModule(device, R"(
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0); return vec4<f32>(1.0, 0.0, 0.0, 1.0);
})"); })");
} }
@ -84,7 +84,7 @@ class StorageTextureValidationTests : public ValidationTest {
ostream << "@group(0) @binding(0) var image0 : " << imageTypeDeclaration << "<" ostream << "@group(0) @binding(0) var image0 : " << imageTypeDeclaration << "<"
<< imageFormatQualifier << ", " << access << imageFormatQualifier << ", " << access
<< ">;\n" << ">;\n"
"@stage(compute) @workgroup_size(1) fn main() {\n" "@compute @workgroup_size(1) fn main() {\n"
" textureDimensions(image0);\n" " textureDimensions(image0);\n"
"}\n"; "}\n";
@ -120,7 +120,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
{ {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = 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(vertex) @vertex
fn main(@builtin(vertex_index) vertex_index : u32) -> @builtin(position) vec4<f32> { 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)); textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
return vec4<f32>(0.0); return vec4<f32>(0.0);
@ -137,7 +137,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
{ {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = 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(fragment) fn main(@builtin(position) position : vec4<f32>) { @fragment fn main(@builtin(position) position : vec4<f32>) {
textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0)); textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})"); })");
@ -158,7 +158,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( 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>) { @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)); textureStore(image0, vec2<i32>(LocalInvocationID.xy), vec4<f32>(0.0, 0.0, 0.0, 0.0));
})"); })");
@ -177,7 +177,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
{ {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>; @group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
@stage(vertex) fn main() { @vertex fn main() {
textureDimensions(image0); textureDimensions(image0);
})")); })"));
} }
@ -186,7 +186,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
{ {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>; @group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
@stage(fragment) fn main() { @fragment fn main() {
textureDimensions(image0); textureDimensions(image0);
})")); })"));
} }
@ -195,7 +195,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
{ {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>; @group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
textureDimensions(image0); textureDimensions(image0);
})")); })"));
} }

View File

@ -48,7 +48,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
{ {
wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase; wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase;
pipelineDesc.compute.module = pipelineDesc.compute.module =
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}"); utils::CreateShaderModule(device, "@compute @workgroup_size(1) fn main() {}");
device.CreateComputePipeline(&pipelineDesc); device.CreateComputePipeline(&pipelineDesc);
} }
@ -59,7 +59,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
@id(1000) override c0: u32 = 1u; @id(1000) override c0: u32 = 1u;
@id(1000) override c1: u32; @id(1000) override c1: u32;
@stage(compute) @workgroup_size(1) fn main() { @compute @workgroup_size(1) fn main() {
_ = c0; _ = c0;
_ = c1; _ = c1;
})")); })"));
@ -69,7 +69,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
{ {
wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase; wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase;
pipelineDesc.compute.module = pipelineDesc.compute.module =
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}"); utils::CreateShaderModule(device, "@compute @workgroup_size(1) fn main() {}");
std::vector<wgpu::ConstantEntry> constants{{nullptr, "c", 1u}}; std::vector<wgpu::ConstantEntry> constants{{nullptr, "c", 1u}};
pipelineDesc.compute.constants = constants.data(); pipelineDesc.compute.constants = constants.data();
pipelineDesc.compute.constantCount = constants.size(); pipelineDesc.compute.constantCount = constants.size();

View File

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

View File

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

View File

@ -44,7 +44,7 @@ class D3D12DescriptorHeapTests : public DawnTest {
mSimpleVSModule = utils::CreateShaderModule(device, R"( mSimpleVSModule = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main( @vertex fn main(
@builtin(vertex_index) VertexIndex : u32 @builtin(vertex_index) VertexIndex : u32
) -> @builtin(position) vec4<f32> { ) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
@ -61,7 +61,7 @@ class D3D12DescriptorHeapTests : public DawnTest {
} }
@group(0) @binding(0) var<uniform> colorBuffer : U; @group(0) @binding(0) var<uniform> colorBuffer : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return colorBuffer.color; return colorBuffer.color;
})"); })");
} }
@ -176,13 +176,13 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) {
// a sampler bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps WILL NOT switch over // a sampler bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps WILL NOT switch over
// because the sampler heap allocations are de-duplicated. // because the sampler heap allocations are de-duplicated.
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main() -> @builtin(position) vec4<f32> { @vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); return vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var sampler0 : sampler; @group(0) @binding(0) var sampler0 : sampler;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
_ = sampler0; _ = sampler0;
return vec4<f32>(0.0, 0.0, 0.0, 0.0); return vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
@ -453,7 +453,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
} }
@group(0) @binding(0) var<uniform> buffer0 : U; @group(0) @binding(0) var<uniform> buffer0 : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(buffer0.heapSize, 0.0, 0.0, 1.0); return vec4<f32>(buffer0.heapSize, 0.0, 0.0, 1.0);
})"); })");
@ -786,7 +786,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
} }
@group(0) @binding(0) var<uniform> buffer0 : U; @group(0) @binding(0) var<uniform> buffer0 : U;
@stage(vertex) fn main( @vertex fn main(
@builtin(vertex_index) VertexIndex : u32 @builtin(vertex_index) VertexIndex : u32
) -> @builtin(position) vec4<f32> { ) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
@ -804,7 +804,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
@group(0) @binding(2) var texture0 : texture_2d<f32>; @group(0) @binding(2) var texture0 : texture_2d<f32>;
@group(0) @binding(3) var<uniform> buffer0 : U; @group(0) @binding(3) var<uniform> buffer0 : U;
@stage(fragment) fn main( @fragment fn main(
@builtin(position) FragCoord : vec4<f32> @builtin(position) FragCoord : vec4<f32>
) -> @location(0) vec4<f32> { ) -> @location(0) vec4<f32> {
return textureSample(texture0, sampler0, FragCoord.xy) + buffer0.color; return textureSample(texture0, sampler0, FragCoord.xy) + buffer0.color;

View File

@ -341,7 +341,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
// Fill in a view heap with "view only" bindgroups (1x view per group) by creating a // Fill in a view heap with "view only" bindgroups (1x view per group) by creating a
// view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over. // view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over.
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) fn main( @vertex fn main(
@builtin(vertex_index) VertexIndex : u32 @builtin(vertex_index) VertexIndex : u32
) -> @builtin(position) vec4<f32> { ) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>( var pos = array<vec2<f32>, 3>(
@ -358,7 +358,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
} }
@group(0) @binding(0) var<uniform> colorBuffer : U; @group(0) @binding(0) var<uniform> colorBuffer : U;
@stage(fragment) fn main() -> @location(0) vec4<f32> { @fragment fn main() -> @location(0) vec4<f32> {
return colorBuffer.color; return colorBuffer.color;
})"); })");

View File

@ -38,7 +38,7 @@ class InternalStorageBufferBindingTests : public DawnTest {
@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) @compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) { fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234u; buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234u;
} }

View File

@ -810,7 +810,7 @@ TEST_P(VulkanImageWrappingUsageTests, SRGBReinterpretation) {
utils::ComboRenderPipelineDescriptor pipelineDesc; utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@stage(vertex) @vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 6>( var pos = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, -1.0),
@ -825,7 +825,7 @@ TEST_P(VulkanImageWrappingUsageTests, SRGBReinterpretation) {
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture : texture_2d<f32>; @group(0) @binding(0) var texture : texture_2d<f32>;
@stage(fragment) @fragment
fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(texture, vec2<i32>(coord.xy), 0); return textureLoad(texture, vec2<i32>(coord.xy), 0);
} }