Minor nit-picks below and on patches 4 and 11. I skimmed the i965
changes, but otherwise everything looks OK AFAICT.
Nice work!
Reviewed-by: Brian Paul <bri...@vmware.com>
On 05/07/2018 12:14 AM, mathias.froehl...@gmx.net wrote:
From: Mathias Fröhlich <mathias.froehl...@web.de>
Compute VAO buffer binding information past the position/generic0 mapping.
Scan for duplicate buffer bindings and collapse them into derived
effective buffer binding index and effective attribute mask variables.
Provide a set of helper functions to access the distilled
information in the VAO. All of them prefixed with _mesa_draw_...
to indicate that they are meant to query draw information.
v2: Also group user space arrays containing interleaved arrays.
Add _Eff*Offset to be copied on attribute and binding copy.
Update comments.
Signed-off-by: Mathias Fröhlich <mathias.froehl...@web.de>
---
src/mesa/main/arrayobj.c | 390 ++++++++++++++++++++++++++++++++++++++++++++-
src/mesa/main/arrayobj.h | 186 +++++++++++++++++++++
src/mesa/main/attrib.c | 1 +
src/mesa/main/mtypes.h | 64 ++++++++
src/mesa/main/varray.c | 9 ++
src/mesa/vbo/vbo.h | 8 +
src/mesa/vbo/vbo_context.c | 17 ++
src/mesa/vbo/vbo_private.h | 7 +-
8 files changed, 675 insertions(+), 7 deletions(-)
[...]
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 2d3eb457f9..dee917f2e4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1426,6 +1426,32 @@ struct gl_array_attributes
unsigned _ElementSize:8; /**< Size of each element in bytes */
/** Index into gl_vertex_array_object::BufferBinding[] array */
unsigned BufferBindingIndex:6;
+
+ /**
+ * Derived effective buffer binding index
+ *
+ * Index into the gl_vertex_buffer_binding array of the vao.
+ * Similar to BufferBindingIndex, but with the mapping of the
+ * position/generic0 attributes applied and with identical
+ * gl_vertex_buffer_binding entries collapsed to a single
+ * entry within the vao.
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ unsigned _EffBufferBindingIndex:6;
+ /**
+ * Derived effective relative offset.
+ *
+ * Relative offset to the effective buffers offset in
+ * gl_vertex_buffer_binding::_EffOffset.
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLushort _EffRelativeOffset;
};
@@ -1441,6 +1467,35 @@ struct gl_vertex_buffer_binding
GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */
GLbitfield _BoundArrays; /**< Arrays bound to this binding
point */
+
+ /**
+ * Derived effective bound arrays.
+ *
+ * The effective binding handles enabled arrays past the
+ * position/generic0 attribute mapping and reduces the refered
+ * gl_vertex_buffer_binding entries to a unique subset.
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLbitfield _EffBoundArrays;
+ /**
+ * Derived offset.
+ *
+ * The absolute offset to that we can collapse some attributes
+ * to this unique effective binding.
+ * For user space array bindings this contains the smalles pointer value
"smallest"
+ * in the bound and interleaved arrays.
+ * For VBO bindings this contains an offset that lets the attributes
+ * _EffRelativeOffset stay positive and in bounds with
+ * Const.MaxVertexAttribRelativeOffset
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLintptr _EffOffset;
};
@@ -1495,6 +1550,15 @@ struct gl_vertex_array_object
/** Mask of VERT_BIT_* values indicating which arrays are enabled */
GLbitfield _Enabled;
+ /**
+ * Mask of VERT_BIT_* enabled arrays past position/generic0 mapping
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLbitfield _EffEnabledVBO;
+
/** Denotes the way the position/generic0 attribute is mapped */
gl_attribute_map_mode _AttributeMapMode;
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 5df38a14f0..d16807b406 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -604,6 +604,11 @@ update_array(struct gl_context *ctx,
/* The Stride and Ptr fields are not set by update_array_format() */
struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
array->Stride = stride;
+ /* For updating the pointer we would need to add the vao->NewArrays flag
+ * to the VAO. But but that is done already unconditionally in
+ * _mesa_update_array_format called above.
+ */
+ assert((vao->NewArrays | ~vao->_Enabled) & VERT_BIT(attrib));
array->Ptr = ptr;
/* Update the vertex buffer binding */
@@ -2868,6 +2873,8 @@ _mesa_copy_vertex_attrib_array(struct gl_context *ctx,
dst->Ptr = src->Ptr;
dst->Enabled = src->Enabled;
dst->_ElementSize = src->_ElementSize;
+ dst->_EffBufferBindingIndex = src->_EffBufferBindingIndex;
+ dst->_EffRelativeOffset = src->_EffRelativeOffset;
}
void
@@ -2879,6 +2886,8 @@ _mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
dst->Stride = src->Stride;
dst->InstanceDivisor = src->InstanceDivisor;
dst->_BoundArrays = src->_BoundArrays;
+ dst->_EffBoundArrays = src->_EffBoundArrays;
+ dst->_EffOffset = src->_EffOffset;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
}
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 9b15066291..ca46f9baa7 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -186,6 +186,14 @@ void
_vbo_update_inputs(struct gl_context *ctx, struct vbo_inputs *inputs);
+const struct gl_array_attributes*
+_vbo_current_attrib(const struct gl_context *ctx, gl_vert_attrib attr);
+
+
+const struct gl_vertex_buffer_binding*
+_vbo_current_binding(const struct gl_context *ctx);
+
+
void GLAPIENTRY
_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index ada78ffd63..f201604de5 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -234,6 +234,23 @@ _vbo_DestroyContext(struct gl_context *ctx)
}
+const struct gl_array_attributes*
Space before * (and below)
+_vbo_current_attrib(const struct gl_context *ctx, gl_vert_attrib attr)
+{
+ const struct vbo_context *vbo = vbo_context((struct gl_context *)ctx);
You could add a new vbo_context_const() function to avoid casting away
const here (and below).
+ const gl_vertex_processing_mode vmp = ctx->VertexProgram._VPMode;
+ return &vbo->current[_vbo_attribute_alias_map[vmp][attr]];
+}
+
+
+const struct gl_vertex_buffer_binding*
+_vbo_current_binding(const struct gl_context *ctx)
+{
+ const struct vbo_context *vbo = vbo_context((struct gl_context *)ctx);
+ return &vbo->binding;
+}
+
+
/*
* Helper function for _vbo_draw_indirect below that additionally takes a zero
* initialized array of _mesa_prim scratch space memory as the last argument.
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index 589c61d675..161762c4d7 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -209,7 +209,12 @@ _vbo_set_attrib_format(struct gl_context *ctx,
const GLboolean doubles = vbo_attrtype_to_double_flag(type);
_mesa_update_array_format(ctx, vao, attr, size, type, GL_RGBA,
GL_FALSE, integer, doubles, offset);
- /* Ptr for userspace arrays */
+ /* Ptr for userspace arrays.
+ * For updating the pointer we would need to add the vao->NewArrays flag
+ * to the VAO. But but that is done already unconditionally in
+ * _mesa_update_array_format called above.
+ */
+ assert((vao->NewArrays | ~vao->_Enabled) & VERT_BIT(attr));
vao->VertexAttrib[attr].Ptr = ADD_POINTERS(buffer_offset, offset);
}
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev