#include "vbo_context.h"
-/* Compute min and max elements for drawelements calls.
+/**
+ * Compute min and max elements for glDraw[Range]Elements() calls.
*/
static void get_minmax_index( GLuint count, GLuint type,
const GLvoid *indices,
}
-/* Just translate the arrayobj into a sane layout.
+/**
+ * Just translate the arrayobj into a sane layout.
*/
static void bind_array_obj( GLcontext *ctx )
{
exec->array.array_obj = arrayObj->Name;
}
+
static void recalculate_input_bindings( GLcontext *ctx )
{
struct vbo_context *vbo = vbo_context(ctx);
switch (exec->array.program_mode) {
case VP_NONE:
- /* When no vertex program is active, we put the material values
- * into the generic slots. This is the only situation where
- * material values are available as per-vertex attributes.
+ /* When no vertex program is active (or the vertex program is generated
+ * from fixed-function state). We put the material values into the
+ * generic slots. This is the only situation where material values
+ * are available as per-vertex attributes.
*/
for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
if (exec->array.legacy_array[i]->Enabled)
inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
}
-
break;
+
case VP_NV:
/* NV_vertex_program - attribute arrays alias and override
* conventional, legacy arrays. No materials, and the generic
inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0];
const_inputs |= 1 << i;
}
-
break;
+
case VP_ARB:
- /* ARB_vertex_program - Only the attribute zero (position) array
- * aliases and overrides the legacy position array.
+ /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0]
+ * attribute array aliases and overrides the legacy position array.
*
* Otherwise, legacy attributes available in the legacy slots,
* generic attributes in the generic slots and materials are not
const_inputs |= 1 << 0;
}
-
for (i = 1; i <= VERT_ATTRIB_TEX7; i++) {
if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
_mesa_set_varying_vp_inputs( ctx, ~const_inputs );
}
+
static void bind_arrays( GLcontext *ctx )
{
#if 0
bind_arrays( ctx );
- /* Again...
+ /* Again... because we may have changed the bitmask of per-vertex varying
+ * attributes. If we regenerate the fixed-function vertex program now
+ * we may be able to prune down the number of vertex attributes which we
+ * need in the shader.
*/
if (ctx->NewState)
_mesa_update_state( ctx );
prim[0].count = count;
prim[0].indexed = 0;
- vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL, start, start + count - 1 );
+ vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL,
+ start, start + count - 1 );
#if 0
{
}
-
static void GLAPIENTRY
vbo_exec_DrawRangeElements(GLenum mode,
GLuint start, GLuint end,
if (end >= ctx->Array.ArrayObj->_MaxElement) {
/* the max element is out of bounds of one or more enabled arrays */
- _mesa_warning(ctx, "glDraw[Range]Elements() index=%u is "
- "out of bounds (max=%u)", end,
- ctx->Array.ArrayObj->_MaxElement);
+ _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, "
+ "type 0x%x) index=%u is out of bounds (max=%u)",
+ start, end, count, type, end,
+ if (0)
+ _mesa_print_arrays(ctx);
return;
}
vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, start, end );
}
+
static void GLAPIENTRY
vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{
* Initialization
*/
-
-
-
void vbo_exec_array_init( struct vbo_exec_context *exec )
{
#if 1