summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Fröhlich <mathias.froehlich@web.de>2018-02-03 21:28:40 +0100
committerMathias Fröhlich <mathias.froehlich@web.de>2018-02-23 05:34:04 +0100
commitc757e416ce9547d3335f350fc02c0261d9e006de (patch)
treeea2b4be8635137bb817c8ae2b28d667de6320782
parentef8028017ddd0aa27d0db07c0d7409d0519de6fe (diff)
vbo: Implement tool functions for vbo specific VAO setup.
Correct VBO_MATERIAL_SHIFT value. The functions will be used next in this series. Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de> Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--src/mesa/vbo/vbo_attrib.h4
-rw-r--r--src/mesa/vbo/vbo_private.h53
2 files changed, 55 insertions, 2 deletions
diff --git a/src/mesa/vbo/vbo_attrib.h b/src/mesa/vbo/vbo_attrib.h
index fb178e17d67..0592d845ba4 100644
--- a/src/mesa/vbo/vbo_attrib.h
+++ b/src/mesa/vbo/vbo_attrib.h
@@ -113,8 +113,8 @@ enum vbo_attrib {
VBO_ATTRIB_LAST_MATERIAL - VBO_ATTRIB_FIRST_MATERIAL + 1)
/** Shift to move legacy material attribs into generic slots */
-#define VBO_MATERIAL_SHIFT (VBO_ATTRIB_FIRST_MATERIAL - VBO_ATTRIB_GENERIC0)
-
+#define VBO_MATERIAL_SHIFT \
+ (VBO_ATTRIB_LAST_MATERIAL - VBO_ATTRIB_FIRST_MATERIAL + 1)
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index 2fda06dec68..2640f3e21f9 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -36,6 +36,7 @@
#include "vbo/vbo_exec.h"
#include "vbo/vbo_save.h"
#include "main/mtypes.h"
+#include "main/varray.h"
struct _glapi_table;
@@ -172,4 +173,56 @@ void
vbo_merge_prims(struct _mesa_prim *p0, const struct _mesa_prim *p1);
+/**
+ * Get the filter mask for vbo draws depending on the vertex_processing_mode.
+ */
+static inline GLbitfield
+_vbo_get_vao_filter(gl_vertex_processing_mode vertex_processing_mode)
+{
+ if (vertex_processing_mode == VP_MODE_FF) {
+ /* The materials mapped into the generic arrays */
+ return VERT_BIT_FF_ALL | VERT_BIT_MAT_ALL;
+ } else {
+ return VERT_BIT_ALL;
+ }
+}
+
+
+/**
+ * Translate the bitmask of VBO_ATTRIB_BITs to VERT_ATTRIB_BITS.
+ * Note that position/generic0 attribute aliasing is done
+ * generically in the VAO.
+ */
+static inline GLbitfield
+_vbo_get_vao_enabled_from_vbo(gl_vertex_processing_mode vertex_processing_mode,
+ GLbitfield64 enabled)
+{
+ if (vertex_processing_mode == VP_MODE_FF) {
+ /* The materials mapped into the generic arrays */
+ return (((GLbitfield)enabled) & VERT_BIT_FF_ALL)
+ | (((GLbitfield)(enabled >> VBO_MATERIAL_SHIFT)) & VERT_BIT_MAT_ALL);
+ } else {
+ return ((GLbitfield)enabled) & VERT_BIT_ALL;
+ }
+}
+
+
+/**
+ * Set the vertex attrib for vbo draw use.
+ */
+static inline void
+_vbo_set_attrib_format(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ gl_vert_attrib attr, GLintptr buffer_offset,
+ GLubyte size, GLenum16 type, GLuint offset)
+{
+ const GLboolean integer = vbo_attrtype_to_integer_flag(type);
+ 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 */
+ vao->VertexAttrib[attr].Ptr = ADD_POINTERS(buffer_offset, offset);
+}
+
+
#endif /* VBO_PRIVATE_H */