mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
[KMSDRM] Minor Vulkan code adjustments regarding pointers and display index.
This commit is contained in:
parent
570768f627
commit
733b3278de
@ -198,7 +198,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
|||||||
VkDisplaySurfaceCreateInfoKHR display_plane_surface_create_info;
|
VkDisplaySurfaceCreateInfoKHR display_plane_surface_create_info;
|
||||||
|
|
||||||
VkExtent2D image_size;
|
VkExtent2D image_size;
|
||||||
VkDisplayModeKHR *display_mode = NULL;
|
VkDisplayModeKHR display_mode = NULL;
|
||||||
VkDisplayModePropertiesKHR display_mode_props = {0};
|
VkDisplayModePropertiesKHR display_mode_props = {0};
|
||||||
VkDisplayModeParametersKHR new_mode_parameters = { {0, 0}, 0};
|
VkDisplayModeParametersKHR new_mode_parameters = { {0, 0}, 0};
|
||||||
|
|
||||||
@ -207,13 +207,9 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
|||||||
SDL_bool valid_gpu = SDL_FALSE;
|
SDL_bool valid_gpu = SDL_FALSE;
|
||||||
SDL_bool mode_found = SDL_FALSE;
|
SDL_bool mode_found = SDL_FALSE;
|
||||||
|
|
||||||
/* We don't receive a display index in KMSDRM_CreateDevice(), only
|
/* Get the display index from the display being used by the window. */
|
||||||
a device index, which determines the GPU to use, but not the output.
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
So we simply use the first connected output (ie, the first connected
|
int display_index = SDL_atoi(display->name);
|
||||||
video output) for now.
|
|
||||||
In other words, change this index to select a different output. Easy! */
|
|
||||||
int display_index = 0;
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Get the function pointers for the functions we will use. */
|
/* Get the function pointers for the functions we will use. */
|
||||||
@ -387,18 +383,22 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
|||||||
display_mode_props.parameters.visibleRegion.width > 0 &&
|
display_mode_props.parameters.visibleRegion.width > 0 &&
|
||||||
display_mode_props.parameters.visibleRegion.height > 0 ) {
|
display_mode_props.parameters.visibleRegion.height > 0 ) {
|
||||||
/* Found a suitable mode among the predefined ones. Use that. */
|
/* Found a suitable mode among the predefined ones. Use that. */
|
||||||
display_mode = &(display_mode_props.displayMode);
|
display_mode = display_mode_props.displayMode;
|
||||||
} else {
|
} else {
|
||||||
/* Can't find a suitable mode among the predefined ones, so try to create our own. */
|
|
||||||
|
/* Couldn't find a suitable mode among the predefined ones, so try to create our own.
|
||||||
|
This won't work for some video chips atm (like Pi's VideoCore) so these are limited
|
||||||
|
to supported resolutions. Don't try to use "closest" resolutions either, because
|
||||||
|
those are often bigger than the window size, thus causing out-of-bunds scanout. */
|
||||||
new_mode_parameters.visibleRegion.width = window->w;
|
new_mode_parameters.visibleRegion.width = window->w;
|
||||||
new_mode_parameters.visibleRegion.height = window->h;
|
new_mode_parameters.visibleRegion.height = window->h;
|
||||||
new_mode_parameters.refreshRate = 60000; /* Always use 60Hz for now. */
|
new_mode_parameters.refreshRate = window->fullscreen_mode.refresh_rate;
|
||||||
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
|
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
|
||||||
display_mode_create_info.parameters = new_mode_parameters;
|
display_mode_create_info.parameters = new_mode_parameters;
|
||||||
result = vkCreateDisplayModeKHR(gpu,
|
result = vkCreateDisplayModeKHR(gpu,
|
||||||
displays_props[display_index].display,
|
displays_props[display_index].display,
|
||||||
&display_mode_create_info,
|
&display_mode_create_info,
|
||||||
NULL, display_mode);
|
NULL, &display_mode);
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode.");
|
SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode.");
|
||||||
goto clean;
|
goto clean;
|
||||||
@ -419,7 +419,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
|||||||
image_size.height = window->h;
|
image_size.height = window->h;
|
||||||
|
|
||||||
display_plane_surface_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
|
display_plane_surface_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
|
||||||
display_plane_surface_create_info.displayMode = *display_mode;
|
display_plane_surface_create_info.displayMode = display_mode;
|
||||||
/* For now, simply use the first plane. */
|
/* For now, simply use the first plane. */
|
||||||
display_plane_surface_create_info.planeIndex = 0;
|
display_plane_surface_create_info.planeIndex = 0;
|
||||||
display_plane_surface_create_info.imageExtent = image_size;
|
display_plane_surface_create_info.imageExtent = image_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user