check dxgi1_6.h before enabling sdr/hdr code in SDL_windowsmodes.c

thanks @madebr
This commit is contained in:
Ozkan Sezer
2024-05-28 22:11:56 +03:00
parent 00a7b14ee7
commit 2b374e6c0f
5 changed files with 13 additions and 1 deletions

View File

@@ -1911,6 +1911,7 @@ elseif(WINDOWS)
endif() endif()
# headers needed elsewhere # headers needed elsewhere
check_include_file(dxgi1_6.h HAVE_DXGI1_6_H)
check_include_file(tpcshrd.h HAVE_TPCSHRD_H) check_include_file(tpcshrd.h HAVE_TPCSHRD_H)
check_include_file(roapi.h HAVE_ROAPI_H) check_include_file(roapi.h HAVE_ROAPI_H)
check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H) check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)

View File

@@ -231,6 +231,7 @@
#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@ #cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@
#cmakedefine HAVE_WINDOWS_GAMING_INPUT_H @HAVE_WINDOWS_GAMING_INPUT_H@ #cmakedefine HAVE_WINDOWS_GAMING_INPUT_H @HAVE_WINDOWS_GAMING_INPUT_H@
#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@ #cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@
#cmakedefine HAVE_DXGI1_6_H @HAVE_DXGI1_6_H@
#cmakedefine HAVE_MMDEVICEAPI_H @HAVE_MMDEVICEAPI_H@ #cmakedefine HAVE_MMDEVICEAPI_H @HAVE_MMDEVICEAPI_H@
#cmakedefine HAVE_AUDIOCLIENT_H @HAVE_AUDIOCLIENT_H@ #cmakedefine HAVE_AUDIOCLIENT_H @HAVE_AUDIOCLIENT_H@

View File

@@ -86,6 +86,7 @@ typedef unsigned int uintptr_t;
#define HAVE_DXGI_H 1 #define HAVE_DXGI_H 1
#define HAVE_XINPUT_H 1 #define HAVE_XINPUT_H 1
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 /* Windows 10 SDK */ #if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 /* Windows 10 SDK */
#define HAVE_DXGI1_6_H 1
#define HAVE_WINDOWS_GAMING_INPUT_H 1 #define HAVE_WINDOWS_GAMING_INPUT_H 1
#endif #endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0602 /* Windows 8 SDK */ #if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0602 /* Windows 8 SDK */

View File

@@ -37,6 +37,7 @@
#define HAVE_DSOUND_H 1 #define HAVE_DSOUND_H 1
/* No SDK version checks needed for these because the SDK has to be new. */ /* No SDK version checks needed for these because the SDK has to be new. */
#define HAVE_DXGI_H 1 #define HAVE_DXGI_H 1
#define HAVE_DXGI1_6_H 1
#define HAVE_XINPUT_H 1 #define HAVE_XINPUT_H 1
#define HAVE_WINDOWS_GAMING_INPUT_H 1 #define HAVE_WINDOWS_GAMING_INPUT_H 1
#define HAVE_D3D11_H 1 #define HAVE_D3D11_H 1

View File

@@ -25,8 +25,10 @@
#include "SDL_windowsvideo.h" #include "SDL_windowsvideo.h"
#include "../../events/SDL_displayevents_c.h" #include "../../events/SDL_displayevents_c.h"
#ifdef HAVE_DXGI1_6_H
#define COBJMACROS #define COBJMACROS
#include <dxgi1_6.h> #include <dxgi1_6.h>
#endif
/* Windows CE compatibility */ /* Windows CE compatibility */
#ifndef CDS_FULLSCREEN #ifndef CDS_FULLSCREEN
@@ -337,6 +339,7 @@ WIN_GetDisplayNameVista_failed:
return NULL; return NULL;
} }
#ifdef HAVE_DXGI1_6_H
static SDL_bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) static SDL_bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc)
{ {
typedef HRESULT (WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); typedef HRESULT (WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
@@ -488,6 +491,7 @@ static void WIN_GetHDRProperties(SDL_VideoDevice *_this, HMONITOR hMonitor, SDL_
} }
} }
} }
#endif /* HAVE_DXGI1_6_H */
static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONITORINFOEXW *info, int *display_index) static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONITORINFOEXW *info, int *display_index)
{ {
@@ -555,7 +559,9 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
} }
SDL_SendDisplayEvent(existing_display, SDL_EVENT_DISPLAY_ORIENTATION, current_orientation); SDL_SendDisplayEvent(existing_display, SDL_EVENT_DISPLAY_ORIENTATION, current_orientation);
SDL_SetDisplayContentScale(existing_display, content_scale); SDL_SetDisplayContentScale(existing_display, content_scale);
#ifdef HAVE_DXGI1_6_H
WIN_GetHDRProperties(_this, hMonitor, &HDR); WIN_GetHDRProperties(_this, hMonitor, &HDR);
#endif
SDL_SetDisplayHDRProperties(existing_display, &HDR); SDL_SetDisplayHDRProperties(existing_display, &HDR);
} }
goto done; goto done;
@@ -588,7 +594,9 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
display.device = _this; display.device = _this;
display.driverdata = displaydata; display.driverdata = displaydata;
WIN_GetDisplayBounds(_this, &display, &displaydata->bounds); WIN_GetDisplayBounds(_this, &display, &displaydata->bounds);
#ifdef HAVE_DXGI1_6_H
WIN_GetHDRProperties(_this, hMonitor, &display.HDR); WIN_GetHDRProperties(_this, hMonitor, &display.HDR);
#endif
SDL_AddVideoDisplay(&display, SDL_FALSE); SDL_AddVideoDisplay(&display, SDL_FALSE);
SDL_free(display.name); SDL_free(display.name);