Skip to content

Commit 3c5bf97

Browse files
committed
One more...
1 parent 4e88504 commit 3c5bf97

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/FNA3D_Driver_Vulkan.c

+27-22
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,7 @@ static uint8_t VULKAN_INTERNAL_CreateInstance(
22952295
) {
22962296
VkResult vulkanResult;
22972297
VkApplicationInfo appInfo;
2298-
#ifdef USE_SDL3
2298+
#if SDL_MAJOR_VERSION >= 3
22992299
char const* const* inferredExtensionNames;
23002300
#endif
23012301
const char **instanceExtensionNames;
@@ -2312,7 +2312,7 @@ static uint8_t VULKAN_INTERNAL_CreateInstance(
23122312
appInfo.engineVersion = FNA3D_COMPILED_VERSION;
23132313
appInfo.apiVersion = VK_MAKE_VERSION(1, 0, 0);
23142314

2315-
#ifdef USE_SDL3
2315+
#if SDL_MAJOR_VERSION >= 3
23162316
inferredExtensionNames = SDL_Vulkan_GetInstanceExtensions(&instanceExtensionCount);
23172317

23182318
if (inferredExtensionNames == NULL)
@@ -4332,13 +4332,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
43324332
VulkanSwapchainData *swapchainData = NULL;
43334333
uint32_t swapchainImageIndex;
43344334
VulkanCommandBuffer *commandBufferToSubmit;
4335-
int32_t refreshRate;
4336-
4337-
#ifdef USE_SDL3
4338-
const SDL_DisplayMode *mode;
4339-
#else
43404335
SDL_DisplayMode mode;
4341-
#endif
43424336

43434337
VkPipelineStageFlags waitStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
43444338
VkPresentInfoKHR presentInfo;
@@ -4354,32 +4348,43 @@ static void VULKAN_INTERNAL_SubmitCommands(
43544348

43554349
if (present)
43564350
{
4357-
#ifdef USE_SDL3
4358-
mode = SDL_GetCurrentDisplayMode(
4351+
#if SDL_MAJOR_VERSION >= 3
4352+
const SDL_DisplayMode *curMode = SDL_GetCurrentDisplayMode(
43594353
SDL_GetDisplayForWindow(
43604354
(SDL_Window*) windowHandle
43614355
)
43624356
);
4363-
refreshRate = mode->refresh_rate;
4357+
SDL_memcpy(&mode, curMode, sizeof(SDL_DisplayMode));
43644358

4365-
swapchainData = (VulkanSwapchainData*) SDL_GetProperty(SDL_GetWindowProperties(windowHandle), WINDOW_SWAPCHAIN_DATA, NULL);
43664359
#else
43674360
SDL_GetCurrentDisplayMode(
43684361
SDL_GetWindowDisplayIndex(
43694362
(SDL_Window*) windowHandle
43704363
),
43714364
&mode
43724365
);
4373-
refreshRate = mode.refresh_rate;
4374-
if (refreshRate == 0)
4366+
#endif
4367+
4368+
if (mode.refresh_rate == 0)
43754369
{
43764370
/* Needs to be _something_ */
4377-
refreshRate = 60;
4371+
mode.refresh_rate = 60;
43784372
}
43794373

4380-
swapchainData = (VulkanSwapchainData*) SDL_GetWindowData(windowHandle, WINDOW_SWAPCHAIN_DATA);
4374+
#if SDL_MAJOR_VERSION >= 3
4375+
swapchainData = (VulkanSwapchainData*) SDL_GetProperty(
4376+
SDL_GetWindowProperties(windowHandle),
4377+
WINDOW_SWAPCHAIN_DATA,
4378+
NULL
4379+
);
4380+
#else
4381+
swapchainData = (VulkanSwapchainData*) SDL_GetWindowData(
4382+
windowHandle,
4383+
WINDOW_SWAPCHAIN_DATA
4384+
);
43814385
#endif
43824386

4387+
43834388
if (swapchainData == NULL)
43844389
{
43854390
createSwapchainResult = VULKAN_INTERNAL_CreateSwapchain(renderer, windowHandle);
@@ -4394,7 +4399,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
43944399
}
43954400
else
43964401
{
4397-
#ifdef USE_SDL3
4402+
#if SDL_MAJOR_VERSION >= 3
43984403
swapchainData = (VulkanSwapchainData *)SDL_GetProperty(SDL_GetWindowProperties(windowHandle), WINDOW_SWAPCHAIN_DATA, NULL);
43994404
#else
44004405
swapchainData = (VulkanSwapchainData*) SDL_GetWindowData(windowHandle, WINDOW_SWAPCHAIN_DATA);
@@ -4413,7 +4418,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
44134418
acquireResult = renderer->vkAcquireNextImageKHR(
44144419
renderer->logicalDevice,
44154420
swapchainData->swapchain,
4416-
10000000000 / refreshRate, /* ~10 frames, so we'll progress even if throttled to zero. */
4421+
10000000000 / mode.refresh_rate, /* ~10 frames, so we'll progress even if throttled to zero. */
44174422
swapchainData->imageAvailableSemaphore,
44184423
VK_NULL_HANDLE,
44194424
&swapchainImageIndex
@@ -4569,7 +4574,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
45694574
{
45704575
if (renderer->supports.GGP_frame_token)
45714576
{
4572-
#ifdef USE_SDL3
4577+
#if SDL_MAJOR_VERSION >= 3
45734578
const void *token = SDL_GetProperty(SDL_GetWindowProperties(windowHandle), "GgpFrameToken", NULL);
45744579
#else
45754580
const void *token = SDL_GetWindowData((SDL_Window*) windowHandle, "GgpFrameToken");
@@ -5093,7 +5098,7 @@ static CreateSwapchainResult VULKAN_INTERNAL_CreateSwapchain(
50935098

50945099
swapchainData->fence = VK_NULL_HANDLE;
50955100

5096-
#ifdef USE_SDL3
5101+
#if SDL_MAJOR_VERSION >= 3
50975102
SDL_SetProperty(SDL_GetWindowProperties(windowHandle), WINDOW_SWAPCHAIN_DATA, swapchainData);
50985103
#else
50995104
SDL_SetWindowData(windowHandle, WINDOW_SWAPCHAIN_DATA, swapchainData);
@@ -5129,7 +5134,7 @@ static void VULKAN_INTERNAL_DestroySwapchain(
51295134
uint32_t i;
51305135
VulkanSwapchainData *swapchainData;
51315136

5132-
#ifdef USE_SDL3
5137+
#if SDL_MAJOR_VERSION >= 3
51335138
swapchainData = (VulkanSwapchainData*) SDL_GetProperty(SDL_GetWindowProperties(windowHandle), WINDOW_SWAPCHAIN_DATA, NULL);
51345139
#else
51355140
swapchainData = (VulkanSwapchainData*) SDL_GetWindowData(windowHandle, WINDOW_SWAPCHAIN_DATA);
@@ -5200,7 +5205,7 @@ static void VULKAN_INTERNAL_DestroySwapchain(
52005205
}
52015206
}
52025207

5203-
#ifdef USE_SDL3
5208+
#if SDL_MAJOR_VERSION >= 3
52045209
SDL_ClearProperty(SDL_GetWindowProperties(windowHandle), WINDOW_SWAPCHAIN_DATA);
52055210
#else
52065211
SDL_SetWindowData(windowHandle, WINDOW_SWAPCHAIN_DATA, NULL);

0 commit comments

Comments
 (0)