From 261d261fd16f98af9f5bbbf3111aec3d9716adfe Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 26 Nov 2020 12:56:45 +0000 Subject: [PATCH] Port ResourceUsageTrackingTests to WGSL Bug: dawn:572 Change-Id: I945aa6720a4dd1cacb4b2a74d40482ffadde5b55 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33930 Reviewed-by: Austin Eng Reviewed-by: Ben Clayton Commit-Queue: Corentin Wallez --- .../validation/ResourceUsageTrackingTests.cpp | 72 ++++++++----------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp b/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp index 0025899d25..3622146e13 100644 --- a/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp +++ b/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp @@ -46,16 +46,12 @@ namespace { // in the caller, so it is always correct for binding validation between bind groups and // pipeline. But those bind groups in caller can be used for validation for other purposes. wgpu::RenderPipeline CreateNoOpRenderPipeline() { - wgpu::ShaderModule vsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - void main() { + wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[stage(vertex)]] fn main() -> void { })"); - wgpu::ShaderModule fsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - void main() { + wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[stage(fragment)]] fn main() -> void { })"); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); pipelineDescriptor.vertexStage.module = vsModule; @@ -65,10 +61,8 @@ namespace { } wgpu::ComputePipeline CreateNoOpComputePipeline() { - wgpu::ShaderModule csModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( - #version 450 - void main() { + wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[stage(compute)]] fn main() -> void { })"); wgpu::ComputePipelineDescriptor pipelineDescriptor; pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, nullptr); @@ -777,19 +771,16 @@ namespace { wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); // Create a passthrough render pipeline with a readonly buffer - wgpu::ShaderModule vsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - void main() { + wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[stage(vertex)]] fn main() -> void { })"); - wgpu::ShaderModule fsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - layout(std140, set = 0, binding = 0) readonly buffer RBuffer { - readonly float value; - } rBuffer; - void main() { + wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[block]] struct RBuffer { + [[offset(0)]] value : f32; + }; + [[set(0), binding(0)]] var rBuffer : [[access(read)]] RBuffer; + [[stage(fragment)]] fn main() -> void { })"); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); pipelineDescriptor.vertexStage.module = vsModule; @@ -824,13 +815,12 @@ namespace { wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); // Create a passthrough compute pipeline with a readonly buffer - wgpu::ShaderModule csModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( - #version 450 - layout(std140, set = 0, binding = 0) readonly buffer RBuffer { - readonly float value; - } rBuffer; - void main() { + wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[block]] struct RBuffer { + [[offset(0)]] value : f32; + }; + [[set(0), binding(0)]] var rBuffer : [[access(read)]] RBuffer; + [[stage(compute)]] fn main() -> void { })"); wgpu::ComputePipelineDescriptor pipelineDescriptor; pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl0); @@ -1595,17 +1585,13 @@ namespace { // Test render pass { // Create a passthrough render pipeline with a readonly storage texture - wgpu::ShaderModule vsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - void main() { + wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[stage(vertex)]] fn main() -> void { })"); - wgpu::ShaderModule fsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - layout(set = 0, binding = 0, rgba8) uniform readonly image2D image; - void main() { + wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[set(0), binding(0)]] var tex : texture_storage_ro_2d; + [[stage(fragment)]] fn main() -> void { })"); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); pipelineDescriptor.vertexStage.module = vsModule; @@ -1629,11 +1615,9 @@ namespace { // Test compute pass { // Create a passthrough compute pipeline with a readonly storage texture - wgpu::ShaderModule csModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( - #version 450 - layout(set = 0, binding = 0, rgba8) uniform readonly image2D image; - void main() { + wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[set(0), binding(0)]] var tex : texture_storage_ro_2d; + [[stage(compute)]] fn main() -> void { })"); wgpu::ComputePipelineDescriptor pipelineDescriptor; pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &readBGL);