Skip to content

Commit

Permalink
Force fullscreen in case of KMS display
Browse files Browse the repository at this point in the history
Change GL2, GL3 and Vulkan drivers to behave as fullscreen if context driver
(such as KMS/DRM or KHR) does not support windowed mode at all.
Take it into account also for refresh rate switch.
  • Loading branch information
zoltanvb committed Jun 14, 2024
1 parent 5bc5a9f commit 37e812d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
20 changes: 17 additions & 3 deletions gfx/drivers/gl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4258,6 +4258,7 @@ static void *gl2_init(const video_info_t *video,
unsigned temp_width = 0;
unsigned temp_height = 0;
bool force_smooth = false;
bool force_fullscreen = false;
const char *vendor = NULL;
const char *renderer = NULL;
const char *version = NULL;
Expand All @@ -4281,6 +4282,13 @@ static void *gl2_init(const video_info_t *video,
gl->ctx_driver->get_video_size(gl->ctx_data,
&mode_width, &mode_height);

if (!video->fullscreen && !gl->ctx_driver->has_windowed)
{
RARCH_DBG("[GL]: Config requires windowed mode, but context driver does not support it. "
"Forcing fullscreen for this session.\n");
force_fullscreen = true;
}

#if defined(DINGUX)
mode_width = 320;
mode_height = 240;
Expand Down Expand Up @@ -4311,17 +4319,23 @@ static void *gl2_init(const video_info_t *video,
win_width = full_x;
win_height = full_y;
}
/* If fullscreen had to be forced, video->width/height is incorrect */
else if (force_fullscreen)
{
win_width = settings->uints.video_fullscreen_x;
win_height = settings->uints.video_fullscreen_y;
}

if ( !gl->ctx_driver->set_video_mode
|| !gl->ctx_driver->set_video_mode(gl->ctx_data,
win_width, win_height, video->fullscreen))
win_width, win_height, (video->fullscreen || force_fullscreen)))
goto error;
#if defined(__APPLE__) && !defined(IOS) && !defined(HAVE_COCOA_METAL)
/* This is a hack for now to work around a very annoying
* issue that currently eludes us. */
if ( !gl->ctx_driver->set_video_mode
|| !gl->ctx_driver->set_video_mode(gl->ctx_data,
win_width, win_height, video->fullscreen))
win_width, win_height, (video->fullscreen || force_fullscreen)))
goto error;
#endif

Expand Down Expand Up @@ -4446,7 +4460,7 @@ static void *gl2_init(const video_info_t *video,
gl2_begin_debug(gl);
#endif

if (video->fullscreen)
if (video->fullscreen || force_fullscreen)
gl->flags |= GL2_FLAG_FULLSCREEN;

mode_width = 0;
Expand Down
18 changes: 16 additions & 2 deletions gfx/drivers/gl3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,7 @@ static void *gl3_init(const video_info_t *video,
unsigned full_x, full_y;
settings_t *settings = config_get_ptr();
bool video_gpu_record = settings->bools.video_gpu_record;
bool force_fullscreen = false;
int interval = 0;
unsigned mode_width = 0;
unsigned mode_height = 0;
Expand Down Expand Up @@ -1799,6 +1800,13 @@ static void *gl3_init(const video_info_t *video,
gl->ctx_driver->get_video_size(gl->ctx_data,
&mode_width, &mode_height);

if (!video->fullscreen && !gl->ctx_driver->has_windowed)
{
RARCH_DBG("[GLCore]: Config requires windowed mode, but context driver does not support it. "
"Forcing fullscreen for this session.\n");
force_fullscreen = true;
}

full_x = mode_width;
full_y = mode_height;
mode_width = 0;
Expand Down Expand Up @@ -1827,10 +1835,16 @@ static void *gl3_init(const video_info_t *video,
win_width = full_x;
win_height = full_y;
}
/* If fullscreen had to be forced, video->width/height is incorrect */
else if (force_fullscreen)
{
win_width = settings->uints.video_fullscreen_x;
win_height = settings->uints.video_fullscreen_y;
}

if ( !gl->ctx_driver->set_video_mode
|| !gl->ctx_driver->set_video_mode(gl->ctx_data,
win_width, win_height, video->fullscreen))
win_width, win_height, (video->fullscreen || force_fullscreen)))
goto error;

if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
Expand Down Expand Up @@ -1889,7 +1903,7 @@ static void *gl3_init(const video_info_t *video,

if (video->vsync)
gl->flags |= GL3_FLAG_VSYNC;
if (video->fullscreen)
if (video->fullscreen || force_fullscreen)
gl->flags |= GL3_FLAG_FULLSCREEN;
if (video->force_aspect)
gl->flags |= GL3_FLAG_KEEP_ASPECT;
Expand Down
18 changes: 16 additions & 2 deletions gfx/drivers/vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,7 @@ static void *vulkan_init(const video_info_t *video,
int interval = 0;
unsigned temp_width = 0;
unsigned temp_height = 0;
bool force_fullscreen = false;
const gfx_ctx_driver_t *ctx_driver = NULL;
settings_t *settings = config_get_ptr();
#ifdef VULKAN_HDR_SWAPCHAIN
Expand Down Expand Up @@ -3351,6 +3352,13 @@ static void *vulkan_init(const video_info_t *video,
vk->ctx_driver->get_video_size(vk->ctx_data,
&mode_width, &mode_height);

if (!video->fullscreen && !vk->ctx_driver->has_windowed)
{
RARCH_DBG("[Vulkan]: Config requires windowed mode, but context driver does not support it. "
"Forcing fullscreen for this session.\n");
force_fullscreen = true;
}

full_x = mode_width;
full_y = mode_height;
mode_width = 0;
Expand All @@ -3376,10 +3384,16 @@ static void *vulkan_init(const video_info_t *video,
win_width = full_x;
win_height = full_y;
}
/* If fullscreen had to be forced, video->width/height is incorrect */
else if (force_fullscreen)
{
win_width = settings->uints.video_fullscreen_x;
win_height = settings->uints.video_fullscreen_y;
}

if ( !vk->ctx_driver->set_video_mode
|| !vk->ctx_driver->set_video_mode(vk->ctx_data,
win_width, win_height, video->fullscreen))
win_width, win_height, (video->fullscreen || force_fullscreen)))
{
RARCH_ERR("[Vulkan]: Failed to set video mode.\n");
goto error;
Expand Down Expand Up @@ -3412,7 +3426,7 @@ static void *vulkan_init(const video_info_t *video,
vk->flags |= VK_FLAG_VSYNC;
else
vk->flags &= ~VK_FLAG_VSYNC;
if (video->fullscreen)
if (video->fullscreen || force_fullscreen)
vk->flags |= VK_FLAG_FULLSCREEN;
else
vk->flags &= ~VK_FLAG_FULLSCREEN;
Expand Down
3 changes: 2 additions & 1 deletion gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,8 @@ void video_switch_refresh_rate_maybe(
unsigned video_bfi = settings->uints.video_black_frame_insertion;
unsigned shader_subframes = settings->uints.video_shader_subframes;
bool vrr_runloop_enable = settings->bools.vrr_runloop_enable;
bool exclusive_fullscreen = settings->bools.video_fullscreen && !settings->bools.video_windowed_fullscreen;
bool exclusive_fullscreen = (video_st->flags | VIDEO_FLAG_FORCE_FULLSCREEN) || (
settings->bools.video_fullscreen && !settings->bools.video_windowed_fullscreen);
bool windowed_fullscreen = settings->bools.video_fullscreen && settings->bools.video_windowed_fullscreen;
bool all_fullscreen = settings->bools.video_fullscreen || settings->bools.video_windowed_fullscreen;

Expand Down

0 comments on commit 37e812d

Please sign in to comment.