From 68fb07787b9f3e84f28077b3bbc748483f65b668 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 1 Aug 2024 15:49:02 +0200
Subject: [PATCH] cmake: Remove HAVE_D3D12_H from sources and introduce
SDL_RENDER_D3D(11|12)
---
CMakeLists.txt | 24 ++++++++-----------
cmake/PreseedMSVCCache.cmake | 4 +---
include/build_config/SDL_build_config.h.cmake | 2 --
.../build_config/SDL_build_config_windows.h | 7 +-----
.../build_config/SDL_build_config_wingdk.h | 3 +--
include/build_config/SDL_build_config_xbox.h | 3 +--
6 files changed, 14 insertions(+), 29 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 048622b7e39a5..ca5e5f07408c7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -327,7 +327,9 @@ dep_option(SDL_COCOA "Use Cocoa video driver" ON "APPLE" OFF)
dep_option(SDL_DIRECTX "Use DirectX for Windows audio/video" ON "SDL_AUDIO OR SDL_VIDEO;WINDOWS" OFF)
dep_option(SDL_XINPUT "Use Xinput for Windows" ON "WINDOWS" OFF)
dep_option(SDL_WASAPI "Use the Windows WASAPI audio driver" ON "WINDOWS;SDL_AUDIO" OFF)
-dep_option(SDL_RENDER_D3D "Enable the Direct3D render driver" ON "SDL_RENDER" OFF)
+dep_option(SDL_RENDER_D3D "Enable the Direct3D 9 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
+dep_option(SDL_RENDER_D3D11 "Enable the Direct3D 11 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
+dep_option(SDL_RENDER_D3D12 "Enable the Direct3D 12 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;${APPLE}" OFF)
dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF)
dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR WINDOWS" OFF)
@@ -1838,14 +1840,8 @@ elseif(WINDOWS)
string(APPEND CMAKE_REQUIRED_FLAGS " /I\"$ENV{DXSDK_DIR}\\Include\"")
endif()
- check_include_file(d3d9.h HAVE_D3D_H)
+ check_include_file(d3d9.h HAVE_D3D9_H)
check_include_file(d3d11_1.h HAVE_D3D11_H)
- check_c_source_compiles("
- #include <d3d12.h>
- #include <d3d12sdklayers.h>
- ID3D12Device1 *device;
- int main(int argc, char **argv) { return 0; }
- " HAVE_D3D12_H)
check_include_file(ddraw.h HAVE_DDRAW_H)
check_include_file(dsound.h HAVE_DSOUND_H)
check_include_file(dinput.h HAVE_DINPUT_H)
@@ -1854,7 +1850,7 @@ elseif(WINDOWS)
endif()
check_include_file(dxgi.h HAVE_DXGI_H)
cmake_pop_check_state()
- if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_D3D12_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H)
+ if(HAVE_D3D9_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H)
set(HAVE_DIRECTX TRUE)
if(NOT MINGW AND NOT USE_WINSDK_DIRECTX)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -1929,17 +1925,17 @@ elseif(WINDOWS)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/windows/*.c")
endif()
- if(SDL_RENDER_D3D AND HAVE_D3D_H AND NOT WINDOWS_STORE)
+ if(SDL_RENDER_D3D AND HAVE_D3D9_H AND NOT WINDOWS_STORE)
set(SDL_VIDEO_RENDER_D3D 1)
set(HAVE_RENDER_D3D TRUE)
endif()
- if(SDL_RENDER_D3D AND HAVE_D3D11_H)
+ if(SDL_RENDER_D3D11 AND HAVE_D3D11_H)
set(SDL_VIDEO_RENDER_D3D11 1)
- set(HAVE_RENDER_D3D TRUE)
+ set(HAVE_RENDER_D3D11 TRUE)
endif()
- if(SDL_RENDER_D3D AND HAVE_D3D12_H AND NOT WINDOWS_STORE)
+ if(SDL_RENDER_D3D12 AND NOT WINDOWS_STORE)
set(SDL_VIDEO_RENDER_D3D12 1)
- set(HAVE_RENDER_D3D TRUE)
+ set(HAVE_RENDER_D3D12 TRUE)
endif()
set(HAVE_SDL_VIDEO TRUE)
endif()
diff --git a/cmake/PreseedMSVCCache.cmake b/cmake/PreseedMSVCCache.cmake
index 370dcadd33395..a4095275e9ce8 100644
--- a/cmake/PreseedMSVCCache.cmake
+++ b/cmake/PreseedMSVCCache.cmake
@@ -4,7 +4,7 @@ if(MSVC)
set(HAVE_ALLOCA_H "" CACHE INTERNAL "Have include alloca.h")
set(HAVE_AUDIOCLIENT_H "1" CACHE INTERNAL "Have include audioclient.h")
set(HAVE_D3D11_H "1" CACHE INTERNAL "Have include d3d11_1.h")
- set(HAVE_D3D_H "1" CACHE INTERNAL "Have include d3d9.h")
+ set(HAVE_D3D9_H "1" CACHE INTERNAL "Have include d3d9.h")
set(HAVE_DDRAW_H "1" CACHE INTERNAL "Have include ddraw.h")
set(HAVE_DINPUT_H "1" CACHE INTERNAL "Have include dinput.h")
set(HAVE_DSOUND_H "1" CACHE INTERNAL "Have include dsound.h")
@@ -170,11 +170,9 @@ if(MSVC)
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.1")
- set(HAVE_D3D12_H "1" CACHE INTERNAL "Test HAVE_D3D12_H")
set(HAVE_ROAPI_H "1" CACHE INTERNAL "Have include roapi.h")
set(HAVE_WINDOWS_GAMING_INPUT_H "1" CACHE INTERNAL "Test HAVE_WINDOWS_GAMING_INPUT_H")
else()
- set(HAVE_D3D12_H "" CACHE INTERNAL "Test HAVE_D3D12_H")
set(HAVE_ROAPI_H "" CACHE INTERNAL "Have include roapi.h")
set(HAVE_WINDOWS_GAMING_INPUT_H "" CACHE INTERNAL "Test HAVE_WINDOWS_GAMING_INPUT_H")
endif()
diff --git a/include/build_config/SDL_build_config.h.cmake b/include/build_config/SDL_build_config.h.cmake
index 0e3645e293809..1e0cdc9db550b 100644
--- a/include/build_config/SDL_build_config.h.cmake
+++ b/include/build_config/SDL_build_config.h.cmake
@@ -226,9 +226,7 @@
#cmakedefine HAVE_LIBUDEV_H 1
#cmakedefine HAVE_LIBDECOR_H 1
-#cmakedefine HAVE_D3D_H @HAVE_D3D_H@
#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@
-#cmakedefine HAVE_D3D12_H @HAVE_D3D12_H@
#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@
#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@
#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@
diff --git a/include/build_config/SDL_build_config_windows.h b/include/build_config/SDL_build_config_windows.h
index 457b58e00d420..6feab76aa82a2 100644
--- a/include/build_config/SDL_build_config_windows.h
+++ b/include/build_config/SDL_build_config_windows.h
@@ -93,11 +93,6 @@ typedef unsigned int uintptr_t;
#define HAVE_D3D11_H 1
#define HAVE_ROAPI_H 1
#endif
-#if defined(__has_include)
-#if __has_include(<d3d12.h>) && __has_include(<d3d12sdklayers.h>)
-#define HAVE_D3D12_H 1
-#endif
-#endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */
#define HAVE_SHELLSCALINGAPI_H 1
#endif
@@ -282,7 +277,7 @@ typedef unsigned int uintptr_t;
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 1
#endif
-#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
+#if !defined(SDL_VIDEO_RENDER_D3D12)
#define SDL_VIDEO_RENDER_D3D12 1
#endif
diff --git a/include/build_config/SDL_build_config_wingdk.h b/include/build_config/SDL_build_config_wingdk.h
index 896499060e43f..e46c4593f9332 100644
--- a/include/build_config/SDL_build_config_wingdk.h
+++ b/include/build_config/SDL_build_config_wingdk.h
@@ -42,7 +42,6 @@
#define HAVE_WINDOWS_GAMING_INPUT_H 1
#define HAVE_D3D11_H 1
#define HAVE_ROAPI_H 1
-#define HAVE_D3D12_H 1
#define HAVE_SHELLSCALINGAPI_H 1
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
@@ -215,7 +214,7 @@
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 1
#endif
-#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
+#if !defined(SDL_VIDEO_RENDER_D3D12)
#define SDL_VIDEO_RENDER_D3D12 1
#endif
diff --git a/include/build_config/SDL_build_config_xbox.h b/include/build_config/SDL_build_config_xbox.h
index 80c5d95a3dcb1..7bba464324931 100644
--- a/include/build_config/SDL_build_config_xbox.h
+++ b/include/build_config/SDL_build_config_xbox.h
@@ -41,7 +41,6 @@
/*#define HAVE_WINDOWS_GAMING_INPUT_H 1*/
/*#define HAVE_D3D11_H 1*/
/*#define HAVE_ROAPI_H 1*/
-#define HAVE_D3D12_H 1
/*#define HAVE_SHELLSCALINGAPI_H 1*/
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
@@ -208,7 +207,7 @@
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_WINDOWS 1
-#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
+#if !defined(SDL_VIDEO_RENDER_D3D12)
#define SDL_VIDEO_RENDER_D3D12 1
#endif