@@ -2295,7 +2295,7 @@ static uint8_t VULKAN_INTERNAL_CreateInstance(
2295
2295
) {
2296
2296
VkResult vulkanResult ;
2297
2297
VkApplicationInfo appInfo ;
2298
- #ifdef USE_SDL3
2298
+ #if SDL_MAJOR_VERSION >= 3
2299
2299
char const * const * inferredExtensionNames ;
2300
2300
#endif
2301
2301
const char * * instanceExtensionNames ;
@@ -2312,7 +2312,7 @@ static uint8_t VULKAN_INTERNAL_CreateInstance(
2312
2312
appInfo .engineVersion = FNA3D_COMPILED_VERSION ;
2313
2313
appInfo .apiVersion = VK_MAKE_VERSION (1 , 0 , 0 );
2314
2314
2315
- #ifdef USE_SDL3
2315
+ #if SDL_MAJOR_VERSION >= 3
2316
2316
inferredExtensionNames = SDL_Vulkan_GetInstanceExtensions (& instanceExtensionCount );
2317
2317
2318
2318
if (inferredExtensionNames == NULL )
@@ -4332,13 +4332,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
4332
4332
VulkanSwapchainData * swapchainData = NULL ;
4333
4333
uint32_t swapchainImageIndex ;
4334
4334
VulkanCommandBuffer * commandBufferToSubmit ;
4335
- int32_t refreshRate ;
4336
-
4337
- #ifdef USE_SDL3
4338
- const SDL_DisplayMode * mode ;
4339
- #else
4340
4335
SDL_DisplayMode mode ;
4341
- #endif
4342
4336
4343
4337
VkPipelineStageFlags waitStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT ;
4344
4338
VkPresentInfoKHR presentInfo ;
@@ -4354,32 +4348,43 @@ static void VULKAN_INTERNAL_SubmitCommands(
4354
4348
4355
4349
if (present )
4356
4350
{
4357
- #ifdef USE_SDL3
4358
- mode = SDL_GetCurrentDisplayMode (
4351
+ #if SDL_MAJOR_VERSION >= 3
4352
+ const SDL_DisplayMode * curMode = SDL_GetCurrentDisplayMode (
4359
4353
SDL_GetDisplayForWindow (
4360
4354
(SDL_Window * ) windowHandle
4361
4355
)
4362
4356
);
4363
- refreshRate = mode -> refresh_rate ;
4357
+ SDL_memcpy ( & mode , curMode , sizeof ( SDL_DisplayMode )) ;
4364
4358
4365
- swapchainData = (VulkanSwapchainData * ) SDL_GetProperty (SDL_GetWindowProperties (windowHandle ), WINDOW_SWAPCHAIN_DATA , NULL );
4366
4359
#else
4367
4360
SDL_GetCurrentDisplayMode (
4368
4361
SDL_GetWindowDisplayIndex (
4369
4362
(SDL_Window * ) windowHandle
4370
4363
),
4371
4364
& mode
4372
4365
);
4373
- refreshRate = mode .refresh_rate ;
4374
- if (refreshRate == 0 )
4366
+ #endif
4367
+
4368
+ if (mode .refresh_rate == 0 )
4375
4369
{
4376
4370
/* Needs to be _something_ */
4377
- refreshRate = 60 ;
4371
+ mode . refresh_rate = 60 ;
4378
4372
}
4379
4373
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
+ );
4381
4385
#endif
4382
4386
4387
+
4383
4388
if (swapchainData == NULL )
4384
4389
{
4385
4390
createSwapchainResult = VULKAN_INTERNAL_CreateSwapchain (renderer , windowHandle );
@@ -4394,7 +4399,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
4394
4399
}
4395
4400
else
4396
4401
{
4397
- #ifdef USE_SDL3
4402
+ #if SDL_MAJOR_VERSION >= 3
4398
4403
swapchainData = (VulkanSwapchainData * )SDL_GetProperty (SDL_GetWindowProperties (windowHandle ), WINDOW_SWAPCHAIN_DATA , NULL );
4399
4404
#else
4400
4405
swapchainData = (VulkanSwapchainData * ) SDL_GetWindowData (windowHandle , WINDOW_SWAPCHAIN_DATA );
@@ -4413,7 +4418,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
4413
4418
acquireResult = renderer -> vkAcquireNextImageKHR (
4414
4419
renderer -> logicalDevice ,
4415
4420
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. */
4417
4422
swapchainData -> imageAvailableSemaphore ,
4418
4423
VK_NULL_HANDLE ,
4419
4424
& swapchainImageIndex
@@ -4569,7 +4574,7 @@ static void VULKAN_INTERNAL_SubmitCommands(
4569
4574
{
4570
4575
if (renderer -> supports .GGP_frame_token )
4571
4576
{
4572
- #ifdef USE_SDL3
4577
+ #if SDL_MAJOR_VERSION >= 3
4573
4578
const void * token = SDL_GetProperty (SDL_GetWindowProperties (windowHandle ), "GgpFrameToken" , NULL );
4574
4579
#else
4575
4580
const void * token = SDL_GetWindowData ((SDL_Window * ) windowHandle , "GgpFrameToken" );
@@ -5093,7 +5098,7 @@ static CreateSwapchainResult VULKAN_INTERNAL_CreateSwapchain(
5093
5098
5094
5099
swapchainData -> fence = VK_NULL_HANDLE ;
5095
5100
5096
- #ifdef USE_SDL3
5101
+ #if SDL_MAJOR_VERSION >= 3
5097
5102
SDL_SetProperty (SDL_GetWindowProperties (windowHandle ), WINDOW_SWAPCHAIN_DATA , swapchainData );
5098
5103
#else
5099
5104
SDL_SetWindowData (windowHandle , WINDOW_SWAPCHAIN_DATA , swapchainData );
@@ -5129,7 +5134,7 @@ static void VULKAN_INTERNAL_DestroySwapchain(
5129
5134
uint32_t i ;
5130
5135
VulkanSwapchainData * swapchainData ;
5131
5136
5132
- #ifdef USE_SDL3
5137
+ #if SDL_MAJOR_VERSION >= 3
5133
5138
swapchainData = (VulkanSwapchainData * ) SDL_GetProperty (SDL_GetWindowProperties (windowHandle ), WINDOW_SWAPCHAIN_DATA , NULL );
5134
5139
#else
5135
5140
swapchainData = (VulkanSwapchainData * ) SDL_GetWindowData (windowHandle , WINDOW_SWAPCHAIN_DATA );
@@ -5200,7 +5205,7 @@ static void VULKAN_INTERNAL_DestroySwapchain(
5200
5205
}
5201
5206
}
5202
5207
5203
- #ifdef USE_SDL3
5208
+ #if SDL_MAJOR_VERSION >= 3
5204
5209
SDL_ClearProperty (SDL_GetWindowProperties (windowHandle ), WINDOW_SWAPCHAIN_DATA );
5205
5210
#else
5206
5211
SDL_SetWindowData (windowHandle , WINDOW_SWAPCHAIN_DATA , NULL );
0 commit comments