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 <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Austin Eng 2020-12-17 19:20:27 +00:00 committed by Commit Bot service account
parent 8d38c0164c
commit 02436022ae

View File

@ -74,13 +74,12 @@ class DepthStencilCopyTests : public DawnTest {
desc->vertexStage.module = mVertexModule; desc->vertexStage.module = mVertexModule;
std::string fsSource = R"( std::string fsSource = R"(
#version 450 [[builtin(frag_depth)]] var<out> FragDepth : f32;
void main() { [[stage(fragment)]] fn main() -> void {
gl_FragDepth = )" + std::to_string(regionDepth) + FragDepth = )" + std::to_string(regionDepth) +
";\n}"; ";\n}";
desc->cFragmentStage.module = desc->cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, fsSource.c_str());
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fsSource.c_str());
desc->cDepthStencilState.format = format; desc->cDepthStencilState.format = format;
desc->cDepthStencilState.depthWriteEnabled = true; desc->cDepthStencilState.depthWriteEnabled = true;
desc->depthStencilState = &desc->cDepthStencilState; desc->depthStencilState = &desc->cDepthStencilState;
@ -253,16 +252,16 @@ class DepthStencilCopyTests : public DawnTest {
// Sample the input texture and write out depth. |result| will only be set to 1 if we // Sample the input texture and write out depth. |result| will only be set to 1 if we
// pass the depth test. // pass the depth test.
pipelineDescriptor.cFragmentStage.module = pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( [[set(0), binding(0)]] var<uniform_constant> texture0 : texture_2d<f32>;
#version 450 [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
layout(set = 0, binding = 0) uniform sampler sampler0;
layout(set = 0, binding = 1) uniform texture2D texture0;
layout(location = 0) out uint result; [[location(0)]] var<out> result : u32;
void main() { [[builtin(frag_depth)]] var<out> FragDepth : f32;
[[stage(fragment)]] fn main() -> void {
result = 1u; result = 1u;
gl_FragDepth = texelFetch(sampler2D(texture0, sampler0), ivec2(gl_FragCoord), 0)[0]; FragDepth = textureLoad(texture0, vec2<i32>(FragCoord.xy), 0)[0];
})"); })");
// Pass the depth test only if the depth is equal. // Pass the depth test only if the depth is equal.
@ -288,11 +287,9 @@ class DepthStencilCopyTests : public DawnTest {
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
// Bind a sampler and the depth data texture. // Bind the depth data texture.
wgpu::SamplerDescriptor samplerDesc = {}; wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
wgpu::BindGroup bindGroup = utils::MakeBindGroup( {{0, depthDataTexture.CreateView()}});
device, pipeline.GetBindGroupLayout(0),
{{0, device.CreateSampler(&samplerDesc)}, {1, depthDataTexture.CreateView()}});
wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&passDescriptor); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&passDescriptor);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);