From 7b15d79eb4ead9306259988affea7c0f5fe7f9a4 Mon Sep 17 00:00:00 2001 From: DarthMew Date: Tue, 22 Feb 2022 23:05:46 +0100 Subject: [PATCH] Exclude D3D12 renderer files for Libretro --- CMakeLists.txt | 1 + src/common/CMakeLists.txt | 32 ++++++++++++++++++-------------- src/core/CMakeLists.txt | 8 ++++++-- src/core/gpu.h | 2 ++ src/core/host_display.h | 2 ++ src/core/settings.cpp | 4 ++++ src/core/shadergen.cpp | 6 ++++++ src/core/system.cpp | 2 ++ src/core/types.h | 2 ++ 9 files changed, 43 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba2b89f1..ddfb3b39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ set(USE_EGL OFF) set(ENABLE_CHEEVOS OFF) set(USE_X11 OFF) set(USE_WAYLAND OFF) +set(USE_D3D12 OFF) # Force PIC when compiling a libretro core. set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0ea2c91a..b5341edb 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -122,20 +122,6 @@ target_link_libraries(common PRIVATE glad stb Threads::Threads libchdr glslang v if(WIN32) target_sources(common PRIVATE - d3d12/context.cpp - d3d12/context.h - d3d12/descriptor_heap_manager.cpp - d3d12/descriptor_heap_manager.h - d3d12/shader_cache.cpp - d3d12/shader_cache.h - d3d12/staging_texture.cpp - d3d12/staging_texture.h - d3d12/stream_buffer.cpp - d3d12/stream_buffer.h - d3d12/texture.cpp - d3d12/texture.h - d3d12/util.cpp - d3d12/util.h d3d11/shader_cache.cpp d3d11/shader_cache.h d3d11/shader_compiler.cpp @@ -148,6 +134,24 @@ if(WIN32) d3d11/texture.h windows_headers.h ) + if(USE_D3D12) + target_sources(common PRIVATE + d3d12/context.cpp + d3d12/context.h + d3d12/descriptor_heap_manager.cpp + d3d12/descriptor_heap_manager.h + d3d12/shader_cache.cpp + d3d12/shader_cache.h + d3d12/staging_texture.cpp + d3d12/staging_texture.h + d3d12/stream_buffer.cpp + d3d12/stream_buffer.h + d3d12/texture.cpp + d3d12/texture.h + d3d12/util.cpp + d3d12/util.h + ) + endif() target_link_libraries(common PRIVATE d3dcompiler.lib) endif() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 739eb3d0..62387361 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -121,11 +121,15 @@ target_link_libraries(core PRIVATE glad stb xxhash) if(WIN32) target_sources(core PRIVATE - gpu_hw_d3d12.cpp - gpu_hw_d3d12.h gpu_hw_d3d11.cpp gpu_hw_d3d11.h ) + if(USE_D3D12) + target_sources(core PRIVATE + gpu_hw_d3d12.cpp + gpu_hw_d3d12.h + ) + endif() target_link_libraries(core PRIVATE winmm.lib) endif() diff --git a/src/core/gpu.h b/src/core/gpu.h index 017cfa1d..660181eb 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -153,8 +153,10 @@ public: // gpu_hw_d3d11.cpp static std::unique_ptr CreateHardwareD3D11Renderer(); +#ifdef USE_D3D12 // gpu_hw_d3d12.cpp static std::unique_ptr CreateHardwareD3D12Renderer(); +#endif // gpu_hw_opengl.cpp static std::unique_ptr CreateHardwareOpenGLRenderer(); diff --git a/src/core/host_display.h b/src/core/host_display.h index ea01f846..ef801abe 100644 --- a/src/core/host_display.h +++ b/src/core/host_display.h @@ -41,7 +41,9 @@ public: { None, D3D11, +#ifdef USE_D3D12 D3D12, +#endif Vulkan, OpenGL, OpenGLES diff --git a/src/core/settings.cpp b/src/core/settings.cpp index bd0bb754..2f1816f4 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -664,13 +664,17 @@ const char* Settings::GetCPUFastmemModeDisplayName(CPUFastmemMode mode) static constexpr auto s_gpu_renderer_names = make_array( #ifdef _WIN32 "D3D11", +#ifdef USE_D3D12 "D3D12", +#endif #endif "Vulkan", "OpenGL", "Software"); static constexpr auto s_gpu_renderer_display_names = make_array( #ifdef _WIN32 TRANSLATABLE("GPURenderer", "Hardware (D3D11)"), +#ifdef USE_D3D12 TRANSLATABLE("GPURenderer", "Hardware (D3D12)"), +#endif #endif TRANSLATABLE("GPURenderer", "Hardware (Vulkan)"), TRANSLATABLE("GPURenderer", "Hardware (OpenGL)"), TRANSLATABLE("GPURenderer", "Software")); diff --git a/src/core/shadergen.cpp b/src/core/shadergen.cpp index 17679516..823a3df7 100644 --- a/src/core/shadergen.cpp +++ b/src/core/shadergen.cpp @@ -7,7 +7,11 @@ Log_SetChannel(ShaderGen); ShaderGen::ShaderGen(HostDisplay::RenderAPI render_api, bool supports_dual_source_blend) +#ifdef USE_D3D12 : m_render_api(render_api), m_glsl(render_api != HostDisplay::RenderAPI::D3D11 && render_api != HostDisplay::RenderAPI::D3D12), +#else + : m_render_api(render_api), m_glsl(render_api != HostDisplay::RenderAPI::D3D11), +#endif m_supports_dual_source_blend(supports_dual_source_blend), m_use_glsl_interface_blocks(false) { if (m_glsl) @@ -133,7 +137,9 @@ void ShaderGen::WriteHeader(std::stringstream& ss) DefineMacro(ss, "API_OPENGL", m_render_api == HostDisplay::RenderAPI::OpenGL); DefineMacro(ss, "API_OPENGL_ES", m_render_api == HostDisplay::RenderAPI::OpenGLES); DefineMacro(ss, "API_D3D11", m_render_api == HostDisplay::RenderAPI::D3D11); +#ifdef USE_D3D12 DefineMacro(ss, "API_D3D12", m_render_api == HostDisplay::RenderAPI::D3D12); +#endif DefineMacro(ss, "API_VULKAN", m_render_api == HostDisplay::RenderAPI::Vulkan); if (m_render_api == HostDisplay::RenderAPI::OpenGLES) diff --git a/src/core/system.cpp b/src/core/system.cpp index 25b5fe1a..294fb3fd 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1031,9 +1031,11 @@ bool CreateGPU(GPURenderer renderer) case GPURenderer::HardwareD3D11: g_gpu = GPU::CreateHardwareD3D11Renderer(); break; +#ifdef USE_D3D12 case GPURenderer::HardwareD3D12: g_gpu = GPU::CreateHardwareD3D12Renderer(); break; +#endif #endif case GPURenderer::Software: diff --git a/src/core/types.h b/src/core/types.h index 27cec669..27089cce 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -56,7 +56,9 @@ enum class GPURenderer : u8 { #ifdef _WIN32 HardwareD3D11, +#ifdef USE_D3D12 HardwareD3D12, +#endif #endif HardwareVulkan, HardwareOpenGL,