libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.14k stars 1.85k forks source link

Avoid usage of `CreateEventEx` in D3D12 GPU backend. #11520

Open Clownacy opened 18 hours ago

Clownacy commented 18 hours ago

CreateEventEx is unavailable in Windows XP. The provided solution was sourced from the WASAPI backend, which had to address the same problem.

According to official documentation, both calls should be functionally identical, with calls to CreateEvent implicitly creating events with the EVENT_ALL_ACCESS access right.

This change alone is not enough to get Windows XP support working again: the usage of CreateWaitableTimerExW in the Windows SDL_systimer.c currently prevents any executables from running, due to the function being introduced in Windows Vista. If the relevant code is removed, however, executables do successfully run. I would add code to load this function at runtime, similarly to this PR, but there does not appear to be any logic for initialisation and deinitialisation that I could insert the code into.

I also corrected a null pointer argument to use NULL instead of 0.

thatcosmonaut commented 13 hours ago

There isn't a single driver for Windows XP that can support D3D12, or Vulkan for that matter, so I think the actual solution here is to disable GPU by default on Windows versions pre-7.

madebr commented 12 hours ago

By avoiding, or dynamically loading, xp incompatible symbols, old school gamers can use "official" binaries and don't have to rebuild. This is important for apps statically linking to SDL3.

slouken commented 3 hours ago

Is there a reason we can't just always use CreateEvent()? Do we need the #ifdef at all?

Clownacy commented 2 hours ago

@chalonverse would know better than me, as they're the one that added the #ifdef for GDK in the WASAPI backend. This PR just copies that.

thatcosmonaut commented 2 hours ago

Is there a reason we can't just always use CreateEvent()? Do we need the #ifdef at all?

I think you might be right. I'm not terribly familiar with Windows APIs so I just used the first thing I saw in an example.