mirror of
https://github.com/mpv-player/mpv
synced 2025-04-18 21:27:00 +00:00
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.
This commit is contained in:
parent
f40717a664
commit
45bae90f4d
@ -90,6 +90,7 @@ struct ra_tex_params {
|
|||||||
const struct ra_format *format;
|
const struct ra_format *format;
|
||||||
bool render_src; // must be useable as source texture in a shader
|
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 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_src; // must be usable as a blit source
|
||||||
bool blit_dst; // must be usable as a blit destination
|
bool blit_dst; // must be usable as a blit destination
|
||||||
bool host_mutable; // texture may be updated with tex_upload
|
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_tex.params.render_src must be true
|
||||||
RA_VARTYPE_IMG_W, // C: ra_tex*, GLSL: various image types
|
RA_VARTYPE_IMG_W, // C: ra_tex*, GLSL: various image types
|
||||||
// write-only (W) image for compute shaders
|
// 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_BYTE_UNORM, // C: uint8_t, GLSL: int, vec* (vertex data only)
|
||||||
RA_VARTYPE_BUF_RW, // C: ra_buf*, GLSL: buffer block
|
RA_VARTYPE_BUF_RW, // C: ra_buf*, GLSL: buffer block
|
||||||
};
|
};
|
||||||
|
@ -893,18 +893,20 @@ static void update_uniform(struct ra *ra, struct ra_renderpass *pass,
|
|||||||
}
|
}
|
||||||
break;
|
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: {
|
case RA_VARTYPE_TEX: {
|
||||||
struct ra_tex *tex = *(struct ra_tex **)val->data;
|
struct ra_tex *tex = *(struct ra_tex **)val->data;
|
||||||
struct ra_tex_gl *tex_gl = tex->priv;
|
struct ra_tex_gl *tex_gl = tex->priv;
|
||||||
assert(tex->params.render_src);
|
assert(tex->params.render_src);
|
||||||
if (input->type == RA_VARTYPE_TEX) {
|
gl->ActiveTexture(GL_TEXTURE0 + input->binding);
|
||||||
gl->ActiveTexture(GL_TEXTURE0 + input->binding);
|
gl->BindTexture(tex_gl->target, tex_gl->texture);
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RA_VARTYPE_BUF_RW: {
|
case RA_VARTYPE_BUF_RW: {
|
||||||
|
@ -174,6 +174,7 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log,
|
|||||||
.src_linear = true,
|
.src_linear = true,
|
||||||
.render_src = true,
|
.render_src = true,
|
||||||
.render_dst = true,
|
.render_dst = true,
|
||||||
|
.storage_dst = true,
|
||||||
.blit_src = true,
|
.blit_src = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user