diff options
author | Mathias Fröhlich <[email protected]> | 2018-01-27 16:07:22 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-02-01 22:39:08 +0100 |
commit | fb10a7b7b0da7b4965a60a9427bf295825bf78c8 (patch) | |
tree | e1c3ff616c53d08269039413b4723f87e2c6fa2a /src | |
parent | 44b1454b968deb5ee0a5ecaf8cd06ed6bf11989a (diff) |
vbo: Simplify input array distribution for imm type draws.
Using the newly introduced VAO array maps, we can
simplify vbo_exec_bind_arrays.
Signed-off-by: Mathias Fröhlich <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/vbo/vbo_exec_draw.c | 81 |
1 files changed, 15 insertions, 66 deletions
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index e3e050595c1..b0cc3946423 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -27,6 +27,7 @@ #include <stdbool.h> #include <stdio.h> +#include "main/arrayobj.h" #include "main/glheader.h" #include "main/bufferobj.h" #include "main/context.h" @@ -176,62 +177,20 @@ vbo_exec_bind_arrays(struct gl_context *ctx) struct gl_vertex_array *arrays = exec->vtx.arrays; GLuint attr; GLbitfield varying_inputs = 0x0; - bool swap_pos = false; const enum vp_mode program_mode = get_vp_mode(exec->ctx); const GLubyte * const map = _vbo_attribute_alias_map[program_mode]; - /* Install the default (ie Current) attributes first */ - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) { - exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; - } + /* Grab VERT_ATTRIB_{POS,GENERIC0} from VBO_ATTRIB_POS */ + const gl_attribute_map_mode mode = ATTRIBUTE_MAP_MODE_POSITION; + const GLubyte *const array_map = _mesa_vao_attribute_map[mode]; + for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { + const GLuint src = map[array_map[attr]]; + const GLubyte size = exec->vtx.attrsz[src]; - /* Overlay other active attributes */ - switch (program_mode) { - case VP_FF: - for (attr = 0; attr < VERT_ATTRIB_MAT0; attr++) { - assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); - exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = - &vbo->currval[VBO_ATTRIB_GENERIC0+attr]; - } - for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) { - assert(VERT_ATTRIB_MAT(attr) < ARRAY_SIZE(exec->vtx.inputs)); - exec->vtx.inputs[VERT_ATTRIB_MAT(attr)] = - &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr]; - } - break; - case VP_SHADER: - for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) { - assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); - exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = - &vbo->currval[VBO_ATTRIB_GENERIC0+attr]; - } - - /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. - * In that case we effectively need to route the data from - * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. - * The original state gets essentially restored below. - */ - const GLbitfield64 inputs_read = - ctx->VertexProgram._Current->info.inputs_read; - if ((inputs_read & VERT_BIT_POS) == 0 && - (inputs_read & VERT_BIT_GENERIC0)) { - swap_pos = true; - exec->vtx.inputs[VERT_ATTRIB_GENERIC0] = exec->vtx.inputs[0]; - exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0]; - exec->vtx.attrtype[VERT_ATTRIB_GENERIC0] = exec->vtx.attrtype[0]; - exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0]; - exec->vtx.attrsz[0] = 0; - } - break; - default: - unreachable("Bad vertex program mode"); - } - - for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) { - const GLuint src = map[attr]; - - if (exec->vtx.attrsz[src]) { + if (size == 0) { + exec->vtx.inputs[attr] = &vbo->currval[map[attr]]; + } else { GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[src] - (GLbyte *)exec->vtx.vertex; @@ -251,13 +210,13 @@ vbo_exec_bind_arrays(struct gl_context *ctx) /* Ptr into ordinary app memory */ arrays[attr].Ptr = (GLubyte *)exec->vtx.buffer_map + offset; } - arrays[attr].Size = exec->vtx.attrsz[src]; + arrays[attr].Size = size; arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); - arrays[attr].Type = exec->vtx.attrtype[src]; - arrays[attr].Integer = - vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]); + const GLenum16 type = exec->vtx.attrtype[src]; + arrays[attr].Type = type; + arrays[attr].Integer = vbo_attrtype_to_integer_flag(type); arrays[attr].Format = GL_RGBA; - arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat); + arrays[attr]._ElementSize = size * sizeof(GLfloat); _mesa_reference_buffer_object(ctx, &arrays[attr].BufferObj, exec->vtx.bufferobj); @@ -266,16 +225,6 @@ vbo_exec_bind_arrays(struct gl_context *ctx) } } - /* In case we swapped the position and generic0 attribute. - * Restore the original setting of the vtx.* variables. - * They are still needed with the original order and settings in case - * of a split primitive. - */ - if (swap_pos) { - exec->vtx.attrsz[0] = exec->vtx.attrsz[VERT_ATTRIB_GENERIC0]; - exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = 0; - } - _mesa_set_varying_vp_inputs(ctx, varying_inputs); ctx->NewDriverState |= ctx->DriverFlags.NewArray; } |