Port ResourceUsageTrackingTests to WGSL

Bug: dawn:572
Change-Id: I945aa6720a4dd1cacb4b2a74d40482ffadde5b55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33930
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-11-26 12:56:45 +00:00 committed by Commit Bot service account
parent 6edd993c47
commit 261d261fd1
1 changed files with 28 additions and 44 deletions

View File

@ -46,16 +46,12 @@ namespace {
// in the caller, so it is always correct for binding validation between bind groups and // 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. // pipeline. But those bind groups in caller can be used for validation for other purposes.
wgpu::RenderPipeline CreateNoOpRenderPipeline() { wgpu::RenderPipeline CreateNoOpRenderPipeline() {
wgpu::ShaderModule vsModule = wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( [[stage(vertex)]] fn main() -> void {
#version 450
void main() {
})"); })");
wgpu::ShaderModule fsModule = wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( [[stage(fragment)]] fn main() -> void {
#version 450
void main() {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
@ -65,10 +61,8 @@ namespace {
} }
wgpu::ComputePipeline CreateNoOpComputePipeline() { wgpu::ComputePipeline CreateNoOpComputePipeline() {
wgpu::ShaderModule csModule = wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( [[stage(compute)]] fn main() -> void {
#version 450
void main() {
})"); })");
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, nullptr); pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, nullptr);
@ -777,19 +771,16 @@ namespace {
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
// Create a passthrough render pipeline with a readonly buffer // Create a passthrough render pipeline with a readonly buffer
wgpu::ShaderModule vsModule = wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( [[stage(vertex)]] fn main() -> void {
#version 450
void main() {
})"); })");
wgpu::ShaderModule fsModule = wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( [[block]] struct RBuffer {
#version 450 [[offset(0)]] value : f32;
layout(std140, set = 0, binding = 0) readonly buffer RBuffer { };
readonly float value; [[set(0), binding(0)]] var<storage_buffer> rBuffer : [[access(read)]] RBuffer;
} rBuffer; [[stage(fragment)]] fn main() -> void {
void main() {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
@ -824,13 +815,12 @@ namespace {
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
// Create a passthrough compute pipeline with a readonly buffer // Create a passthrough compute pipeline with a readonly buffer
wgpu::ShaderModule csModule = wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( [[block]] struct RBuffer {
#version 450 [[offset(0)]] value : f32;
layout(std140, set = 0, binding = 0) readonly buffer RBuffer { };
readonly float value; [[set(0), binding(0)]] var<storage_buffer> rBuffer : [[access(read)]] RBuffer;
} rBuffer; [[stage(compute)]] fn main() -> void {
void main() {
})"); })");
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl0); pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl0);
@ -1595,17 +1585,13 @@ namespace {
// Test render pass // Test render pass
{ {
// Create a passthrough render pipeline with a readonly storage texture // Create a passthrough render pipeline with a readonly storage texture
wgpu::ShaderModule vsModule = wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( [[stage(vertex)]] fn main() -> void {
#version 450
void main() {
})"); })");
wgpu::ShaderModule fsModule = wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( [[set(0), binding(0)]] var<uniform_constant> tex : texture_storage_ro_2d<rgba8unorm>;
#version 450 [[stage(fragment)]] fn main() -> void {
layout(set = 0, binding = 0, rgba8) uniform readonly image2D image;
void main() {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
@ -1629,11 +1615,9 @@ namespace {
// Test compute pass // Test compute pass
{ {
// Create a passthrough compute pipeline with a readonly storage texture // Create a passthrough compute pipeline with a readonly storage texture
wgpu::ShaderModule csModule = wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( [[set(0), binding(0)]] var<uniform_constant> tex : texture_storage_ro_2d<rgba8unorm>;
#version 450 [[stage(compute)]] fn main() -> void {
layout(set = 0, binding = 0, rgba8) uniform readonly image2D image;
void main() {
})"); })");
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &readBGL); pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &readBGL);