mesa: implement glGet queries and error handling for ARB_transform_feedback3
authorMarek Olšák <maraeo@gmail.com>
Sun, 18 Dec 2011 01:43:31 +0000 (02:43 +0100)
committerMarek Olšák <maraeo@gmail.com>
Thu, 12 Jul 2012 11:05:58 +0000 (13:05 +0200)
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/context.c
src/mesa/main/get.c
src/mesa/main/mtypes.h
src/mesa/main/transformfeedback.c

index 7de714b818ae1effb3e5816d1883cce0aa05519a..d5ccce076b92cd6ece2f705334ba022084477eb7 100644 (file)
@@ -655,6 +655,7 @@ _mesa_init_constants(struct gl_context *ctx)
    ctx->Const.MaxTransformFeedbackBuffers = MAX_FEEDBACK_BUFFERS;
    ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS;
    ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS;
+   ctx->Const.MaxVertexStreams = 1;
 
    /** GL_ARB_uniform_buffer_object */
    ctx->Const.MaxCombinedUniformBlocks = 36;
index cff4cf394555ebbf9ac5813d562f4d8763c7bb91..15de321e400058fac370ea474b55d4ccee1f2089 100644 (file)
@@ -328,6 +328,7 @@ EXTRA_EXT(ARB_sync);
 EXTRA_EXT(ARB_vertex_shader);
 EXTRA_EXT(EXT_transform_feedback);
 EXTRA_EXT(ARB_transform_feedback2);
+EXTRA_EXT(ARB_transform_feedback3);
 EXTRA_EXT(EXT_pixel_buffer_object);
 EXTRA_EXT(ARB_vertex_program);
 EXTRA_EXT2(NV_point_sprite, ARB_point_sprite);
@@ -1247,6 +1248,14 @@ static const struct value_desc values[] = {
    { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0,
      extra_ARB_transform_feedback2 },
 
+   /* GL_ARB_transform_feedback3 */
+   { GL_MAX_TRANSFORM_FEEDBACK_BUFFERS,
+     CONTEXT_INT(Const.MaxTransformFeedbackBuffers),
+     extra_ARB_transform_feedback3 },
+   { GL_MAX_VERTEX_STREAMS,
+     CONTEXT_INT(Const.MaxVertexStreams),
+     extra_ARB_transform_feedback3 },
+
    /* GL_ARB_geometry_shader4 */
    { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB,
      CONTEXT_INT(Const.MaxGeometryTextureImageUnits),
index 276bfe5c1f532265d8c9f406fde5db3996add1a8..578ac9485d7ff000efaab1ffd4e4b1f83e8940f6 100644 (file)
@@ -2837,6 +2837,7 @@ struct gl_constants
    GLuint MaxTransformFeedbackBuffers;
    GLuint MaxTransformFeedbackSeparateComponents;
    GLuint MaxTransformFeedbackInterleavedComponents;
+   GLuint MaxVertexStreams;
 
    /** GL_EXT_gpu_shader4 */
    GLint MinProgramTexelOffset, MaxProgramTexelOffset;
index 6f82212010565da4f1d516ff2a60a46c9c5464e8..7679b4b08539703d2313b9235a172a0676aeb6f8 100644 (file)
@@ -603,6 +603,38 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
       return;
    }
 
+   if (ctx->Extensions.ARB_transform_feedback3) {
+      if (bufferMode == GL_INTERLEAVED_ATTRIBS) {
+         unsigned buffers = 1;
+
+         for (i = 0; i < count; i++) {
+            if (strcmp(varyings[i], "gl_NextBuffer") == 0)
+               buffers++;
+         }
+
+         if (buffers > ctx->Const.MaxTransformFeedbackBuffers) {
+            _mesa_error(ctx, GL_INVALID_OPERATION,
+                        "glTransformFeedbackVaryings(too many gl_NextBuffer "
+                        "occurences)");
+            return;
+         }
+      } else {
+         for (i = 0; i < count; i++) {
+            if (strcmp(varyings[i], "gl_NextBuffer") == 0 ||
+                strcmp(varyings[i], "gl_SkipComponents1") == 0 ||
+                strcmp(varyings[i], "gl_SkipComponents2") == 0 ||
+                strcmp(varyings[i], "gl_SkipComponents3") == 0 ||
+                strcmp(varyings[i], "gl_SkipComponents4") == 0) {
+               _mesa_error(ctx, GL_INVALID_OPERATION,
+                           "glTransformFeedbackVaryings(SEPARATE_ATTRIBS,"
+                           "varying=%s)",
+                           varyings[i]);
+               return;
+            }
+         }
+      }
+   }
+
    /* free existing varyings, if any */
    for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {
       free(shProg->TransformFeedback.VaryingNames[i]);