Mesa (master): glsl: Transform fb buffers are only active if a variable uses them
Neil Roberts
nroberts at kemper.freedesktop.org
Thu Nov 9 04:48:56 UTC 2017
Module: Mesa
Branch: master
Commit: 4dc8458cd13154daa48bd97c3f8393daf02aa351
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4dc8458cd13154daa48bd97c3f8393daf02aa351
Author: Neil Roberts <nroberts at igalia.com>
Date: Mon Oct 30 13:22:49 2017 +0100
glsl: Transform fb buffers are only active if a variable uses them
The GL spec will soon be revised to clarify that a buffer binding for
a transform feedback buffer is only required if a variable is actually
defined to use the buffer binding point. Previously a declaration for
the default transform buffer would make it require a binding even if
nothing was declared to use the default buffer.
Affects:
KHR-GL44/45.enhanced_layouts.xfb_stride_of_empty_list
KHR-GL44/45.enhanced_layouts.xfb_stride_of_empty_list_and_api
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
Cc: mesa-stable at lists.freedesktop.org
---
src/compiler/glsl/link_varyings.cpp | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 66a20a2c9b..e6639306be 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -1364,7 +1364,6 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
if (has_xfb_qualifiers) {
for (unsigned j = 0; j < MAX_FEEDBACK_BUFFERS; j++) {
if (prog->TransformFeedback.BufferStride[j]) {
- buffers |= 1 << j;
explicit_stride[j] = true;
xfb_prog->sh.LinkedTransformFeedback->Buffers[j].Stride =
prog->TransformFeedback.BufferStride[j] / 4;
@@ -1389,10 +1388,24 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
num_buffers++;
buffer_stream_id = -1;
continue;
- } else if (tfeedback_decls[i].is_varying()) {
+ }
+
+ if (has_xfb_qualifiers) {
+ buffer = tfeedback_decls[i].get_buffer();
+ } else {
+ buffer = num_buffers;
+ }
+
+ if (tfeedback_decls[i].is_varying()) {
if (buffer_stream_id == -1) {
/* First varying writing to this buffer: remember its stream */
buffer_stream_id = (int) tfeedback_decls[i].get_stream_id();
+
+ /* Only mark a buffer as active when there is a varying
+ * attached to it. This behaviour is based on a revised version
+ * of section 13.2.2 of the GL 4.6 spec.
+ */
+ buffers |= 1 << buffer;
} else if (buffer_stream_id !=
(int) tfeedback_decls[i].get_stream_id()) {
/* Varying writes to the same buffer from a different stream */
@@ -1408,13 +1421,6 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
}
}
- if (has_xfb_qualifiers) {
- buffer = tfeedback_decls[i].get_buffer();
- } else {
- buffer = num_buffers;
- }
- buffers |= 1 << buffer;
-
if (!tfeedback_decls[i].store(ctx, prog,
xfb_prog->sh.LinkedTransformFeedback,
buffer, num_buffers, num_outputs,
More information about the mesa-commit
mailing list