mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Move video state to gfx/video_driver.c - reduces filesize of retroarch.c to 809kb (#13104)
* Move video state to gfx/video_driver.c - reduces filesize of retroarch.c to 809Kb
This commit is contained in:
parent
0b2c80a402
commit
0a888f7868
@ -633,9 +633,11 @@ static void win32_save_position(void)
|
||||
}
|
||||
if (window_save_positions)
|
||||
{
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
|
||||
if ( !video_fullscreen &&
|
||||
!retroarch_is_forced_fullscreen() &&
|
||||
!retroarch_is_switching_display_mode())
|
||||
!video_st->force_fullscreen &&
|
||||
!video_st->is_switching_display_mode)
|
||||
{
|
||||
settings->uints.window_position_x = g_win32->pos_x;
|
||||
settings->uints.window_position_y = g_win32->pos_y;
|
||||
|
@ -16,15 +16,23 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <retro_math.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "video_driver.h"
|
||||
#include "video_filter.h"
|
||||
#include "video_display_server.h"
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#include "video_thread_wrapper.h"
|
||||
#endif
|
||||
|
||||
#include "../frontend/frontend_driver.h"
|
||||
#include "../ui/ui_companion_driver.h"
|
||||
#include "../file_path_special.h"
|
||||
#include "../list_special.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../verbosity.h"
|
||||
@ -42,6 +50,21 @@ static gfx_api_gpu_map gpu_map[] = {
|
||||
{ NULL, GFX_CTX_DIRECT3D12_API }
|
||||
};
|
||||
|
||||
static const video_display_server_t dispserv_null = {
|
||||
NULL, /* init */
|
||||
NULL, /* destroy */
|
||||
NULL, /* set_window_opacity */
|
||||
NULL, /* set_window_progress */
|
||||
NULL, /* set_window_decorations */
|
||||
NULL, /* set_resolution */
|
||||
NULL, /* get_resolution_list */
|
||||
NULL, /* get_output_options */
|
||||
NULL, /* set_screen_orientation */
|
||||
NULL, /* get_screen_orientation */
|
||||
NULL, /* get_flags */
|
||||
"null"
|
||||
};
|
||||
|
||||
static void *video_null_init(const video_info_t *video,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
@ -217,6 +240,50 @@ const video_driver_t *video_drivers[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static video_driver_state_t video_driver_st = { 0 };
|
||||
static const video_display_server_t *current_display_server =
|
||||
&dispserv_null;
|
||||
|
||||
struct retro_hw_render_callback *video_driver_get_hw_context(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
return VIDEO_DRIVER_GET_HW_CONTEXT_INTERNAL(video_st);
|
||||
}
|
||||
|
||||
video_driver_state_t *video_state_get_ptr(void)
|
||||
{
|
||||
return &video_driver_st;
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
void *video_thread_get_ptr(video_driver_state_t *video_st)
|
||||
{
|
||||
const thread_video_t *thr = (const thread_video_t*)video_st->data;
|
||||
if (thr)
|
||||
return thr->driver_data;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* video_driver_get_ptr:
|
||||
*
|
||||
* Use this if you need the real video driver
|
||||
* and driver data pointers.
|
||||
*
|
||||
* Returns: video driver's userdata.
|
||||
**/
|
||||
void *video_driver_get_ptr(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
return VIDEO_DRIVER_GET_PTR_INTERNAL(video_st);
|
||||
}
|
||||
|
||||
void *video_driver_get_data(void)
|
||||
{
|
||||
return video_driver_st.data;
|
||||
}
|
||||
|
||||
video_driver_t *hw_render_context_driver(
|
||||
enum retro_hw_context_type type, int major, int minor)
|
||||
{
|
||||
@ -496,6 +563,9 @@ void video_driver_force_fallback(const char *driver)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static bool get_metrics_null(void *data, enum display_metric_types type,
|
||||
float *value) { return false; }
|
||||
|
||||
static bool video_context_driver_get_metrics_null(
|
||||
void *data, enum display_metric_types type,
|
||||
float *value) { return false; }
|
||||
@ -692,3 +762,576 @@ void video_driver_reset_custom_viewport(settings_t *settings)
|
||||
custom_vp->x = 0;
|
||||
custom_vp->y = 0;
|
||||
}
|
||||
|
||||
struct retro_system_av_info *video_viewport_get_system_av_info(void)
|
||||
{
|
||||
return &video_driver_st.av_info;
|
||||
}
|
||||
|
||||
void video_driver_gpu_record_deinit(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (video_st->record_gpu_buffer)
|
||||
free(video_st->record_gpu_buffer);
|
||||
video_st->record_gpu_buffer = NULL;
|
||||
}
|
||||
|
||||
void recording_dump_frame(
|
||||
const void *data, unsigned width,
|
||||
unsigned height, size_t pitch, bool is_idle)
|
||||
{
|
||||
struct record_video_data ffemu_data;
|
||||
video_driver_state_t
|
||||
*video_st = &video_driver_st;
|
||||
recording_state_t
|
||||
*record_st = recording_state_get_ptr();
|
||||
|
||||
ffemu_data.data = data;
|
||||
ffemu_data.width = width;
|
||||
ffemu_data.height = height;
|
||||
ffemu_data.pitch = (int)pitch;
|
||||
ffemu_data.is_dupe = false;
|
||||
|
||||
if (video_st->record_gpu_buffer)
|
||||
{
|
||||
struct video_viewport vp;
|
||||
|
||||
vp.x = 0;
|
||||
vp.y = 0;
|
||||
vp.width = 0;
|
||||
vp.height = 0;
|
||||
vp.full_width = 0;
|
||||
vp.full_height = 0;
|
||||
|
||||
video_driver_get_viewport_info(&vp);
|
||||
|
||||
if (!vp.width || !vp.height)
|
||||
{
|
||||
RARCH_WARN("[recording] %s \n",
|
||||
msg_hash_to_str(MSG_VIEWPORT_SIZE_CALCULATION_FAILED));
|
||||
video_driver_gpu_record_deinit();
|
||||
recording_dump_frame(
|
||||
data, width, height, pitch, is_idle);
|
||||
return;
|
||||
}
|
||||
|
||||
/* User has resized. We kinda have a problem now. */
|
||||
if ( vp.width != record_st->gpu_width ||
|
||||
vp.height != record_st->gpu_height)
|
||||
{
|
||||
RARCH_WARN("[recording] %s\n",
|
||||
msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE));
|
||||
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE),
|
||||
1, 180, true,
|
||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Big bottleneck.
|
||||
* Since we might need to do read-backs asynchronously,
|
||||
* it might take 3-4 times before this returns true. */
|
||||
if (!video_driver_read_viewport(video_st->record_gpu_buffer, is_idle))
|
||||
return;
|
||||
|
||||
ffemu_data.pitch = (int)(record_st->gpu_width * 3);
|
||||
ffemu_data.width = (unsigned)record_st->gpu_width;
|
||||
ffemu_data.height = (unsigned)record_st->gpu_height;
|
||||
ffemu_data.data = video_st->record_gpu_buffer + (ffemu_data.height - 1) * ffemu_data.pitch;
|
||||
|
||||
ffemu_data.pitch = -ffemu_data.pitch;
|
||||
}
|
||||
else
|
||||
ffemu_data.is_dupe = !data;
|
||||
|
||||
record_st->driver->push_video(record_st->data, &ffemu_data);
|
||||
}
|
||||
|
||||
const char *video_display_server_get_ident(void)
|
||||
{
|
||||
if (!current_display_server)
|
||||
return FILE_PATH_UNKNOWN;
|
||||
return current_display_server->ident;
|
||||
}
|
||||
|
||||
void* video_display_server_init(enum rarch_display_type type)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
video_display_server_destroy();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RARCH_DISPLAY_WIN32:
|
||||
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
|
||||
current_display_server = &dispserv_win32;
|
||||
#endif
|
||||
break;
|
||||
case RARCH_DISPLAY_X11:
|
||||
#if defined(HAVE_X11)
|
||||
current_display_server = &dispserv_x11;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
#if defined(ANDROID)
|
||||
current_display_server = &dispserv_android;
|
||||
#else
|
||||
current_display_server = &dispserv_null;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (current_display_server)
|
||||
{
|
||||
if (current_display_server->init)
|
||||
video_st->current_display_server_data = current_display_server->init();
|
||||
|
||||
if (!string_is_empty(current_display_server->ident))
|
||||
{
|
||||
RARCH_LOG("[Video]: Found display server: %s\n",
|
||||
current_display_server->ident);
|
||||
}
|
||||
}
|
||||
|
||||
video_st->initial_screen_orientation =
|
||||
video_display_server_get_screen_orientation();
|
||||
video_st->current_screen_orientation =
|
||||
video_st->initial_screen_orientation;
|
||||
|
||||
return video_st->current_display_server_data;
|
||||
}
|
||||
|
||||
void video_display_server_destroy(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
const enum rotation initial_screen_orientation = video_st->initial_screen_orientation;
|
||||
const enum rotation current_screen_orientation = video_st->current_screen_orientation;
|
||||
|
||||
if (initial_screen_orientation != current_screen_orientation)
|
||||
video_display_server_set_screen_orientation(initial_screen_orientation);
|
||||
|
||||
if (current_display_server)
|
||||
if (video_st->current_display_server_data)
|
||||
current_display_server->destroy(video_st->current_display_server_data);
|
||||
}
|
||||
|
||||
bool video_display_server_set_window_opacity(unsigned opacity)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->set_window_opacity)
|
||||
return current_display_server->set_window_opacity(
|
||||
video_st->current_display_server_data, opacity);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool video_display_server_set_window_progress(int progress, bool finished)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->set_window_progress)
|
||||
return current_display_server->set_window_progress(
|
||||
video_st->current_display_server_data, progress, finished);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool video_display_server_set_window_decorations(bool on)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->set_window_decorations)
|
||||
return current_display_server->set_window_decorations(
|
||||
video_st->current_display_server_data, on);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool video_display_server_set_resolution(unsigned width, unsigned height,
|
||||
int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->set_resolution)
|
||||
return current_display_server->set_resolution(
|
||||
video_st->current_display_server_data, width, height, int_hz,
|
||||
hz, center, monitor_index, xoffset, padjust);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool video_display_server_has_resolution_list(void)
|
||||
{
|
||||
return (current_display_server
|
||||
&& current_display_server->get_resolution_list);
|
||||
}
|
||||
|
||||
void *video_display_server_get_resolution_list(unsigned *size)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (video_display_server_has_resolution_list())
|
||||
return current_display_server->get_resolution_list(
|
||||
video_st->current_display_server_data, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool video_display_server_has_refresh_rate(float hz)
|
||||
{
|
||||
unsigned i, size = 0;
|
||||
bool rate_exists = false;
|
||||
|
||||
struct video_display_config *video_list = (struct video_display_config*)
|
||||
video_display_server_get_resolution_list(&size);
|
||||
|
||||
if (video_list)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
unsigned video_driver_width = video_st->width;
|
||||
unsigned video_driver_height = video_st->height;
|
||||
|
||||
for (i = 0; i < size && !rate_exists; i++)
|
||||
{
|
||||
if (video_list[i].width == video_driver_width &&
|
||||
video_list[i].height == video_driver_height &&
|
||||
video_list[i].refreshrate == floor(hz))
|
||||
rate_exists = true;
|
||||
}
|
||||
|
||||
free(video_list);
|
||||
}
|
||||
|
||||
return rate_exists;
|
||||
}
|
||||
|
||||
bool video_display_server_set_refresh_rate(float hz)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->set_resolution)
|
||||
return current_display_server->set_resolution(
|
||||
video_st->current_display_server_data, 0, 0, (int)hz,
|
||||
hz, 0, 0, 0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
void video_display_server_restore_refresh_rate(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
settings_t *settings = config_get_ptr();
|
||||
float refresh_rate_original = video_st->video_refresh_rate_original;
|
||||
float refresh_rate_current = settings->floats.video_refresh_rate;
|
||||
|
||||
if (!refresh_rate_original || refresh_rate_current == refresh_rate_original)
|
||||
return;
|
||||
|
||||
video_monitor_set_refresh_rate(refresh_rate_original);
|
||||
video_display_server_set_refresh_rate(refresh_rate_original);
|
||||
}
|
||||
|
||||
const char *video_display_server_get_output_options(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->get_output_options)
|
||||
return current_display_server->get_output_options(
|
||||
video_st->current_display_server_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void video_display_server_set_screen_orientation(enum rotation rotation)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->set_screen_orientation)
|
||||
{
|
||||
RARCH_LOG("[Video]: Setting screen orientation to %d.\n", rotation);
|
||||
video_st->current_screen_orientation = rotation;
|
||||
current_display_server->set_screen_orientation(video_st->current_display_server_data, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
bool video_display_server_can_set_screen_orientation(void)
|
||||
{
|
||||
return (current_display_server && current_display_server->set_screen_orientation);
|
||||
}
|
||||
|
||||
enum rotation video_display_server_get_screen_orientation(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (current_display_server && current_display_server->get_screen_orientation)
|
||||
return current_display_server->get_screen_orientation(
|
||||
video_st->current_display_server_data);
|
||||
return ORIENTATION_NORMAL;
|
||||
}
|
||||
|
||||
bool video_display_server_get_flags(gfx_ctx_flags_t *flags)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (!flags || !current_display_server || !current_display_server->get_flags)
|
||||
return false;
|
||||
flags->flags = current_display_server->get_flags(
|
||||
video_st->current_display_server_data);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool video_driver_started_fullscreen(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
return video_st->started_fullscreen;
|
||||
}
|
||||
|
||||
bool video_driver_is_threaded(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
return VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st);
|
||||
}
|
||||
|
||||
bool *video_driver_get_threaded(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
#if defined(__MACH__) && defined(__APPLE__)
|
||||
/* TODO/FIXME - force threaded video to disabled on Apple for now
|
||||
* until NSWindow/UIWindow concurrency issues are taken care of */
|
||||
video_st->threaded = false;
|
||||
#endif
|
||||
return &video_st->threaded;
|
||||
}
|
||||
|
||||
void video_driver_set_threaded(bool val)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
#if defined(__MACH__) && defined(__APPLE__)
|
||||
/* TODO/FIXME - force threaded video to disabled on Apple for now
|
||||
* until NSWindow/UIWindow concurrency issues are taken care of */
|
||||
video_st->threaded = false;
|
||||
#else
|
||||
video_st->threaded = val;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *video_driver_get_ident(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (!video_st->current_video)
|
||||
return NULL;
|
||||
#ifdef HAVE_THREADS
|
||||
if (VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st))
|
||||
{
|
||||
const thread_video_t *thr = (const thread_video_t*)video_st->data;
|
||||
if (!thr || !thr->driver)
|
||||
return NULL;
|
||||
return thr->driver->ident;
|
||||
}
|
||||
#endif
|
||||
|
||||
return video_st->current_video->ident;
|
||||
}
|
||||
|
||||
void video_context_driver_reset(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (!video_st->current_video_context.get_metrics)
|
||||
video_st->current_video_context.get_metrics = get_metrics_null;
|
||||
}
|
||||
|
||||
bool video_context_driver_set(const gfx_ctx_driver_t *data)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (!data)
|
||||
return false;
|
||||
video_st->current_video_context = *data;
|
||||
video_context_driver_reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
uintptr_t video_driver_get_current_framebuffer(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if ( video_st->poke
|
||||
&& video_st->poke->get_current_framebuffer)
|
||||
return video_st->poke->get_current_framebuffer(video_st->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
retro_proc_address_t video_driver_get_proc_address(const char *sym)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if ( video_st->poke
|
||||
&& video_st->poke->get_proc_address)
|
||||
return video_st->poke->get_proc_address(video_st->data, sym);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
void video_driver_filter_free(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
if (video_st->state_filter)
|
||||
rarch_softfilter_free(video_st->state_filter);
|
||||
video_st->state_filter = NULL;
|
||||
|
||||
if (video_st->state_buffer)
|
||||
{
|
||||
#ifdef _3DS
|
||||
linearFree(video_st->state_buffer);
|
||||
#else
|
||||
free(video_st->state_buffer);
|
||||
#endif
|
||||
}
|
||||
video_st->state_buffer = NULL;
|
||||
|
||||
video_st->state_scale = 0;
|
||||
video_st->state_out_bpp = 0;
|
||||
video_st->state_out_rgb32 = false;
|
||||
}
|
||||
|
||||
void video_driver_init_filter(enum retro_pixel_format colfmt_int,
|
||||
settings_t *settings)
|
||||
{
|
||||
unsigned pow2_x, pow2_y, maxsize;
|
||||
void *buf = NULL;
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
struct retro_game_geometry *geom = &video_st->av_info.geometry;
|
||||
unsigned width = geom->max_width;
|
||||
unsigned height = geom->max_height;
|
||||
/* Deprecated format. Gets pre-converted. */
|
||||
enum retro_pixel_format colfmt =
|
||||
(colfmt_int == RETRO_PIXEL_FORMAT_0RGB1555) ?
|
||||
RETRO_PIXEL_FORMAT_RGB565 : colfmt_int;
|
||||
|
||||
if (video_driver_is_hw_context())
|
||||
{
|
||||
RARCH_WARN("[Video]: Cannot use CPU filters when hardware rendering is used.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
video_st->state_filter = rarch_softfilter_new(
|
||||
settings->paths.path_softfilter_plugin,
|
||||
RARCH_SOFTFILTER_THREADS_AUTO, colfmt, width, height);
|
||||
|
||||
if (!video_st->state_filter)
|
||||
{
|
||||
RARCH_ERR("[Video]: Failed to load filter.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rarch_softfilter_get_max_output_size(
|
||||
video_st->state_filter,
|
||||
&width, &height);
|
||||
|
||||
pow2_x = next_pow2(width);
|
||||
pow2_y = next_pow2(height);
|
||||
maxsize = MAX(pow2_x, pow2_y);
|
||||
|
||||
#ifdef _3DS
|
||||
/* On 3DS, video is disabled if the output resolution
|
||||
* exceeds 2048x2048. To avoid the user being presented
|
||||
* with a black screen, we therefore have to check that
|
||||
* the filter upscaling buffer fits within this limit. */
|
||||
if (maxsize >= 2048)
|
||||
{
|
||||
RARCH_ERR("[Video]: Softfilter initialization failed."
|
||||
" Upscaling buffer exceeds hardware limitations.\n");
|
||||
video_driver_filter_free();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
video_st->state_scale = maxsize / RARCH_SCALE_BASE;
|
||||
video_st->state_out_rgb32 = rarch_softfilter_get_output_format(
|
||||
video_st->state_filter) == RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
|
||||
video_st->state_out_bpp =
|
||||
video_st->state_out_rgb32
|
||||
? sizeof(uint32_t)
|
||||
: sizeof(uint16_t);
|
||||
|
||||
/* TODO: Aligned output. */
|
||||
#ifdef _3DS
|
||||
buf = linearMemAlign(
|
||||
width * height * video_st->state_out_bpp, 0x80);
|
||||
#else
|
||||
buf = malloc(
|
||||
width * height * video_st->state_out_bpp);
|
||||
#endif
|
||||
if (!buf)
|
||||
{
|
||||
RARCH_ERR("[Video]: Softfilter initialization failed.\n");
|
||||
video_driver_filter_free();
|
||||
return;
|
||||
}
|
||||
|
||||
video_st->state_buffer = buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
void video_driver_free_hw_context(void)
|
||||
{
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
VIDEO_DRIVER_CONTEXT_LOCK(video_st);
|
||||
|
||||
if (video_st->hw_render.context_destroy)
|
||||
video_st->hw_render.context_destroy();
|
||||
|
||||
memset(&video_st->hw_render, 0, sizeof(video_st->hw_render));
|
||||
|
||||
VIDEO_DRIVER_CONTEXT_UNLOCK(video_st);
|
||||
|
||||
video_st->hw_render_context_negotiation = NULL;
|
||||
}
|
||||
|
||||
void video_driver_free_internal(void)
|
||||
{
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
video_driver_state_t *video_st = &video_driver_st;
|
||||
#ifdef HAVE_THREADS
|
||||
bool is_threaded =
|
||||
VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VIDEO_LAYOUT
|
||||
video_layout_deinit();
|
||||
#endif
|
||||
|
||||
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
||||
|
||||
if (!video_driver_is_video_cache_context())
|
||||
video_driver_free_hw_context();
|
||||
|
||||
if (!(input_st->current_data == video_st->data))
|
||||
{
|
||||
if (input_st->current_driver)
|
||||
if (input_st->current_driver->free)
|
||||
input_st->current_driver->free(input_st->current_data);
|
||||
if (input_st->primary_joypad)
|
||||
{
|
||||
const input_device_driver_t *tmp = input_st->primary_joypad;
|
||||
input_st->primary_joypad = NULL;
|
||||
tmp->destroy();
|
||||
}
|
||||
#ifdef HAVE_MFI
|
||||
if (input_st->secondary_joypad)
|
||||
{
|
||||
const input_device_driver_t *tmp = input_st->secondary_joypad;
|
||||
input_st->secondary_joypad = NULL;
|
||||
tmp->destroy();
|
||||
}
|
||||
#endif
|
||||
input_st->keyboard_mapping_blocked = false;
|
||||
input_st->current_data = NULL;
|
||||
}
|
||||
|
||||
if ( video_st->data
|
||||
&& video_st->current_video
|
||||
&& video_st->current_video->free)
|
||||
video_st->current_video->free(video_st->data);
|
||||
|
||||
if (video_st->scaler_ptr)
|
||||
video_driver_pixel_converter_free(video_st->scaler_ptr);
|
||||
video_st->scaler_ptr = NULL;
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
video_driver_filter_free();
|
||||
#endif
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
dir_free_shader(
|
||||
(struct rarch_dir_shader_list*)&video_st->dir_shader_list,
|
||||
config_get_ptr()->bools.video_shader_remember_last_dir);
|
||||
#endif
|
||||
#ifdef HAVE_THREADS
|
||||
if (is_threaded)
|
||||
return;
|
||||
#endif
|
||||
|
||||
video_monitor_compute_fps_statistics(video_st->frame_time_count);
|
||||
}
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#include <rthreads/rthreads.h>
|
||||
#endif
|
||||
|
||||
#include <gfx/scaler/pixconv.h>
|
||||
#include <gfx/scaler/scaler.h>
|
||||
|
||||
@ -35,16 +39,24 @@
|
||||
#include "../input/input_driver.h"
|
||||
#include "../input/input_types.h"
|
||||
|
||||
#include "video_defines.h"
|
||||
|
||||
#ifdef HAVE_VIDEO_LAYOUT
|
||||
#include "video_layout.h"
|
||||
#endif
|
||||
|
||||
#include "video_defines.h"
|
||||
#ifdef HAVE_CRTSWITCHRES
|
||||
#include "video_crt_switch.h"
|
||||
#endif
|
||||
|
||||
#include "video_coord_array.h"
|
||||
#include "video_shader_parse.h"
|
||||
#include "video_filter.h"
|
||||
|
||||
#define RARCH_SCALE_BASE 256
|
||||
|
||||
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
|
||||
|
||||
#define VIDEO_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1)
|
||||
#define VIDEO_SHADER_MENU (GFX_MAX_SHADERS - 2)
|
||||
#define VIDEO_SHADER_MENU_2 (GFX_MAX_SHADERS - 3)
|
||||
@ -72,6 +84,52 @@
|
||||
|
||||
#define MAX_VARIABLES 64
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#define VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st) ((!video_driver_is_hw_context() && video_st->threaded) ? true : false)
|
||||
#define VIDEO_DRIVER_LOCK(video_st) \
|
||||
if (video_st->display_lock) \
|
||||
slock_lock(video_st->display_lock)
|
||||
|
||||
#define VIDEO_DRIVER_UNLOCK(video_st) \
|
||||
if (video_st->display_lock) \
|
||||
slock_unlock(video_st->display_lock)
|
||||
|
||||
#define VIDEO_DRIVER_CONTEXT_LOCK(video_st) \
|
||||
if (video_st->context_lock) \
|
||||
slock_lock(video_st->context_lock)
|
||||
|
||||
#define VIDEO_DRIVER_CONTEXT_UNLOCK(video_st) \
|
||||
if (video_st->context_lock) \
|
||||
slock_unlock(video_st->context_lock)
|
||||
|
||||
#define VIDEO_DRIVER_LOCK_FREE(video_st) \
|
||||
slock_free(video_st->display_lock); \
|
||||
slock_free(video_st->context_lock); \
|
||||
video_st->display_lock = NULL; \
|
||||
video_st->context_lock = NULL
|
||||
|
||||
#define VIDEO_DRIVER_THREADED_LOCK(video_st, is_threaded) \
|
||||
if (is_threaded) \
|
||||
VIDEO_DRIVER_LOCK(video_st)
|
||||
|
||||
#define VIDEO_DRIVER_THREADED_UNLOCK(video_st, is_threaded) \
|
||||
if (is_threaded) \
|
||||
VIDEO_DRIVER_UNLOCK(video_st)
|
||||
#define VIDEO_DRIVER_GET_PTR_INTERNAL(video_st) ((VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st)) ? video_thread_get_ptr(video_st) : video_st->data)
|
||||
#else
|
||||
#define VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st) (false)
|
||||
#define VIDEO_DRIVER_LOCK(video_st) ((void)0)
|
||||
#define VIDEO_DRIVER_UNLOCK(video_st) ((void)0)
|
||||
#define VIDEO_DRIVER_LOCK_FREE(video_st) ((void)0)
|
||||
#define VIDEO_DRIVER_THREADED_LOCK(video_st, is_threaded) ((void)0)
|
||||
#define VIDEO_DRIVER_THREADED_UNLOCK(video_st, is_threaded) ((void)0)
|
||||
#define VIDEO_DRIVER_CONTEXT_LOCK(video_st) ((void)0)
|
||||
#define VIDEO_DRIVER_CONTEXT_UNLOCK(video_st) ((void)0)
|
||||
#define VIDEO_DRIVER_GET_PTR_INTERNAL(video_st) (video_st->data)
|
||||
#endif
|
||||
|
||||
#define VIDEO_DRIVER_GET_HW_CONTEXT_INTERNAL(video_st) (&video_st->hw_render)
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
enum
|
||||
@ -818,6 +876,146 @@ typedef struct video_driver
|
||||
#endif
|
||||
} video_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#ifdef HAVE_CRTSWITCHRES
|
||||
videocrt_switch_t crt_switch_st; /* double alignment */
|
||||
#endif
|
||||
struct retro_system_av_info av_info; /* double alignment */
|
||||
retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT];
|
||||
uint64_t frame_time_count;
|
||||
uint64_t frame_count;
|
||||
uint8_t *record_gpu_buffer;
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
rarch_softfilter_t *state_filter;
|
||||
void *state_buffer;
|
||||
#endif
|
||||
void *data;
|
||||
video_driver_t *current_video;
|
||||
/* Interface for "poking". */
|
||||
const video_poke_interface_t *poke;
|
||||
gfx_ctx_driver_t current_video_context; /* ptr alignment */
|
||||
struct retro_hw_render_callback hw_render; /* ptr alignment */
|
||||
struct rarch_dir_shader_list dir_shader_list; /* ptr alignment */
|
||||
#ifdef HAVE_THREADS
|
||||
slock_t *display_lock;
|
||||
slock_t *context_lock;
|
||||
#endif
|
||||
|
||||
/* Used for 15-bit -> 16-bit conversions that take place before
|
||||
* being passed to video driver. */
|
||||
video_pixel_scaler_t *scaler_ptr;
|
||||
video_driver_frame_t frame_bak; /* ptr alignment */
|
||||
|
||||
void *current_display_server_data;
|
||||
|
||||
const void *frame_cache_data;
|
||||
|
||||
const struct
|
||||
retro_hw_render_context_negotiation_interface *
|
||||
hw_render_context_negotiation;
|
||||
|
||||
void *context_data;
|
||||
|
||||
/* Opaque handles to currently running window.
|
||||
* Used by e.g. input drivers which bind to a window.
|
||||
* Drivers are responsible for setting these if an input driver
|
||||
* could potentially make use of this. */
|
||||
uintptr_t display_userdata;
|
||||
uintptr_t display;
|
||||
uintptr_t window;
|
||||
|
||||
size_t frame_cache_pitch;
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
unsigned state_scale;
|
||||
unsigned state_out_bpp;
|
||||
#endif
|
||||
unsigned frame_cache_width;
|
||||
unsigned frame_cache_height;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
|
||||
float core_hz;
|
||||
float aspect_ratio;
|
||||
float video_refresh_rate_original;
|
||||
|
||||
enum retro_pixel_format pix_fmt;
|
||||
enum rarch_display_type display_type;
|
||||
enum rotation initial_screen_orientation;
|
||||
enum rotation current_screen_orientation;
|
||||
|
||||
/**
|
||||
* dynamic.c:dynamic_request_hw_context will try to set flag data when the context
|
||||
* is in the middle of being rebuilt; in these cases we will save flag
|
||||
* data and set this to true.
|
||||
* When the context is reinit, it checks this, reads from
|
||||
* deferred_flag_data and cleans it.
|
||||
*
|
||||
* TODO - Dirty hack, fix it better
|
||||
*/
|
||||
gfx_ctx_flags_t deferred_flag_data; /* uint32_t alignment */
|
||||
|
||||
char cached_driver_id[32];
|
||||
char title_buf[64];
|
||||
char gpu_device_string[128];
|
||||
char gpu_api_version_string[128];
|
||||
char window_title[512];
|
||||
|
||||
/**
|
||||
* dynamic.c:dynamic_request_hw_context will try to set
|
||||
* flag data when the context
|
||||
* is in the middle of being rebuilt; in these cases we will save flag
|
||||
* data and set this to true.
|
||||
* When the context is reinit, it checks this, reads from
|
||||
* deferred_flag_data and cleans it.
|
||||
*
|
||||
* TODO - Dirty hack, fix it better
|
||||
*/
|
||||
bool deferred_video_context_driver_set_flags;
|
||||
bool window_title_update;
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
bool widgets_paused;
|
||||
bool widgets_fast_forward;
|
||||
bool widgets_rewinding;
|
||||
#endif
|
||||
bool started_fullscreen;
|
||||
|
||||
/* Graphics driver requires RGBA byte order data (ABGR on little-endian)
|
||||
* for 32-bit.
|
||||
* This takes effect for overlay and shader cores that wants to load
|
||||
* data into graphics driver. Kinda hackish to place it here, it is only
|
||||
* used for GLES.
|
||||
* TODO: Refactor this better. */
|
||||
bool use_rgba;
|
||||
|
||||
/* Graphics driver supports HDR displays
|
||||
* Currently only D3D11/D3D12 supports HDR displays and
|
||||
* whether we've enabled it */
|
||||
bool hdr_support;
|
||||
|
||||
/* If set during context deinit, the driver should keep
|
||||
* graphics context alive to avoid having to reset all
|
||||
* context state. */
|
||||
bool cache_context;
|
||||
|
||||
/* Set to true by driver if context caching succeeded. */
|
||||
bool cache_context_ack;
|
||||
|
||||
bool active;
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
bool state_out_rgb32;
|
||||
#endif
|
||||
bool crt_switching_active;
|
||||
bool force_fullscreen;
|
||||
bool threaded;
|
||||
bool is_switching_display_mode;
|
||||
|
||||
#ifdef HAVE_RUNAHEAD
|
||||
bool runahead_is_active;
|
||||
#endif
|
||||
} video_driver_state_t;
|
||||
|
||||
extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END];
|
||||
|
||||
bool video_driver_has_windowed(void);
|
||||
@ -914,6 +1112,8 @@ const char* config_get_video_driver_options(void);
|
||||
**/
|
||||
void *video_driver_get_ptr(void);
|
||||
|
||||
video_driver_state_t *video_state_get_ptr(void);
|
||||
|
||||
void *video_driver_get_data(void);
|
||||
|
||||
bool video_driver_set_rotation(unsigned rotation);
|
||||
@ -1198,10 +1398,52 @@ video_pixel_scaler_t *video_driver_pixel_converter_init(
|
||||
struct retro_hw_render_callback *hwr,
|
||||
unsigned size);
|
||||
|
||||
void recording_dump_frame(
|
||||
const void *data, unsigned width,
|
||||
unsigned height, size_t pitch, bool is_idle);
|
||||
|
||||
void video_driver_gpu_record_deinit(void);
|
||||
|
||||
void video_driver_init_filter(enum retro_pixel_format colfmt_int,
|
||||
settings_t *settings);
|
||||
|
||||
void video_context_driver_reset(void);
|
||||
|
||||
void video_driver_free_internal(void);
|
||||
|
||||
/**
|
||||
* video_driver_get_current_framebuffer:
|
||||
*
|
||||
* Gets pointer to current hardware renderer framebuffer object.
|
||||
* Used by RETRO_ENVIRONMENT_SET_HW_RENDER.
|
||||
*
|
||||
* Returns: pointer to hardware framebuffer object, otherwise 0.
|
||||
**/
|
||||
uintptr_t video_driver_get_current_framebuffer(void);
|
||||
|
||||
retro_proc_address_t video_driver_get_proc_address(const char *sym);
|
||||
|
||||
void video_driver_free_hw_context(void);
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
void video_driver_filter_free(void);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
/**
|
||||
* video_thread_get_ptr:
|
||||
*
|
||||
* Gets the underlying video driver associated with the
|
||||
* threaded video wrapper. Sets @drv to the found
|
||||
* video driver.
|
||||
*
|
||||
* Returns: Video driver data of the video driver associated
|
||||
* with the threaded wrapper (if successful). If not successful,
|
||||
* NULL.
|
||||
**/
|
||||
void *video_thread_get_ptr(video_driver_state_t *video_st);
|
||||
#endif
|
||||
|
||||
extern const video_driver_t *video_drivers[];
|
||||
|
||||
extern video_driver_t video_gl_core;
|
||||
|
@ -205,16 +205,18 @@ void pad_connection_pad_deregister(joypad_connection_t *joyconn,
|
||||
{
|
||||
int i;
|
||||
int slot;
|
||||
joypad_connection_t *pad;
|
||||
|
||||
if(!iface->multi_pad) {
|
||||
if(!iface->multi_pad)
|
||||
{
|
||||
legacy_pad_connection_pad_deregister(joyconn, iface, pad_data);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; i < iface->max_pad; i++) {
|
||||
for(i = 0; i < iface->max_pad; i++)
|
||||
{
|
||||
slot = joypad_to_slot(joyconn, iface->joypad(pad_data, i));
|
||||
if(slot >= 0) {
|
||||
if(slot >= 0)
|
||||
{
|
||||
input_autoconfigure_disconnect(slot, iface->get_name(joyconn[slot].connection));
|
||||
iface->pad_deinit(joyconn[slot].connection);
|
||||
}
|
||||
|
@ -3221,8 +3221,112 @@ void input_overlay_set_visibility(int overlay_idx,
|
||||
ol->iface->set_alpha(ol->iface_data, overlay_idx, 0.0);
|
||||
}
|
||||
|
||||
void input_overlay_loaded(retro_task_t *task,
|
||||
void *task_data, void *user_data, const char *err);
|
||||
static bool video_driver_overlay_interface(
|
||||
const video_overlay_interface_t **iface)
|
||||
{
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
if (!video_st->current_video || !video_st->current_video->overlay_interface)
|
||||
return false;
|
||||
video_st->current_video->overlay_interface(video_st->data, iface);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* task_data = overlay_task_data_t* */
|
||||
static void input_overlay_loaded(retro_task_t *task,
|
||||
void *task_data, void *user_data, const char *err)
|
||||
{
|
||||
size_t i;
|
||||
overlay_task_data_t *data = (overlay_task_data_t*)task_data;
|
||||
input_overlay_t *ol = NULL;
|
||||
const video_overlay_interface_t *iface = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool input_overlay_show_mouse_cursor = settings->bools.input_overlay_show_mouse_cursor;
|
||||
bool inp_overlay_auto_rotate = settings->bools.input_overlay_auto_rotate;
|
||||
bool input_overlay_enable = settings->bools.input_overlay_enable;
|
||||
video_driver_state_t *video_st = video_state_get_ptr();
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
if (err)
|
||||
return;
|
||||
|
||||
if (data->overlay_enable)
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
/* We can't display when the menu is up */
|
||||
if (data->hide_in_menu && menu_state_get_ptr()->alive)
|
||||
goto abort_load;
|
||||
#endif
|
||||
|
||||
/* If 'hide_when_gamepad_connected' is enabled,
|
||||
* we can't display when a gamepad is connected */
|
||||
if (data->hide_when_gamepad_connected &&
|
||||
(input_config_get_device_name(0) != NULL))
|
||||
goto abort_load;
|
||||
}
|
||||
|
||||
if ( !data->overlay_enable ||
|
||||
!video_driver_overlay_interface(&iface) ||
|
||||
!iface)
|
||||
{
|
||||
RARCH_ERR("Overlay interface is not present in video driver,"
|
||||
" or not enabled.\n");
|
||||
goto abort_load;
|
||||
}
|
||||
|
||||
ol = (input_overlay_t*)calloc(1, sizeof(*ol));
|
||||
ol->overlays = data->overlays;
|
||||
ol->size = data->size;
|
||||
ol->active = data->active;
|
||||
ol->iface = iface;
|
||||
ol->iface_data = video_st->data;
|
||||
|
||||
input_overlay_load_active(input_st->overlay_visibility,
|
||||
ol, data->overlay_opacity);
|
||||
|
||||
/* Enable or disable the overlay. */
|
||||
ol->enable = data->overlay_enable;
|
||||
|
||||
if (ol->iface->enable)
|
||||
ol->iface->enable(ol->iface_data, data->overlay_enable);
|
||||
|
||||
input_overlay_set_scale_factor(ol, &data->layout_desc,
|
||||
video_st->width, video_st->height);
|
||||
|
||||
ol->next_index = (unsigned)((ol->index + 1) % ol->size);
|
||||
ol->state = OVERLAY_STATUS_NONE;
|
||||
ol->alive = true;
|
||||
|
||||
/* Due to the asynchronous nature of overlay loading
|
||||
* it is possible for overlay_ptr to be non-NULL here
|
||||
* > Ensure it is free()'d before assigning new pointer */
|
||||
if (input_st->overlay_ptr)
|
||||
{
|
||||
input_overlay_free_overlays(input_st->overlay_ptr);
|
||||
free(input_st->overlay_ptr);
|
||||
}
|
||||
input_st->overlay_ptr = ol;
|
||||
|
||||
free(data);
|
||||
|
||||
if (!input_overlay_show_mouse_cursor)
|
||||
video_driver_hide_mouse();
|
||||
|
||||
/* Attempt to automatically rotate overlay, if required */
|
||||
if (inp_overlay_auto_rotate)
|
||||
input_overlay_auto_rotate_(
|
||||
video_st->width,
|
||||
video_st->height,
|
||||
input_overlay_enable,
|
||||
input_st->overlay_ptr);
|
||||
|
||||
return;
|
||||
|
||||
abort_load:
|
||||
for (i = 0; i < data->size; i++)
|
||||
input_overlay_free_overlay(&data->overlays[i]);
|
||||
|
||||
free(data->overlays);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void input_overlay_init(void)
|
||||
{
|
||||
|
2172
retroarch.c
2172
retroarch.c
File diff suppressed because it is too large
Load Diff
@ -43,8 +43,6 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
|
||||
|
||||
#define RETRO_ENVIRONMENT_RETROARCH_START_BLOCK 0x800000
|
||||
|
||||
#define RETRO_ENVIRONMENT_SET_SAVE_STATE_IN_BACKGROUND (2 | RETRO_ENVIRONMENT_RETROARCH_START_BLOCK)
|
||||
@ -85,15 +83,11 @@ void retroarch_override_setting_unset(enum rarch_override_setting enum_idx, void
|
||||
|
||||
bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx, void *data);
|
||||
|
||||
bool retroarch_is_forced_fullscreen(void);
|
||||
|
||||
void retroarch_set_current_core_type(
|
||||
enum rarch_core_type type, bool explicitly_set);
|
||||
|
||||
const char* retroarch_get_shader_preset(void);
|
||||
|
||||
bool retroarch_is_switching_display_mode(void);
|
||||
|
||||
/**
|
||||
* retroarch_main_init:
|
||||
* @argc : Count of (commandline) arguments.
|
||||
|
210
retroarch_data.h
210
retroarch_data.h
@ -64,60 +64,6 @@
|
||||
#define DEFAULT_NETWORK_GAMEPAD_PORT 55400
|
||||
#define UDP_FRAME_PACKETS 16
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#define VIDEO_DRIVER_IS_THREADED_INTERNAL() ((!video_driver_is_hw_context() && p_rarch->video_driver_threaded) ? true : false)
|
||||
#else
|
||||
#define VIDEO_DRIVER_IS_THREADED_INTERNAL() (false)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#define VIDEO_DRIVER_LOCK() \
|
||||
if (p_rarch->display_lock) \
|
||||
slock_lock(p_rarch->display_lock)
|
||||
|
||||
#define VIDEO_DRIVER_UNLOCK() \
|
||||
if (p_rarch->display_lock) \
|
||||
slock_unlock(p_rarch->display_lock)
|
||||
|
||||
#define VIDEO_DRIVER_CONTEXT_LOCK() \
|
||||
if (p_rarch->context_lock) \
|
||||
slock_lock(p_rarch->context_lock)
|
||||
|
||||
#define VIDEO_DRIVER_CONTEXT_UNLOCK() \
|
||||
if (p_rarch->context_lock) \
|
||||
slock_unlock(p_rarch->context_lock)
|
||||
|
||||
#define VIDEO_DRIVER_LOCK_FREE() \
|
||||
slock_free(p_rarch->display_lock); \
|
||||
slock_free(p_rarch->context_lock); \
|
||||
p_rarch->display_lock = NULL; \
|
||||
p_rarch->context_lock = NULL
|
||||
|
||||
#define VIDEO_DRIVER_THREADED_LOCK(is_threaded) \
|
||||
if (is_threaded) \
|
||||
VIDEO_DRIVER_LOCK()
|
||||
|
||||
#define VIDEO_DRIVER_THREADED_UNLOCK(is_threaded) \
|
||||
if (is_threaded) \
|
||||
VIDEO_DRIVER_UNLOCK()
|
||||
#else
|
||||
#define VIDEO_DRIVER_LOCK() ((void)0)
|
||||
#define VIDEO_DRIVER_UNLOCK() ((void)0)
|
||||
#define VIDEO_DRIVER_LOCK_FREE() ((void)0)
|
||||
#define VIDEO_DRIVER_THREADED_LOCK(is_threaded) ((void)0)
|
||||
#define VIDEO_DRIVER_THREADED_UNLOCK(is_threaded) ((void)0)
|
||||
#define VIDEO_DRIVER_CONTEXT_LOCK() ((void)0)
|
||||
#define VIDEO_DRIVER_CONTEXT_UNLOCK() ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#define VIDEO_DRIVER_GET_PTR_INTERNAL(p_rarch) ((VIDEO_DRIVER_IS_THREADED_INTERNAL()) ? video_thread_get_ptr(p_rarch) : p_rarch->video_driver_data)
|
||||
#else
|
||||
#define VIDEO_DRIVER_GET_PTR_INTERNAL(p_rarch) (p_rarch->video_driver_data)
|
||||
#endif
|
||||
|
||||
#define VIDEO_DRIVER_GET_HW_CONTEXT_INTERNAL(p_rarch) (&p_rarch->hw_render)
|
||||
|
||||
#ifdef HAVE_BSV_MOVIE
|
||||
#define BSV_MOVIE_IS_EOF(p_rarch) || (input_st->bsv_movie_state.movie_end && \
|
||||
input_st->bsv_movie_state.eof_exit)
|
||||
@ -125,7 +71,7 @@ input_st->bsv_movie_state.eof_exit)
|
||||
#define BSV_MOVIE_IS_EOF(p_rarch)
|
||||
#endif
|
||||
|
||||
#define VIDEO_HAS_FOCUS(p_rarch) (p_rarch->current_video->focus ? (p_rarch->current_video->focus(p_rarch->video_driver_data)) : true)
|
||||
#define VIDEO_HAS_FOCUS(video_st) (video_st->current_video->focus ? (video_st->current_video->focus(video_st->data)) : true)
|
||||
|
||||
#if HAVE_DYNAMIC
|
||||
#define RUNAHEAD_RUN_SECONDARY(p_rarch) \
|
||||
@ -134,10 +80,10 @@ input_st->bsv_movie_state.eof_exit)
|
||||
#endif
|
||||
|
||||
#define RUNAHEAD_RESUME_VIDEO(p_rarch) \
|
||||
if (p_rarch->runahead_video_driver_is_active) \
|
||||
p_rarch->video_driver_active = true; \
|
||||
if (video_st->runahead_is_active) \
|
||||
video_st->active = true; \
|
||||
else \
|
||||
p_rarch->video_driver_active = false
|
||||
video_st->active = false
|
||||
|
||||
#define _PSUPP_BUF(buf, var, name, desc) \
|
||||
strlcat(buf, " ", sizeof(buf)); \
|
||||
@ -306,21 +252,6 @@ input_st->bsv_movie_state.eof_exit)
|
||||
|
||||
/* DRIVERS */
|
||||
|
||||
static const video_display_server_t dispserv_null = {
|
||||
NULL, /* init */
|
||||
NULL, /* destroy */
|
||||
NULL, /* set_window_opacity */
|
||||
NULL, /* set_window_progress */
|
||||
NULL, /* set_window_decorations */
|
||||
NULL, /* set_resolution */
|
||||
NULL, /* get_resolution_list */
|
||||
NULL, /* get_output_options */
|
||||
NULL, /* set_screen_orientation */
|
||||
NULL, /* get_screen_orientation */
|
||||
NULL, /* get_flags */
|
||||
"null"
|
||||
};
|
||||
|
||||
#ifdef HAVE_VULKAN
|
||||
static const gfx_ctx_driver_t *gfx_ctx_vk_drivers[] = {
|
||||
#if defined(__APPLE__)
|
||||
@ -640,16 +571,10 @@ typedef struct discord_state discord_state_t;
|
||||
|
||||
struct rarch_state
|
||||
{
|
||||
struct retro_system_av_info video_driver_av_info; /* double alignment */
|
||||
#ifdef HAVE_CRTSWITCHRES
|
||||
videocrt_switch_t crt_switch_st; /* double alignment */
|
||||
#endif
|
||||
retro_time_t frame_limit_minimum_time;
|
||||
retro_time_t frame_limit_last_time;
|
||||
retro_time_t libretro_core_runtime_last;
|
||||
retro_time_t libretro_core_runtime_usec;
|
||||
retro_time_t video_driver_frame_time_samples[
|
||||
MEASURE_FRAME_TIME_SAMPLES_COUNT];
|
||||
struct global g_extern; /* retro_time_t alignment */
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
rarch_timer_t shader_delay_timer; /* int64_t alignment */
|
||||
@ -668,13 +593,10 @@ struct rarch_state
|
||||
uint64_t runahead_last_frame_count;
|
||||
#endif
|
||||
|
||||
uint64_t video_driver_frame_time_count;
|
||||
uint64_t video_driver_frame_count;
|
||||
struct retro_camera_callback camera_cb; /* uint64_t alignment */
|
||||
|
||||
struct string_list *subsystem_fullpaths;
|
||||
|
||||
uint8_t *video_driver_record_gpu_buffer;
|
||||
bool *load_no_content_hook;
|
||||
#if defined(HAVE_RUNAHEAD)
|
||||
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
||||
@ -683,11 +605,6 @@ struct rarch_state
|
||||
retro_ctx_load_content_info_t *load_content_info;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
slock_t *display_lock;
|
||||
slock_t *context_lock;
|
||||
#endif
|
||||
|
||||
const camera_driver_t *camera_driver;
|
||||
void *camera_data;
|
||||
|
||||
@ -705,31 +622,6 @@ struct rarch_state
|
||||
const wifi_driver_t *wifi_driver;
|
||||
void *wifi_data;
|
||||
|
||||
void *current_display_server_data;
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
rarch_softfilter_t *video_driver_state_filter;
|
||||
void *video_driver_state_buffer;
|
||||
#endif
|
||||
|
||||
const void *frame_cache_data;
|
||||
|
||||
void *video_driver_data;
|
||||
video_driver_t *current_video;
|
||||
|
||||
/* Interface for "poking". */
|
||||
const video_poke_interface_t *video_driver_poke;
|
||||
|
||||
/* Used for 15-bit -> 16-bit conversions that take place before
|
||||
* being passed to video driver. */
|
||||
video_pixel_scaler_t *video_driver_scaler_ptr;
|
||||
|
||||
const struct
|
||||
retro_hw_render_context_negotiation_interface *
|
||||
hw_render_context_negotiation;
|
||||
|
||||
void *video_context_data;
|
||||
|
||||
#ifdef HAVE_HID
|
||||
const void *hid_data;
|
||||
#endif
|
||||
@ -758,12 +650,8 @@ struct rarch_state
|
||||
subsystem_data_roms[SUBSYSTEM_MAX_SUBSYSTEMS]
|
||||
[SUBSYSTEM_MAX_SUBSYSTEM_ROMS]; /* ptr alignment */
|
||||
|
||||
gfx_ctx_driver_t current_video_context; /* ptr alignment */
|
||||
content_state_t content_st; /* ptr alignment */
|
||||
struct retro_hw_render_callback hw_render; /* ptr alignment */
|
||||
retro_input_state_t input_state_callback_original; /* ptr alignment */
|
||||
video_driver_frame_t frame_bak; /* ptr alignment */
|
||||
struct rarch_dir_shader_list dir_shader_list; /* ptr alignment */
|
||||
#ifdef HAVE_RUNAHEAD
|
||||
function_t retro_reset_callback_original; /* ptr alignment */
|
||||
function_t original_retro_deinit; /* ptr alignment */
|
||||
@ -789,16 +677,6 @@ struct rarch_state
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Opaque handles to currently running window.
|
||||
* Used by e.g. input drivers which bind to a window.
|
||||
* Drivers are responsible for setting these if an input driver
|
||||
* could potentially make use of this. */
|
||||
uintptr_t video_driver_display_userdata;
|
||||
uintptr_t video_driver_display;
|
||||
uintptr_t video_driver_window;
|
||||
|
||||
size_t frame_cache_pitch;
|
||||
|
||||
#ifdef HAVE_RUNAHEAD
|
||||
size_t runahead_save_state_size;
|
||||
#endif
|
||||
@ -833,14 +711,6 @@ struct rarch_state
|
||||
#endif
|
||||
unsigned fastforward_after_frames;
|
||||
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
unsigned video_driver_state_scale;
|
||||
unsigned video_driver_state_out_bpp;
|
||||
#endif
|
||||
unsigned frame_cache_width;
|
||||
unsigned frame_cache_height;
|
||||
unsigned video_driver_width;
|
||||
unsigned video_driver_height;
|
||||
#ifdef HAVE_NETWORKING
|
||||
unsigned server_port_deferred;
|
||||
#endif
|
||||
@ -848,42 +718,19 @@ struct rarch_state
|
||||
unsigned perf_ptr_rarch;
|
||||
unsigned perf_ptr_libretro;
|
||||
|
||||
float video_driver_core_hz;
|
||||
float video_driver_aspect_ratio;
|
||||
float video_refresh_rate_original;
|
||||
|
||||
enum rarch_core_type current_core_type;
|
||||
enum rarch_core_type explicit_current_core_type;
|
||||
enum rotation initial_screen_orientation;
|
||||
enum rotation current_screen_orientation;
|
||||
enum retro_pixel_format video_driver_pix_fmt;
|
||||
#if defined(HAVE_COMMAND)
|
||||
enum cmd_source_t lastcmd_source;
|
||||
#endif
|
||||
#if defined(HAVE_RUNAHEAD)
|
||||
enum rarch_core_type last_core_type;
|
||||
#endif
|
||||
enum rarch_display_type video_driver_display_type;
|
||||
enum poll_type_override_t core_poll_type_override;
|
||||
|
||||
/**
|
||||
* dynamic.c:dynamic_request_hw_context will try to set flag data when the context
|
||||
* is in the middle of being rebuilt; in these cases we will save flag
|
||||
* data and set this to true.
|
||||
* When the context is reinit, it checks this, reads from
|
||||
* deferred_flag_data and cleans it.
|
||||
*
|
||||
* TODO - Dirty hack, fix it better
|
||||
*/
|
||||
gfx_ctx_flags_t deferred_flag_data; /* uint32_t alignment */
|
||||
retro_bits_t has_set_libretro_device; /* uint32_t alignment */
|
||||
|
||||
char cached_video_driver[32];
|
||||
char video_driver_title_buf[64];
|
||||
char video_driver_gpu_device_string[128];
|
||||
char video_driver_gpu_api_version_string[128];
|
||||
char error_string[255];
|
||||
char video_driver_window_title[512];
|
||||
#ifdef HAVE_NETWORKING
|
||||
char server_address_deferred[512];
|
||||
#endif
|
||||
@ -926,7 +773,6 @@ struct rarch_state
|
||||
#endif
|
||||
bool has_set_username;
|
||||
bool rarch_error_on_init;
|
||||
bool rarch_force_fullscreen;
|
||||
bool has_set_core;
|
||||
bool has_set_verbosity;
|
||||
bool has_set_libretro;
|
||||
@ -943,7 +789,6 @@ struct rarch_state
|
||||
#endif
|
||||
bool has_set_log_to_file;
|
||||
bool rarch_is_inited;
|
||||
bool rarch_is_switching_display_mode;
|
||||
bool rarch_is_sram_load_disabled;
|
||||
bool rarch_is_sram_save_disabled;
|
||||
bool rarch_use_sram;
|
||||
@ -953,48 +798,10 @@ struct rarch_state
|
||||
#ifdef HAVE_PATCH
|
||||
bool rarch_patch_blocked;
|
||||
#endif
|
||||
bool video_driver_window_title_update;
|
||||
|
||||
/**
|
||||
* dynamic.c:dynamic_request_hw_context will try to set
|
||||
* flag data when the context
|
||||
* is in the middle of being rebuilt; in these cases we will save flag
|
||||
* data and set this to true.
|
||||
* When the context is reinit, it checks this, reads from
|
||||
* deferred_flag_data and cleans it.
|
||||
*
|
||||
* TODO - Dirty hack, fix it better
|
||||
*/
|
||||
bool deferred_video_context_driver_set_flags;
|
||||
bool ignore_environment_cb;
|
||||
bool core_set_shared_context;
|
||||
|
||||
/* Graphics driver requires RGBA byte order data (ABGR on little-endian)
|
||||
* for 32-bit.
|
||||
* This takes effect for overlay and shader cores that wants to load
|
||||
* data into graphics driver. Kinda hackish to place it here, it is only
|
||||
* used for GLES.
|
||||
* TODO: Refactor this better. */
|
||||
bool video_driver_use_rgba;
|
||||
|
||||
/* Graphics driver supports HDR displays
|
||||
* Currently only D3D11/D3D12 supports HDR displays and
|
||||
* whether we've enabled it */
|
||||
bool video_driver_hdr_support;
|
||||
|
||||
/* If set during context deinit, the driver should keep
|
||||
* graphics context alive to avoid having to reset all
|
||||
* context state. */
|
||||
bool video_driver_cache_context;
|
||||
|
||||
/* Set to true by driver if context caching succeeded. */
|
||||
bool video_driver_cache_context_ack;
|
||||
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
bool gfx_widgets_paused;
|
||||
bool gfx_widgets_fast_forward;
|
||||
bool gfx_widgets_rewinding;
|
||||
#endif
|
||||
#ifdef HAVE_ACCESSIBILITY
|
||||
/* Is text-to-speech accessibility turned on? */
|
||||
bool accessibility_enabled;
|
||||
@ -1009,15 +816,7 @@ struct rarch_state
|
||||
bool location_driver_active;
|
||||
bool bluetooth_driver_active;
|
||||
bool wifi_driver_active;
|
||||
bool video_driver_active;
|
||||
bool camera_driver_active;
|
||||
#ifdef HAVE_VIDEO_FILTER
|
||||
bool video_driver_state_out_rgb32;
|
||||
#endif
|
||||
bool video_driver_crt_switching_active;
|
||||
bool video_driver_threaded;
|
||||
|
||||
bool video_started_fullscreen;
|
||||
|
||||
#ifdef HAVE_RUNAHEAD
|
||||
bool runahead_save_state_size_known;
|
||||
@ -1041,7 +840,6 @@ struct rarch_state
|
||||
bool shader_presets_need_reload;
|
||||
#endif
|
||||
#ifdef HAVE_RUNAHEAD
|
||||
bool runahead_video_driver_is_active;
|
||||
bool runahead_available;
|
||||
bool runahead_secondary_core_available;
|
||||
bool runahead_force_input_dirty;
|
||||
|
@ -73,11 +73,7 @@ static void ui_companion_driver_init_first(
|
||||
settings_t *settings,
|
||||
struct rarch_state *p_rarch);
|
||||
|
||||
static void video_driver_gpu_record_deinit(struct rarch_state *p_rarch);
|
||||
static retro_proc_address_t video_driver_get_proc_address(const char *sym);
|
||||
static uintptr_t video_driver_get_current_framebuffer(void);
|
||||
static bool video_driver_find_driver(
|
||||
struct rarch_state *p_rarch,
|
||||
settings_t *settings,
|
||||
const char *prefix, bool verbosity_enabled);
|
||||
|
||||
@ -121,8 +117,7 @@ static bool retroarch_apply_shader(
|
||||
enum rarch_shader_type type, const char *preset_path,
|
||||
bool message);
|
||||
|
||||
static void video_driver_restore_cached(struct rarch_state *p_rarch,
|
||||
settings_t *settings);
|
||||
static void video_driver_restore_cached(settings_t *settings);
|
||||
|
||||
static const void *find_driver_nonempty(
|
||||
const char *label, int i,
|
||||
|
Loading…
Reference in New Issue
Block a user