aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arrayobj.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/arrayobj.h')
-rw-r--r--src/mesa/main/arrayobj.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index ff26157c79e..411ed65c50b 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -89,6 +89,80 @@ _mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao);
extern bool
_mesa_all_buffers_are_unmapped(const struct gl_vertex_array_object *vao);
+
+/**
+ * Array to apply the position/generic0 aliasing map to
+ * an attribute value used in vertex processing inputs to an attribute
+ * as they appear in the vao.
+ */
+extern const GLubyte
+_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX];
+
+
+/**
+ * Depending on the position and generic0 attributes enable flags select
+ * the one that is used for both attributes.
+ * The generic0 attribute takes precedence.
+ */
+static inline void
+_mesa_update_attribute_map_mode(const struct gl_context *ctx,
+ struct gl_vertex_array_object *vao)
+{
+ /*
+ * There is no need to change the mapping away from the
+ * identity mapping if we are not in compat mode.
+ */
+ if (ctx->API != API_OPENGL_COMPAT)
+ return;
+ /* The generic0 attribute superseeds the position attribute */
+ const GLbitfield enabled = vao->_Enabled;
+ if (enabled & VERT_BIT_GENERIC0)
+ vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_GENERIC0;
+ else if (enabled & VERT_BIT_POS)
+ vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_POSITION;
+ else
+ vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_IDENTITY;
+}
+
+
+/**
+ * Apply the position/generic0 aliasing map to a bitfield from the vao.
+ * Use for example to convert gl_vertex_array_object::_Enabled
+ * or gl_vertex_buffer_binding::_VertexBinding from the vao numbering to
+ * the numbering used with vertex processing inputs.
+ */
+static inline GLbitfield
+_mesa_vao_enable_to_vp_inputs(gl_attribute_map_mode mode, GLbitfield enabled)
+{
+ switch (mode) {
+ case ATTRIBUTE_MAP_MODE_IDENTITY:
+ return enabled;
+ case ATTRIBUTE_MAP_MODE_POSITION:
+ /* Copy VERT_ATTRIB_POS enable bit into GENERIC0 position */
+ return (enabled & ~VERT_BIT_GENERIC0)
+ | ((enabled & VERT_BIT_POS) << VERT_ATTRIB_GENERIC0);
+ case ATTRIBUTE_MAP_MODE_GENERIC0:
+ /* Copy VERT_ATTRIB_GENERIC0 enable bit into POS position */
+ return (enabled & ~VERT_BIT_POS)
+ | ((enabled & VERT_BIT_GENERIC0) >> VERT_ATTRIB_GENERIC0);
+ default:
+ return 0;
+ }
+}
+
+
+/**
+ * Return the vp_inputs enabled bitmask after application of
+ * the position/generic0 aliasing map.
+ */
+static inline GLbitfield
+_mesa_get_vao_vp_inputs(const struct gl_vertex_array_object *vao)
+{
+ const gl_attribute_map_mode mode = vao->_AttributeMapMode;
+ return _mesa_vao_enable_to_vp_inputs(mode, vao->_Enabled);
+}
+
+
/*
* API functions
*/