Import fixes from X.org tree (Søren Sandmann <sandmann@redhat.com>).
[mesa.git] / src / glx / x11 / indirect.c
index 33fc9f9a3c774db731ef48628e92f2bd21c52fa8..b81811cdb80c1784032d54130df874b16919bfb6 100644 (file)
@@ -6062,14 +6062,16 @@ void
 __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 24;
-    emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(params), 8);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(&target), 4);
-    (void) memcpy((void *)(gc->pc + 16), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 20), (void *)(&num), 4);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 16 + __GLX_PAD((num * 8));
+    if (__builtin_expect(num >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(&num), 4);
+        (void) memcpy((void *)(gc->pc + 16), (void *)(params), (num * 8));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_ProgramParameters4fvNV 4186
@@ -6531,13 +6533,15 @@ void
 __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 20;
-    emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(v), 8);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 16), (void *)(&n), 4);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs2fvNV 4207
@@ -6545,13 +6549,15 @@ void
 __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 16;
-    emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(v), 4);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs2svNV 4203
@@ -6559,13 +6565,15 @@ void
 __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 16;
-    emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(v), 2);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 2));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs3dvNV 4212
@@ -6573,13 +6581,15 @@ void
 __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 20;
-    emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(v), 8);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 16), (void *)(&n), 4);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs3fvNV 4208
@@ -6587,13 +6597,15 @@ void
 __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 16;
-    emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(v), 4);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs3svNV 4204
@@ -6601,13 +6613,15 @@ void
 __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 16;
-    emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(v), 2);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 2));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs4dvNV 4213
@@ -6615,13 +6629,15 @@ void
 __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 20;
-    emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(v), 8);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 16), (void *)(&n), 4);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs4fvNV 4209
@@ -6629,13 +6645,15 @@ void
 __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 16;
-    emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(v), 4);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs4svNV 4205
@@ -6643,13 +6661,15 @@ void
 __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 16;
-    emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(v), 2);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 2));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_VertexAttribs4ubvNV 4214
@@ -6657,13 +6677,15 @@ void
 __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v)
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
-    const GLuint cmdlen = 16;
-    emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen);
-    (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
-    (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
-    (void) memcpy((void *)(gc->pc + 12), (void *)(v), 1);
-    gc->pc += cmdlen;
-    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    const GLuint cmdlen = 12 + __GLX_PAD((n * 1));
+    if (__builtin_expect(n >= 0, 1)) {
+        emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen);
+        (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+        (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+        (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 1));
+        gc->pc += cmdlen;
+        if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+    }
 }
 
 #define X_GLrop_PointParameteriNV 4221