Add wgpu::TextureComponentType::DepthComparison

And deprecate using ::Float in the bind group layout for
"shadow textures" in the pipeline (along with a deprecation test).

Adds the ability to be used with DepthComparison only to depth textures,
this could potentially a breaking change if users where doing
depth-comparison on float32 textures but that's not supported in WebGPU.

Bug: dawn:527
Change-Id: Ib28b0443e3002e0aa2811713b9e843c2417e13e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30240
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez
2020-10-16 14:13:16 +00:00
committed by Commit Bot service account
parent 2a8ada7951
commit 4196a546bf
16 changed files with 204 additions and 23 deletions

View File

@@ -345,6 +345,41 @@ TEST_F(BindGroupValidationTest, SamplingDepthTexture) {
}
}
// Check that a texture must have a correct format for DepthComparison
TEST_F(BindGroupValidationTest, TextureComponentTypeDepthComparison) {
wgpu::BindGroupLayout depthLayout = utils::MakeBindGroupLayout(
device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison}});
// Control case: setting a depth texture works.
wgpu::Texture depthTexture =
CreateTexture(wgpu::TextureUsage::Sampled, wgpu::TextureFormat::Depth32Float, 1);
utils::MakeBindGroup(device, depthLayout, {{0, depthTexture.CreateView()}});
// Error case: setting a Float typed texture view fails.
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, depthLayout, {{0, mSampledTextureView}}));
}
// Check that a depth texture is allowed to be used for both TextureComponentType::Float and
// ::DepthComparison
TEST_F(BindGroupValidationTest, TextureComponentTypeForDepthTexture) {
wgpu::BindGroupLayout depthLayout = utils::MakeBindGroupLayout(
device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison}});
wgpu::BindGroupLayout floatLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0,
false, wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::Texture depthTexture =
CreateTexture(wgpu::TextureUsage::Sampled, wgpu::TextureFormat::Depth32Float, 1);
utils::MakeBindGroup(device, depthLayout, {{0, depthTexture.CreateView()}});
utils::MakeBindGroup(device, floatLayout, {{0, depthTexture.CreateView()}});
}
// Check that a texture must have the correct dimension
TEST_F(BindGroupValidationTest, TextureDimension) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
@@ -900,7 +935,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
}
// Test that multisampled textures must be 2D sampled textures
TEST_F(BindGroupLayoutValidationTest, MultisampledTextures) {
TEST_F(BindGroupLayoutValidationTest, MultisampledTextureViewDimension) {
// Multisampled 2D texture works.
utils::MakeBindGroupLayout(
device, {
@@ -958,6 +993,45 @@ TEST_F(BindGroupLayoutValidationTest, MultisampledTextures) {
}));
}
// Test that multisampled textures cannot be DepthComparison
TEST_F(BindGroupLayoutValidationTest, MultisampledTextureComponentType) {
// Multisampled float component type works.
utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false,
0, false, wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float},
});
// Multisampled float (defaulted) component type works.
utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false,
0, false, wgpu::TextureViewDimension::e2D},
});
// Multisampled uint component type works.
utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false,
0, false, wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Uint},
});
// Multisampled sint component type works.
utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false,
0, false, wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Sint},
});
// Multisampled depth comparison component typeworks.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device,
{
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, 0, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison},
}));
}
// Test that it is an error to pass multisampled=true for non-texture bindings
TEST_F(BindGroupLayoutValidationTest, MultisampledMustBeTexture) {
// Base: Multisampled 2D texture works.