From 9ec746e3b9b17e518d40b089946f66cf405f5580 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 24 Feb 2023 16:26:00 +0000 Subject: [PATCH] Disable async pipeline compilation on Mac AMD with backend validation Instead, compile pipelines synchronously. When backend validation is on with Mac AMD, the driver crashes during pipeline compilation. This seems to only occur when partition alloc is enabled. Bug: dawn:1200 Change-Id: I520087eeae9c356990962d0c4a96eba017735af1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121400 Commit-Queue: Austin Eng Kokoro: Kokoro Reviewed-by: Corentin Wallez --- src/dawn/native/metal/ComputePipelineMTL.mm | 10 ++++++++++ src/dawn/native/metal/RenderPipelineMTL.mm | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/dawn/native/metal/ComputePipelineMTL.mm b/src/dawn/native/metal/ComputePipelineMTL.mm index 3ed84dcc13..9d48e6eb9a 100644 --- a/src/dawn/native/metal/ComputePipelineMTL.mm +++ b/src/dawn/native/metal/ComputePipelineMTL.mm @@ -15,7 +15,9 @@ #include "dawn/native/metal/ComputePipelineMTL.h" #include "dawn/common/Math.h" +#include "dawn/native/Adapter.h" #include "dawn/native/CreatePipelineAsyncTask.h" +#include "dawn/native/Instance.h" #include "dawn/native/metal/DeviceMTL.h" #include "dawn/native/metal/ShaderModuleMTL.h" #include "dawn/native/metal/UtilsMetal.h" @@ -84,9 +86,17 @@ bool ComputePipeline::RequiresStorageBufferLength() const { void ComputePipeline::InitializeAsync(Ref computePipeline, WGPUCreateComputePipelineAsyncCallback callback, void* userdata) { + AdapterBase* adapter = computePipeline->GetDevice()->GetAdapter(); std::unique_ptr asyncTask = std::make_unique(std::move(computePipeline), callback, userdata); + // Workaround a crash where the validation layers on AMD crash with partition alloc. + // See crbug.com/dawn/1200. + if (adapter->GetInstance()->IsBackendValidationEnabled() && + gpu_info::IsAMD(adapter->GetVendorId())) { + asyncTask->Run(); + return; + } CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask)); } diff --git a/src/dawn/native/metal/RenderPipelineMTL.mm b/src/dawn/native/metal/RenderPipelineMTL.mm index f147474f6e..57ef5c5108 100644 --- a/src/dawn/native/metal/RenderPipelineMTL.mm +++ b/src/dawn/native/metal/RenderPipelineMTL.mm @@ -14,7 +14,9 @@ #include "dawn/native/metal/RenderPipelineMTL.h" +#include "dawn/native/Adapter.h" #include "dawn/native/CreatePipelineAsyncTask.h" +#include "dawn/native/Instance.h" #include "dawn/native/VertexFormat.h" #include "dawn/native/metal/DeviceMTL.h" #include "dawn/native/metal/PipelineLayoutMTL.h" @@ -508,9 +510,17 @@ NSRef RenderPipeline::MakeVertexDesc() { void RenderPipeline::InitializeAsync(Ref renderPipeline, WGPUCreateRenderPipelineAsyncCallback callback, void* userdata) { + AdapterBase* adapter = renderPipeline->GetDevice()->GetAdapter(); std::unique_ptr asyncTask = std::make_unique(std::move(renderPipeline), callback, userdata); + // Workaround a crash where the validation layers on AMD crash with partition alloc. + // See crbug.com/dawn/1200. + if (adapter->GetInstance()->IsBackendValidationEnabled() && + gpu_info::IsAMD(adapter->GetVendorId())) { + asyncTask->Run(); + return; + } CreateRenderPipelineAsyncTask::RunAsync(std::move(asyncTask)); }