mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
(D3D9) Make video texture load functions thread-safe
This commit is contained in:
parent
a8af4ee8c6
commit
843a7f200c
@ -1646,18 +1646,28 @@ static void d3d9_set_menu_texture_enable(void *data,
|
||||
d3d->menu->fullscreen = full_screen;
|
||||
}
|
||||
|
||||
static void d3d9_video_texture_load_d3d(d3d_video_t *d3d,
|
||||
struct texture_image *ti,
|
||||
enum texture_filter_type filter_type,
|
||||
struct d3d9_texture_info
|
||||
{
|
||||
void *userdata;
|
||||
void *data;
|
||||
enum texture_filter_type type;
|
||||
};
|
||||
|
||||
static void d3d9_video_texture_load_d3d(struct d3d9_texture_info *info,
|
||||
uintptr_t *id)
|
||||
{
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
LPDIRECT3DTEXTURE9 tex = NULL;
|
||||
unsigned usage = 0;
|
||||
bool want_mipmap = false;
|
||||
LPDIRECT3DTEXTURE9 tex = NULL;
|
||||
unsigned usage = 0;
|
||||
bool want_mipmap = false;
|
||||
d3d_video_t *d3d = (d3d_video_t*)info->userdata;
|
||||
struct texture_image *ti = (struct texture_image*)info->data;
|
||||
|
||||
if((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) ||
|
||||
(filter_type == TEXTURE_FILTER_MIPMAP_NEAREST))
|
||||
if (!ti)
|
||||
return;
|
||||
|
||||
if((info->type == TEXTURE_FILTER_MIPMAP_LINEAR) ||
|
||||
(info->type == TEXTURE_FILTER_MIPMAP_NEAREST))
|
||||
want_mipmap = true;
|
||||
|
||||
tex = (LPDIRECT3DTEXTURE9)d3d_texture_new(d3d->dev, NULL,
|
||||
@ -1688,19 +1698,14 @@ static void d3d9_video_texture_load_d3d(d3d_video_t *d3d,
|
||||
*id = (uintptr_t)tex;
|
||||
}
|
||||
|
||||
static int d3d9_video_texture_load_wrap_d3d_mipmap(void *data)
|
||||
{
|
||||
uintptr_t id = 0;
|
||||
d3d9_video_texture_load_d3d((d3d_video_t*)video_driver_get_ptr(true),
|
||||
(struct texture_image*)data, TEXTURE_FILTER_MIPMAP_LINEAR, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
static int d3d9_video_texture_load_wrap_d3d(void *data)
|
||||
{
|
||||
uintptr_t id = 0;
|
||||
d3d9_video_texture_load_d3d((d3d_video_t*)video_driver_get_ptr(true),
|
||||
(struct texture_image*)data, TEXTURE_FILTER_LINEAR, &id);
|
||||
struct d3d9_texture_info *info = (struct d3d9_texture_info*)data;
|
||||
if (!info)
|
||||
return 0;
|
||||
d3d9_video_texture_load_d3d(info, &id);
|
||||
free(info);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -1708,27 +1713,20 @@ static uintptr_t d3d9_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
uintptr_t id = 0;
|
||||
struct d3d9_texture_info *info = (struct d3d9_texture_info*)calloc(1, sizeof(*info));
|
||||
|
||||
if (!info)
|
||||
return 0;
|
||||
|
||||
info->userdata = video_data;
|
||||
info->data = data;
|
||||
info->type = filter_type;
|
||||
|
||||
if (threaded)
|
||||
{
|
||||
custom_command_method_t func = d3d9_video_texture_load_wrap_d3d;
|
||||
return video_thread_texture_load(info, d3d9_video_texture_load_wrap_d3d);
|
||||
|
||||
switch (filter_type)
|
||||
{
|
||||
case TEXTURE_FILTER_MIPMAP_LINEAR:
|
||||
case TEXTURE_FILTER_MIPMAP_NEAREST:
|
||||
func = d3d9_video_texture_load_wrap_d3d_mipmap;
|
||||
break;
|
||||
default:
|
||||
func = d3d9_video_texture_load_wrap_d3d;
|
||||
break;
|
||||
}
|
||||
|
||||
return video_thread_texture_load(data, func);
|
||||
}
|
||||
|
||||
d3d9_video_texture_load_d3d((d3d_video_t*)video_driver_get_ptr(false),
|
||||
(struct texture_image*)data, filter_type, &id);
|
||||
d3d9_video_texture_load_d3d(info, &id);
|
||||
free(info);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user