Support sampling depth and stencil of combined d/s formats

This CL adds sampling of depth-only and stencil-only texture
views on all backends. However, Metal on macOS <= 10.11 will
need a workaround to use separate depth/stencil textures for
each aspect since it is impossible to sample the stencil
aspect of a combined depth/stencil texture.

Also fixes sampling of depth24plus on D3D12 which had an
incomplete check for determining if a TYPELESS format is
necessary.

Bug: dawn:439, dawn:553
Change-Id: Id4991c565f822add200054296714e2dcd330119a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30725
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Austin Eng
2020-11-04 15:27:11 +00:00
committed by Commit Bot service account
parent 9d6265bc07
commit a0f1725c4f
9 changed files with 633 additions and 153 deletions

View File

@@ -311,10 +311,8 @@ TEST_F(BindGroupValidationTest, TextureComponentType) {
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, uintTextureView}}));
}
// Test which depth-stencil formats are allowed to be sampled.
// This is a regression test for a change in dawn_native mistakenly allowing the depth24plus formats
// to be sampled without proper backend support.
TEST_F(BindGroupValidationTest, SamplingDepthTexture) {
// Test which depth-stencil formats are allowed to be sampled (all).
TEST_F(BindGroupValidationTest, SamplingDepthStencilTexture) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}});
@@ -330,20 +328,30 @@ TEST_F(BindGroupValidationTest, SamplingDepthTexture) {
utils::MakeBindGroup(device, layout, {{0, texture.CreateView()}});
}
// Depth24Plus is not allowed to be sampled.
// Depth24Plus is allowed to be sampled.
{
desc.format = wgpu::TextureFormat::Depth24Plus;
wgpu::Texture texture = device.CreateTexture(&desc);
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, texture.CreateView()}}));
utils::MakeBindGroup(device, layout, {{0, texture.CreateView()}});
}
// Depth24PlusStencil8 is not allowed to be sampled.
// Depth24PlusStencil8 is allowed to be sampled, if the depth or stencil aspect is selected.
{
desc.format = wgpu::TextureFormat::Depth24PlusStencil8;
wgpu::Texture texture = device.CreateTexture(&desc);
wgpu::TextureViewDescriptor viewDesc = {};
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, texture.CreateView()}}));
viewDesc.aspect = wgpu::TextureAspect::DepthOnly;
utils::MakeBindGroup(device, layout, {{0, texture.CreateView(&viewDesc)}});
wgpu::BindGroupLayoutEntry entry = {0, wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture};
entry.textureComponentType = wgpu::TextureComponentType::Uint;
layout = utils::MakeBindGroupLayout(device, {entry});
viewDesc.aspect = wgpu::TextureAspect::StencilOnly;
utils::MakeBindGroup(device, layout, {{0, texture.CreateView(&viewDesc)}});
}
}