diff options
author | Niklas Haas <git@haasn.xyz> | 2017-08-19 04:33:40 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-08-22 09:55:49 +0200 |
commit | 09c501a40eed7cb05c73fc30ea814d1d256ac0eb (patch) | |
tree | 2508bf03c8a22b098d955ddc7b3abc328d089296 /video/out/opengl/utils.h | |
parent | 371000108acb40a99412316fe1bba2883441c38a (diff) | |
download | mpv-09c501a40eed7cb05c73fc30ea814d1d256ac0eb.tar.bz2 mpv-09c501a40eed7cb05c73fc30ea814d1d256ac0eb.tar.xz |
vo_opengl: refactor tex_upload to ra_buf_pool
Also refactors the usage of tex_upload to make ra_tex_upload_pbo a
RA-internal thing again.
ra_buf_pool has the main advantage of being dynamically sized depending
on buf_poll, so for OpenGL we'll end up only using one buffer (when not
persistently mapping) - while for vulkan we'll use as many as necessary,
which depends on the swapchain depth anyway.
Diffstat (limited to 'video/out/opengl/utils.h')
-rw-r--r-- | video/out/opengl/utils.h | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/video/out/opengl/utils.h b/video/out/opengl/utils.h index aaaf4bd12e..8c52680f14 100644 --- a/video/out/opengl/utils.h +++ b/video/out/opengl/utils.h @@ -69,6 +69,25 @@ struct fbodst { void gl_transform_ortho_fbodst(struct gl_transform *t, struct fbodst fbo); +// A pool of buffers, which can grow as needed +struct ra_buf_pool { + struct ra_buf_params current_params; + struct ra_buf **buffers; + int num_buffers; + int index; +}; + +void ra_buf_pool_uninit(struct ra *ra, struct ra_buf_pool *pool); + +// Note: params->initial_data is *not* supported +struct ra_buf *ra_buf_pool_get(struct ra *ra, struct ra_buf_pool *pool, + const struct ra_buf_params *params); + +// Helper that wraps ra_tex_upload using texture upload buffers to ensure that +// params->buf is always set. This is intended for RA-internal usage. +bool ra_tex_upload_pbo(struct ra *ra, struct ra_buf_pool *pbo, + const struct ra_tex_upload_params *params); + struct fbotex { struct ra *ra; struct ra_tex *tex; @@ -83,21 +102,6 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, #define FBOTEX_FUZZY_H 2 #define FBOTEX_FUZZY (FBOTEX_FUZZY_W | FBOTEX_FUZZY_H) -#define NUM_PBO_BUFFERS 3 - -// A wrapper around tex_upload that uses PBOs internally if requested or -// required -struct tex_upload { - size_t buffer_size; - struct ra_buf *buffers[NUM_PBO_BUFFERS]; - int index; -}; - -bool tex_upload(struct ra *ra, struct tex_upload *pbo, bool want_pbo, - const struct ra_tex_upload_params *params); - -void tex_upload_uninit(struct ra *ra, struct tex_upload *pbo); - // A wrapper around ra_timer that does result pooling, averaging etc. struct timer_pool; |