From 03cf7c3eaeaf79325e23937aa7a3069e148fe2aa Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Wed, 29 Jul 2020 19:44:41 +0000 Subject: [PATCH] Enable GBV by default for correctness tests. Dawn apps using debug builds may hang due to GBV being always on by default. This change turns on GBV for correctness tests only. BUG=dawn:490 Change-Id: I2728d834ed53f9acc7556f8d1178d718c0b49457 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25421 Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng Commit-Queue: Bryan Bernhart --- src/dawn_native/DawnNative.cpp | 4 ++++ src/dawn_native/Instance.cpp | 8 ++++++++ src/dawn_native/Instance.h | 4 ++++ src/dawn_native/d3d12/BackendD3D12.cpp | 9 ++++++--- src/include/dawn_native/DawnNative.h | 3 +++ src/tests/DawnTest.cpp | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp index 32061152bd..3fe408c101 100644 --- a/src/dawn_native/DawnNative.cpp +++ b/src/dawn_native/DawnNative.cpp @@ -149,6 +149,10 @@ namespace dawn_native { mImpl->EnableBackendValidation(enableBackendValidation); } + void Instance::EnableGPUBasedBackendValidation(bool enableGPUBasedBackendValidation) { + mImpl->EnableGPUBasedBackendValidation(enableGPUBasedBackendValidation); + } + void Instance::EnableBeginCaptureOnStartup(bool beginCaptureOnStartup) { mImpl->EnableBeginCaptureOnStartup(beginCaptureOnStartup); } diff --git a/src/dawn_native/Instance.cpp b/src/dawn_native/Instance.cpp index 58e6cffd24..49db4b60fc 100644 --- a/src/dawn_native/Instance.cpp +++ b/src/dawn_native/Instance.cpp @@ -202,6 +202,14 @@ namespace dawn_native { return mEnableBackendValidation; } + void InstanceBase::EnableGPUBasedBackendValidation(bool enableGPUBasedBackendValidation) { + mEnableGPUValidation = enableGPUBasedBackendValidation; + } + + bool InstanceBase::IsGPUBasedBackendValidationEnabled() const { + return mEnableGPUValidation; + } + void InstanceBase::EnableBeginCaptureOnStartup(bool beginCaptureOnStartup) { mBeginCaptureOnStartup = beginCaptureOnStartup; } diff --git a/src/dawn_native/Instance.h b/src/dawn_native/Instance.h index 0ade98b4e6..14d4eef2ff 100644 --- a/src/dawn_native/Instance.h +++ b/src/dawn_native/Instance.h @@ -60,6 +60,9 @@ namespace dawn_native { void EnableBackendValidation(bool enableBackendValidation); bool IsBackendValidationEnabled() const; + void EnableGPUBasedBackendValidation(bool enableGPUBasedBackendValidation); + bool IsGPUBasedBackendValidationEnabled() const; + void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup); bool IsBeginCaptureOnStartupEnabled() const; @@ -88,6 +91,7 @@ namespace dawn_native { bool mEnableBackendValidation = false; bool mBeginCaptureOnStartup = false; + bool mEnableGPUValidation = false; dawn_platform::Platform* mPlatform = nullptr; diff --git a/src/dawn_native/d3d12/BackendD3D12.cpp b/src/dawn_native/d3d12/BackendD3D12.cpp index 7075093953..946ce7bd98 100644 --- a/src/dawn_native/d3d12/BackendD3D12.cpp +++ b/src/dawn_native/d3d12/BackendD3D12.cpp @@ -26,7 +26,8 @@ namespace dawn_native { namespace d3d12 { ResultOrError> CreateFactory(const PlatformFunctions* functions, bool enableBackendValidation, - bool beginCaptureOnStartup) { + bool beginCaptureOnStartup, + bool enableGPUBasedBackendValidation) { ComPtr factory; uint32_t dxgiFactoryFlags = 0; @@ -39,7 +40,8 @@ namespace dawn_native { namespace d3d12 { functions->d3d12GetDebugInterface(IID_PPV_ARGS(&debugController)))) { ASSERT(debugController != nullptr); debugController->EnableDebugLayer(); - debugController->SetEnableGPUBasedValidation(true); + debugController->SetEnableGPUBasedValidation( + enableGPUBasedBackendValidation); // Enable additional debug layers. dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG; @@ -96,7 +98,8 @@ namespace dawn_native { namespace d3d12 { DAWN_TRY_ASSIGN(mFactory, CreateFactory(mFunctions.get(), instance->IsBackendValidationEnabled(), - instance->IsBeginCaptureOnStartupEnabled())); + instance->IsBeginCaptureOnStartupEnabled(), + instance->IsGPUBasedBackendValidationEnabled())); return {}; } diff --git a/src/include/dawn_native/DawnNative.h b/src/include/dawn_native/DawnNative.h index 219e53fa94..d8bf6b4f06 100644 --- a/src/include/dawn_native/DawnNative.h +++ b/src/include/dawn_native/DawnNative.h @@ -157,6 +157,9 @@ namespace dawn_native { // Enable debug capture on Dawn startup void EnableBeginCaptureOnStartup(bool beginCaptureOnStartup); + // Enable GPU based backend validation if it has. + void EnableGPUBasedBackendValidation(bool enableGPUBasedBackendValidation); + void SetPlatform(dawn_platform::Platform* platform); // Returns the underlying WGPUInstance object. diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp index d396e25b6a..613a4dd615 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -368,6 +368,7 @@ std::unique_ptr DawnTestEnvironment::CreateInstanceAndDis const { auto instance = std::make_unique(); instance->EnableBackendValidation(mEnableBackendValidation); + instance->EnableGPUBasedBackendValidation(mEnableBackendValidation); instance->EnableBeginCaptureOnStartup(mBeginCaptureOnStartup); instance->DiscoverDefaultAdapters();