[App] Only start D3D12 if DLL exists
This commit is contained in:
parent
9aaef8871d
commit
890a32bd98
|
@ -105,10 +105,12 @@ std::unique_ptr<gpu::GraphicsSystem> CreateGraphicsSystem() {
|
||||||
std::unique_ptr<gpu::GraphicsSystem> best;
|
std::unique_ptr<gpu::GraphicsSystem> best;
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
best = std::unique_ptr<gpu::GraphicsSystem>(
|
if (xe::gpu::d3d12::D3D12GraphicsSystem::IsD3D12APIAvailable()) {
|
||||||
new xe::gpu::d3d12::D3D12GraphicsSystem());
|
best = std::unique_ptr<gpu::GraphicsSystem>(
|
||||||
if (best) {
|
new xe::gpu::d3d12::D3D12GraphicsSystem());
|
||||||
return best;
|
if (best) {
|
||||||
|
return best;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // XE_PLATFORM_WIN32
|
#endif // XE_PLATFORM_WIN32
|
||||||
best = std::unique_ptr<gpu::GraphicsSystem>(
|
best = std::unique_ptr<gpu::GraphicsSystem>(
|
||||||
|
|
|
@ -27,6 +27,10 @@ D3D12GraphicsSystem::D3D12GraphicsSystem() {}
|
||||||
|
|
||||||
D3D12GraphicsSystem::~D3D12GraphicsSystem() {}
|
D3D12GraphicsSystem::~D3D12GraphicsSystem() {}
|
||||||
|
|
||||||
|
bool D3D12GraphicsSystem::IsD3D12APIAvailable() {
|
||||||
|
return xe::ui::d3d12::D3D12Provider::IsD3D12APIAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
std::wstring D3D12GraphicsSystem::name() const {
|
std::wstring D3D12GraphicsSystem::name() const {
|
||||||
auto d3d12_command_processor =
|
auto d3d12_command_processor =
|
||||||
static_cast<D3D12CommandProcessor*>(command_processor());
|
static_cast<D3D12CommandProcessor*>(command_processor());
|
||||||
|
|
|
@ -26,6 +26,8 @@ class D3D12GraphicsSystem : public GraphicsSystem {
|
||||||
D3D12GraphicsSystem();
|
D3D12GraphicsSystem();
|
||||||
~D3D12GraphicsSystem() override;
|
~D3D12GraphicsSystem() override;
|
||||||
|
|
||||||
|
static bool IsD3D12APIAvailable();
|
||||||
|
|
||||||
std::wstring name() const override;
|
std::wstring name() const override;
|
||||||
|
|
||||||
X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state,
|
X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state,
|
||||||
|
|
|
@ -27,6 +27,15 @@ namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
namespace d3d12 {
|
namespace d3d12 {
|
||||||
|
|
||||||
|
bool D3D12Provider::IsD3D12APIAvailable() {
|
||||||
|
HMODULE library_d3d12 = LoadLibrary(L"D3D12.dll");
|
||||||
|
if (!library_d3d12) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
FreeLibrary(library_d3d12);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<D3D12Provider> D3D12Provider::Create(Window* main_window) {
|
std::unique_ptr<D3D12Provider> D3D12Provider::Create(Window* main_window) {
|
||||||
std::unique_ptr<D3D12Provider> provider(new D3D12Provider(main_window));
|
std::unique_ptr<D3D12Provider> provider(new D3D12Provider(main_window));
|
||||||
InitializationResult result = provider->Initialize();
|
InitializationResult result = provider->Initialize();
|
||||||
|
@ -81,6 +90,7 @@ D3D12Provider::InitializationResult D3D12Provider::Initialize() {
|
||||||
library_d3dcompiler_ = LoadLibrary(L"D3DCompiler_47.dll");
|
library_d3dcompiler_ = LoadLibrary(L"D3DCompiler_47.dll");
|
||||||
if (library_dxgi_ == nullptr || library_d3d12_ == nullptr ||
|
if (library_dxgi_ == nullptr || library_d3d12_ == nullptr ||
|
||||||
library_d3dcompiler_ == nullptr) {
|
library_d3dcompiler_ == nullptr) {
|
||||||
|
XELOGE("Failed to load dxgi.dll, D3D12.dll and D3DCompiler_47.dll.");
|
||||||
return InitializationResult::kLibraryLoadFailed;
|
return InitializationResult::kLibraryLoadFailed;
|
||||||
}
|
}
|
||||||
bool libraries_loaded = true;
|
bool libraries_loaded = true;
|
||||||
|
|
|
@ -23,6 +23,8 @@ class D3D12Provider : public GraphicsProvider {
|
||||||
public:
|
public:
|
||||||
~D3D12Provider() override;
|
~D3D12Provider() override;
|
||||||
|
|
||||||
|
static bool IsD3D12APIAvailable();
|
||||||
|
|
||||||
static std::unique_ptr<D3D12Provider> Create(Window* main_window);
|
static std::unique_ptr<D3D12Provider> Create(Window* main_window);
|
||||||
|
|
||||||
std::unique_ptr<GraphicsContext> CreateContext(
|
std::unique_ptr<GraphicsContext> CreateContext(
|
||||||
|
|
Loading…
Reference in New Issue