Fix for multiplanar video in Compat validation.
Relax view validation for multiplanar video textures.
Views of the same texture can differ in format if the texture
format is multiplanar.
Bug: 430849277
Change-Id: Iffdad5f9b2265fcc98fb7202f7dffc229c09fbf9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/252698
Reviewed-by: Gregg Tavares <gman@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/CommandBufferStateTracker.cpp b/src/dawn/native/CommandBufferStateTracker.cpp
index f4bda93..728c0bd 100644
--- a/src/dawn/native/CommandBufferStateTracker.cpp
+++ b/src/dawn/native/CommandBufferStateTracker.cpp
@@ -276,7 +276,14 @@
bool TextureViewsMatch(const TextureViewBase* a, const TextureViewBase* b) {
DAWN_ASSERT(a->GetTexture() == b->GetTexture());
- return a->GetFormat().GetIndex() == b->GetFormat().GetIndex() &&
+ // If the texture format is multiplanar, the view formats are permitted to differ (e.g., R8
+ // and RG8), referring to different planes of the same YUV texture. This cannot happen in
+ // OpenGL that actually needs the validation of texture views matching so it's safe for
+ // backends to ignore this here. We don't allow creating multiplanar texture views directly in
+ // WebGPU so this code cannot be triggered in JavaScript and only occurs hit when Chromium
+ // creates a YUV texture internally.
+ return (a->GetFormat().GetIndex() == b->GetFormat().GetIndex() ||
+ a->GetTexture()->GetFormat().IsMultiPlanar()) &&
a->GetDimension() == b->GetDimension() && a->GetBaseMipLevel() == b->GetBaseMipLevel() &&
a->GetLevelCount() == b->GetLevelCount() &&
a->GetBaseArrayLayer() == b->GetBaseArrayLayer() &&
diff --git a/src/dawn/tests/end2end/VideoViewsTests.cpp b/src/dawn/tests/end2end/VideoViewsTests.cpp
index ea2ab9f..676a554 100644
--- a/src/dawn/tests/end2end/VideoViewsTests.cpp
+++ b/src/dawn/tests/end2end/VideoViewsTests.cpp
@@ -58,12 +58,6 @@
DAWN_TEST_UNSUPPORTED_IF(!IsMultiPlanarFormatsSupported());
// TODO(crbug.com/342213634): Crashes on ChromeOS volteer devices.
DAWN_SUPPRESS_TEST_IF(IsChromeOS() && IsVulkan() && IsIntel() && IsBackendValidationEnabled());
-
- // compat mode doesn't allow different texture views to be used in a draw call unless
- // FlexibleTextureViews feature is enabled. The tests need texture views to sample and render to
- // separate planes of a multiplanar texture.
- DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode() &&
- !SupportsFeatures({wgpu::FeatureName::FlexibleTextureViews}));
}
std::vector<wgpu::FeatureName> VideoViewsTestsBase::GetRequiredFeatures() {