Enable D3D12 validation layers
Run end2end tests with argument '-d' or '--enable-backend-validation' Change-Id: I34a3f453dcd3a57d76301801ae2abe42f847cb1b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7140 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Hao Li <hao.x.li@intel.com>
This commit is contained in:
parent
2e56970932
commit
0195dbf908
|
@ -99,4 +99,11 @@ namespace dawn_native {
|
||||||
return mImpl->GetToggleInfo(toggleName);
|
return mImpl->GetToggleInfo(toggleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Instance::EnableBackendValidation(bool enableBackendValidation) {
|
||||||
|
mImpl->EnableBackendValidation(enableBackendValidation);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Instance::IsBackendValidationEnabled() {
|
||||||
|
return mImpl->IsBackendValidationEnabled();
|
||||||
|
}
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -230,4 +230,12 @@ namespace dawn_native {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceBase::EnableBackendValidation(bool enableBackendValidation) {
|
||||||
|
mEnableBackendValidation = enableBackendValidation;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InstanceBase::IsBackendValidationEnabled() {
|
||||||
|
return mEnableBackendValidation;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -51,6 +51,9 @@ namespace dawn_native {
|
||||||
Toggle ToggleNameToEnum(const char* toggleName);
|
Toggle ToggleNameToEnum(const char* toggleName);
|
||||||
const char* ToggleEnumToName(Toggle toggle);
|
const char* ToggleEnumToName(Toggle toggle);
|
||||||
|
|
||||||
|
void EnableBackendValidation(bool enableBackendValidation);
|
||||||
|
bool IsBackendValidationEnabled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Lazily creates connections to all backends that have been compiled.
|
// Lazily creates connections to all backends that have been compiled.
|
||||||
void EnsureBackendConnections();
|
void EnsureBackendConnections();
|
||||||
|
@ -66,6 +69,7 @@ namespace dawn_native {
|
||||||
bool mDiscoveredDefaultAdapters = false;
|
bool mDiscoveredDefaultAdapters = false;
|
||||||
|
|
||||||
bool mToggleNameToEnumMapInitialized = false;
|
bool mToggleNameToEnumMapInitialized = false;
|
||||||
|
bool mEnableBackendValidation = false;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<BackendConnection>> mBackends;
|
std::vector<std::unique_ptr<BackendConnection>> mBackends;
|
||||||
std::vector<std::unique_ptr<AdapterBase>> mAdapters;
|
std::vector<std::unique_ptr<AdapterBase>> mAdapters;
|
||||||
|
|
|
@ -23,30 +23,33 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
ResultOrError<ComPtr<IDXGIFactory4>> CreateFactory(const PlatformFunctions* functions) {
|
ResultOrError<ComPtr<IDXGIFactory4>> CreateFactory(const PlatformFunctions* functions,
|
||||||
|
bool enableBackendValidation) {
|
||||||
ComPtr<IDXGIFactory4> factory;
|
ComPtr<IDXGIFactory4> factory;
|
||||||
|
|
||||||
uint32_t dxgiFactoryFlags = 0;
|
uint32_t dxgiFactoryFlags = 0;
|
||||||
#if defined(DAWN_ENABLE_ASSERTS)
|
|
||||||
// Enable the debug layer (requires the Graphics Tools "optional feature").
|
// Enable the debug layer (requires the Graphics Tools "optional feature").
|
||||||
{
|
{
|
||||||
ComPtr<ID3D12Debug> debugController;
|
if (enableBackendValidation) {
|
||||||
if (SUCCEEDED(functions->d3d12GetDebugInterface(IID_PPV_ARGS(&debugController)))) {
|
ComPtr<ID3D12Debug> debugController;
|
||||||
ASSERT(debugController != nullptr);
|
if (SUCCEEDED(
|
||||||
debugController->EnableDebugLayer();
|
functions->d3d12GetDebugInterface(IID_PPV_ARGS(&debugController)))) {
|
||||||
|
ASSERT(debugController != nullptr);
|
||||||
|
debugController->EnableDebugLayer();
|
||||||
|
|
||||||
// Enable additional debug layers.
|
// Enable additional debug layers.
|
||||||
dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG;
|
dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<IDXGIDebug1> dxgiDebug;
|
ComPtr<IDXGIDebug1> dxgiDebug;
|
||||||
if (SUCCEEDED(functions->dxgiGetDebugInterface1(0, IID_PPV_ARGS(&dxgiDebug)))) {
|
if (SUCCEEDED(functions->dxgiGetDebugInterface1(0, IID_PPV_ARGS(&dxgiDebug)))) {
|
||||||
ASSERT(dxgiDebug != nullptr);
|
ASSERT(dxgiDebug != nullptr);
|
||||||
dxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL,
|
dxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL,
|
||||||
DXGI_DEBUG_RLO_FLAGS(DXGI_DEBUG_RLO_ALL));
|
DXGI_DEBUG_RLO_FLAGS(DXGI_DEBUG_RLO_ALL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // defined(DAWN_ENABLE_ASSERTS)
|
|
||||||
|
|
||||||
if (FAILED(functions->createDxgiFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory)))) {
|
if (FAILED(functions->createDxgiFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory)))) {
|
||||||
return DAWN_CONTEXT_LOST_ERROR("Failed to create a DXGI factory");
|
return DAWN_CONTEXT_LOST_ERROR("Failed to create a DXGI factory");
|
||||||
|
@ -65,7 +68,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
mFunctions = std::make_unique<PlatformFunctions>();
|
mFunctions = std::make_unique<PlatformFunctions>();
|
||||||
DAWN_TRY(mFunctions->LoadFunctions());
|
DAWN_TRY(mFunctions->LoadFunctions());
|
||||||
|
|
||||||
DAWN_TRY_ASSIGN(mFactory, CreateFactory(mFunctions.get()));
|
DAWN_TRY_ASSIGN(
|
||||||
|
mFactory, CreateFactory(mFunctions.get(), GetInstance()->IsBackendValidationEnabled()));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
#include <dxgi1_4.h>
|
#include <dxgi1_4.h>
|
||||||
#include <wrl.h>
|
#include <wrl.h>
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_ASSERTS)
|
#include <dxgidebug.h>
|
||||||
# include <dxgidebug.h>
|
|
||||||
#endif // defined(DAWN_ENABLE_ASSERTS)
|
|
||||||
|
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,10 @@ namespace dawn_native {
|
||||||
|
|
||||||
const ToggleInfo* GetToggleInfo(const char* toggleName);
|
const ToggleInfo* GetToggleInfo(const char* toggleName);
|
||||||
|
|
||||||
|
// Enable backend's validation layers if it has.
|
||||||
|
void EnableBackendValidation(bool enableBackendValidation);
|
||||||
|
bool IsBackendValidationEnabled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InstanceBase* mImpl = nullptr;
|
InstanceBase* mImpl = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -102,9 +102,17 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp("-d", argv[i]) == 0 || strcmp("--enable-backend-validation", argv[i]) == 0) {
|
||||||
|
mEnableBackendValidation = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
||||||
std::cout << "\n\nUsage: " << argv[0] << " [GTEST_FLAGS...] [-w] \n";
|
std::cout << "\n\nUsage: " << argv[0]
|
||||||
std::cout << " -w, --use-wire: Run the tests through the wire (defaults to no wire)";
|
<< " [GTEST_FLAGS...] [-w] [--enable-validation-layers]\n";
|
||||||
|
std::cout << " -w, --use-wire: Run the tests through the wire (defaults to no wire)\n";
|
||||||
|
std::cout << " -d, --enable-backend-validation: Enable backend validation (defaults"
|
||||||
|
<< " to disabled)\n";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +123,7 @@ void DawnTestEnvironment::SetUp() {
|
||||||
ASSERT_TRUE(glfwInit());
|
ASSERT_TRUE(glfwInit());
|
||||||
|
|
||||||
mInstance = std::make_unique<dawn_native::Instance>();
|
mInstance = std::make_unique<dawn_native::Instance>();
|
||||||
|
mInstance->EnableBackendValidation(mEnableBackendValidation);
|
||||||
|
|
||||||
static constexpr dawn_native::BackendType kAllBackends[] = {
|
static constexpr dawn_native::BackendType kAllBackends[] = {
|
||||||
dawn_native::BackendType::D3D12,
|
dawn_native::BackendType::D3D12,
|
||||||
|
@ -134,6 +143,8 @@ void DawnTestEnvironment::SetUp() {
|
||||||
std::cout << "Testing configuration\n";
|
std::cout << "Testing configuration\n";
|
||||||
std::cout << "---------------------\n";
|
std::cout << "---------------------\n";
|
||||||
std::cout << "UseWire: " << (mUseWire ? "true" : "false") << "\n";
|
std::cout << "UseWire: " << (mUseWire ? "true" : "false") << "\n";
|
||||||
|
std::cout << "EnableBackendValidation: " << (mEnableBackendValidation ? "true" : "false")
|
||||||
|
<< "\n";
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
|
|
||||||
// Preparing for outputting hex numbers
|
// Preparing for outputting hex numbers
|
||||||
|
|
|
@ -114,6 +114,7 @@ class DawnTestEnvironment : public testing::Environment {
|
||||||
void CreateBackendWindow(dawn_native::BackendType type);
|
void CreateBackendWindow(dawn_native::BackendType type);
|
||||||
|
|
||||||
bool mUseWire = false;
|
bool mUseWire = false;
|
||||||
|
bool mEnableBackendValidation = false;
|
||||||
std::unique_ptr<dawn_native::Instance> mInstance;
|
std::unique_ptr<dawn_native::Instance> mInstance;
|
||||||
|
|
||||||
// Windows don't usually like to be bound to one API than the other, for example switching
|
// Windows don't usually like to be bound to one API than the other, for example switching
|
||||||
|
|
Loading…
Reference in New Issue