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();