Add e2e tests for CopyTextureForBrowser_Formats with tier1-enabled formats This commit adds e2e tests for CopyTextureForBrowser_Formats with renderable formats enabled by tier1. Bug: 421941589 Change-Id: I7d14a75fde171f51c2ffd7175c3be895a508d294 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/260774 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Shanxing Mei <shanxing.mei@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/CopyTextureForBrowserHelper.cpp b/src/dawn/native/CopyTextureForBrowserHelper.cpp index 1f0e09e..5f22b74 100644 --- a/src/dawn/native/CopyTextureForBrowserHelper.cpp +++ b/src/dawn/native/CopyTextureForBrowserHelper.cpp
@@ -263,30 +263,6 @@ return {}; } -MaybeError ValidateCopyForBrowserDestinationFormat(const wgpu::TextureFormat dstFormat) { - switch (dstFormat) { - case wgpu::TextureFormat::R8Unorm: - case wgpu::TextureFormat::R16Float: - case wgpu::TextureFormat::R32Float: - case wgpu::TextureFormat::RG8Unorm: - case wgpu::TextureFormat::RG16Float: - case wgpu::TextureFormat::RG32Float: - case wgpu::TextureFormat::RGBA8Unorm: - case wgpu::TextureFormat::RGBA8UnormSrgb: - case wgpu::TextureFormat::BGRA8Unorm: - case wgpu::TextureFormat::BGRA8UnormSrgb: - case wgpu::TextureFormat::RGB10A2Unorm: - case wgpu::TextureFormat::RGBA16Float: - case wgpu::TextureFormat::RGBA32Float: - break; - default: - return DAWN_VALIDATION_ERROR("Destination texture format (%s) is not supported.", - dstFormat); - } - - return {}; -} - RenderPipelineBase* GetCachedCopyTexturePipeline(InternalPipelineStore* store, wgpu::TextureFormat dstFormat) { auto pipeline = store->copyTextureForBrowserPipelines.find(dstFormat); @@ -617,13 +593,15 @@ options.internalUsage ? UsageValidationMode::Internal : UsageValidationMode::Default; DAWN_TRY(ValidateCanUseAs(destination.texture, wgpu::TextureUsage::CopyDst, mode)); DAWN_TRY(ValidateCanUseAs(destination.texture, wgpu::TextureUsage::RenderAttachment, mode)); - + const Format& dstFormat = destination.texture->GetFormat(); + DAWN_INVALID_IF(dstFormat.aspects != Aspect::Color, + "The destination %s is not a color texture.", destination.texture); + DAWN_INVALID_IF(dstFormat.GetAspectInfo(Aspect::Color).baseType != TextureComponentType::Float, + "The destination %s must not be an integer format.", destination.texture); DAWN_INVALID_IF(destination.texture->GetSampleCount() > 1, "The destination texture sample count (%u) is not 1.", destination.texture->GetSampleCount()); - DAWN_TRY(ValidateCopyForBrowserDestinationFormat(destination.texture->GetFormat().format)); - // The valid destination formats are all color formats. DAWN_INVALID_IF( destination.aspect != wgpu::TextureAspect::All,
diff --git a/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp b/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp index 6e3c728..08d5f3a 100644 --- a/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp +++ b/src/dawn/tests/end2end/CopyTextureForBrowserTests.cpp
@@ -383,14 +383,25 @@ case wgpu::TextureFormat::RGB10A2Unorm: case wgpu::TextureFormat::RGBA16Float: case wgpu::TextureFormat::RGBA32Float: + case wgpu::TextureFormat::RGBA16Unorm: + case wgpu::TextureFormat::RGBA16Snorm: + case wgpu::TextureFormat::RGBA8Snorm: return 4; + case wgpu::TextureFormat::RG11B10Ufloat: + return 3; case wgpu::TextureFormat::RG8Unorm: case wgpu::TextureFormat::RG16Float: case wgpu::TextureFormat::RG32Float: + case wgpu::TextureFormat::RG16Unorm: + case wgpu::TextureFormat::RG16Snorm: + case wgpu::TextureFormat::RG8Snorm: return 2; case wgpu::TextureFormat::R8Unorm: case wgpu::TextureFormat::R16Float: case wgpu::TextureFormat::R32Float: + case wgpu::TextureFormat::R16Unorm: + case wgpu::TextureFormat::R16Snorm: + case wgpu::TextureFormat::R8Snorm: return 1; default: DAWN_UNREACHABLE(); @@ -588,6 +599,14 @@ class CopyTextureForBrowser_Formats : public CopyTextureForBrowserTests<DawnTestWithParams<FormatTestParams>> { protected: + std::vector<wgpu::FeatureName> GetRequiredFeatures() override { + std::vector<wgpu::FeatureName> requiredFeatures = {}; + if (SupportsFeatures({wgpu::FeatureName::TextureFormatsTier1})) { + requiredFeatures.push_back(wgpu::FeatureName::TextureFormatsTier1); + } + return requiredFeatures; + } + bool IsDstFormatSrgbFormats() { return GetParam().mDstFormat == wgpu::TextureFormat::RGBA8UnormSrgb || GetParam().mDstFormat == wgpu::TextureFormat::BGRA8UnormSrgb; @@ -698,6 +717,7 @@ TextureSpec dstTextureSpec; dstTextureSpec.format = GetParam().mDstFormat; + DAWN_TEST_UNSUPPORTED_IF(!utils::IsRenderableFormat(device, dstTextureSpec.format)); wgpu::Extent3D copySize = {kDefaultTextureWidth, kDefaultTextureHeight}; wgpu::CopyTextureForBrowserOptions options = {}; @@ -1154,19 +1174,25 @@ DoColorConversionTest(); } -DAWN_INSTANTIATE_TEST_P( - CopyTextureForBrowser_Formats, - {D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()}, - std::vector<wgpu::TextureFormat>({wgpu::TextureFormat::RGBA8Unorm, - wgpu::TextureFormat::BGRA8Unorm, - wgpu::TextureFormat::RGBA16Float}), - std::vector<wgpu::TextureFormat>( - {wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::R16Float, wgpu::TextureFormat::R32Float, - wgpu::TextureFormat::RG8Unorm, wgpu::TextureFormat::RG16Float, - wgpu::TextureFormat::RG32Float, wgpu::TextureFormat::RGBA8Unorm, - wgpu::TextureFormat::RGBA8UnormSrgb, wgpu::TextureFormat::BGRA8Unorm, - wgpu::TextureFormat::BGRA8UnormSrgb, wgpu::TextureFormat::RGB10A2Unorm, - wgpu::TextureFormat::RGBA16Float, wgpu::TextureFormat::RGBA32Float})); +DAWN_INSTANTIATE_TEST_P(CopyTextureForBrowser_Formats, + {D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), + VulkanBackend()}, + std::vector<wgpu::TextureFormat>({wgpu::TextureFormat::RGBA8Unorm, + wgpu::TextureFormat::BGRA8Unorm, + wgpu::TextureFormat::RGBA16Float}), + std::vector<wgpu::TextureFormat>( + {wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::R16Float, + wgpu::TextureFormat::R32Float, wgpu::TextureFormat::RG8Unorm, + wgpu::TextureFormat::RG16Float, wgpu::TextureFormat::RG32Float, + wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureFormat::RGBA8UnormSrgb, + wgpu::TextureFormat::BGRA8Unorm, wgpu::TextureFormat::BGRA8UnormSrgb, + wgpu::TextureFormat::RGB10A2Unorm, wgpu::TextureFormat::RGBA16Float, + wgpu::TextureFormat::RGBA32Float, wgpu::TextureFormat::R16Unorm, + wgpu::TextureFormat::RG16Unorm, wgpu::TextureFormat::RGBA16Unorm, + wgpu::TextureFormat::R16Snorm, wgpu::TextureFormat::RG16Snorm, + wgpu::TextureFormat::RGBA16Snorm, wgpu::TextureFormat::R8Snorm, + wgpu::TextureFormat::RG8Snorm, wgpu::TextureFormat::RGBA8Snorm, + wgpu::TextureFormat::RG11B10Ufloat})); // Verify |CopyTextureForBrowser| doing subrect copy. // Source texture is a full red texture and dst texture is a full
diff --git a/src/dawn/utils/TextureUtils.cpp b/src/dawn/utils/TextureUtils.cpp index f61f207..4e21552 100644 --- a/src/dawn/utils/TextureUtils.cpp +++ b/src/dawn/utils/TextureUtils.cpp
@@ -248,11 +248,11 @@ switch (textureFormat) { case wgpu::TextureFormat::RGB9E5Ufloat: + return false; case wgpu::TextureFormat::R8Snorm: case wgpu::TextureFormat::RG8Snorm: case wgpu::TextureFormat::RGBA8Snorm: - return false; - + return device.HasFeature(wgpu::FeatureName::TextureFormatsTier1); case wgpu::TextureFormat::RG11B10Ufloat: return device.HasFeature(wgpu::FeatureName::RG11B10UfloatRenderable);