#include "main/api_arrayelt.h"
#include "main/vtxfmt.h"
#include "main/dispatch.h"
+#include "main/state.h"
#include "util/bitscan.h"
#include "vbo_context.h"
* Called when a glBegin is getting compiled into a display list.
* Updating of ctx->Driver.CurrentSavePrimitive is already taken care of.
*/
-GLboolean
+void
vbo_save_NotifyBegin(struct gl_context *ctx, GLenum mode)
{
struct vbo_save_context *save = &vbo_context(ctx)->save;
/* We need to call vbo_save_SaveFlushVertices() if there's state change */
ctx->Driver.SaveNeedFlush = GL_TRUE;
-
- /* GL_TRUE means we've handled this glBegin here; don't compile a BEGIN
- * opcode into the display list.
- */
- return GL_TRUE;
}
static void GLAPIENTRY
_save_PrimitiveRestartNV(void)
{
- GLenum curPrim;
GET_CURRENT_CONTEXT(ctx);
+ struct vbo_save_context *save = &vbo_context(ctx)->save;
- curPrim = ctx->Driver.CurrentSavePrimitive;
-
- _save_End();
- _save_Begin(curPrim);
+ if (save->prim_count == 0) {
+ /* We're not inside a glBegin/End pair, so calling glPrimitiverRestartNV
+ * is an error.
+ */
+ _mesa_compile_error(ctx, GL_INVALID_OPERATION,
+ "glPrimitiveRestartNV called outside glBegin/End");
+ } else {
+ /* get current primitive mode */
+ GLenum curPrim = save->prim[save->prim_count - 1].mode;
+
+ /* restart primitive */
+ CALL_End(GET_DISPATCH(), ());
+ vbo_save_NotifyBegin(ctx, curPrim);
+ }
}
if (save->out_of_memory)
return;
+ /* Make sure to process any VBO binding changes */
+ _mesa_update_state(ctx);
+
_ae_map_vbos(ctx);
vbo_save_NotifyBegin(ctx, (mode | VBO_SAVE_PRIM_WEAK
}
+static void GLAPIENTRY
+_save_OBE_MultiDrawArrays(GLenum mode, const GLint *first,
+ const GLsizei *count, GLsizei primcount)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ if (!_mesa_is_valid_prim_mode(ctx, mode)) {
+ _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMultiDrawArrays(mode)");
+ return;
+ }
+
+ if (primcount < 0) {
+ _mesa_compile_error(ctx, GL_INVALID_VALUE,
+ "glMultiDrawArrays(primcount<0)");
+ return;
+ }
+
+ for (i = 0; i < primcount; i++) {
+ if (count[i] < 0) {
+ _mesa_compile_error(ctx, GL_INVALID_VALUE,
+ "glMultiDrawArrays(count[i]<0)");
+ return;
+ }
+ }
+
+ for (i = 0; i < primcount; i++) {
+ if (count[i] > 0) {
+ _save_OBE_DrawArrays(mode, first[i], count[i]);
+ }
+ }
+}
+
+
/* Could do better by copying the arrays and element list intact and
* then emitting an indexed prim at runtime.
*/
if (save->out_of_memory)
return;
+ /* Make sure to process any VBO binding changes */
+ _mesa_update_state(ctx);
+
_ae_map_vbos(ctx);
if (_mesa_is_bufferobj(indexbuf))
vfmt->VertexAttribL3dv = _save_VertexAttribL3dv;
vfmt->VertexAttribL4dv = _save_VertexAttribL4dv;
+ vfmt->VertexAttribL1ui64ARB = _save_VertexAttribL1ui64ARB;
+ vfmt->VertexAttribL1ui64vARB = _save_VertexAttribL1ui64vARB;
+
/* This will all require us to fallback to saving the list as opcodes:
*/
vfmt->CallList = _save_CallList;
struct _glapi_table *exec)
{
SET_DrawArrays(exec, _save_OBE_DrawArrays);
+ SET_MultiDrawArrays(exec, _save_OBE_MultiDrawArrays);
SET_DrawElements(exec, _save_OBE_DrawElements);
SET_DrawElementsBaseVertex(exec, _save_OBE_DrawElementsBaseVertex);
SET_DrawRangeElements(exec, _save_OBE_DrawRangeElements);