Closed edo9300 closed 1 month ago
Maybe we should define that enum value as a macro for such old SDKs, like:
diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c
--- a/src/video/windows/SDL_windowsmodes.c
+++ b/src/video/windows/SDL_windowsmodes.c
@@ -513,6 +513,7 @@ static float WIN_GetSDRWhitePoint(SDL_VideoDevice *_this, HMONITOR hMonitor)
float SDR_white_level = 1.0f;
if (WIN_GetMonitorPathInfo(videodata, hMonitor, &path_info)) {
+ #define DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL 11 /* for old SDKs. */
DISPLAYCONFIG_SDR_WHITE_LEVEL white_level;
SDL_zero(white_level);
@slouken?
Maybe we should define that enum value as a macro for such old SDKs, like:
diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -513,6 +513,7 @@ static float WIN_GetSDRWhitePoint(SDL_VideoDevice *_this, HMONITOR hMonitor) float SDR_white_level = 1.0f; if (WIN_GetMonitorPathInfo(videodata, hMonitor, &path_info)) { + #define DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL 11 /* for old SDKs. */ DISPLAYCONFIG_SDR_WHITE_LEVEL white_level; SDL_zero(white_level);
@slouken?
that would solve half of the problem, to have things "cleaner" it would be better to also unconditionally redefine the struct (to another name), as it's not really easy to check if it's available or not
Maybe at the top of the file, we can add #ifndef DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL
...
Maybe at the top of the file, we can add
#ifndef DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL
It's not a macro, it's an enumerated value in the DISPLAYCONFIG_DEVICE_INFO_TYPE
enum, therefore it can be defined as a macro directly. (DISPLAYCONFIG_DEVICE_INFO_TYPE
enum is actually present in 10.0.16299.0 sdk, but it lacks the specific value in question.)
@edo9300, is there any reason you can't upgrade your build SDK?
The enum value DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL
is already defined in:
https://github.com/libsdl-org/SDL/blob/d7be7fc168f2077accfe12a0de376082a1650b29/src/video/windows/SDL_windowsvideo.h#L241
The only thing missing is the struct DISPLAYCONFIG_SDR_WHITE_LEVEL
, which is used here:
https://github.com/libsdl-org/SDL/blob/d7be7fc168f2077accfe12a0de376082a1650b29/src/video/windows/SDL_windowsmodes.c#L516
Maybe it could be defined in the same header SDL_windowsvideo.h
, for the SDK versions it isn't defined in?
Edit:
Missed, that DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL
is already inside a version check
https://github.com/libsdl-org/SDL/blob/d7be7fc168f2077accfe12a0de376082a1650b29/src/video/windows/SDL_windowsvideo.h#L67
@edo9300, is there any reason you can't upgrade your build SDK?
This was the sdk I happened to have installed locally, but I'm not really sure if upgrading the sdk would really be a worthwile fix for this issue, since basically half of the window support code uses checks and other means to define structs, functions and values not present in older sdks, at that point the requirement would become having a compiler with a windows 11 sdk, making all the other fallbacks meaningless
Does this help? (untested):
diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h
index 87eaaaf47..24ac9de22 100644
--- a/src/video/windows/SDL_windowsvideo.h
+++ b/src/video/windows/SDL_windowsvideo.h
@@ -250,6 +250,12 @@ typedef struct DISPLAYCONFIG_DEVICE_INFO_HEADER
UINT32 id;
} DISPLAYCONFIG_DEVICE_INFO_HEADER;
+typedef struct DISPLAYCONFIG_SDR_WHITE_LEVEL
+{
+ DISPLAYCONFIG_DEVICE_INFO_HEADER header;
+ ULONG SDRWhiteLevel;
+} DISPLAYCONFIG_SDR_WHITE_LEVEL;
+
typedef struct DISPLAYCONFIG_SOURCE_DEVICE_NAME
{
DISPLAYCONFIG_DEVICE_INFO_HEADER header;
DISPLAYCONFIG_DEVICE_INFO_HEADER
that would be required for the case where WINVER
is less than 0x0601
, but in my case, with the windows 10 sdk, WINVER
is a value greater than that, so that whole block of code won't be considered.
Maybe doing checks like these would be enough
https://github.com/libsdl-org/SDL/blob/1cc85c912bb3352a121b1fdc181c6ab6546157df/src/video/windows/SDL_windowsvideo.h#L329-L337
And it would be just a matter of finding what sdk added those values first, so it would become a general
#if NTDDI_VERSION < 0x0A000XXX
#define DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL 11
typedef struct DISPLAYCONFIG_SDR_WHITE_LEVEL
{
DISPLAYCONFIG_DEVICE_INFO_HEADER header;
ULONG SDRWhiteLevel;
} DISPLAYCONFIG_SDR_WHITE_LEVEL;
#endif // NTDDI_VERSION < 0x0A000XXX
These values seems to have been first introduced in the 10.0.17134.0 sdk, with a default NTDDI_VERSION
of 0x0A000005
Feel free to submit a PR that works for you, and we can iterate on that in CI.
I'm trying to build SDL3 with visual studio on windows, currently the library fails to build due to the absence of that struct, alongside the absence of its associated enum value
DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL
, on my end i have currently installed the10.0.16299.0
sdk, and it seems those values are entirely missing from it (so it's not an issue with the wrongWINVER
being defined