From 01058b16f98d57ed5ce8637731e1d56d44dbcc5c Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Fri, 18 Aug 2017 02:04:29 +0200 Subject: vo_opengl: allow texture uploads to fail Surprisingly makes the code shorter, not longer --- video/out/opengl/ra.h | 4 ++-- video/out/opengl/ra_gl.c | 4 +++- video/out/opengl/utils.c | 9 +++------ 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'video') diff --git a/video/out/opengl/ra.h b/video/out/opengl/ra.h index f0798f018c..eee1728bba 100644 --- a/video/out/opengl/ra.h +++ b/video/out/opengl/ra.h @@ -321,8 +321,8 @@ struct ra_fns { // the image - conversions between bit depth etc. are not supported. // The buffer *may* be marked as "in use" while this operation is going on, // and the contents must not be touched again by the API user until - // buf_poll returns true. - void (*tex_upload)(struct ra *ra, const struct ra_tex_upload_params *params); + // buf_poll returns true. Returns whether successful. + bool (*tex_upload)(struct ra *ra, const struct ra_tex_upload_params *params); // Create a buffer. This can be used as a persistently mapped buffer, // a uniform buffer, a shader storage buffer or possibly others. diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index 36109753aa..f63bbe3ea5 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -424,7 +424,7 @@ bool ra_is_gl(struct ra *ra) return ra->fns == &ra_fns_gl; } -static void gl_tex_upload(struct ra *ra, +static bool gl_tex_upload(struct ra *ra, const struct ra_tex_upload_params *params) { GL *gl = ra_gl_get(ra); @@ -480,6 +480,8 @@ static void gl_tex_upload(struct ra *ra, buf_gl->fence = gl->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); } } + + return true; } static void gl_buf_destroy(struct ra *ra, struct ra_buf *buf) diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 2a120dd5e3..5ef4349fff 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -126,10 +126,8 @@ bool tex_upload(struct ra *ra, struct tex_upload *pbo, bool want_pbo, if (!(ra->caps & RA_CAP_DIRECT_UPLOAD)) want_pbo = true; - if (!want_pbo || params->buf) { - ra->fns->tex_upload(ra, params); - return true; - } + if (!want_pbo || params->buf) + return ra->fns->tex_upload(ra, params); struct ra_tex *tex = params->tex; size_t row_size = tex->params.dimensions == 2 ? params->stride : @@ -169,8 +167,7 @@ bool tex_upload(struct ra *ra, struct tex_upload *pbo, bool want_pbo, newparams.buf = buf; newparams.src = NULL; - ra->fns->tex_upload(ra, &newparams); - return true; + return ra->fns->tex_upload(ra, &newparams); } void tex_upload_uninit(struct ra *ra, struct tex_upload *pbo) -- cgit v1.2.3