mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
testvulkan: Clamp the drawable size to the allowed range
SDL_Vulkan_GetDrawableSize() doesn't always return a size which is within the Vulkan swapchain's allowed image extent range. (This happens on X11 a lot when resizing, which is bug #3287) Clamp the value we get back from SDL_Vulkan_GetDrawableSize() to this range. Given the range usually is just a single value, this is almost always equivalent to just using the min or max image extent, but this seems logically most correct.
This commit is contained in:
parent
2e6dac870f
commit
773e1ba19f
@ -719,8 +719,17 @@ static SDL_bool createSwapchain(void)
|
||||
|
||||
// get size
|
||||
SDL_Vulkan_GetDrawableSize(state->windows[0], &w, &h);
|
||||
vulkanContext.swapchainSize.width = w;
|
||||
vulkanContext.swapchainSize.height = h;
|
||||
|
||||
// Clamp the size to the allowable image extent.
|
||||
// SDL_Vulkan_GetDrawableSize()'s result it not always in this range (bug #3287)
|
||||
vulkanContext.swapchainSize.width = SDL_max(vulkanContext.surfaceCapabilities.minImageExtent.width,
|
||||
SDL_min(w,
|
||||
vulkanContext.surfaceCapabilities.maxImageExtent.width));
|
||||
|
||||
vulkanContext.swapchainSize.height = SDL_max(vulkanContext.surfaceCapabilities.minImageExtent.height,
|
||||
SDL_min(h,
|
||||
vulkanContext.surfaceCapabilities.maxImageExtent.height));
|
||||
|
||||
if(w == 0 || h == 0)
|
||||
return SDL_FALSE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user