mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-20 07:42:38 +00:00
move gpu record buffer to video_driver.c
This commit is contained in:
parent
c4d1f2c49d
commit
bbbf6513fd
@ -1199,9 +1199,6 @@ bool event_command(enum event_command cmd)
|
||||
#endif
|
||||
break;
|
||||
case EVENT_CMD_DSP_FILTER_DEINIT:
|
||||
if (!global)
|
||||
break;
|
||||
|
||||
audio_driver_dsp_filter_free();
|
||||
break;
|
||||
case EVENT_CMD_DSP_FILTER_INIT:
|
||||
@ -1211,12 +1208,7 @@ bool event_command(enum event_command cmd)
|
||||
audio_driver_dsp_filter_init(settings->audio.dsp_plugin);
|
||||
break;
|
||||
case EVENT_CMD_GPU_RECORD_DEINIT:
|
||||
if (!global)
|
||||
break;
|
||||
|
||||
if (global->record.gpu_buffer)
|
||||
free(global->record.gpu_buffer);
|
||||
global->record.gpu_buffer = NULL;
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT, NULL);
|
||||
break;
|
||||
case EVENT_CMD_RECORD_DEINIT:
|
||||
if (!recording_deinit())
|
||||
|
@ -1395,6 +1395,7 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_hw_render_callback *hw_render =
|
||||
(const struct retro_hw_render_callback*)video_driver_callback();
|
||||
static uint8_t *video_driver_record_gpu_buffer = NULL;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
@ -1661,6 +1662,33 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
|
||||
break;
|
||||
case RARCH_DISPLAY_CTL_IS_ACTIVE:
|
||||
return video_driver_active;
|
||||
case RARCH_DISPLAY_CTL_HAS_GPU_RECORD:
|
||||
return (video_driver_record_gpu_buffer != NULL);
|
||||
case RARCH_DISPLAY_CTL_GPU_RECORD_GET:
|
||||
{
|
||||
uint8_t **new_data = (uint8_t**)data;
|
||||
|
||||
if (!new_data)
|
||||
return false;
|
||||
*new_data = video_driver_record_gpu_buffer;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case RARCH_DISPLAY_CTL_GPU_RECORD_INIT:
|
||||
{
|
||||
unsigned *new_size = (unsigned*)data;
|
||||
if (!new_size)
|
||||
return false;
|
||||
video_driver_record_gpu_buffer = (uint8_t*)malloc(*new_size);
|
||||
if (!video_driver_record_gpu_buffer)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
case RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT:
|
||||
if (video_driver_record_gpu_buffer)
|
||||
free(video_driver_record_gpu_buffer);
|
||||
video_driver_record_gpu_buffer = NULL;
|
||||
break;
|
||||
case RARCH_DISPLAY_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
@ -1820,7 +1848,6 @@ void video_driver_frame(const void *data, unsigned width,
|
||||
unsigned output_height = 0;
|
||||
unsigned output_pitch = 0;
|
||||
const char *msg = NULL;
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_ACTIVE, NULL))
|
||||
@ -1844,7 +1871,7 @@ void video_driver_frame(const void *data, unsigned width,
|
||||
!video_driver_state.filter.filter
|
||||
|| !settings->video.post_filter_record
|
||||
|| !data
|
||||
|| (global && global->record.gpu_buffer)
|
||||
|| video_driver_ctl(RARCH_DISPLAY_CTL_HAS_GPU_RECORD, NULL)
|
||||
)
|
||||
)
|
||||
recording_dump_frame(data, width, height, pitch);
|
||||
|
@ -145,7 +145,11 @@ enum rarch_display_ctl_state
|
||||
RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT_ACK,
|
||||
RARCH_DISPLAY_CTL_SET_ACTIVE,
|
||||
RARCH_DISPLAY_CTL_UNSET_ACTIVE,
|
||||
RARCH_DISPLAY_CTL_IS_ACTIVE
|
||||
RARCH_DISPLAY_CTL_IS_ACTIVE,
|
||||
RARCH_DISPLAY_CTL_HAS_GPU_RECORD,
|
||||
RARCH_DISPLAY_CTL_GPU_RECORD_GET,
|
||||
RARCH_DISPLAY_CTL_GPU_RECORD_INIT,
|
||||
RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT
|
||||
};
|
||||
|
||||
typedef struct video_info
|
||||
|
@ -177,8 +177,9 @@ void recording_dump_frame(const void *data, unsigned width,
|
||||
ffemu_data.height = height;
|
||||
ffemu_data.data = data;
|
||||
|
||||
if (global->record.gpu_buffer)
|
||||
if (video_driver_ctl(RARCH_DISPLAY_CTL_HAS_GPU_RECORD, NULL))
|
||||
{
|
||||
uint8_t *gpu_buf = NULL;
|
||||
struct video_viewport vp = {0};
|
||||
|
||||
video_driver_viewport_info(&vp);
|
||||
@ -204,22 +205,24 @@ void recording_dump_frame(const void *data, unsigned width,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!video_driver_ctl(RARCH_DISPLAY_CTL_GPU_RECORD_GET, &gpu_buf))
|
||||
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_ctl(RARCH_DISPLAY_CTL_READ_VIEWPORT, global->record.gpu_buffer))
|
||||
if (!video_driver_ctl(RARCH_DISPLAY_CTL_READ_VIEWPORT, gpu_buf))
|
||||
return;
|
||||
|
||||
ffemu_data.pitch = global->record.gpu_width * 3;
|
||||
ffemu_data.width = global->record.gpu_width;
|
||||
ffemu_data.height = global->record.gpu_height;
|
||||
ffemu_data.data = global->record.gpu_buffer +
|
||||
(ffemu_data.height - 1) * ffemu_data.pitch;
|
||||
ffemu_data.data = gpu_buf + (ffemu_data.height - 1) * ffemu_data.pitch;
|
||||
|
||||
ffemu_data.pitch = -ffemu_data.pitch;
|
||||
}
|
||||
|
||||
if (!global->record.gpu_buffer)
|
||||
if (!video_driver_ctl(RARCH_DISPLAY_CTL_HAS_GPU_RECORD, NULL))
|
||||
ffemu_data.is_dupe = !data;
|
||||
|
||||
if (recording_driver && recording_driver->push_video)
|
||||
@ -331,6 +334,7 @@ bool recording_init(void)
|
||||
|
||||
if (video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RECORDING, NULL))
|
||||
{
|
||||
unsigned gpu_size;
|
||||
struct video_viewport vp = {0};
|
||||
|
||||
video_driver_viewport_info(&vp);
|
||||
@ -360,8 +364,8 @@ bool recording_init(void)
|
||||
RARCH_LOG("%s %u x %u\n", msg_hash_to_str(MSG_DETECTED_VIEWPORT_OF),
|
||||
vp.width, vp.height);
|
||||
|
||||
global->record.gpu_buffer = (uint8_t*)malloc(vp.width * vp.height * 3);
|
||||
if (!global->record.gpu_buffer)
|
||||
gpu_size = vp.width * vp.height * 3;
|
||||
if (!video_driver_ctl(RARCH_DISPLAY_CTL_GPU_RECORD_INIT, &gpu_size))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user