diff --git a/CMakeLists.txt b/CMakeLists.txt index a8ad2a3d2..e41e32c1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,8 @@ option(USE_GLES2 "Use GLES2 API" OFF) option(USE_HOST_LIBZIP "Use host libzip" ON) option(USE_OPENMP "Use OpenMP if available" ON) option(USE_VULKAN "Build with Vulkan support" ON) +option(USE_DX9 "Build with Direct3D 9 support" ON) +option(USE_DX11 "Build with Direct3D 11 support" ON) option(LIBRETRO "Build libretro core" OFF) option(USE_OPENGL "Use OpenGL API" ON) option(USE_VIDEOCORE "RPI: use the legacy Broadcom GLES libraries" OFF) @@ -1181,7 +1183,7 @@ if(USE_VULKAN) endif() endif() -if(WIN32 AND NOT LIBRETRO AND NOT WINDOWS_STORE) +if(WIN32 AND USE_DX9 AND NOT LIBRETRO AND NOT WINDOWS_STORE) set(REND_DX9_FILES core/rend/dx9/d3d_overlay.h core/rend/dx9/d3d_overlay.cpp @@ -1207,14 +1209,13 @@ if(WIN32 AND NOT LIBRETRO AND NOT WINDOWS_STORE) endif() endif() + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_D3D9) target_link_libraries(${PROJECT_NAME} PUBLIC d3d9 d3dx9) target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DX9) endif() -if(WIN32) - if(LIBRETRO) - target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_D3D11) - else() +if(WIN32 AND USE_DX11) + if(NOT LIBRETRO) target_sources(${PROJECT_NAME} PRIVATE core/rend/dx11/imgui_impl_dx11.cpp core/rend/dx11/imgui_impl_dx11.h) @@ -1242,6 +1243,8 @@ if(WIN32) core/rend/dx11/oit/dx11_oitrenderer.cpp core/rend/dx11/oit/dx11_oitshaders.cpp core/rend/dx11/oit/dx11_oitshaders.h) + + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_D3D11) target_link_libraries(${PROJECT_NAME} PRIVATE d3d11 d3dcompiler) endif() diff --git a/core/build.h b/core/build.h index 9e2bd19df..f992db969 100755 --- a/core/build.h +++ b/core/build.h @@ -217,8 +217,13 @@ #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) #define TARGET_UWP #endif +#ifdef HAVE_D3D9 +#define USE_DX9 +#endif +#ifdef HAVE_D3D11 +#define USE_DX11 +#endif #endif - #if !defined(LIBRETRO) && !defined(TARGET_NO_EXCEPTIONS) #define USE_GGPO diff --git a/core/cfg/option.h b/core/cfg/option.h index e3d850aea..39440b27a 100644 --- a/core/cfg/option.h +++ b/core/cfg/option.h @@ -417,7 +417,7 @@ public: RendererOption() #ifdef USE_DX9 : Option("pvr.rend", RenderType::DirectX9) {} -#elif defined(TARGET_UWP) +#elif defined(USE_DX11) : Option("pvr.rend", RenderType::DirectX11) {} #else : Option("pvr.rend", RenderType::OpenGL) {} diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index d01ac97a3..44de7dc0e 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -270,7 +270,7 @@ static void rend_create_renderer() renderer = rend_DirectX9(); break; #endif -#if (defined(_WIN32) && !defined(LIBRETRO)) || defined(HAVE_D3D11) +#ifdef USE_DX11 case RenderType::DirectX11: renderer = rend_DirectX11(); break; diff --git a/core/rend/dx11/dx11context_lr.cpp b/core/rend/dx11/dx11context_lr.cpp index ed22decd6..217156337 100644 --- a/core/rend/dx11/dx11context_lr.cpp +++ b/core/rend/dx11/dx11context_lr.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with Flycast. If not, see . */ -#ifdef HAVE_D3D11 +#ifdef LIBRETRO #include "dx11context_lr.h" #include #include "rend/osd.h" diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 385a4ba12..e9f357d03 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1784,7 +1784,7 @@ static void gui_display_settings() #ifdef USE_OPENGL + 1 #endif - #ifdef _WIN32 + #ifdef USE_DX11 + 1 #endif ; @@ -1811,7 +1811,7 @@ static void gui_display_settings() ImGui::RadioButton("DirectX 9", &renderApi, 2); ImGui::NextColumn(); #endif -#ifdef _WIN32 +#ifdef USE_DX11 ImGui::RadioButton("DirectX 11", &renderApi, 3); ImGui::NextColumn(); #endif diff --git a/core/wsi/switcher.cpp b/core/wsi/switcher.cpp index 117ef09e1..cb78afdd2 100644 --- a/core/wsi/switcher.cpp +++ b/core/wsi/switcher.cpp @@ -46,7 +46,7 @@ void initRenderApi(void *window, void *display) config::RendererType = RenderType::OpenGL; } #endif -#ifdef _WIN32 +#ifdef USE_DX11 if (config::RendererType == RenderType::DirectX11 || config::RendererType == RenderType::DirectX11_OIT) { theDX11Context.setWindow(window, display);