diff --git a/gfx/video_driver.c b/gfx/video_driver.c index f3f3f1a836..2dc7e2ff23 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1422,9 +1422,20 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) const video_driver_t *video = video_driver_ctx_get_ptr(driver); const video_poke_interface_t *poke = video_driver_get_poke_ptr(driver); settings_t *settings = config_get_ptr(); + const struct retro_hw_render_callback *hw_render = + (const struct retro_hw_render_callback*)video_driver_callback(); switch (state) { + case RARCH_DISPLAY_CTL_SUPPORTS_RECORDING: + return settings->video.gpu_record && driver->current_video->read_viewport; + case RARCH_DISPLAY_CTL_SUPPORTS_VIEWPORT_READ: + return (settings->video.gpu_screenshot || + ((hw_render->context_type + != RETRO_HW_CONTEXT_NONE) && !driver->current_video->read_frame_raw)) + && driver->current_video->read_viewport && driver->current_video->viewport_info; + case RARCH_DISPLAY_CTL_SUPPORTS_READ_FRAME_RAW: + return driver->current_video->read_frame_raw; case RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG: return video_viewport_set_config(); case RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL: @@ -1531,6 +1542,8 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) return false; return (video_state.frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID); case RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER: + if (!driver->current_video) + return false; return video_driver_cached_frame(driver); case RARCH_DISPLAY_CTL_IS_ALIVE: return video->alive(driver->video_data); diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 087679349a..42b5a8ed2a 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -299,6 +299,9 @@ enum rarch_display_ctl_state RARCH_DISPLAY_CTL_GET_PREV_VIDEO_OUT, RARCH_DISPLAY_CTL_GET_NEXT_VIDEO_OUT, RARCH_DISPLAY_CTL_HAS_WINDOWED, + RARCH_DISPLAY_CTL_SUPPORTS_RECORDING, + RARCH_DISPLAY_CTL_SUPPORTS_VIEWPORT_READ, + RARCH_DISPLAY_CTL_SUPPORTS_READ_FRAME_RAW, RARCH_DISPLAY_CTL_IS_FOCUSED, RARCH_DISPLAY_CTL_IS_ALIVE, RARCH_DISPLAY_CTL_SET_ASPECT_RATIO, diff --git a/record/record_driver.c b/record/record_driver.c index 0b7a71f34b..05d35c23e2 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -317,7 +317,7 @@ bool recording_init(void) if (*global->record.config) params.config = global->record.config; - if (settings->video.gpu_record && driver->current_video->read_viewport) + if (video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RECORDING, NULL)) { struct video_viewport vp = {0}; diff --git a/screenshot.c b/screenshot.c index 2d169aa14f..9b22332e44 100644 --- a/screenshot.c +++ b/screenshot.c @@ -61,18 +61,16 @@ static bool screenshot_dump(const char *folder, const void *frame, struct scaler_ctx scaler = {0}; RFILE *file = NULL; uint8_t *out_buffer = NULL; - driver_t *driver = driver_get_ptr(); (void)file; (void)out_buffer; (void)scaler; - (void)driver; fill_dated_filename(shotname, IMG_EXT, sizeof(shotname)); fill_pathname_join(filename, folder, shotname, sizeof(filename)); #ifdef _XBOX1 - d3d_video_t *d3d = (d3d_video_t*)driver->video_data; + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true); settings_t *settings = config_get_ptr(); D3DSurface *surf = NULL; @@ -207,35 +205,27 @@ bool take_screenshot(void) bool viewport_read = false; bool ret = true; const char *msg = NULL; - driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - const struct retro_hw_render_callback *hw_render = - (const struct retro_hw_render_callback*)video_driver_callback(); /* No way to infer screenshot directory. */ if ((!*settings->screenshot_directory) && (!*global->name.base)) return false; - viewport_read = (settings->video.gpu_screenshot || - ((hw_render->context_type - != RETRO_HW_CONTEXT_NONE) && !driver->current_video->read_frame_raw)) - && driver->current_video->read_viewport && driver->current_video->viewport_info; + viewport_read = video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_VIEWPORT_READ, NULL); if (viewport_read) { /* Avoid taking screenshot of GUI overlays. */ video_driver_set_texture_enable(false, false); - - if (driver->current_video) - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); } if (viewport_read) ret = take_screenshot_viewport(); else if (!video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB, NULL)) ret = take_screenshot_raw(); - else if (driver->current_video->read_frame_raw) + else if (video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_READ_FRAME_RAW, NULL)) { unsigned old_width, old_height; size_t old_pitch;