From 314840bba1078acae936680ffac87b7bbae3aead Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Wed, 15 Jun 2022 00:21:26 +0000 Subject: [PATCH] Remove call of TextureFormatSupportsRendering from TextureValidationTest/SampleCount This patch removes the call of TextureFormatSupportsRendering() from the dawn_unittest TextureValidationTest/SampleCount as in Dawn we have already updated the restriction that non-renderable formats cannot be used to create multisampled textures. Bug: dawn:1459 Test: dawn_unittests Change-Id: I3b7a016328c8cd06c771c58dd181005b61e01510 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93421 Commit-Queue: Jiawei Shao Kokoro: Kokoro Reviewed-by: Austin Eng Reviewed-by: Corentin Wallez --- .../RenderPassDescriptorValidationTests.cpp | 2 +- .../validation/TextureValidationTests.cpp | 4 -- src/dawn/utils/TextureUtils.cpp | 54 ++++++------------- src/dawn/utils/TextureUtils.h | 2 +- 4 files changed, 17 insertions(+), 45 deletions(-) diff --git a/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp index f9a99ff6fa..452a222d9d 100644 --- a/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp @@ -720,7 +720,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetFormat) { for (wgpu::TextureFormat format : utils::kAllTextureFormats) { if (!utils::TextureFormatSupportsMultisampling(format) || - !utils::TextureFormatSupportsRendering(format)) { + utils::IsDepthOrStencilFormat(format)) { continue; } diff --git a/src/dawn/tests/unittests/validation/TextureValidationTests.cpp b/src/dawn/tests/unittests/validation/TextureValidationTests.cpp index 56594239f6..543d7e03fe 100644 --- a/src/dawn/tests/unittests/validation/TextureValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/TextureValidationTests.cpp @@ -145,10 +145,6 @@ TEST_F(TextureValidationTest, SampleCount) { descriptor.sampleCount = 4; for (wgpu::TextureFormat format : utils::kFormatsInCoreSpec) { - if (!utils::TextureFormatSupportsRendering(format)) { - continue; - } - descriptor.format = format; if (utils::TextureFormatSupportsMultisampling(format)) { device.CreateTexture(&descriptor); diff --git a/src/dawn/utils/TextureUtils.cpp b/src/dawn/utils/TextureUtils.cpp index f11d724ff7..ad2739f3c9 100644 --- a/src/dawn/utils/TextureUtils.cpp +++ b/src/dawn/utils/TextureUtils.cpp @@ -130,6 +130,21 @@ bool IsDepthOnlyFormat(wgpu::TextureFormat textureFormat) { } } +bool IsDepthOrStencilFormat(wgpu::TextureFormat textureFormat) { + switch (textureFormat) { + case wgpu::TextureFormat::Depth16Unorm: + case wgpu::TextureFormat::Depth24Plus: + case wgpu::TextureFormat::Depth32Float: + case wgpu::TextureFormat::Depth24PlusStencil8: + case wgpu::TextureFormat::Depth24UnormStencil8: + case wgpu::TextureFormat::Depth32FloatStencil8: + case wgpu::TextureFormat::Stencil8: + return true; + default: + return false; + } +} + bool TextureFormatSupportsMultisampling(wgpu::TextureFormat textureFormat) { if (IsBCTextureFormat(textureFormat) || IsETC2TextureFormat(textureFormat) || IsASTCTextureFormat(textureFormat)) { @@ -157,45 +172,6 @@ bool TextureFormatSupportsMultisampling(wgpu::TextureFormat textureFormat) { } } -bool TextureFormatSupportsRendering(wgpu::TextureFormat textureFormat) { - switch (textureFormat) { - case wgpu::TextureFormat::R8Unorm: - case wgpu::TextureFormat::R8Uint: - case wgpu::TextureFormat::R8Sint: - case wgpu::TextureFormat::RG8Unorm: - case wgpu::TextureFormat::RG8Uint: - case wgpu::TextureFormat::RG8Sint: - case wgpu::TextureFormat::RGBA8Unorm: - case wgpu::TextureFormat::RGBA8Uint: - case wgpu::TextureFormat::RGBA8Sint: - case wgpu::TextureFormat::BGRA8Unorm: - case wgpu::TextureFormat::BGRA8UnormSrgb: - case wgpu::TextureFormat::R16Uint: - case wgpu::TextureFormat::R16Sint: - case wgpu::TextureFormat::R16Float: - case wgpu::TextureFormat::RG16Uint: - case wgpu::TextureFormat::RG16Sint: - case wgpu::TextureFormat::RG16Float: - case wgpu::TextureFormat::RGBA16Uint: - case wgpu::TextureFormat::RGBA16Sint: - case wgpu::TextureFormat::RGBA16Float: - case wgpu::TextureFormat::R32Uint: - case wgpu::TextureFormat::R32Sint: - case wgpu::TextureFormat::R32Float: - case wgpu::TextureFormat::RG32Uint: - case wgpu::TextureFormat::RG32Sint: - case wgpu::TextureFormat::RG32Float: - case wgpu::TextureFormat::RGBA32Uint: - case wgpu::TextureFormat::RGBA32Sint: - case wgpu::TextureFormat::RGBA32Float: - case wgpu::TextureFormat::RGB10A2Unorm: - return true; - - default: - return false; - } -} - bool TextureFormatSupportsResolveTarget(wgpu::TextureFormat textureFormat) { switch (textureFormat) { case wgpu::TextureFormat::R8Unorm: diff --git a/src/dawn/utils/TextureUtils.h b/src/dawn/utils/TextureUtils.h index 80fecabfdb..5b0025d1da 100644 --- a/src/dawn/utils/TextureUtils.h +++ b/src/dawn/utils/TextureUtils.h @@ -228,10 +228,10 @@ bool IsASTCTextureFormat(wgpu::TextureFormat textureFormat); bool IsDepthOnlyFormat(wgpu::TextureFormat textureFormat); bool IsStencilOnlyFormat(wgpu::TextureFormat textureFormat); +bool IsDepthOrStencilFormat(wgpu::TextureFormat textureFormat); bool TextureFormatSupportsMultisampling(wgpu::TextureFormat textureFormat); bool TextureFormatSupportsResolveTarget(wgpu::TextureFormat textureFormat); -bool TextureFormatSupportsRendering(wgpu::TextureFormat textureFormat); uint32_t GetTexelBlockSizeInBytes(wgpu::TextureFormat textureFormat); uint32_t GetTextureFormatBlockWidth(wgpu::TextureFormat textureFormat);