mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 13:14:04 +00:00
Add extra parameter to unload_texture
This commit is contained in:
parent
1204ae6edb
commit
3d893b7602
@ -261,7 +261,7 @@ static void caca_set_texture_frame(void *data,
|
||||
}
|
||||
|
||||
static const video_poke_interface_t caca_poke_interface = {
|
||||
NULL, /* get_flags */
|
||||
NULL, /* get_flags */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -158,7 +158,7 @@ static void ctr_update_viewport(
|
||||
bool video_scale_integer = settings->bools.video_scale_integer;
|
||||
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
|
||||
|
||||
if(ctr->rotation & 0x1)
|
||||
if (ctr->rotation & 0x1)
|
||||
desired_aspect = 1.0 / desired_aspect;
|
||||
|
||||
if (video_scale_integer)
|
||||
@ -227,10 +227,10 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
{
|
||||
ctr_video_t *ctr = (ctr_video_t*)param;
|
||||
|
||||
if(!ctr)
|
||||
if (!ctr)
|
||||
return;
|
||||
|
||||
if(hook == APTHOOK_ONRESTORE)
|
||||
if (hook == APTHOOK_ONRESTORE)
|
||||
{
|
||||
GPUCMD_SetBufferOffset(0);
|
||||
shaderProgramUse(&ctr->shader);
|
||||
@ -269,7 +269,7 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
ctr->p3d_event_pending = false;
|
||||
}
|
||||
|
||||
if((hook == APTHOOK_ONSUSPEND) && (ctr->video_mode == CTR_VIDEO_MODE_2D_400X240))
|
||||
if ((hook == APTHOOK_ONSUSPEND) && (ctr->video_mode == CTR_VIDEO_MODE_2D_400X240))
|
||||
{
|
||||
memcpy(gfxTopRightFramebuffers[ctr->current_buffer_top],
|
||||
gfxTopLeftFramebuffers[ctr->current_buffer_top],
|
||||
@ -280,7 +280,7 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
if ((hook == APTHOOK_ONSUSPEND) && ctr->supports_parallax_disable)
|
||||
ctr_set_parallax_layer(*(float*)0x1FF81080 != 0.0);
|
||||
|
||||
if((hook == APTHOOK_ONSUSPEND) || (hook == APTHOOK_ONRESTORE) || (hook == APTHOOK_ONWAKEUP))
|
||||
if ((hook == APTHOOK_ONSUSPEND) || (hook == APTHOOK_ONRESTORE) || (hook == APTHOOK_ONWAKEUP))
|
||||
{
|
||||
Handle lcd_handle;
|
||||
u8 not_2DS;
|
||||
@ -1103,31 +1103,36 @@ static void ctr_viewport_info(void* data, struct video_viewport* vp)
|
||||
static uintptr_t ctr_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
ctr_video_t* ctr = (ctr_video_t*)video_data;
|
||||
struct texture_image *image = (struct texture_image*)data;
|
||||
int size = image->width * image->height * sizeof(uint32_t);
|
||||
|
||||
if((size * 3) > linearSpaceFree())
|
||||
return 0;
|
||||
|
||||
if(!ctr || !image || image->width > 2048 || image->height > 2048)
|
||||
return 0;
|
||||
|
||||
ctr_texture_t* texture = calloc(1, sizeof(ctr_texture_t));
|
||||
|
||||
void* tmpdata;
|
||||
texture->width = next_pow2(image->width);
|
||||
texture->height = next_pow2(image->height);
|
||||
texture->active_width = image->width;
|
||||
texture->active_height = image->height;
|
||||
texture->data = linearAlloc(texture->width * texture->height * sizeof(uint32_t));
|
||||
texture->type = filter_type;
|
||||
ctr_texture_t *texture = NULL;
|
||||
ctr_video_t *ctr = (ctr_video_t*)video_data;
|
||||
struct texture_image *image = (struct texture_image*)data;
|
||||
int size = image->width
|
||||
* image->height * sizeof(uint32_t);
|
||||
|
||||
if ((size * 3) > linearSpaceFree())
|
||||
return 0;
|
||||
|
||||
if (!ctr || !image || image->width > 2048 || image->height > 2048)
|
||||
return 0;
|
||||
|
||||
texture = (ctr_texture_t*)
|
||||
calloc(1, sizeof(ctr_texture_t));
|
||||
|
||||
texture->width = next_pow2(image->width);
|
||||
texture->height = next_pow2(image->height);
|
||||
texture->active_width = image->width;
|
||||
texture->active_height = image->height;
|
||||
texture->data = linearAlloc(
|
||||
texture->width * texture->height * sizeof(uint32_t));
|
||||
texture->type = filter_type;
|
||||
|
||||
if (!texture->data)
|
||||
{
|
||||
free(texture);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((image->width <= 32) || (image->height <= 32))
|
||||
{
|
||||
int i, j;
|
||||
@ -1136,34 +1141,51 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
|
||||
for (j = 0; j < image->height; j++)
|
||||
for (i = 0; i < image->width; i++)
|
||||
{
|
||||
((uint32_t*)texture->data)[ctrgu_swizzle_coords(i, j, texture->width)] =
|
||||
((*src >> 8) & 0x00FF00) | ((*src >> 24) & 0xFF)| ((*src << 8) & 0xFF0000)| ((*src << 24) & 0xFF000000);
|
||||
((uint32_t*)texture->data)[ctrgu_swizzle_coords(i, j,
|
||||
texture->width)] =
|
||||
((*src >> 8) & 0x00FF00)
|
||||
| ((*src >> 24) & 0xFF)
|
||||
| ((*src << 8) & 0xFF0000)
|
||||
| ((*src << 24) & 0xFF000000);
|
||||
src++;
|
||||
}
|
||||
GSPGPU_FlushDataCache(texture->data, texture->width * texture->height * sizeof(uint32_t));
|
||||
GSPGPU_FlushDataCache(texture->data, texture->width
|
||||
* texture->height * sizeof(uint32_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpdata = linearAlloc(image->width * image->height * sizeof(uint32_t));
|
||||
int i;
|
||||
uint32_t *src = NULL;
|
||||
uint32_t *dst = NULL;
|
||||
|
||||
tmpdata = linearAlloc(image->width
|
||||
* image->height * sizeof(uint32_t));
|
||||
if (!tmpdata)
|
||||
{
|
||||
free(texture->data);
|
||||
free(texture);
|
||||
return 0;
|
||||
}
|
||||
int i;
|
||||
uint32_t* src = (uint32_t*)image->pixels;
|
||||
uint32_t* dst = (uint32_t*)tmpdata;
|
||||
|
||||
src = (uint32_t*)image->pixels;
|
||||
dst = (uint32_t*)tmpdata;
|
||||
|
||||
for (i = 0; i < image->width * image->height; i++)
|
||||
{
|
||||
*dst = ((*src >> 8) & 0x00FF00) | ((*src >> 24) & 0xFF)| ((*src << 8) & 0xFF0000)| ((*src << 24) & 0xFF000000);
|
||||
*dst =
|
||||
((*src >> 8) & 0x00FF00)
|
||||
| ((*src >> 24) & 0xFF)
|
||||
| ((*src << 8) & 0xFF0000)
|
||||
| ((*src << 24) & 0xFF000000);
|
||||
dst++;
|
||||
src++;
|
||||
}
|
||||
|
||||
GSPGPU_FlushDataCache(tmpdata, image->width * image->height * sizeof(uint32_t));
|
||||
ctrGuCopyImage(true, tmpdata, image->width, image->height, CTRGU_RGBA8, false,
|
||||
texture->data, texture->width, CTRGU_RGBA8, true);
|
||||
GSPGPU_FlushDataCache(tmpdata,
|
||||
image->width * image->height * sizeof(uint32_t));
|
||||
ctrGuCopyImage(true, tmpdata,
|
||||
image->width, image->height, CTRGU_RGBA8, false,
|
||||
texture->data, texture->width, CTRGU_RGBA8, true);
|
||||
#if 0
|
||||
gspWaitForEvent(GSPGPU_EVENT_PPF, false);
|
||||
ctr->ppf_event_pending = false;
|
||||
@ -1176,7 +1198,8 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
|
||||
static void ctr_unload_texture(void *data, uintptr_t handle)
|
||||
static void ctr_unload_texture(void *data, bool threaded,
|
||||
uintptr_t handle)
|
||||
{
|
||||
struct ctr_texture *texture = (struct ctr_texture*)handle;
|
||||
|
||||
@ -1185,7 +1208,7 @@ static void ctr_unload_texture(void *data, uintptr_t handle)
|
||||
|
||||
if (texture->data)
|
||||
{
|
||||
if(((u32)texture->data & 0xFF000000) == 0x1F000000)
|
||||
if (((u32)texture->data & 0xFF000000) == 0x1F000000)
|
||||
vramFree(texture->data);
|
||||
else
|
||||
linearFree(texture->data);
|
||||
|
@ -1707,7 +1707,8 @@ static uintptr_t d3d10_gfx_load_texture(
|
||||
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
static void d3d10_gfx_unload_texture(void* data, uintptr_t handle)
|
||||
static void d3d10_gfx_unload_texture(void* data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
d3d10_texture_t* texture = (d3d10_texture_t*)handle;
|
||||
|
||||
|
@ -1789,7 +1789,8 @@ static uintptr_t d3d11_gfx_load_texture(
|
||||
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
static void d3d11_gfx_unload_texture(void* data, uintptr_t handle)
|
||||
static void d3d11_gfx_unload_texture(void* data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
d3d11_texture_t* texture = (d3d11_texture_t*)handle;
|
||||
|
||||
|
@ -1798,7 +1798,8 @@ static uintptr_t d3d12_gfx_load_texture(
|
||||
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
static void d3d12_gfx_unload_texture(void* data, uintptr_t handle)
|
||||
static void d3d12_gfx_unload_texture(void* data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
d3d12_texture_t* texture = (d3d12_texture_t*)handle;
|
||||
|
||||
|
@ -1763,7 +1763,8 @@ static uintptr_t d3d8_load_texture(void *video_data, void *data,
|
||||
return id;
|
||||
}
|
||||
|
||||
static void d3d8_unload_texture(void *data, uintptr_t id)
|
||||
static void d3d8_unload_texture(void *data, bool threaded,
|
||||
uintptr_t id)
|
||||
{
|
||||
LPDIRECT3DTEXTURE8 texid;
|
||||
if (!id)
|
||||
|
@ -1930,7 +1930,8 @@ static uintptr_t d3d9_load_texture(void *video_data, void *data,
|
||||
return id;
|
||||
}
|
||||
|
||||
static void d3d9_unload_texture(void *data, uintptr_t id)
|
||||
static void d3d9_unload_texture(void *data,
|
||||
bool threaded, uintptr_t id)
|
||||
{
|
||||
LPDIRECT3DTEXTURE9 texid;
|
||||
if (!id)
|
||||
|
@ -646,8 +646,8 @@ static uint32_t gcm_get_flags(void *data)
|
||||
|
||||
static const video_poke_interface_t gcm_poke_interface = {
|
||||
gcm_get_flags,
|
||||
NULL, /* load_texture */
|
||||
NULL, /* unload_texture */
|
||||
NULL, /* load_texture */
|
||||
NULL, /* unload_texture */
|
||||
NULL,
|
||||
NULL,
|
||||
gcm_set_filtering,
|
||||
|
@ -665,7 +665,8 @@ static uintptr_t gdi_load_texture(void *video_data, void *data,
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
|
||||
static void gdi_unload_texture(void *data, uintptr_t handle)
|
||||
static void gdi_unload_texture(void *data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
struct gdi_texture *texture = (struct gdi_texture*)handle;
|
||||
|
||||
|
@ -4489,7 +4489,8 @@ static uintptr_t gl2_load_texture(void *video_data, void *data,
|
||||
return id;
|
||||
}
|
||||
|
||||
static void gl2_unload_texture(void *data, uintptr_t id)
|
||||
static void gl2_unload_texture(void *data,
|
||||
bool threaded, uintptr_t id)
|
||||
{
|
||||
GLuint glid;
|
||||
if (!id)
|
||||
|
@ -1323,7 +1323,8 @@ static void gl1_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
gl1->should_resize = true;
|
||||
}
|
||||
|
||||
static void gl1_unload_texture(void *data, uintptr_t id)
|
||||
static void gl1_unload_texture(void *data,
|
||||
bool threaded, uintptr_t id)
|
||||
{
|
||||
GLuint glid;
|
||||
if (!id)
|
||||
|
@ -2097,7 +2097,8 @@ static uintptr_t gl_core_load_texture(void *video_data, void *data,
|
||||
return id;
|
||||
}
|
||||
|
||||
static void gl_core_unload_texture(void *data, uintptr_t id)
|
||||
static void gl_core_unload_texture(void *data, bool threaded,
|
||||
uintptr_t id)
|
||||
{
|
||||
GLuint glid;
|
||||
if (!id)
|
||||
|
@ -1606,7 +1606,8 @@ static uintptr_t wiiu_gfx_load_texture(void *video_data, void *data,
|
||||
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
static void wiiu_gfx_unload_texture(void *data, uintptr_t handle)
|
||||
static void wiiu_gfx_unload_texture(void *data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
GX2Texture *texture = (GX2Texture *)handle;
|
||||
|
||||
|
@ -307,7 +307,8 @@ static uintptr_t metal_load_texture(void *video_data, void *data,
|
||||
return (uintptr_t)(__bridge_retained void *)(t);
|
||||
}
|
||||
|
||||
static void metal_unload_texture(void *data, uintptr_t handle)
|
||||
static void metal_unload_texture(void *data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
@ -716,7 +716,8 @@ static uintptr_t vita_load_texture(void *video_data, void *data,
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
|
||||
static void vita_unload_texture(void *data, uintptr_t handle)
|
||||
static void vita_unload_texture(void *data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
struct vita2d_texture *texture = (struct vita2d_texture*)handle;
|
||||
if (!texture)
|
||||
@ -727,7 +728,9 @@ static void vita_unload_texture(void *data, uintptr_t handle)
|
||||
vita2d_wait_rendering_done();
|
||||
vita2d_free_texture(texture);
|
||||
|
||||
//free(texture);
|
||||
#if 0
|
||||
free(texture);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool vita_get_current_sw_framebuffer(void *data,
|
||||
|
@ -2494,7 +2494,8 @@ static uintptr_t vulkan_load_texture(void *video_data, void *data,
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
|
||||
static void vulkan_unload_texture(void *data, uintptr_t handle)
|
||||
static void vulkan_unload_texture(void *data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
vk_t *vk = (vk_t*)data;
|
||||
struct vk_texture *texture = (struct vk_texture*)handle;
|
||||
|
@ -312,18 +312,18 @@ const gfx_ctx_driver_t gfx_ctx_vk_android = {
|
||||
android_gfx_ctx_vk_set_swap_interval,
|
||||
android_gfx_ctx_vk_set_video_mode,
|
||||
android_gfx_ctx_vk_get_video_size,
|
||||
NULL, /* get_refresh_rate */
|
||||
NULL, /* get_video_output_size */
|
||||
NULL, /* get_video_output_prev */
|
||||
NULL, /* get_video_output_next */
|
||||
NULL, /* get_refresh_rate */
|
||||
NULL, /* get_video_output_size */
|
||||
NULL, /* get_video_output_prev */
|
||||
NULL, /* get_video_output_next */
|
||||
android_gfx_ctx_vk_get_metrics,
|
||||
NULL,
|
||||
NULL, /* update_title */
|
||||
NULL, /* update_title */
|
||||
android_gfx_ctx_vk_check_window,
|
||||
android_gfx_ctx_vk_set_resize,
|
||||
android_gfx_ctx_vk_has_focus,
|
||||
android_gfx_ctx_vk_suppress_screensaver,
|
||||
false, /* has_windowed */
|
||||
false, /* has_windowed */
|
||||
android_gfx_ctx_vk_swap_buffers,
|
||||
android_gfx_ctx_vk_input_driver,
|
||||
android_gfx_ctx_vk_get_proc_address,
|
||||
@ -335,5 +335,5 @@ const gfx_ctx_driver_t gfx_ctx_vk_android = {
|
||||
android_gfx_ctx_vk_set_flags,
|
||||
android_gfx_ctx_vk_bind_hw_render,
|
||||
android_gfx_ctx_vk_get_context_data,
|
||||
NULL
|
||||
NULL /* make_current */
|
||||
};
|
||||
|
@ -336,7 +336,7 @@ const gfx_ctx_driver_t gfx_ctx_w_vk = {
|
||||
gfx_ctx_w_vk_set_resize,
|
||||
win32_has_focus,
|
||||
win32_suppress_screensaver,
|
||||
true, /* has_windowed */
|
||||
true, /* has_windowed */
|
||||
gfx_ctx_w_vk_swap_buffers,
|
||||
gfx_ctx_w_vk_input_driver,
|
||||
NULL,
|
||||
@ -348,5 +348,5 @@ const gfx_ctx_driver_t gfx_ctx_w_vk = {
|
||||
gfx_ctx_w_vk_set_flags,
|
||||
gfx_ctx_w_vk_bind_hw_render,
|
||||
gfx_ctx_w_vk_get_context_data,
|
||||
NULL
|
||||
NULL /* make_current */
|
||||
};
|
||||
|
@ -1229,15 +1229,13 @@ static uintptr_t thread_load_texture(void *video_data, void *data,
|
||||
return thr->poke->load_texture(thr->driver_data, data, threaded, filter_type);
|
||||
}
|
||||
|
||||
static void thread_unload_texture(void *video_data, uintptr_t id)
|
||||
static void thread_unload_texture(void *video_data, bool threaded,
|
||||
uintptr_t id)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)video_data;
|
||||
|
||||
if (!thr)
|
||||
return;
|
||||
|
||||
if (thr->poke && thr->poke->unload_texture)
|
||||
thr->poke->unload_texture(thr->driver_data, id);
|
||||
if (thr && thr->poke && thr->poke->unload_texture)
|
||||
thr->poke->unload_texture(thr->driver_data, threaded,
|
||||
id);
|
||||
}
|
||||
|
||||
static void thread_apply_state_changes(void *data)
|
||||
|
@ -32936,7 +32936,10 @@ bool video_driver_texture_unload(uintptr_t *id)
|
||||
p_rarch->current_video_context.make_current(false);
|
||||
#endif
|
||||
|
||||
p_rarch->video_driver_poke->unload_texture(p_rarch->video_driver_data, *id);
|
||||
p_rarch->video_driver_poke->unload_texture(
|
||||
p_rarch->video_driver_data,
|
||||
VIDEO_DRIVER_IS_THREADED_INTERNAL(),
|
||||
*id);
|
||||
*id = 0;
|
||||
return true;
|
||||
}
|
||||
|
@ -1307,7 +1307,7 @@ typedef struct gfx_ctx_driver
|
||||
* which do not have global context state. */
|
||||
void *(*get_context_data)(void *data);
|
||||
|
||||
/* Optional. Makes driver context (only GLX right now)
|
||||
/* Optional. Makes driver context (only GL right now)
|
||||
* active for this thread. */
|
||||
void (*make_current)(bool release);
|
||||
} gfx_ctx_driver_t;
|
||||
@ -1376,7 +1376,7 @@ typedef struct video_poke_interface
|
||||
uint32_t (*get_flags)(void *data);
|
||||
uintptr_t (*load_texture)(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type);
|
||||
void (*unload_texture)(void *data, uintptr_t id);
|
||||
void (*unload_texture)(void *data, bool threaded, uintptr_t id);
|
||||
void (*set_video_mode)(void *data, unsigned width,
|
||||
unsigned height, bool fullscreen);
|
||||
float (*get_refresh_rate)(void *data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user