From 02436022aee96150bccda1a1b54ff64f000626f3 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 17 Dec 2020 19:20:27 +0000 Subject: [PATCH] Update DepthStencilCopyTests to use WGSL - FragDepth Bug: dawn:572 Change-Id: If21d9b7d85394d56f38b079370d9333d342c0b44 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33885 Commit-Queue: Austin Eng Reviewed-by: Corentin Wallez --- src/tests/end2end/DepthStencilCopyTests.cpp | 37 ++++++++++----------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/tests/end2end/DepthStencilCopyTests.cpp b/src/tests/end2end/DepthStencilCopyTests.cpp index 5591cf1999..ce20ef1649 100644 --- a/src/tests/end2end/DepthStencilCopyTests.cpp +++ b/src/tests/end2end/DepthStencilCopyTests.cpp @@ -74,13 +74,12 @@ class DepthStencilCopyTests : public DawnTest { desc->vertexStage.module = mVertexModule; std::string fsSource = R"( - #version 450 - void main() { - gl_FragDepth = )" + std::to_string(regionDepth) + + [[builtin(frag_depth)]] var FragDepth : f32; + [[stage(fragment)]] fn main() -> void { + FragDepth = )" + std::to_string(regionDepth) + ";\n}"; - desc->cFragmentStage.module = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fsSource.c_str()); + desc->cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, fsSource.c_str()); desc->cDepthStencilState.format = format; desc->cDepthStencilState.depthWriteEnabled = true; desc->depthStencilState = &desc->cDepthStencilState; @@ -253,17 +252,17 @@ class DepthStencilCopyTests : public DawnTest { // Sample the input texture and write out depth. |result| will only be set to 1 if we // pass the depth test. - pipelineDescriptor.cFragmentStage.module = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - layout(set = 0, binding = 0) uniform sampler sampler0; - layout(set = 0, binding = 1) uniform texture2D texture0; + pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( + [[set(0), binding(0)]] var texture0 : texture_2d; + [[builtin(frag_coord)]] var FragCoord : vec4; - layout(location = 0) out uint result; - void main() { - result = 1u; - gl_FragDepth = texelFetch(sampler2D(texture0, sampler0), ivec2(gl_FragCoord), 0)[0]; - })"); + [[location(0)]] var result : u32; + [[builtin(frag_depth)]] var FragDepth : f32; + + [[stage(fragment)]] fn main() -> void { + result = 1u; + FragDepth = textureLoad(texture0, vec2(FragCoord.xy), 0)[0]; + })"); // Pass the depth test only if the depth is equal. pipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; @@ -288,11 +287,9 @@ class DepthStencilCopyTests : public DawnTest { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); - // Bind a sampler and the depth data texture. - wgpu::SamplerDescriptor samplerDesc = {}; - wgpu::BindGroup bindGroup = utils::MakeBindGroup( - device, pipeline.GetBindGroupLayout(0), - {{0, device.CreateSampler(&samplerDesc)}, {1, depthDataTexture.CreateView()}}); + // Bind the depth data texture. + wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), + {{0, depthDataTexture.CreateView()}}); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&passDescriptor); pass.SetPipeline(pipeline);