summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/gl_utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-05 14:20:14 +0200
committerwm4 <wm4@nowhere>2017-08-05 16:27:09 +0200
commit333cae74ef0fa62e0355e85d21f0f41ced3963e7 (patch)
tree08e390dd9bdf7e997bf91ebef5bd5579336f27eb /video/out/opengl/gl_utils.c
parentf72a33d2cb223df921967cfe7ae203f882ba6921 (diff)
downloadmpv-333cae74ef0fa62e0355e85d21f0f41ced3963e7.tar.bz2
mpv-333cae74ef0fa62e0355e85d21f0f41ced3963e7.tar.xz
vo_opengl: move shader handling to ra
Now all GL-specifics of shader compilation are abstracted through ra. Of course we still have everything hardcoded to GLSL - that isn't going to change. Some things will probably change later - in particular, the way we pass uniforms and textures to the shader. Currently, there is a confusing mismatch between "primitive" uniforms like floats, and others like textures. Also, SSBOs are not abstracted yet.
Diffstat (limited to 'video/out/opengl/gl_utils.c')
-rw-r--r--video/out/opengl/gl_utils.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/video/out/opengl/gl_utils.c b/video/out/opengl/gl_utils.c
index c870756b1e..df6f0543ad 100644
--- a/video/out/opengl/gl_utils.c
+++ b/video/out/opengl/gl_utils.c
@@ -150,17 +150,32 @@ static void gl_vao_enable_attribs(struct gl_vao *vao)
{
GL *gl = vao->gl;
- for (int n = 0; vao->entries[n].name; n++) {
- const struct gl_vao_entry *e = &vao->entries[n];
+ for (int n = 0; n < vao->num_entries; n++) {
+ const struct ra_renderpass_input *e = &vao->entries[n];
+ GLenum type = 0;
+ bool normalized = false;
+ switch (e->type) {
+ case RA_VARTYPE_FLOAT:
+ type = GL_FLOAT;
+ break;
+ case RA_VARTYPE_BYTE_UNORM:
+ type = GL_UNSIGNED_BYTE;
+ normalized = true;
+ break;
+ default:
+ abort();
+ }
+ assert(e->dim_m == 1);
gl->EnableVertexAttribArray(n);
- gl->VertexAttribPointer(n, e->num_elems, e->type, e->normalized,
- vao->stride, (void *)(intptr_t)e->offset);
+ gl->VertexAttribPointer(n, e->dim_v, type, normalized,
+ vao->stride, (void *)(intptr_t)e->binding);
}
}
void gl_vao_init(struct gl_vao *vao, GL *gl, int stride,
- const struct gl_vao_entry *entries)
+ const struct ra_renderpass_input *entries,
+ int num_entries)
{
assert(!vao->vao);
assert(!vao->buffer);
@@ -169,6 +184,7 @@ void gl_vao_init(struct gl_vao *vao, GL *gl, int stride,
.gl = gl,
.stride = stride,
.entries = entries,
+ .num_entries = num_entries,
};
gl->GenBuffers(1, &vao->buffer);