mirror of
https://github.com/libretro/RetroArch
synced 2025-03-05 19:13:45 +00:00
Cleanups
This commit is contained in:
parent
9f9d59f2be
commit
8cfbe3b8d4
@ -41,15 +41,15 @@
|
||||
#define HAVE_OSMESA_CREATE_CONTEXT_EXT 1
|
||||
#endif
|
||||
|
||||
#define OSMESA_DEFAULT_FORMAT OSMESA_RGBA
|
||||
#define OSMESA_BPP 4
|
||||
#define OSMESA_FIFO_PATH "/tmp/osmesa-retroarch.sock"
|
||||
|
||||
/* TODO/FIXME - static globals */
|
||||
static bool g_osmesa_profile = OSMESA_COMPAT_PROFILE;
|
||||
static int g_osmesa_major = 2;
|
||||
static int g_osmesa_minor = 1;
|
||||
|
||||
static const int g_osmesa_format = OSMESA_RGBA;
|
||||
static const int g_osmesa_bpp = 4;
|
||||
static const char *g_osmesa_fifo = "/tmp/osmesa-retroarch.sock";
|
||||
|
||||
typedef struct gfx_osmesa_ctx_data
|
||||
{
|
||||
uint8_t *screen;
|
||||
@ -77,11 +77,12 @@ static void osmesa_fifo_open(gfx_ctx_osmesa_data_t *osmesa)
|
||||
|
||||
saun.sun_family = AF_UNIX;
|
||||
|
||||
strlcpy(saun.sun_path, g_osmesa_fifo, sizeof(saun.sun_path));
|
||||
strlcpy(saun.sun_path, OSMESA_FIFO_PATH, sizeof(saun.sun_path));
|
||||
|
||||
unlink(g_osmesa_fifo);
|
||||
unlink(OSMESA_FIFO_PATH);
|
||||
|
||||
if (bind(osmesa->socket, &saun, sizeof(saun.sun_family) + sizeof(saun.sun_path)) < 0)
|
||||
if (bind(osmesa->socket,
|
||||
&saun, sizeof(saun.sun_family) + sizeof(saun.sun_path)) < 0)
|
||||
{
|
||||
perror("[osmesa] bind()");
|
||||
close(osmesa->socket);
|
||||
@ -95,8 +96,10 @@ static void osmesa_fifo_open(gfx_ctx_osmesa_data_t *osmesa)
|
||||
return;
|
||||
}
|
||||
|
||||
RARCH_ERR("[osmesa] Frame size is %ix%ix%i\n", osmesa->width, osmesa->height, osmesa->pixsize);
|
||||
RARCH_ERR("[osmesa] Please connect to unix:%s\n", g_osmesa_fifo);
|
||||
RARCH_ERR("[osmesa] Frame size is %ix%ix%i\n",
|
||||
osmesa->width, osmesa->height, osmesa->pixsize);
|
||||
RARCH_ERR("[osmesa] Please connect to unix:%s\n",
|
||||
OSMESA_FIFO_PATH);
|
||||
}
|
||||
|
||||
static void osmesa_fifo_accept(gfx_ctx_osmesa_data_t *osmesa)
|
||||
@ -146,7 +149,7 @@ static void *osmesa_ctx_init(void *video_driver)
|
||||
{
|
||||
#ifdef HAVE_OSMESA_CREATE_CONTEXT_ATTRIBS
|
||||
const int attribs[] = {
|
||||
OSMESA_FORMAT, g_osmesa_format,
|
||||
OSMESA_FORMAT, OSMESA_DEFAULT_FORMAT,
|
||||
OSMESA_DEPTH_BITS, 0,
|
||||
OSMESA_STENCIL_BITS, 0,
|
||||
OSMESA_ACCUM_BITS, 0,
|
||||
@ -168,7 +171,7 @@ static void *osmesa_ctx_init(void *video_driver)
|
||||
|
||||
#ifdef HAVE_OSMESA_CREATE_CONTEXT_EXT
|
||||
if (!osmesa->ctx)
|
||||
osmesa->ctx = OSMesaCreateContextExt(g_osmesa_format, 0, 0, 0, NULL);
|
||||
osmesa->ctx = OSMesaCreateContextExt(OSMESA_DEFAULT_FORMAT, 0, 0, 0, NULL);
|
||||
#endif
|
||||
|
||||
if (!osmesa->ctx)
|
||||
@ -176,13 +179,13 @@ static void *osmesa_ctx_init(void *video_driver)
|
||||
#if defined(HAVE_OSMESA_CREATE_CONTEXT_ATTRIBS) || defined(HAVE_OSMESA_CREATE_CONTEXT_EXT)
|
||||
RARCH_WARN("[osmesa]: Falling back to standard context creation.\n");
|
||||
#endif
|
||||
osmesa->ctx = OSMesaCreateContext(g_osmesa_format, NULL);
|
||||
osmesa->ctx = OSMesaCreateContext(OSMESA_DEFAULT_FORMAT, NULL);
|
||||
}
|
||||
|
||||
if (!osmesa->ctx)
|
||||
goto error;
|
||||
|
||||
osmesa->pixsize = g_osmesa_bpp;
|
||||
osmesa->pixsize = OSMESA_BPP;
|
||||
|
||||
return osmesa;
|
||||
|
||||
|
@ -34,19 +34,19 @@
|
||||
|
||||
typedef struct gfx_ctx_sdl_data
|
||||
{
|
||||
int g_width;
|
||||
int g_height;
|
||||
int g_new_width;
|
||||
int g_new_height;
|
||||
int width;
|
||||
int height;
|
||||
int new_width;
|
||||
int new_height;
|
||||
|
||||
bool g_full;
|
||||
bool g_resized;
|
||||
bool full;
|
||||
bool resized;
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
SDL_Window *g_win;
|
||||
SDL_GLContext g_ctx;
|
||||
SDL_Window *win;
|
||||
SDL_GLContext ctx;
|
||||
#else
|
||||
SDL_Surface *g_win;
|
||||
SDL_Surface *win;
|
||||
#endif
|
||||
} gfx_ctx_sdl_data_t;
|
||||
|
||||
@ -59,18 +59,18 @@ static void sdl_ctx_destroy_resources(gfx_ctx_sdl_data_t *sdl)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
if (sdl->g_ctx)
|
||||
SDL_GL_DeleteContext(sdl->g_ctx);
|
||||
if (sdl->ctx)
|
||||
SDL_GL_DeleteContext(sdl->ctx);
|
||||
|
||||
if (sdl->g_win)
|
||||
SDL_DestroyWindow(sdl->g_win);
|
||||
if (sdl->win)
|
||||
SDL_DestroyWindow(sdl->win);
|
||||
|
||||
sdl->g_ctx = NULL;
|
||||
sdl->ctx = NULL;
|
||||
#else
|
||||
if (sdl->g_win)
|
||||
SDL_FreeSurface(sdl->g_win);
|
||||
if (sdl->win)
|
||||
SDL_FreeSurface(sdl->win);
|
||||
#endif
|
||||
sdl->g_win = NULL;
|
||||
sdl->win = NULL;
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
@ -168,14 +168,14 @@ static bool sdl_ctx_set_video_mode(void *data,
|
||||
unsigned width, unsigned height,
|
||||
bool fullscreen)
|
||||
{
|
||||
unsigned fsflag = 0;
|
||||
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool windowed_fullscreen= settings->bools.video_windowed_fullscreen;
|
||||
unsigned fsflag = 0;
|
||||
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool windowed_fullscreen = settings->bools.video_windowed_fullscreen;
|
||||
unsigned video_monitor_index = settings->uints.video_monitor_index;
|
||||
|
||||
sdl->g_new_width = width;
|
||||
sdl->g_new_height = height;
|
||||
sdl->new_width = width;
|
||||
sdl->new_height = height;
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
|
||||
@ -187,18 +187,18 @@ static bool sdl_ctx_set_video_mode(void *data,
|
||||
fsflag = SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
|
||||
if (sdl->g_win)
|
||||
if (sdl->win)
|
||||
{
|
||||
SDL_SetWindowSize(sdl->g_win, width, height);
|
||||
SDL_SetWindowSize(sdl->win, width, height);
|
||||
|
||||
if (fullscreen)
|
||||
SDL_SetWindowFullscreen(sdl->g_win, fsflag);
|
||||
SDL_SetWindowFullscreen(sdl->win, fsflag);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned display = video_monitor_index;
|
||||
|
||||
sdl->g_win = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED_DISPLAY(display),
|
||||
sdl->win = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED_DISPLAY(display),
|
||||
SDL_WINDOWPOS_UNDEFINED_DISPLAY(display),
|
||||
width, height, SDL_WINDOW_OPENGL | fsflag);
|
||||
}
|
||||
@ -206,35 +206,35 @@ static bool sdl_ctx_set_video_mode(void *data,
|
||||
if (fullscreen)
|
||||
fsflag = SDL_FULLSCREEN;
|
||||
|
||||
sdl->g_win = SDL_SetVideoMode(width, height, 0, SDL_OPENGL | fsflag);
|
||||
sdl->win = SDL_SetVideoMode(width, height, 0, SDL_OPENGL | fsflag);
|
||||
#endif
|
||||
|
||||
if (!sdl->g_win)
|
||||
if (!sdl->win)
|
||||
goto error;
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
#if defined(_WIN32)
|
||||
sdl2_set_handles(sdl->g_win, RARCH_DISPLAY_WIN32);
|
||||
sdl2_set_handles(sdl->win, RARCH_DISPLAY_WIN32);
|
||||
#elif defined(HAVE_X11)
|
||||
sdl2_set_handles(sdl->g_win, RARCH_DISPLAY_X11);
|
||||
sdl2_set_handles(sdl->win, RARCH_DISPLAY_X11);
|
||||
#elif defined(HAVE_COCOA)
|
||||
sdl2_set_handles(sdl->g_win, RARCH_DISPLAY_OSX);
|
||||
sdl2_set_handles(sdl->win, RARCH_DISPLAY_OSX);
|
||||
#endif
|
||||
|
||||
if (sdl->g_ctx)
|
||||
if (sdl->ctx)
|
||||
video_driver_set_video_cache_context_ack();
|
||||
else
|
||||
{
|
||||
sdl->g_ctx = SDL_GL_CreateContext(sdl->g_win);
|
||||
sdl->ctx = SDL_GL_CreateContext(sdl->win);
|
||||
|
||||
if (!sdl->g_ctx)
|
||||
if (!sdl->ctx)
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
|
||||
sdl->g_full = fullscreen;
|
||||
sdl->g_width = width;
|
||||
sdl->g_height = height;
|
||||
sdl->full = fullscreen;
|
||||
sdl->width = width;
|
||||
sdl->height = height;
|
||||
|
||||
return true;
|
||||
|
||||
@ -252,10 +252,10 @@ static void sdl_ctx_get_video_size(void *data,
|
||||
if (!sdl)
|
||||
return;
|
||||
|
||||
*width = sdl->g_width;
|
||||
*height = sdl->g_height;
|
||||
*width = sdl->width;
|
||||
*height = sdl->height;
|
||||
|
||||
if (!sdl->g_win)
|
||||
if (!sdl->win)
|
||||
{
|
||||
#ifdef HAVE_SDL2
|
||||
SDL_DisplayMode mode = {0};
|
||||
@ -327,15 +327,15 @@ static void sdl_ctx_check_window(void *data, bool *quit,
|
||||
case SDL_WINDOWEVENT:
|
||||
if (event.window.event == SDL_WINDOWEVENT_RESIZED)
|
||||
{
|
||||
sdl->g_resized = true;
|
||||
sdl->g_new_width = event.window.data1;
|
||||
sdl->g_new_height = event.window.data2;
|
||||
sdl->resized = true;
|
||||
sdl->new_width = event.window.data1;
|
||||
sdl->new_height = event.window.data2;
|
||||
}
|
||||
#else
|
||||
case SDL_VIDEORESIZE:
|
||||
sdl->g_resized = true;
|
||||
sdl->g_new_width = event.resize.w;
|
||||
sdl->g_new_height = event.resize.h;
|
||||
sdl->resized = true;
|
||||
sdl->new_width = event.resize.w;
|
||||
sdl->new_height = event.resize.h;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
@ -343,12 +343,12 @@ static void sdl_ctx_check_window(void *data, bool *quit,
|
||||
}
|
||||
}
|
||||
|
||||
if (sdl->g_resized)
|
||||
if (sdl->resized)
|
||||
{
|
||||
*width = sdl->g_new_width;
|
||||
*height = sdl->g_new_height;
|
||||
*width = sdl->new_width;
|
||||
*height = sdl->new_height;
|
||||
*resize = true;
|
||||
sdl->g_resized = false;
|
||||
sdl->resized = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ static bool sdl_ctx_has_focus(void *data)
|
||||
#ifdef HAVE_SDL2
|
||||
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data;
|
||||
flags = (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS);
|
||||
return (SDL_GetWindowFlags(sdl->g_win) & flags) == flags;
|
||||
return (SDL_GetWindowFlags(sdl->win) & flags) == flags;
|
||||
#else
|
||||
flags = (SDL_APPINPUTFOCUS | SDL_APPACTIVE);
|
||||
return (SDL_GetAppState() & flags) == flags;
|
||||
@ -371,7 +371,7 @@ static void sdl_ctx_swap_buffers(void *data)
|
||||
#ifdef HAVE_SDL2
|
||||
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data;
|
||||
if (sdl)
|
||||
SDL_GL_SwapWindow(sdl->g_win);
|
||||
SDL_GL_SwapWindow(sdl->win);
|
||||
#else
|
||||
SDL_GL_SwapBuffers();
|
||||
#endif
|
||||
|
@ -42,9 +42,9 @@
|
||||
|
||||
typedef struct gfx_ctx_x_vk_data
|
||||
{
|
||||
bool g_should_reset_mode;
|
||||
bool should_reset_mode;
|
||||
|
||||
int g_interval;
|
||||
int interval;
|
||||
|
||||
gfx_ctx_vulkan_data_t vk;
|
||||
} gfx_ctx_x_vk_data_t;
|
||||
@ -104,10 +104,10 @@ static void gfx_ctx_x_vk_destroy_resources(gfx_ctx_x_vk_data_t *x)
|
||||
|
||||
if (g_x11_dpy)
|
||||
{
|
||||
if (x->g_should_reset_mode)
|
||||
if (x->should_reset_mode)
|
||||
{
|
||||
x11_exit_fullscreen(g_x11_dpy);
|
||||
x->g_should_reset_mode = false;
|
||||
x->should_reset_mode = false;
|
||||
}
|
||||
|
||||
if (!video_driver_is_video_cache_context())
|
||||
@ -138,9 +138,9 @@ static void gfx_ctx_x_vk_swap_interval(void *data, int interval)
|
||||
{
|
||||
gfx_ctx_x_vk_data_t *x = (gfx_ctx_x_vk_data_t*)data;
|
||||
|
||||
if (x->g_interval != interval)
|
||||
if (x->interval != interval)
|
||||
{
|
||||
x->g_interval = interval;
|
||||
x->interval = interval;
|
||||
if (x->vk.swapchain)
|
||||
x->vk.need_new_swapchain = true;
|
||||
}
|
||||
@ -171,7 +171,7 @@ static bool gfx_ctx_x_vk_set_resize(void *data,
|
||||
|
||||
/* FIXME/TODO - threading error here */
|
||||
|
||||
if (!vulkan_create_swapchain(&x->vk, width, height, x->g_interval))
|
||||
if (!vulkan_create_swapchain(&x->vk, width, height, x->interval))
|
||||
{
|
||||
RARCH_ERR("[X/Vulkan]: Failed to update swapchain.\n");
|
||||
x->vk.swapchain = VK_NULL_HANDLE;
|
||||
@ -270,7 +270,7 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
|
||||
{
|
||||
if (x11_enter_fullscreen(g_x11_dpy, width, height))
|
||||
{
|
||||
x->g_should_reset_mode = true;
|
||||
x->should_reset_mode = true;
|
||||
true_full = true;
|
||||
}
|
||||
else
|
||||
@ -407,7 +407,7 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
|
||||
* We can obtain the XCB connection directly from X11. */
|
||||
if (!vulkan_surface_create(&x->vk, VULKAN_WSI_XCB,
|
||||
g_x11_dpy, &g_x11_win,
|
||||
width, height, x->g_interval))
|
||||
width, height, x->interval))
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
|
||||
|
||||
x11_install_quit_atom();
|
||||
|
||||
gfx_ctx_x_vk_swap_interval(data, x->g_interval);
|
||||
gfx_ctx_x_vk_swap_interval(data, x->interval);
|
||||
|
||||
/* This can blow up on some drivers.
|
||||
* It's not fatal, so override errors for this call. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user