gpu: Use the window event watcher list for Vulkan and D3D12

Events won't be delivered to the regular event watcher list callbacks if a client event filter discards events. Use the special window event watcher list to watch for resizes in the GPU renderers, as events are delivered to this list before a client can potentially discard them.

(cherry picked from commit cb4f33b644)
This commit is contained in:
Frank Praznik
2025-12-30 21:45:16 -05:00
committed by Sam Lantinga
parent cfc41248be
commit 6034cf5cd8
2 changed files with 6 additions and 4 deletions

View File

@@ -23,6 +23,7 @@
#ifdef SDL_GPU_D3D12
#include "../../events/SDL_windowevents_c.h"
#include "../../core/windows/SDL_windows.h"
#include "../../video/directx/SDL_d3d12.h"
#include "../SDL_sysgpu.h"
@@ -7055,7 +7056,7 @@ static bool D3D12_ClaimWindow(
renderer->claimedWindowCount += 1;
SDL_UnlockMutex(renderer->windowLock);
SDL_AddEventWatch(D3D12_INTERNAL_OnWindowResize, window);
SDL_AddWindowEventWatch(SDL_WINDOW_EVENT_WATCH_NORMAL, D3D12_INTERNAL_OnWindowResize, window);
return true;
} else {
@@ -7103,7 +7104,7 @@ static void D3D12_ReleaseWindow(
SDL_free(windowData);
SDL_ClearProperty(SDL_GetWindowProperties(window), WINDOW_PROPERTY_DATA);
SDL_RemoveEventWatch(D3D12_INTERNAL_OnWindowResize, window);
SDL_RemoveWindowEventWatch(SDL_WINDOW_EVENT_WATCH_NORMAL, D3D12_INTERNAL_OnWindowResize, window);
}
static bool D3D12_SetSwapchainParameters(

View File

@@ -32,6 +32,7 @@
#include <SDL3/SDL_vulkan.h>
#include "../SDL_sysgpu.h"
#include "../../events/SDL_windowevents_c.h"
#define VULKAN_INTERNAL_clamp(val, min, max) SDL_max(min, SDL_min(val, max))
@@ -9841,7 +9842,7 @@ static bool VULKAN_ClaimWindow(
renderer->claimedWindowCount += 1;
SDL_UnlockMutex(renderer->windowLock);
SDL_AddEventWatch(VULKAN_INTERNAL_OnWindowResize, window);
SDL_AddWindowEventWatch(SDL_WINDOW_EVENT_WATCH_NORMAL, VULKAN_INTERNAL_OnWindowResize, window);
return true;
} else if (createSwapchainResult == VULKAN_INTERNAL_TRY_AGAIN) {
@@ -9896,7 +9897,7 @@ static void VULKAN_ReleaseWindow(
SDL_free(windowData);
SDL_ClearProperty(SDL_GetWindowProperties(window), WINDOW_PROPERTY_DATA);
SDL_RemoveEventWatch(VULKAN_INTERNAL_OnWindowResize, window);
SDL_RemoveWindowEventWatch(SDL_WINDOW_EVENT_WATCH_NORMAL, VULKAN_INTERNAL_OnWindowResize, window);
}
static Uint32 VULKAN_INTERNAL_RecreateSwapchain(