#include "util/bitscan.h"
+const GLubyte
+_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX] =
+{
+ /* ATTRIBUTE_MAP_MODE_IDENTITY
+ *
+ * Grab vertex processing attribute VERT_ATTRIB_POS from
+ * the VAO attribute VERT_ATTRIB_POS, and grab vertex processing
+ * attribute VERT_ATTRIB_GENERIC0 from the VAO attribute
+ * VERT_ATTRIB_GENERIC0.
+ */
+ {
+ VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */
+ VERT_ATTRIB_NORMAL, /* VERT_ATTRIB_NORMAL */
+ VERT_ATTRIB_COLOR0, /* VERT_ATTRIB_COLOR0 */
+ VERT_ATTRIB_COLOR1, /* VERT_ATTRIB_COLOR1 */
+ VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+ VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+ VERT_ATTRIB_EDGEFLAG, /* VERT_ATTRIB_EDGEFLAG */
+ VERT_ATTRIB_TEX0, /* VERT_ATTRIB_TEX0 */
+ VERT_ATTRIB_TEX1, /* VERT_ATTRIB_TEX1 */
+ VERT_ATTRIB_TEX2, /* VERT_ATTRIB_TEX2 */
+ VERT_ATTRIB_TEX3, /* VERT_ATTRIB_TEX3 */
+ VERT_ATTRIB_TEX4, /* VERT_ATTRIB_TEX4 */
+ VERT_ATTRIB_TEX5, /* VERT_ATTRIB_TEX5 */
+ VERT_ATTRIB_TEX6, /* VERT_ATTRIB_TEX6 */
+ VERT_ATTRIB_TEX7, /* VERT_ATTRIB_TEX7 */
+ VERT_ATTRIB_POINT_SIZE, /* VERT_ATTRIB_POINT_SIZE */
+ VERT_ATTRIB_GENERIC0, /* VERT_ATTRIB_GENERIC0 */
+ VERT_ATTRIB_GENERIC1, /* VERT_ATTRIB_GENERIC1 */
+ VERT_ATTRIB_GENERIC2, /* VERT_ATTRIB_GENERIC2 */
+ VERT_ATTRIB_GENERIC3, /* VERT_ATTRIB_GENERIC3 */
+ VERT_ATTRIB_GENERIC4, /* VERT_ATTRIB_GENERIC4 */
+ VERT_ATTRIB_GENERIC5, /* VERT_ATTRIB_GENERIC5 */
+ VERT_ATTRIB_GENERIC6, /* VERT_ATTRIB_GENERIC6 */
+ VERT_ATTRIB_GENERIC7, /* VERT_ATTRIB_GENERIC7 */
+ VERT_ATTRIB_GENERIC8, /* VERT_ATTRIB_GENERIC8 */
+ VERT_ATTRIB_GENERIC9, /* VERT_ATTRIB_GENERIC9 */
+ VERT_ATTRIB_GENERIC10, /* VERT_ATTRIB_GENERIC10 */
+ VERT_ATTRIB_GENERIC11, /* VERT_ATTRIB_GENERIC11 */
+ VERT_ATTRIB_GENERIC12, /* VERT_ATTRIB_GENERIC12 */
+ VERT_ATTRIB_GENERIC13, /* VERT_ATTRIB_GENERIC13 */
+ VERT_ATTRIB_GENERIC14, /* VERT_ATTRIB_GENERIC14 */
+ VERT_ATTRIB_GENERIC15 /* VERT_ATTRIB_GENERIC15 */
+ },
+
+ /* ATTRIBUTE_MAP_MODE_POSITION
+ *
+ * Grab vertex processing attribute VERT_ATTRIB_POS as well as
+ * vertex processing attribute VERT_ATTRIB_GENERIC0 from the
+ * VAO attribute VERT_ATTRIB_POS.
+ */
+ {
+ VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */
+ VERT_ATTRIB_NORMAL, /* VERT_ATTRIB_NORMAL */
+ VERT_ATTRIB_COLOR0, /* VERT_ATTRIB_COLOR0 */
+ VERT_ATTRIB_COLOR1, /* VERT_ATTRIB_COLOR1 */
+ VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+ VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+ VERT_ATTRIB_EDGEFLAG, /* VERT_ATTRIB_EDGEFLAG */
+ VERT_ATTRIB_TEX0, /* VERT_ATTRIB_TEX0 */
+ VERT_ATTRIB_TEX1, /* VERT_ATTRIB_TEX1 */
+ VERT_ATTRIB_TEX2, /* VERT_ATTRIB_TEX2 */
+ VERT_ATTRIB_TEX3, /* VERT_ATTRIB_TEX3 */
+ VERT_ATTRIB_TEX4, /* VERT_ATTRIB_TEX4 */
+ VERT_ATTRIB_TEX5, /* VERT_ATTRIB_TEX5 */
+ VERT_ATTRIB_TEX6, /* VERT_ATTRIB_TEX6 */
+ VERT_ATTRIB_TEX7, /* VERT_ATTRIB_TEX7 */
+ VERT_ATTRIB_POINT_SIZE, /* VERT_ATTRIB_POINT_SIZE */
+ VERT_ATTRIB_POS, /* VERT_ATTRIB_GENERIC0 */
+ VERT_ATTRIB_GENERIC1, /* VERT_ATTRIB_GENERIC1 */
+ VERT_ATTRIB_GENERIC2, /* VERT_ATTRIB_GENERIC2 */
+ VERT_ATTRIB_GENERIC3, /* VERT_ATTRIB_GENERIC3 */
+ VERT_ATTRIB_GENERIC4, /* VERT_ATTRIB_GENERIC4 */
+ VERT_ATTRIB_GENERIC5, /* VERT_ATTRIB_GENERIC5 */
+ VERT_ATTRIB_GENERIC6, /* VERT_ATTRIB_GENERIC6 */
+ VERT_ATTRIB_GENERIC7, /* VERT_ATTRIB_GENERIC7 */
+ VERT_ATTRIB_GENERIC8, /* VERT_ATTRIB_GENERIC8 */
+ VERT_ATTRIB_GENERIC9, /* VERT_ATTRIB_GENERIC9 */
+ VERT_ATTRIB_GENERIC10, /* VERT_ATTRIB_GENERIC10 */
+ VERT_ATTRIB_GENERIC11, /* VERT_ATTRIB_GENERIC11 */
+ VERT_ATTRIB_GENERIC12, /* VERT_ATTRIB_GENERIC12 */
+ VERT_ATTRIB_GENERIC13, /* VERT_ATTRIB_GENERIC13 */
+ VERT_ATTRIB_GENERIC14, /* VERT_ATTRIB_GENERIC14 */
+ VERT_ATTRIB_GENERIC15 /* VERT_ATTRIB_GENERIC15 */
+ },
+
+ /* ATTRIBUTE_MAP_MODE_GENERIC0
+ *
+ * Grab vertex processing attribute VERT_ATTRIB_POS as well as
+ * vertex processing attribute VERT_ATTRIB_GENERIC0 from the
+ * VAO attribute VERT_ATTRIB_GENERIC0.
+ */
+ {
+ VERT_ATTRIB_GENERIC0, /* VERT_ATTRIB_POS */
+ VERT_ATTRIB_NORMAL, /* VERT_ATTRIB_NORMAL */
+ VERT_ATTRIB_COLOR0, /* VERT_ATTRIB_COLOR0 */
+ VERT_ATTRIB_COLOR1, /* VERT_ATTRIB_COLOR1 */
+ VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+ VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+ VERT_ATTRIB_EDGEFLAG, /* VERT_ATTRIB_EDGEFLAG */
+ VERT_ATTRIB_TEX0, /* VERT_ATTRIB_TEX0 */
+ VERT_ATTRIB_TEX1, /* VERT_ATTRIB_TEX1 */
+ VERT_ATTRIB_TEX2, /* VERT_ATTRIB_TEX2 */
+ VERT_ATTRIB_TEX3, /* VERT_ATTRIB_TEX3 */
+ VERT_ATTRIB_TEX4, /* VERT_ATTRIB_TEX4 */
+ VERT_ATTRIB_TEX5, /* VERT_ATTRIB_TEX5 */
+ VERT_ATTRIB_TEX6, /* VERT_ATTRIB_TEX6 */
+ VERT_ATTRIB_TEX7, /* VERT_ATTRIB_TEX7 */
+ VERT_ATTRIB_POINT_SIZE, /* VERT_ATTRIB_POINT_SIZE */
+ VERT_ATTRIB_GENERIC0, /* VERT_ATTRIB_GENERIC0 */
+ VERT_ATTRIB_GENERIC1, /* VERT_ATTRIB_GENERIC1 */
+ VERT_ATTRIB_GENERIC2, /* VERT_ATTRIB_GENERIC2 */
+ VERT_ATTRIB_GENERIC3, /* VERT_ATTRIB_GENERIC3 */
+ VERT_ATTRIB_GENERIC4, /* VERT_ATTRIB_GENERIC4 */
+ VERT_ATTRIB_GENERIC5, /* VERT_ATTRIB_GENERIC5 */
+ VERT_ATTRIB_GENERIC6, /* VERT_ATTRIB_GENERIC6 */
+ VERT_ATTRIB_GENERIC7, /* VERT_ATTRIB_GENERIC7 */
+ VERT_ATTRIB_GENERIC8, /* VERT_ATTRIB_GENERIC8 */
+ VERT_ATTRIB_GENERIC9, /* VERT_ATTRIB_GENERIC9 */
+ VERT_ATTRIB_GENERIC10, /* VERT_ATTRIB_GENERIC10 */
+ VERT_ATTRIB_GENERIC11, /* VERT_ATTRIB_GENERIC11 */
+ VERT_ATTRIB_GENERIC12, /* VERT_ATTRIB_GENERIC12 */
+ VERT_ATTRIB_GENERIC13, /* VERT_ATTRIB_GENERIC13 */
+ VERT_ATTRIB_GENERIC14, /* VERT_ATTRIB_GENERIC14 */
+ VERT_ATTRIB_GENERIC15 /* VERT_ATTRIB_GENERIC15 */
+ }
+};
+
+
/**
* Look up the array object for the given ID.
*
}
}
+ vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_IDENTITY;
+
_mesa_reference_buffer_object(ctx, &vao->IndexBufferObj,
ctx->Shared->NullBufferObj);
}
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
*/