mirror of
https://github.com/mpv-player/mpv
synced 2025-03-02 20:28:02 +00:00
vo_gpu: attempt re-using the FBO format for p->output_tex
This allows RAs with support for non-opaque FBO formats to use a more appropriate FBO format for the output tex, possibly enabling a more efficient blit operation. This requires distinguishing between real formats (which can be used to create textures) and fake formats (e.g. ra_gl's FBO hack).
This commit is contained in:
parent
80540be211
commit
a42b8b1142
@ -85,6 +85,8 @@ struct ra_format {
|
||||
// only applies to 2-component textures
|
||||
bool linear_filter; // linear filtering available from shader
|
||||
bool renderable; // can be used for render targets
|
||||
bool dummy_format; // is not a real ra_format but a fake one (e.g. FBO).
|
||||
// dummy formats cannot be used to create textures
|
||||
|
||||
// If not 0, the format represents some sort of packed fringe format, whose
|
||||
// shader representation is given by the special_imgfmt_desc pointer.
|
||||
|
@ -3069,9 +3069,15 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,
|
||||
if (frame->num_vsyncs > 1 && frame->display_synced &&
|
||||
!p->dumb_mode && (p->ra->caps & RA_CAP_BLIT))
|
||||
{
|
||||
// Attempt to use the same format as the destination FBO
|
||||
// if possible. Some RAs use a wrapped dummy format here,
|
||||
// so fall back to the fbo_format in that case.
|
||||
const struct ra_format *fmt = fbo.tex->params.format;
|
||||
if (fmt->dummy_format)
|
||||
fmt = p->fbo_format;
|
||||
bool r = ra_tex_resize(p->ra, p->log, &p->output_tex,
|
||||
fbo.tex->params.w, fbo.tex->params.h,
|
||||
p->fbo_format);
|
||||
fmt);
|
||||
if (r) {
|
||||
dest_fbo = (struct ra_fbo) { p->output_tex };
|
||||
p->output_tex_valid = true;
|
||||
|
@ -283,6 +283,8 @@ static struct ra_tex *gl_tex_create(struct ra *ra,
|
||||
const struct ra_tex_params *params)
|
||||
{
|
||||
GL *gl = ra_gl_get(ra);
|
||||
assert(!params->format->dummy_format);
|
||||
|
||||
struct ra_tex *tex = gl_tex_create_blank(ra, params);
|
||||
if (!tex)
|
||||
return NULL;
|
||||
@ -382,6 +384,7 @@ static const struct ra_format fbo_dummy_format = {
|
||||
.flags = F_CR,
|
||||
},
|
||||
.renderable = true,
|
||||
.dummy_format = true,
|
||||
};
|
||||
|
||||
// Create a ra_tex that merely wraps an existing framebuffer. gl_fbo can be 0
|
||||
|
@ -511,6 +511,7 @@ static struct ra_tex *vk_tex_create(struct ra *ra,
|
||||
const struct ra_tex_params *params)
|
||||
{
|
||||
struct mpvk_ctx *vk = ra_vk_get(ra);
|
||||
assert(!params->format->dummy_format);
|
||||
|
||||
struct ra_tex *tex = talloc_zero(NULL, struct ra_tex);
|
||||
tex->params = *params;
|
||||
|
Loading…
Reference in New Issue
Block a user