mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Move readback function to renderchain
This commit is contained in:
parent
c825f849f5
commit
5f7527df08
@ -919,7 +919,6 @@ static struct video_shader *gl_get_current_shader(void *data)
|
|||||||
return shader_info.data;
|
return shader_info.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GL_ASYNC_READBACK
|
|
||||||
static void gl_pbo_async_readback(gl_t *gl)
|
static void gl_pbo_async_readback(gl_t *gl)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENGLES3
|
#ifdef HAVE_OPENGLES3
|
||||||
@ -938,18 +937,13 @@ static void gl_pbo_async_readback(gl_t *gl)
|
|||||||
/* 4 frames back, we can readback. */
|
/* 4 frames back, we can readback. */
|
||||||
gl->pbo_readback_valid[gl->pbo_readback_index] = true;
|
gl->pbo_readback_valid[gl->pbo_readback_index] = true;
|
||||||
|
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT,
|
if (gl->renderchain_driver->readback)
|
||||||
video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t)));
|
gl->renderchain_driver->readback(gl,
|
||||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t)),
|
||||||
glReadBuffer(GL_BACK);
|
fmt, type, NULL);
|
||||||
|
|
||||||
glReadPixels(gl->vp.x, gl->vp.y,
|
|
||||||
gl->vp.width, gl->vp.height,
|
|
||||||
fmt, type, NULL);
|
|
||||||
if (gl->renderchain_driver->unbind_pbo)
|
if (gl->renderchain_driver->unbind_pbo)
|
||||||
gl->renderchain_driver->unbind_pbo();
|
gl->renderchain_driver->unbind_pbo();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
|
static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
|
||||||
{
|
{
|
||||||
@ -1226,17 +1220,12 @@ static bool gl_frame(void *data, const void *frame,
|
|||||||
/* Screenshots. */
|
/* Screenshots. */
|
||||||
if (gl->readback_buffer_screenshot)
|
if (gl->readback_buffer_screenshot)
|
||||||
{
|
{
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
if (gl->renderchain_driver->readback)
|
||||||
#ifndef HAVE_OPENGLES
|
gl->renderchain_driver->readback(gl,
|
||||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
4, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||||
glReadBuffer(GL_BACK);
|
gl->readback_buffer_screenshot);
|
||||||
#endif
|
|
||||||
glReadPixels(gl->vp.x, gl->vp.y,
|
|
||||||
gl->vp.width, gl->vp.height,
|
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, gl->readback_buffer_screenshot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GL_ASYNC_READBACK
|
|
||||||
/* Don't readback if we're in menu mode. */
|
/* Don't readback if we're in menu mode. */
|
||||||
else if (gl->pbo_readback_enable)
|
else if (gl->pbo_readback_enable)
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
@ -1244,7 +1233,6 @@ static bool gl_frame(void *data, const void *frame,
|
|||||||
if (!gl->menu_texture_enable)
|
if (!gl->menu_texture_enable)
|
||||||
#endif
|
#endif
|
||||||
gl_pbo_async_readback(gl);
|
gl_pbo_async_readback(gl);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Disable BFI during fast forward, slow-motion,
|
/* Disable BFI during fast forward, slow-motion,
|
||||||
* and pause to prevent flicker. */
|
* and pause to prevent flicker. */
|
||||||
@ -1543,7 +1531,6 @@ static INLINE void gl_set_texture_fmts(gl_t *gl, bool rgb32)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GL_ASYNC_READBACK
|
|
||||||
static bool gl_init_pbo_readback(gl_t *gl)
|
static bool gl_init_pbo_readback(gl_t *gl)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -1585,7 +1572,6 @@ static bool gl_init_pbo_readback(gl_t *gl)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
|
static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
|
||||||
{
|
{
|
||||||
|
@ -1365,7 +1365,26 @@ static void gl2_renderchain_init_pbo(unsigned size,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gl2_renderchain_readback(void *data,
|
||||||
|
unsigned alignment,
|
||||||
|
unsigned fmt, unsigned type,
|
||||||
|
void *src)
|
||||||
|
{
|
||||||
|
gl_t *gl = (gl_t*)data;
|
||||||
|
|
||||||
|
glPixelStorei(GL_PACK_ALIGNMENT, alignment);
|
||||||
|
#ifndef HAVE_OPENGLES
|
||||||
|
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||||
|
glReadBuffer(GL_BACK);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
glReadPixels(gl->vp.x, gl->vp.y,
|
||||||
|
gl->vp.width, gl->vp.height,
|
||||||
|
(GLenum)fmt, (GLenum)type, (GLvoid*)src);
|
||||||
|
}
|
||||||
|
|
||||||
gl_renderchain_driver_t gl2_renderchain = {
|
gl_renderchain_driver_t gl2_renderchain = {
|
||||||
|
gl2_renderchain_readback,
|
||||||
gl2_renderchain_init_pbo,
|
gl2_renderchain_init_pbo,
|
||||||
gl2_renderchain_bind_pbo,
|
gl2_renderchain_bind_pbo,
|
||||||
gl2_renderchain_unbind_pbo,
|
gl2_renderchain_unbind_pbo,
|
||||||
|
@ -827,6 +827,10 @@ typedef struct d3d_renderchain_driver
|
|||||||
|
|
||||||
typedef struct gl_renderchain_driver
|
typedef struct gl_renderchain_driver
|
||||||
{
|
{
|
||||||
|
void (*readback)(void *data,
|
||||||
|
unsigned alignment,
|
||||||
|
unsigned fmt, unsigned type,
|
||||||
|
void *src);
|
||||||
void (*init_pbo)(unsigned size, const void *data);
|
void (*init_pbo)(unsigned size, const void *data);
|
||||||
void (*bind_pbo)(unsigned idx);
|
void (*bind_pbo)(unsigned idx);
|
||||||
void (*unbind_pbo)(void);
|
void (*unbind_pbo)(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user