mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 16:13:40 +00:00
(NSW) since we haven't yet gotten the OS graphics driver, upon calling display_finalize
, to release some of the (currently global) resouces we give it when we initialized it, we need to maintain a little bit of global state in the graphics driver so it can be freed and reinitialized when we load a core. this should be able to be reverted when we implement alloc_pages
in libtransistor. see https://github.com/reswitched/libtransistor/issues/74 and https://github.com/reswitched/libtransistor/issues/69
This commit is contained in:
parent
7cc614263a
commit
be5ebbc039
@ -37,8 +37,6 @@ typedef struct
|
|||||||
bool vsync;
|
bool vsync;
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
unsigned rotation;
|
unsigned rotation;
|
||||||
surface_t surface;
|
|
||||||
revent_h vsync_h;
|
|
||||||
struct video_viewport vp;
|
struct video_viewport vp;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -56,6 +54,10 @@ typedef struct
|
|||||||
|
|
||||||
static uint32_t image[1280*720];
|
static uint32_t image[1280*720];
|
||||||
|
|
||||||
|
static bool has_initialized = false;
|
||||||
|
static surface_t surface;
|
||||||
|
static revent_h vsync_h;
|
||||||
|
|
||||||
static void *switch_init(const video_info_t *video,
|
static void *switch_init(const video_info_t *video,
|
||||||
const input_driver_t **input, void **input_data)
|
const input_driver_t **input, void **input_data)
|
||||||
{
|
{
|
||||||
@ -68,6 +70,8 @@ static void *switch_init(const video_info_t *video,
|
|||||||
|
|
||||||
if (libtransistor_context.magic != LIBTRANSISTOR_CONTEXT_MAGIC)
|
if (libtransistor_context.magic != LIBTRANSISTOR_CONTEXT_MAGIC)
|
||||||
RARCH_LOG("running under CTU, skipping graphics init...\n");
|
RARCH_LOG("running under CTU, skipping graphics init...\n");
|
||||||
|
else if(has_initialized)
|
||||||
|
RARCH_LOG("global graphics were already initialized; skipping...\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result_t r = display_init();
|
result_t r = display_init();
|
||||||
@ -76,7 +80,7 @@ static void *switch_init(const video_info_t *video,
|
|||||||
free(sw);
|
free(sw);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
r = display_open_layer(&sw->surface);
|
r = display_open_layer(&surface);
|
||||||
|
|
||||||
if (r != RESULT_OK)
|
if (r != RESULT_OK)
|
||||||
{
|
{
|
||||||
@ -84,7 +88,7 @@ static void *switch_init(const video_info_t *video,
|
|||||||
free(sw);
|
free(sw);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
r = display_get_vsync_event(&sw->vsync_h);
|
r = display_get_vsync_event(&vsync_h);
|
||||||
|
|
||||||
if (r != RESULT_OK)
|
if (r != RESULT_OK)
|
||||||
{
|
{
|
||||||
@ -92,6 +96,9 @@ static void *switch_init(const video_info_t *video,
|
|||||||
free(sw);
|
free(sw);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atexit(display_finalize);
|
||||||
|
has_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sw->vp.x = 0;
|
sw->vp.x = 0;
|
||||||
@ -119,8 +126,8 @@ static void *switch_init(const video_info_t *video,
|
|||||||
static void switch_wait_vsync(switch_video_t *sw)
|
static void switch_wait_vsync(switch_video_t *sw)
|
||||||
{
|
{
|
||||||
uint32_t handle_idx;
|
uint32_t handle_idx;
|
||||||
svcWaitSynchronization(&handle_idx, &sw->vsync_h, 1, 33333333);
|
svcWaitSynchronization(&handle_idx, &vsync_h, 1, 33333333);
|
||||||
svcResetSignal(sw->vsync_h);
|
svcResetSignal(vsync_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool switch_frame(void *data, const void *frame,
|
static bool switch_frame(void *data, const void *frame,
|
||||||
@ -212,7 +219,7 @@ static bool switch_frame(void *data, const void *frame,
|
|||||||
|
|
||||||
post_vsync = svcGetSystemTick();
|
post_vsync = svcGetSystemTick();
|
||||||
|
|
||||||
r = surface_dequeue_buffer(&sw->surface, &out_buffer);
|
r = surface_dequeue_buffer(&surface, &out_buffer);
|
||||||
|
|
||||||
if (r != RESULT_OK)
|
if (r != RESULT_OK)
|
||||||
return false;
|
return false;
|
||||||
@ -221,7 +228,7 @@ static bool switch_frame(void *data, const void *frame,
|
|||||||
gfx_slow_swizzling_blit(out_buffer, image, 1280, 720, 0, 0);
|
gfx_slow_swizzling_blit(out_buffer, image, 1280, 720, 0, 0);
|
||||||
post_swizzle = svcGetSystemTick();
|
post_swizzle = svcGetSystemTick();
|
||||||
|
|
||||||
r = surface_queue_buffer(&sw->surface);
|
r = surface_queue_buffer(&surface);
|
||||||
|
|
||||||
if (r != RESULT_OK)
|
if (r != RESULT_OK)
|
||||||
return false;
|
return false;
|
||||||
@ -270,7 +277,6 @@ static void switch_free(void *data)
|
|||||||
{
|
{
|
||||||
switch_video_t *sw = data;
|
switch_video_t *sw = data;
|
||||||
free(sw);
|
free(sw);
|
||||||
display_finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool switch_set_shader(void *data,
|
static bool switch_set_shader(void *data,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user