Module: Mesa
Branch: master
Commit: de31fb2f4f75b253e7d9e4617da6c1d04ae18df9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=de31fb2f4f75b253e7d9e4617da6c1d04ae18df9

Author: Antia Puentes <[email protected]>
Date:   Sat Dec 22 18:40:29 2018 +0100

nir/linker: Fix TRANSFORM_FEEDBACK_BUFFER_INDEX

From the ARB_enhanced_layouts specification:

  "For the property TRANSFORM_FEEDBACK_BUFFER_INDEX, a single integer
   identifying the index of the active transform feedback buffer
   associated with an active variable is written to <params>.  For
   variables corresponding to the special names "gl_NextBuffer",
   "gl_SkipComponents1", "gl_SkipComponents2", "gl_SkipComponents3",
   and "gl_SkipComponents4", -1 is written to <params>."

We were storing the xfb_buffer value, instead of the value
corresponding to GL_TRANSFORM_FEEDBACK_BUFFER_INDEX.

Note that the implementation assumes that varyings would be sorted by
offset and buffer.

Signed-off-by: Antia Puentes <[email protected]>
Signed-off-by: Alejandro PiƱeiro <[email protected]>

Reviewed-by: Timothy Arceri <[email protected]>

---

 src/compiler/glsl/gl_nir_link_xfb.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/gl_nir_link_xfb.c 
b/src/compiler/glsl/gl_nir_link_xfb.c
index bd40ce0efdd..587d65bfb37 100644
--- a/src/compiler/glsl/gl_nir_link_xfb.c
+++ b/src/compiler/glsl/gl_nir_link_xfb.c
@@ -110,6 +110,11 @@ gl_nir_link_assign_xfb_resources(struct gl_context *ctx,
                     xfb_info->varying_count);
    linked_xfb->NumVarying = xfb_info->varying_count;
 
+   int buffer_index = 0; /* Corresponds to GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 
*/
+   int xfb_buffer =
+      (xfb_info->varying_count > 0) ?
+      xfb_info->outputs[0].buffer : 0;
+
    for (unsigned i = 0; i < xfb_info->varying_count; i++) {
       nir_xfb_varying_info *xfb_varying = &xfb_info->varyings[i];
 
@@ -139,13 +144,18 @@ gl_nir_link_assign_xfb_resources(struct gl_context *ctx,
        */
       prog->TransformFeedback.VaryingNames[i] = NULL;
 
+      if (xfb_buffer != xfb_varying->buffer) {
+         buffer_index++;
+         xfb_buffer = xfb_varying->buffer;
+      }
+
       struct gl_transform_feedback_varying_info *varying =
          linked_xfb->Varyings + i;
 
       /* ARB_gl_spirv: see above. */
       varying->Name = NULL;
       varying->Type = glsl_get_gl_type(xfb_varying->type);
-      varying->BufferIndex = xfb_varying->buffer;
+      varying->BufferIndex = buffer_index;
       varying->Size = glsl_get_length(xfb_varying->type);
       varying->Offset = xfb_varying->offset;
    }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to