From 333cae74ef0fa62e0355e85d21f0f41ced3963e7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 5 Aug 2017 14:20:14 +0200 Subject: 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. --- video/out/opengl/gl_utils.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'video/out/opengl/gl_utils.c') 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); -- cgit v1.2.3