diff options
author | Niklas Haas <git@haasn.xyz> | 2017-09-20 10:45:33 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-09-22 16:58:55 +0200 |
commit | 62ddc85d178e647e8cfbee6da4d173c661b4f1fc (patch) | |
tree | ab58cbd56fe8a6251ada92f7b75e002e52e0d430 /video/out/gpu/utils.c | |
parent | 2af2fa7a27586f6938f4db8f45e316212e18e442 (diff) | |
download | mpv-62ddc85d178e647e8cfbee6da4d173c661b4f1fc.tar.bz2 mpv-62ddc85d178e647e8cfbee6da4d173c661b4f1fc.tar.xz |
vo_gpu: simplify structs / names
Due to the plethora of historical baggage from different eras getting
confusing, I decided to simplify and unify the struct organization and
naming scheme.
Structs that got renamed:
1. fbodst -> ra_fbo (and moved to gpu/context.h)
2. fbotex -> removed (redundant after 2af2fa7a)
3. fbosurface -> surface
4. img_tex -> image
In addition to these structs being renamed, all of the names have been
made consistent. The new scheme is as follows:
struct image img;
struct ra_tex *tex;
struct ra_fbo fbo;
This also affects derived names, e.g. indirect_fbo -> indirect_tex.
Notably also, finish_pass_fbo -> finish_pass_tex and finish_pass_direct
-> finish_pass_fbo.
The new equivalent of fbotex_change() is called ra_tex_resize().
This commit (should) contain no logic changes, just renaming a bunch of
crap.
Diffstat (limited to 'video/out/gpu/utils.c')
-rw-r--r-- | video/out/gpu/utils.c | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/video/out/gpu/utils.c b/video/out/gpu/utils.c index 38d1e9b7cd..daf570cba5 100644 --- a/video/out/gpu/utils.c +++ b/video/out/gpu/utils.c @@ -33,7 +33,7 @@ void gl_transform_trans(struct gl_transform t, struct gl_transform *x) gl_transform_vec(t, &x->t[0], &x->t[1]); } -void gl_transform_ortho_fbodst(struct gl_transform *t, struct fbodst fbo) +void gl_transform_ortho_fbo(struct gl_transform *t, struct ra_fbo fbo) { int y_dir = fbo.flip ? -1 : 1; gl_transform_ortho(t, 0, fbo.tex->params.w, 0, fbo.tex->params.h * y_dir); @@ -167,35 +167,24 @@ struct ra_layout std430_layout(struct ra_renderpass_input *inp) }; } -// Create a texture and a FBO using the texture as color attachments. -// fmt: texture internal format -// If the parameters are the same as the previous call, do not touch it. -bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, +// Resize a texture to a new desired size and format if necessary +bool ra_tex_resize(struct ra *ra, struct mp_log *log, struct ra_tex **tex, int w, int h, const struct ra_format *fmt) { - int lw = w, lh = h; - - if (fbo->tex) { - int cw = w, ch = h; - int rw = fbo->tex->params.w, rh = fbo->tex->params.h; - - if (rw == cw && rh == ch && fbo->tex->params.format == fmt) - goto done; + if (*tex) { + struct ra_tex_params cur_params = (*tex)->params; + if (cur_params.w == w && cur_params.h == h && cur_params.format == fmt) + return true; } - mp_verbose(log, "Create FBO: %dx%d (%dx%d)\n", lw, lh, w, h); + mp_verbose(log, "Resizing texture: %dx%d\n", w, h); if (!fmt || !fmt->renderable || !fmt->linear_filter) { mp_err(log, "Format %s not supported.\n", fmt ? fmt->name : "(unset)"); return false; } - fbotex_uninit(fbo); - - *fbo = (struct fbotex) { - .ra = ra, - }; - + ra_tex_free(ra, tex); struct ra_tex_params params = { .dimensions = 2, .w = w, @@ -209,32 +198,11 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, .blit_src = true, }; - fbo->tex = ra_tex_create(fbo->ra, ¶ms); - - if (!fbo->tex) { - mp_err(log, "Error: framebuffer could not be created.\n"); - fbotex_uninit(fbo); - return false; - } - -done: + *tex = ra_tex_create(ra, ¶ms); + if (!*tex) + mp_err(log, "Error: texture could not be created.\n"); - fbo->lw = lw; - fbo->lh = lh; - - fbo->fbo = (struct fbodst){ - .tex = fbo->tex, - }; - - return true; -} - -void fbotex_uninit(struct fbotex *fbo) -{ - if (fbo->ra) { - ra_tex_free(fbo->ra, &fbo->tex); - *fbo = (struct fbotex) {0}; - } + return *tex; } struct timer_pool { |