diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 10fdf4987e055..4c9bfb8c0d4aa 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -2008,13 +2008,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuUnclaimWindow( * \param window an SDL_Window that has been claimed * \param swapchainComposition the desired composition of the swapchain * \param presentMode the desired present mode for the swapchain + * \returns SDL_TRUE if successful, SDL_FALSE on error * * \since This function is available since SDL 3.x.x * * \sa SDL_GpuSupportsPresentMode * \sa SDL_GpuSupportsSwapchainComposition */ -extern SDL_DECLSPEC void SDLCALL SDL_GpuSetSwapchainParameters( +extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GpuSetSwapchainParameters( SDL_GpuDevice *device, SDL_Window *window, SDL_GpuSwapchainComposition swapchainComposition, diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 80a1954e80f3b..c1868f5ae0289 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -1145,7 +1145,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_GpuSupportsSwapchainComposition,(SDL_GpuDevice *a, SDL_DYNAPI_PROC(SDL_bool,SDL_GpuSupportsPresentMode,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuPresentMode c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GpuClaimWindow,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuSwapchainComposition c, SDL_GpuPresentMode d),(a,b,c,d),return) SDL_DYNAPI_PROC(void,SDL_GpuUnclaimWindow,(SDL_GpuDevice *a, SDL_Window *b),(a,b),) -SDL_DYNAPI_PROC(void,SDL_GpuSetSwapchainParameters,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuSwapchainComposition c, SDL_GpuPresentMode d),(a,b,c,d),) +SDL_DYNAPI_PROC(SDL_bool,SDL_GpuSetSwapchainParameters,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuSwapchainComposition c, SDL_GpuPresentMode d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_GpuTextureFormat,SDL_GpuGetSwapchainTextureFormat,(SDL_GpuDevice *a, SDL_Window *b),(a,b),return) SDL_DYNAPI_PROC(SDL_GpuTexture*,SDL_GpuAcquireSwapchainTexture,(SDL_GpuCommandBuffer *a, SDL_Window *b, Uint32 *c, Uint32 *d),(a,b,c,d),return) SDL_DYNAPI_PROC(void,SDL_GpuSubmit,(SDL_GpuCommandBuffer *a),(a),) diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index 8a1544f75543b..bb9a55d031e64 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -1285,14 +1285,14 @@ void SDL_GpuUnclaimWindow( window); } -void SDL_GpuSetSwapchainParameters( +SDL_bool SDL_GpuSetSwapchainParameters( SDL_GpuDevice *device, SDL_Window *window, SDL_GpuSwapchainComposition swapchainFormat, SDL_GpuPresentMode presentMode) { NULL_ASSERT(device); - device->SetSwapchainParameters( + return device->SetSwapchainParameters( device->driverData, window, swapchainFormat, diff --git a/src/gpu/SDL_gpu_driver.h b/src/gpu/SDL_gpu_driver.h index d387efd83eb40..74c7c03c69a36 100644 --- a/src/gpu/SDL_gpu_driver.h +++ b/src/gpu/SDL_gpu_driver.h @@ -538,7 +538,7 @@ struct SDL_GpuDevice SDL_GpuRenderer *driverData, SDL_Window *window); - void (*SetSwapchainParameters)( + SDL_bool (*SetSwapchainParameters)( SDL_GpuRenderer *driverData, SDL_Window *window, SDL_GpuSwapchainComposition swapchainComposition, @@ -684,7 +684,7 @@ typedef struct SDL_GpuDriver { const char *Name; const SDL_GpuBackend backendflag; - Uint8 (*PrepareDriver)(SDL_VideoDevice *_this); + SDL_bool (*PrepareDriver)(SDL_VideoDevice *_this); SDL_GpuDevice *(*CreateDevice)(SDL_bool debugMode); } SDL_GpuDriver; diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c index 3362002ac6beb..ca21538c24d1c 100644 --- a/src/gpu/d3d11/SDL_gpu_d3d11.c +++ b/src/gpu/d3d11/SDL_gpu_d3d11.c @@ -3240,7 +3240,7 @@ static D3D11CommandBuffer *D3D11_INTERNAL_GetInactiveCommandBufferFromPool( return commandBuffer; } -static Uint8 D3D11_INTERNAL_CreateFence( +static SDL_bool D3D11_INTERNAL_CreateFence( D3D11Renderer *renderer) { D3D11_QUERY_DESC queryDesc; @@ -3271,10 +3271,10 @@ static Uint8 D3D11_INTERNAL_CreateFence( renderer->availableFences[renderer->availableFenceCount] = fence; renderer->availableFenceCount += 1; - return 1; + return SDL_TRUE; } -static Uint8 D3D11_INTERNAL_AcquireFence( +static SDL_bool D3D11_INTERNAL_AcquireFence( D3D11CommandBuffer *commandBuffer) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; @@ -3288,7 +3288,7 @@ static Uint8 D3D11_INTERNAL_AcquireFence( if (!D3D11_INTERNAL_CreateFence(renderer)) { SDL_UnlockMutex(renderer->fenceLock); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create fence!"); - return 0; + return SDL_FALSE; } } @@ -3301,7 +3301,7 @@ static Uint8 D3D11_INTERNAL_AcquireFence( commandBuffer->fence = fence; (void)SDL_AtomicIncRef(&commandBuffer->fence->referenceCount); - return 1; + return SDL_TRUE; } static SDL_GpuCommandBuffer *D3D11_AcquireCommandBuffer( @@ -4970,7 +4970,7 @@ static D3D11WindowData *D3D11_INTERNAL_FetchWindowData( return (D3D11WindowData *)SDL_GetProperty(properties, WINDOW_PROPERTY_DATA, NULL); } -static Uint8 D3D11_INTERNAL_InitializeSwapchainTexture( +static SDL_bool D3D11_INTERNAL_InitializeSwapchainTexture( D3D11Renderer *renderer, IDXGISwapChain *swapchain, DXGI_FORMAT swapchainFormat, @@ -5012,7 +5012,7 @@ static Uint8 D3D11_INTERNAL_InitializeSwapchainTexture( if (FAILED(res)) { ID3D11Texture2D_Release(swapchainTexture); D3D11_INTERNAL_LogError(renderer->device, "Swapchain SRV creation failed", res); - return 0; + return SDL_FALSE; } /* Create the RTV for the swapchain */ @@ -5029,7 +5029,7 @@ static Uint8 D3D11_INTERNAL_InitializeSwapchainTexture( ID3D11ShaderResourceView_Release(srv); ID3D11Texture2D_Release(swapchainTexture); D3D11_INTERNAL_LogError(renderer->device, "Swapchain RTV creation failed", res); - return 0; + return SDL_FALSE; } uavDesc.Format = swapchainFormat; @@ -5046,7 +5046,7 @@ static Uint8 D3D11_INTERNAL_InitializeSwapchainTexture( ID3D11RenderTargetView_Release(rtv); ID3D11Texture2D_Release(swapchainTexture); D3D11_INTERNAL_LogError(renderer->device, "Swapchain UAV creation failed", res); - return 0; + return SDL_FALSE; } /* Fill out the texture struct */ @@ -5077,10 +5077,10 @@ static Uint8 D3D11_INTERNAL_InitializeSwapchainTexture( /* Cleanup */ ID3D11Texture2D_Release(swapchainTexture); - return 1; + return SDL_TRUE; } -static Uint8 D3D11_INTERNAL_CreateSwapchain( +static SDL_bool D3D11_INTERNAL_CreateSwapchain( D3D11Renderer *renderer, D3D11WindowData *windowData, SDL_GpuSwapchainComposition swapchainComposition, @@ -5198,7 +5198,7 @@ static Uint8 D3D11_INTERNAL_CreateSwapchain( if (!(colorSpaceSupport & DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT)) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Requested colorspace is unsupported!"); - return 0; + return SDL_FALSE; } IDXGISwapChain3_SetColorSpace1( @@ -5208,7 +5208,7 @@ static Uint8 D3D11_INTERNAL_CreateSwapchain( IDXGISwapChain3_Release(swapchain3); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DXGI 1.4 not supported, cannot use colorspace other than SDL_GPU_COLORSPACE_NONLINEAR_SRGB!"); - return 0; + return SDL_FALSE; } /* If a you are using a FLIP model format you can't create the swapchain as DXGI_FORMAT_B8G8R8A8_UNORM_SRGB. @@ -5221,17 +5221,17 @@ static Uint8 D3D11_INTERNAL_CreateSwapchain( (swapchainComposition == SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR) ? DXGI_FORMAT_B8G8R8A8_UNORM_SRGB : windowData->swapchainFormat, &windowData->texture)) { IDXGISwapChain_Release(swapchain); - return 0; + return SDL_FALSE; } /* Initialize dummy container */ SDL_zerop(&windowData->textureContainer); windowData->textureContainer.textures = SDL_calloc(1, sizeof(D3D11Texture *)); - return 1; + return SDL_TRUE; } -static Uint8 D3D11_INTERNAL_ResizeSwapchain( +static SDL_bool D3D11_INTERNAL_ResizeSwapchain( D3D11Renderer *renderer, D3D11WindowData *windowData, Sint32 width, @@ -5334,15 +5334,15 @@ static SDL_bool D3D11_ClaimWindow( SDL_UnlockMutex(renderer->windowLock); - return 1; + return SDL_TRUE; } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create swapchain, failed to claim window!"); SDL_free(windowData); - return 0; + return SDL_FALSE; } } else { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Window already claimed!"); - return 0; + return SDL_FALSE; } } @@ -5530,7 +5530,7 @@ static SDL_GpuTextureFormat D3D11_GetSwapchainTextureFormat( } } -static void D3D11_SetSwapchainParameters( +static SDL_bool D3D11_SetSwapchainParameters( SDL_GpuRenderer *driverData, SDL_Window *window, SDL_GpuSwapchainComposition swapchainComposition, @@ -5539,6 +5539,21 @@ static void D3D11_SetSwapchainParameters( D3D11Renderer *renderer = (D3D11Renderer *)driverData; D3D11WindowData *windowData = D3D11_INTERNAL_FetchWindowData(window); + if (windowData == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Cannot set swapchain parameters on unclaimed window!"); + return SDL_FALSE; + } + + if (!D3D11_SupportsSwapchainComposition(driverData, window, swapchainComposition)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Swapchain composition not supported!"); + return SDL_FALSE; + } + + if (!D3D11_SupportsPresentMode(driverData, window, presentMode)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Present mode not supported!"); + return SDL_FALSE; + } + if ( swapchainComposition != windowData->swapchainComposition || presentMode != windowData->presentMode) { @@ -5549,12 +5564,14 @@ static void D3D11_SetSwapchainParameters( renderer, windowData); - D3D11_INTERNAL_CreateSwapchain( + return D3D11_INTERNAL_CreateSwapchain( renderer, windowData, swapchainComposition, presentMode); } + + return SDL_TRUE; } /* Submission */ @@ -5782,7 +5799,7 @@ static SDL_bool D3D11_IsTextureFormatSupported( /* Device Creation */ -static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) +static SDL_bool D3D11_PrepareDriver(SDL_VideoDevice *_this) { void *d3d11_dll, *dxgi_dll, *d3dcompiler_dll; PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; @@ -5796,7 +5813,7 @@ static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) d3d11_dll = SDL_LoadObject(D3D11_DLL); if (d3d11_dll == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D11: Could not find " D3D11_DLL); - return 0; + return SDL_FALSE; } D3D11CreateDeviceFunc = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction( @@ -5805,7 +5822,7 @@ static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) if (D3D11CreateDeviceFunc == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D11: Could not find function " D3D11_CREATE_DEVICE_FUNC " in " D3D11_DLL); SDL_UnloadObject(d3d11_dll); - return 0; + return SDL_FALSE; } /* Can we create a device? */ @@ -5826,7 +5843,7 @@ static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) if (FAILED(res)) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D11: Could not create D3D11Device with feature level 11_0"); - return 0; + return SDL_FALSE; } /* Can we load DXGI? */ @@ -5834,7 +5851,7 @@ static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) dxgi_dll = SDL_LoadObject(DXGI_DLL); if (dxgi_dll == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D11: Could not find " DXGI_DLL); - return 0; + return SDL_FALSE; } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction( @@ -5843,7 +5860,7 @@ static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) SDL_UnloadObject(dxgi_dll); /* We're not going to call this function, so we can just unload now. */ if (CreateDXGIFactoryFunc == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D11: Could not find function " CREATE_DXGI_FACTORY1_FUNC " in " DXGI_DLL); - return 0; + return SDL_FALSE; } /* Can we load D3DCompiler? */ @@ -5851,7 +5868,7 @@ static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) d3dcompiler_dll = SDL_LoadObject(D3DCOMPILER_DLL); if (d3dcompiler_dll == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D11: Could not find " D3DCOMPILER_DLL); - return 0; + return SDL_FALSE; } D3DCompileFunc = (PFN_D3DCOMPILE)SDL_LoadFunction( @@ -5860,10 +5877,10 @@ static Uint8 D3D11_PrepareDriver(SDL_VideoDevice *_this) SDL_UnloadObject(d3dcompiler_dll); /* We're not going to call this function, so we can just unload now. */ if (D3DCompileFunc == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D11: Could not find function D3DCompile in " D3DCOMPILER_DLL); - return 0; + return SDL_FALSE; } - return 1; + return SDL_TRUE; } static void D3D11_INTERNAL_TryInitializeDXGIDebug(D3D11Renderer *renderer) diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index 7ae91bc3e2790..2d3edb9c50150 100644 --- a/src/gpu/metal/SDL_gpu_metal.m +++ b/src/gpu/metal/SDL_gpu_metal.m @@ -3537,7 +3537,7 @@ static SDL_GpuTextureFormat METAL_GetSwapchainTextureFormat( return windowData->textureContainer.createInfo.format; } -static void METAL_SetSwapchainParameters( +static SDL_bool METAL_SetSwapchainParameters( SDL_GpuRenderer *driverData, SDL_Window *window, SDL_GpuSwapchainComposition swapchainComposition, @@ -3548,7 +3548,17 @@ static void METAL_SetSwapchainParameters( if (windowData == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Cannot set swapchain parameters, window has not been claimed!"); - return; + return SDL_FALSE; + } + + if (!METAL_SupportsSwapchainComposition(driverData, window, swapchainComposition)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Swapchain composition not supported!"); + return SDL_FALSE; + } + + if (!METAL_SupportsPresentMode(driverData, window, presentMode)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Present mode not supported!"); + return SDL_FALSE; } METAL_Wait(driverData); @@ -3566,6 +3576,8 @@ static void METAL_SetSwapchainParameters( CGColorSpaceRelease(colorspace); windowData->textureContainer.createInfo.format = SwapchainCompositionToFormat[swapchainComposition]; + + return SDL_TRUE; } /* Submission */ @@ -3714,7 +3726,7 @@ static SDL_bool METAL_IsTextureFormatSupported( /* Device Creation */ -static Uint8 METAL_PrepareDriver(SDL_VideoDevice *_this) +static SDL_bool METAL_PrepareDriver(SDL_VideoDevice *_this) { /* FIXME: Add a macOS / iOS version check! Maybe support >= 10.14? */ return (_this->Metal_CreateView != NULL); diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index 6fc561273c05d..ab38a258df17e 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -4161,7 +4161,7 @@ static SDL_bool VULKAN_INTERNAL_VerifySwapPresentMode( return SDL_FALSE; } -static Uint8 VULKAN_INTERNAL_CreateSwapchain( +static SDL_bool VULKAN_INTERNAL_CreateSwapchain( VulkanRenderer *renderer, WindowData *windowData) { @@ -4194,7 +4194,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( SDL_LOG_CATEGORY_APPLICATION, "Vulkan_CreateSurface failed: %s", SDL_GetError()); - return 0; + return SDL_FALSE; } if (!VULKAN_INTERNAL_QuerySwapchainSupport( @@ -4214,7 +4214,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( } SDL_free(swapchainData); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device does not support swap chain creation"); - return 0; + return SDL_FALSE; } if (swapchainSupportDetails.capabilities.currentExtent.width == 0 || @@ -4231,7 +4231,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( SDL_free(swapchainSupportDetails.presentModes); } SDL_free(swapchainData); - return 0; + return SDL_FALSE; } swapchainData->format = SwapchainCompositionToFormat[windowData->swapchainComposition]; @@ -4264,7 +4264,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( SDL_free(swapchainData); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device does not support requested colorspace!"); - return 0; + return SDL_FALSE; } if (!VULKAN_INTERNAL_VerifySwapSurfaceFormat( @@ -4287,7 +4287,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( SDL_free(swapchainData); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device does not support requested colorspace!"); - return 0; + return SDL_FALSE; } } @@ -4310,7 +4310,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( SDL_free(swapchainData); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device does not support requested present mode!"); - return 0; + return SDL_FALSE; } swapchainData->presentMode = SDLToVK_PresentMode[windowData->presentMode]; @@ -4348,7 +4348,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( } SDL_free(swapchainData); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No fallback swapchain size available!"); - return 0; + return SDL_FALSE; } } @@ -4414,7 +4414,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( NULL); SDL_free(swapchainData); LogVulkanResultAsError("vkCreateSwapchainKHR", vulkanResult); - return 0; + return SDL_FALSE; } renderer->vkGetSwapchainImagesKHR( @@ -4433,7 +4433,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( swapchainData->surface, NULL); SDL_free(swapchainData); - return 0; + return SDL_FALSE; } swapchainImages = SDL_stack_alloc(VkImage, swapchainData->imageCount); @@ -4485,7 +4485,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( SDL_free(swapchainData->textureContainers); SDL_free(swapchainData); LogVulkanResultAsError("vkCreateImageView", vulkanResult); - return 0; + return SDL_FALSE; } /* Swapchain memory is managed by the driver */ @@ -4549,7 +4549,7 @@ static Uint8 VULKAN_INTERNAL_CreateSwapchain( } windowData->swapchainData = swapchainData; - return 1; + return SDL_TRUE; } /* Command Buffers */ @@ -9602,7 +9602,7 @@ static void VULKAN_UnclaimWindow( SDL_ClearProperty(SDL_GetWindowProperties(window), WINDOW_PROPERTY_DATA); } -static void VULKAN_INTERNAL_RecreateSwapchain( +static SDL_bool VULKAN_INTERNAL_RecreateSwapchain( VulkanRenderer *renderer, WindowData *windowData) { @@ -9621,7 +9621,7 @@ static void VULKAN_INTERNAL_RecreateSwapchain( } VULKAN_INTERNAL_DestroySwapchain(renderer, windowData); - VULKAN_INTERNAL_CreateSwapchain(renderer, windowData); + return VULKAN_INTERNAL_CreateSwapchain(renderer, windowData); } static SDL_GpuTexture *VULKAN_AcquireSwapchainTexture( @@ -9843,7 +9843,7 @@ static SDL_GpuTextureFormat VULKAN_GetSwapchainTextureFormat( } } -static void VULKAN_SetSwapchainParameters( +static SDL_bool VULKAN_SetSwapchainParameters( SDL_GpuRenderer *driverData, SDL_Window *window, SDL_GpuSwapchainComposition swapchainComposition, @@ -9852,15 +9852,21 @@ static void VULKAN_SetSwapchainParameters( WindowData *windowData = VULKAN_INTERNAL_FetchWindowData(window); if (windowData == NULL) { - SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Cannot set present mode, window has not been claimed!"); - return; + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Cannot set swapchain parameters on unclaimed window!"); + return SDL_FALSE; + } + + if (!VULKAN_SupportsSwapchainComposition(driverData, window, swapchainComposition)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Swapchain composition not supported!"); + return SDL_FALSE; } - /* The window size may have changed, always update even if these params are the same */ - windowData->presentMode = presentMode; - windowData->swapchainComposition = swapchainComposition; + if (!VULKAN_SupportsPresentMode(driverData, window, presentMode)) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Present mode not supported!"); + return SDL_FALSE; + } - VULKAN_INTERNAL_RecreateSwapchain( + return VULKAN_INTERNAL_RecreateSwapchain( (VulkanRenderer *)driverData, windowData); } @@ -11325,7 +11331,7 @@ static void VULKAN_INTERNAL_LoadEntryPoints(void) #include "SDL_gpu_vulkan_vkfuncs.h" } -static Uint8 VULKAN_INTERNAL_PrepareVulkan( +static SDL_bool VULKAN_INTERNAL_PrepareVulkan( VulkanRenderer *renderer) { SDL_Window *dummyWindowHandle; @@ -11342,13 +11348,13 @@ static Uint8 VULKAN_INTERNAL_PrepareVulkan( if (dummyWindowHandle == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Vulkan: Could not create dummy window"); - return 0; + return SDL_FALSE; } if (!VULKAN_INTERNAL_CreateInstance(renderer, dummyWindowHandle)) { SDL_DestroyWindow(dummyWindowHandle); SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Vulkan: Could not create Vulkan instance"); - return 0; + return SDL_FALSE; } if (!SDL_Vulkan_CreateSurface( @@ -11361,7 +11367,7 @@ static Uint8 VULKAN_INTERNAL_PrepareVulkan( SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_CreateSurface failed: %s", SDL_GetError()); - return 0; + return SDL_FALSE; } #define VULKAN_INSTANCE_FUNCTION(ext, ret, func, params) \ @@ -11377,7 +11383,7 @@ static Uint8 VULKAN_INTERNAL_PrepareVulkan( NULL); SDL_DestroyWindow(dummyWindowHandle); - return 0; + return SDL_FALSE; } if (!VULKAN_INTERNAL_QuerySwapchainSupport( @@ -11391,7 +11397,7 @@ static Uint8 VULKAN_INTERNAL_PrepareVulkan( NULL); SDL_DestroyWindow(dummyWindowHandle); - return 0; + return SDL_FALSE; } SDL_free(swapchainSupportDetails.formats); @@ -11403,21 +11409,21 @@ static Uint8 VULKAN_INTERNAL_PrepareVulkan( NULL); SDL_DestroyWindow(dummyWindowHandle); - return 1; + return SDL_TRUE; } -static Uint8 VULKAN_PrepareDriver(SDL_VideoDevice *_this) +static SDL_bool VULKAN_PrepareDriver(SDL_VideoDevice *_this) { /* Set up dummy VulkanRenderer */ VulkanRenderer *renderer; Uint8 result; if (_this->Vulkan_CreateSurface == NULL) { - return 0; + return SDL_FALSE; } if (SDL_Vulkan_LoadLibrary(NULL) < 0) { - return 0; + return SDL_FALSE; } renderer = (VulkanRenderer *)SDL_malloc(sizeof(VulkanRenderer));