glsl: Two varyings can't write to the same buffer from different streams.
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 6 Jun 2014 07:44:34 +0000 (09:44 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 30 Jun 2014 06:08:50 +0000 (08:08 +0200)
If this is detected, fail to link.

Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/link_varyings.cpp

index 3b20594873cdb27174f9106e01558aa8da05f9f9..3d5a6807cdd044a19f7d8279ec222eb5871f0145 100644 (file)
@@ -635,10 +635,27 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
    }
    else {
       /* GL_INVERLEAVED_ATTRIBS */
+      int buffer_stream_id = -1;
       for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
          if (tfeedback_decls[i].is_next_buffer_separator()) {
             num_buffers++;
+            buffer_stream_id = -1;
             continue;
+         } else if (buffer_stream_id == -1)  {
+            /* First varying writing to this buffer: remember its stream */
+            buffer_stream_id = (int) tfeedback_decls[i].get_stream_id();
+         } else if (buffer_stream_id !=
+                    (int) tfeedback_decls[i].get_stream_id()) {
+            /* Varying writes to the same buffer from a different stream */
+            linker_error(prog,
+                         "Transform feedback can't capture varyings belonging "
+                         "to different vertex streams in a single buffer. "
+                         "Varying %s writes to buffer from stream %u, other "
+                         "varyings in the same buffer write from stream %u.",
+                         tfeedback_decls[i].name(),
+                         tfeedback_decls[i].get_stream_id(),
+                         buffer_stream_id);
+            return false;
          }
 
          if (!tfeedback_decls[i].store(ctx, prog,