SET_GetStringi(exec, _mesa_GetStringi);
SET_ClampColor(exec, _mesa_ClampColorARB);
+ /* GL_ARB_instanced_arrays */
+ SET_VertexAttribDivisorARB(exec, _mesa_VertexAttribDivisor);
return exec;
}
OPCODE_ACTIVE_PROGRAM_EXT,
OPCODE_USE_SHADER_PROGRAM_EXT,
+ /* GL_ARB_instanced_arrays */
+ OPCODE_VERTEX_ATTRIB_DIVISOR,
+
/* The following three are meta instructions */
OPCODE_ERROR, /* raise compiled-in error */
OPCODE_CONTINUE,
}
+/* GL_ARB_instanced_arrays */
+static void
+save_VertexAttribDivisor(GLuint index, GLuint divisor)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2);
+ if (n) {
+ n[1].ui = index;
+ n[2].ui = divisor;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttribDivisorARB(ctx->Exec, (index, divisor));
+ }
+}
}
break;
+ case OPCODE_VERTEX_ATTRIB_DIVISOR:
+ /* GL_ARB_instanced_arrays */
+ CALL_VertexAttribDivisorARB(ctx->Exec, (n[1].ui, n[2].ui));
+ break;
+
case OPCODE_CONTINUE:
n = (Node *) n[1].next;
break;
(void) save_Uniform4uiv;
#endif
+ /* GL_ARB_instanced_arrays */
+ SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor);
+
return table;
}
GLboolean Enabled; /**< Enabled flag is a boolean */
GLboolean Normalized; /**< GL_ARB_vertex_program */
GLboolean Integer; /**< Integer-valued? */
+ GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
GLuint _ElementSize; /**< size of each element in bytes */
struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
if (ctx->Extensions.EXT_gpu_shader4) {
return array->Integer;
}
- /* fall-through */
+ goto error;
+ case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB:
+ if (ctx->Extensions.ARB_instanced_arrays) {
+ return array->InstanceDivisor;
+ }
+ goto error;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname);
- return 0;
+ ; /* fall-through */
}
+
+error:
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname);
+ return 0;
}
}
+/**
+ * See GL_ARB_instanced_arrays.
+ * Note that the instance divisor only applies to generic arrays, not
+ * the legacy vertex arrays.
+ */
+void GLAPIENTRY
+_mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (!ctx->Extensions.ARB_instanced_arrays) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glVertexAttribDivisor()");
+ return;
+ }
+
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glVertexAttribDivisor(index = %u)",
+ index);
+ return;
+ }
+
+ ctx->Array.ArrayObj->VertexAttrib[index].InstanceDivisor = divisor;
+}
+
+
+
/**
* Copy one client vertex array to another.
*/
dst->Enabled = src->Enabled;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
+ dst->InstanceDivisor = src->InstanceDivisor;
dst->_ElementSize = src->_ElementSize;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
dst->_MaxElement = src->_MaxElement;
_mesa_PrimitiveRestartIndex(GLuint index);
+extern void GLAPIENTRY
+_mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
+
+
extern void
_mesa_copy_client_array(struct gl_context *ctx,
struct gl_client_array *dst,