diff options
author | Niklas Haas <git@haasn.xyz> | 2017-08-26 05:33:00 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-08-27 14:36:00 +0200 |
commit | 45bae90f4d98c64f01ec2fe419a6aa6c068331b2 (patch) | |
tree | feffd338887dd828212b64e3ab79f4c4bde256d5 /video/out | |
parent | f40717a66430c238fbe3fa28fc39a88d804bdc9c (diff) | |
download | mpv-45bae90f4d98c64f01ec2fe419a6aa6c068331b2.tar.bz2 mpv-45bae90f4d98c64f01ec2fe419a6aa6c068331b2.tar.xz |
vo_opengl: be explicit about IMG_RW
Both vulkan and opengl distinguish between rendering to an image and
using an image as a storage attachment. So make this an explicit
capability instead of lumping it in with render_dst. (That way we could
support, for example, using an image as a storage attachment without
requiring a framebuffer)
The real reason for this change is that you can directly use the output
FBO as a storage attachment on vulkan but you can't on opengl, which
makes this param structly separate from render_dst.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/opengl/ra.h | 2 | ||||
-rw-r--r-- | video/out/opengl/ra_gl.c | 18 | ||||
-rw-r--r-- | video/out/opengl/utils.c | 1 |
3 files changed, 13 insertions, 8 deletions
diff --git a/video/out/opengl/ra.h b/video/out/opengl/ra.h index f2b41256db..f09fa6c861 100644 --- a/video/out/opengl/ra.h +++ b/video/out/opengl/ra.h @@ -90,6 +90,7 @@ struct ra_tex_params { const struct ra_format *format; bool render_src; // must be useable as source texture in a shader bool render_dst; // must be useable as target texture in a shader + bool storage_dst; // must be usable as a storage image (RA_VARTYPE_IMG_W) bool blit_src; // must be usable as a blit source bool blit_dst; // must be usable as a blit destination bool host_mutable; // texture may be updated with tex_upload @@ -170,6 +171,7 @@ enum ra_vartype { // ra_tex.params.render_src must be true RA_VARTYPE_IMG_W, // C: ra_tex*, GLSL: various image types // write-only (W) image for compute shaders + // ra_tex.params.storage_dst must be true RA_VARTYPE_BYTE_UNORM, // C: uint8_t, GLSL: int, vec* (vertex data only) RA_VARTYPE_BUF_RW, // C: ra_buf*, GLSL: buffer block }; diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index e31948c2b1..d9c7205815 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -893,18 +893,20 @@ static void update_uniform(struct ra *ra, struct ra_renderpass *pass, } break; } - case RA_VARTYPE_IMG_W: /* fall through */ + case RA_VARTYPE_IMG_W: { + struct ra_tex *tex = *(struct ra_tex **)val->data; + struct ra_tex_gl *tex_gl = tex->priv; + assert(tex->params.storage_dst); + gl->BindImageTexture(input->binding, tex_gl->texture, 0, GL_FALSE, 0, + GL_WRITE_ONLY, tex_gl->internal_format); + break; + } case RA_VARTYPE_TEX: { struct ra_tex *tex = *(struct ra_tex **)val->data; struct ra_tex_gl *tex_gl = tex->priv; assert(tex->params.render_src); - if (input->type == RA_VARTYPE_TEX) { - gl->ActiveTexture(GL_TEXTURE0 + input->binding); - gl->BindTexture(tex_gl->target, tex_gl->texture); - } else { - gl->BindImageTexture(input->binding, tex_gl->texture, 0, GL_FALSE, 0, - GL_WRITE_ONLY, tex_gl->internal_format); - } + gl->ActiveTexture(GL_TEXTURE0 + input->binding); + gl->BindTexture(tex_gl->target, tex_gl->texture); break; } case RA_VARTYPE_BUF_RW: { diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index e7fce62662..cdd8903bc5 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -174,6 +174,7 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log, .src_linear = true, .render_src = true, .render_dst = true, + .storage_dst = true, .blit_src = true, }; |