summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/shader_cache.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-08-05 22:29:48 +0200
committerNiklas Haas <git@haasn.xyz>2017-08-07 12:46:30 +0200
commit9581fbe56926c75e52bc015fa6146b7f11f3d6a3 (patch)
tree252ff1098cd07bc5ae56770eecf0a3c0549435a5 /video/out/opengl/shader_cache.c
parent207458c7a9b682185a82ee23910c1327a70d276b (diff)
downloadmpv-9581fbe56926c75e52bc015fa6146b7f11f3d6a3.tar.bz2
mpv-9581fbe56926c75e52bc015fa6146b7f11f3d6a3.tar.xz
vo_opengl: generalize ra_buf to support other buffer objects
This allows us to integrate PBOs and SSBOs into the same abstraction, with the potential to easily add UBOs if the need arises.
Diffstat (limited to 'video/out/opengl/shader_cache.c')
-rw-r--r--video/out/opengl/shader_cache.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/video/out/opengl/shader_cache.c b/video/out/opengl/shader_cache.c
index 68d9d4cab2..050d01d36d 100644
--- a/video/out/opengl/shader_cache.c
+++ b/video/out/opengl/shader_cache.c
@@ -22,15 +22,16 @@
union uniform_val {
float f[9]; // RA_VARTYPE_FLOAT
- int i[4]; // RA_VARTYPE_INT, RA_VARTYPE_SSBO
+ int i[4]; // RA_VARTYPE_INT
struct ra_tex *tex; // RA_VARTYPE_TEX, RA_VARTYPE_IMG_*
+ struct ra_buf *buf; // RA_VARTYPE_BUF_*
};
struct sc_uniform {
struct ra_renderpass_input input;
const char *glsl_type;
union uniform_val v;
- char *ssbo_format;
+ char *buffer_format;
};
struct sc_cached_uniform {
@@ -264,20 +265,20 @@ void gl_sc_uniform_image2D_wo(struct gl_shader_cache *sc, const char *name,
u->v.tex = tex;
}
-void gl_sc_ssbo(struct gl_shader_cache *sc, char *name, int gl_ssbo,
+void gl_sc_ssbo(struct gl_shader_cache *sc, char *name, struct ra_buf *buf,
char *format, ...)
{
gl_sc_enable_extension(sc, "GL_ARB_shader_storage_buffer_object");
struct sc_uniform *u = find_uniform(sc, name);
- u->input.type = RA_VARTYPE_SSBO;
+ u->input.type = RA_VARTYPE_BUF_RW;
u->glsl_type = "";
u->input.binding = sc->next_buffer_binding++;
- u->v.i[0] = gl_ssbo;
+ u->v.buf = buf;
va_list ap;
va_start(ap, format);
- u->ssbo_format = ta_vasprintf(sc, format, ap);
+ u->buffer_format = ta_vasprintf(sc, format, ap);
va_end(ap);
}
@@ -516,9 +517,9 @@ static void add_uniforms(struct gl_shader_cache *sc, bstr *dst)
case RA_VARTYPE_IMG_W:
ADD(dst, "uniform %s %s;\n", u->glsl_type, u->input.name);
break;
- case RA_VARTYPE_SSBO:
+ case RA_VARTYPE_BUF_RW:
ADD(dst, "layout(std430, binding=%d) buffer %s { %s };\n",
- u->input.binding, u->input.name, u->ssbo_format);
+ u->input.binding, u->input.name, u->buffer_format);
break;
default: abort();
}