glsl: Two varyings can't write to the same buffer from different streams.

If this is detected, fail to link.

Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Iago Toral Quiroga
2014-06-06 09:44:34 +02:00
parent 1e1f071d25
commit e2dd717616

View File

@@ -635,10 +635,27 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
} }
else { else {
/* GL_INVERLEAVED_ATTRIBS */ /* GL_INVERLEAVED_ATTRIBS */
int buffer_stream_id = -1;
for (unsigned i = 0; i < num_tfeedback_decls; ++i) { for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
if (tfeedback_decls[i].is_next_buffer_separator()) { if (tfeedback_decls[i].is_next_buffer_separator()) {
num_buffers++; num_buffers++;
buffer_stream_id = -1;
continue; 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, if (!tfeedback_decls[i].store(ctx, prog,