From 6e673b4b81932454056035d736397aa7b34f803e Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Wed, 23 Jun 2021 00:52:09 +0000 Subject: [PATCH] Disallow creating stencil textures with multiple mips on Metal Various aspects with this appear to be broken. Bug: dawn:838 Change-Id: If706508b90214f9b5f4b2884448f281945295827 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/55560 Auto-Submit: Austin Eng Reviewed-by: Corentin Wallez Reviewed-by: Jiawei Shao Commit-Queue: Jiawei Shao --- src/dawn_native/Texture.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index 0bec0015b8..14a14a9bdf 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -19,6 +19,7 @@ #include "common/Assert.h" #include "common/Constants.h" #include "common/Math.h" +#include "dawn_native/Adapter.h" #include "dawn_native/Device.h" #include "dawn_native/EnumMaskIterator.h" #include "dawn_native/PassResourceUsage.h" @@ -289,6 +290,17 @@ namespace dawn_native { DAWN_TRY(ValidateTextureSize(descriptor, format)); + if (device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs) && format->HasStencil() && + descriptor->mipLevelCount > 1 && + device->GetAdapter()->GetBackendType() == wgpu::BackendType::Metal) { + // TODO(crbug.com/dawn/838): Implement a workaround for this issue. + // Readbacks from the non-zero mip of a stencil texture may contain + // garbage data. + return DAWN_VALIDATION_ERROR( + "crbug.com/dawn/838: Stencil textures with more than one mip level are " + "disabled on Metal."); + } + return {}; }