mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Refactor away some video driver functions
This commit is contained in:
parent
e70eb9ded2
commit
696dae6e70
@ -2599,7 +2599,8 @@ void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index)
|
||||
void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk,
|
||||
bool destroy_surface)
|
||||
{
|
||||
uint32_t video_st_flags = 0;
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
uint32_t video_st_flags = 0;
|
||||
if (!vk->context.instance)
|
||||
return;
|
||||
|
||||
@ -2620,7 +2621,7 @@ void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk,
|
||||
vkDestroyDebugUtilsMessengerEXT(vk->context.instance, vk->context.debug_callback, NULL);
|
||||
#endif
|
||||
|
||||
video_st_flags = video_driver_get_st_flags();
|
||||
video_st_flags = video_st->flags;
|
||||
|
||||
if (video_st_flags & VIDEO_FLAG_CACHE_CONTEXT)
|
||||
{
|
||||
|
@ -860,7 +860,8 @@ static void win32_save_position(void)
|
||||
|
||||
if (window_save_positions)
|
||||
{
|
||||
uint32_t video_st_flags = video_driver_get_st_flags();
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
uint32_t video_st_flags = video_st->flags;
|
||||
bool video_fullscreen = settings->bools.video_fullscreen;
|
||||
|
||||
if ( !video_fullscreen
|
||||
|
@ -563,6 +563,7 @@ static void d3d10_gfx_free(void* data)
|
||||
{
|
||||
int i;
|
||||
#if 0
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
uint32_t video_st_flags;
|
||||
#endif
|
||||
d3d10_video_t* d3d10 = (d3d10_video_t*)data;
|
||||
@ -611,7 +612,7 @@ static void d3d10_gfx_free(void* data)
|
||||
font_driver_free_osd();
|
||||
|
||||
#if 0
|
||||
video_st_flags = video_driver_get_st_flags();
|
||||
video_st_flags = video_st->flags;
|
||||
if (video_st_flags & VIDEO_FLAG_CACHE_CONTEXT)
|
||||
{
|
||||
cached_device_d3d10 = d3d10->device;
|
||||
|
@ -762,7 +762,8 @@ static void d3d11_gfx_free(void* data)
|
||||
{
|
||||
int i;
|
||||
uint32_t video_st_flags;
|
||||
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
|
||||
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
|
||||
if (!d3d11)
|
||||
return;
|
||||
@ -818,7 +819,7 @@ static void d3d11_gfx_free(void* data)
|
||||
Release(d3d11->scissor_disabled);
|
||||
Release(d3d11->swapChain);
|
||||
|
||||
video_st_flags = video_driver_get_st_flags();
|
||||
video_st_flags = video_st->flags;
|
||||
if (video_st_flags & VIDEO_FLAG_CACHE_CONTEXT)
|
||||
{
|
||||
cached_device_d3d11 = d3d11->device;
|
||||
|
@ -868,13 +868,11 @@ static void vulkan_init_textures(vk_t *vk)
|
||||
static void vulkan_deinit_textures(vk_t *vk)
|
||||
{
|
||||
int i;
|
||||
const void* cached_frame;
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
|
||||
/* Avoid memcpying from a destroyed/unmapped texture later on. */
|
||||
video_driver_cached_frame_get(&cached_frame, NULL, NULL, NULL);
|
||||
const void *cached_frame = video_st->frame_cache_data;
|
||||
if (vulkan_is_mapped_swapchain_texture_ptr(vk, cached_frame))
|
||||
video_st->frame_cache_data = NULL;
|
||||
video_st->frame_cache_data = NULL;
|
||||
|
||||
vkDestroySampler(vk->context->device, vk->samplers.nearest, NULL);
|
||||
vkDestroySampler(vk->context->device, vk->samplers.linear, NULL);
|
||||
|
@ -523,10 +523,11 @@ static void gfx_ctx_wgl_destroy(void *data)
|
||||
if (win32_hrc)
|
||||
{
|
||||
uint32_t video_st_flags;
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
gl_finish();
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
|
||||
video_st_flags = video_driver_get_st_flags();
|
||||
video_st_flags = video_st->flags;
|
||||
if (!(video_st_flags & VIDEO_FLAG_CACHE_CONTEXT))
|
||||
{
|
||||
if (win32_hw_hrc)
|
||||
|
@ -175,11 +175,13 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x)
|
||||
if (x->ctx)
|
||||
{
|
||||
uint32_t video_st_flags;
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
|
||||
glXSwapBuffers(g_x11_dpy, x->glx_win);
|
||||
gl_finish();
|
||||
glXMakeContextCurrent(g_x11_dpy, None, None, NULL);
|
||||
|
||||
video_st_flags = video_driver_get_st_flags();
|
||||
video_st_flags = video_st->flags;
|
||||
if (!(video_st_flags & VIDEO_FLAG_CACHE_CONTEXT))
|
||||
{
|
||||
if (x->hw_ctx)
|
||||
|
@ -59,6 +59,8 @@
|
||||
|
||||
#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time)))
|
||||
|
||||
#define FRAME_DELAY_AUTO_DEBUG 0
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct string_list *list;
|
||||
@ -1656,25 +1658,6 @@ bool video_driver_get_video_output_size(unsigned *width, unsigned *height, char
|
||||
return true;
|
||||
}
|
||||
|
||||
void video_driver_set_texture_enable(bool enable, bool fullscreen)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (video_st->poke && video_st->poke->set_texture_enable)
|
||||
video_st->poke->set_texture_enable(video_st->data,
|
||||
enable, fullscreen);
|
||||
}
|
||||
|
||||
void video_driver_set_texture_frame(const void *frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if ( video_st->poke
|
||||
&& video_st->poke->set_texture_frame)
|
||||
video_st->poke->set_texture_frame(video_st->data,
|
||||
frame, rgb32, width, height, alpha);
|
||||
}
|
||||
|
||||
|
||||
void *video_driver_read_frame_raw(unsigned *width,
|
||||
unsigned *height, size_t *pitch)
|
||||
{
|
||||
@ -1698,20 +1681,6 @@ void video_driver_set_filtering(unsigned index,
|
||||
index, smooth, ctx_scaling);
|
||||
}
|
||||
|
||||
void video_driver_cached_frame_get(const void **data, unsigned *width,
|
||||
unsigned *height, size_t *pitch)
|
||||
{
|
||||
video_driver_state_t *video_st= &video_driver_st;
|
||||
if (data)
|
||||
*data = video_st->frame_cache_data;
|
||||
if (width)
|
||||
*width = video_st->frame_cache_width;
|
||||
if (height)
|
||||
*height = video_st->frame_cache_height;
|
||||
if (pitch)
|
||||
*pitch = video_st->frame_cache_pitch;
|
||||
}
|
||||
|
||||
void video_driver_get_size(unsigned *width, unsigned *height)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
@ -3278,7 +3247,10 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
|
||||
}
|
||||
|
||||
#if defined(PSP)
|
||||
video_driver_set_texture_frame(&dummy_pixels, false, 1, 1, 1.0f);
|
||||
if ( video_st->poke
|
||||
&& video_st->poke->set_texture_frame)
|
||||
video_st->poke->set_texture_frame(video_st->data,
|
||||
&dummy_pixels, false, 1, 1, 1.0f);
|
||||
#endif
|
||||
|
||||
video_context_driver_reset();
|
||||
@ -3968,13 +3940,6 @@ void video_driver_reinit(int flags)
|
||||
video_st->flags &= ~VIDEO_FLAG_CACHE_CONTEXT;
|
||||
}
|
||||
|
||||
uint32_t video_driver_get_st_flags(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
return video_st->flags;
|
||||
}
|
||||
|
||||
#define FRAME_DELAY_AUTO_DEBUG 0
|
||||
void video_frame_delay_auto(video_driver_state_t *video_st, video_frame_delay_auto_t *vfda)
|
||||
{
|
||||
int i;
|
||||
|
@ -967,11 +967,6 @@ bool video_driver_set_video_mode(unsigned width,
|
||||
bool video_driver_get_video_output_size(
|
||||
unsigned *width, unsigned *height, char *desc, size_t desc_len);
|
||||
|
||||
void video_driver_set_texture_enable(bool enable, bool full_screen);
|
||||
|
||||
void video_driver_set_texture_frame(const void *frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha);
|
||||
|
||||
void * video_driver_read_frame_raw(unsigned *width,
|
||||
unsigned *height, size_t *pitch);
|
||||
|
||||
@ -988,12 +983,6 @@ void video_driver_set_size(unsigned width, unsigned height);
|
||||
|
||||
float video_driver_get_aspect_ratio(void);
|
||||
|
||||
void video_driver_cached_frame_set(const void *data, unsigned width,
|
||||
unsigned height, size_t pitch);
|
||||
|
||||
void video_driver_cached_frame_get(const void **data, unsigned *width,
|
||||
unsigned *height, size_t *pitch);
|
||||
|
||||
void video_driver_menu_settings(void **list_data, void *list_info_data,
|
||||
void *group_data, void *subgroup_data, const char *parent_group);
|
||||
|
||||
@ -1282,8 +1271,6 @@ void video_driver_set_viewport_config(
|
||||
|
||||
void video_driver_set_viewport_square_pixel(struct retro_game_geometry *geom);
|
||||
|
||||
uint32_t video_driver_get_st_flags(void);
|
||||
|
||||
bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled);
|
||||
|
||||
/**
|
||||
|
@ -6570,9 +6570,20 @@ static void rgui_free(void *data)
|
||||
rgui_thumbnail_free(&rgui->mini_left_thumbnail);
|
||||
}
|
||||
|
||||
static void rgui_set_texture_frame(video_driver_state_t *video_st,
|
||||
const void *frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
if ( video_st->poke
|
||||
&& video_st->poke->set_texture_frame)
|
||||
video_st->poke->set_texture_frame(video_st->data,
|
||||
frame, rgb32, width, height, alpha);
|
||||
}
|
||||
|
||||
static void rgui_set_texture(void *data)
|
||||
{
|
||||
unsigned fb_width, fb_height;
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
gfx_display_t *p_disp = disp_get_ptr();
|
||||
#if defined(DINGUX)
|
||||
@ -6592,7 +6603,7 @@ static void rgui_set_texture(void *data)
|
||||
p_disp->flags &= ~GFX_DISP_FLAG_FB_DIRTY;
|
||||
|
||||
if (internal_upscale_level == RGUI_UPSCALE_NONE)
|
||||
video_driver_set_texture_frame(rgui->frame_buf.data,
|
||||
rgui_set_texture_frame(video_st, rgui->frame_buf.data,
|
||||
false, fb_width, fb_height, 1.0f);
|
||||
else
|
||||
{
|
||||
@ -6604,7 +6615,7 @@ static void rgui_set_texture(void *data)
|
||||
/* If viewport is currently the same size (or smaller)
|
||||
* than the menu framebuffer, no scaling is required */
|
||||
if ((vp.width <= fb_width) && (vp.height <= fb_height))
|
||||
video_driver_set_texture_frame(rgui->frame_buf.data,
|
||||
rgui_set_texture_frame(video_st, rgui->frame_buf.data,
|
||||
false, fb_width, fb_height, 1.0f);
|
||||
else
|
||||
{
|
||||
@ -6651,7 +6662,7 @@ static void rgui_set_texture(void *data)
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.menu_rgui_internal_upscale_level,
|
||||
RGUI_UPSCALE_NONE);
|
||||
video_driver_set_texture_frame(frame_buf->data,
|
||||
rgui_set_texture_frame(video_st, frame_buf->data,
|
||||
false, fb_width, fb_height, 1.0f);
|
||||
return;
|
||||
}
|
||||
@ -6674,7 +6685,7 @@ static void rgui_set_texture(void *data)
|
||||
}
|
||||
|
||||
/* Draw upscaled texture */
|
||||
video_driver_set_texture_frame(upscale_buf->data,
|
||||
rgui_set_texture_frame(video_st, upscale_buf->data,
|
||||
false, out_width, out_height, 1.0f);
|
||||
}
|
||||
}
|
||||
|
@ -6380,7 +6380,9 @@ void retroarch_menu_running_finished(bool quit)
|
||||
menu_st->driver_ctx->environ_cb(MENU_ENVIRON_DISABLE_SCREENSAVER,
|
||||
NULL, menu_st->userdata);
|
||||
}
|
||||
video_driver_set_texture_enable(false, false);
|
||||
if (video_st->poke && video_st->poke->set_texture_enable)
|
||||
video_st->poke->set_texture_enable(video_st->data,
|
||||
false, false);
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (!quit)
|
||||
if (settings && settings->bools.input_overlay_hide_in_menu)
|
||||
|
@ -456,15 +456,17 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool take_screenshot_raw(const char *screenshot_dir,
|
||||
static bool take_screenshot_raw(
|
||||
video_driver_state_t *video_st,
|
||||
const char *screenshot_dir,
|
||||
const char *name_base, void *userbuf,
|
||||
bool savestate, uint32_t runloop_flags, bool fullpath, bool use_thread,
|
||||
unsigned pixel_format_type)
|
||||
{
|
||||
size_t pitch;
|
||||
unsigned width, height;
|
||||
const void *data = NULL;
|
||||
video_driver_cached_frame_get(&data, &width, &height, &pitch);
|
||||
const void *data = video_st->frame_cache_data;
|
||||
unsigned width = video_st->frame_cache_width;
|
||||
unsigned height = video_st->frame_cache_height;
|
||||
size_t pitch = video_st->frame_cache_pitch;
|
||||
/* Negative pitch is needed as screenshot takes bottom-up,
|
||||
* but we use top-down.
|
||||
*/
|
||||
@ -500,7 +502,9 @@ static bool take_screenshot_choice(
|
||||
if (supports_viewport_read)
|
||||
{
|
||||
/* Avoid taking screenshot of GUI overlays. */
|
||||
video_driver_set_texture_enable(false, false);
|
||||
if (video_st->poke && video_st->poke->set_texture_enable)
|
||||
video_st->poke->set_texture_enable(video_st->data,
|
||||
false, false);
|
||||
if (!(runloop_flags & RUNLOOP_FLAG_IDLE))
|
||||
video_driver_cached_frame();
|
||||
return take_screenshot_viewport(screenshot_dir,
|
||||
@ -509,20 +513,17 @@ static bool take_screenshot_choice(
|
||||
}
|
||||
|
||||
if (!has_valid_framebuffer)
|
||||
return take_screenshot_raw(screenshot_dir,
|
||||
return take_screenshot_raw(video_st, screenshot_dir,
|
||||
name_base, NULL, savestate, runloop_flags, fullpath, use_thread,
|
||||
pixel_format_type);
|
||||
|
||||
if (supports_read_frame_raw)
|
||||
{
|
||||
size_t old_pitch;
|
||||
unsigned old_width, old_height;
|
||||
void *frame_data = NULL;
|
||||
const void* old_data = NULL;
|
||||
video_driver_cached_frame_get(&old_data, &old_width, &old_height,
|
||||
&old_pitch);
|
||||
|
||||
frame_data = video_driver_read_frame_raw(
|
||||
const void *old_data = video_st->frame_cache_data;
|
||||
unsigned old_width = video_st->frame_cache_width;
|
||||
unsigned old_height = video_st->frame_cache_height;
|
||||
size_t old_pitch = video_st->frame_cache_pitch;
|
||||
void *frame_data = video_driver_read_frame_raw(
|
||||
&old_width, &old_height, &old_pitch);
|
||||
|
||||
video_st->frame_cache_data = old_data;
|
||||
@ -533,7 +534,7 @@ static bool take_screenshot_choice(
|
||||
if (frame_data)
|
||||
{
|
||||
video_st->frame_cache_data = frame_data;
|
||||
return take_screenshot_raw(screenshot_dir,
|
||||
return take_screenshot_raw(video_st, screenshot_dir,
|
||||
name_base, frame_data, savestate, runloop_flags, fullpath, use_thread,
|
||||
pixel_format_type);
|
||||
}
|
||||
|
@ -295,7 +295,10 @@ static void handle_translation_cb(
|
||||
if (raw_image_file_data)
|
||||
{
|
||||
/* Get the video frame dimensions reference */
|
||||
video_driver_cached_frame_get(&dummy_data, &width, &height, &pitch);
|
||||
dummy_data = video_st->frame_cache_data;
|
||||
width = video_st->frame_cache_width;
|
||||
height = video_st->frame_cache_height;
|
||||
pitch = video_st->frame_cache_pitch;
|
||||
|
||||
/* try two different modes for text display *
|
||||
* In the first mode, we use display widget overlays, but they require
|
||||
@ -850,7 +853,10 @@ bool run_translation_service(settings_t *settings, bool paused)
|
||||
if (!scaler)
|
||||
goto finish;
|
||||
|
||||
video_driver_cached_frame_get(&data, &width, &height, &pitch);
|
||||
data = video_st->frame_cache_data;
|
||||
width = video_st->frame_cache_width;
|
||||
height = video_st->frame_cache_height;
|
||||
pitch = video_st->frame_cache_pitch;
|
||||
|
||||
if (!data)
|
||||
goto finish;
|
||||
|
Loading…
x
Reference in New Issue
Block a user