mesa: add support to query GL_TRANSFORM_FEEDBACK_BUFFER_INDEX
authorTimothy Arceri <timothy.arceri@collabora.com>
Thu, 10 Mar 2016 04:57:19 +0000 (15:57 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Thu, 31 Mar 2016 01:52:47 +0000 (12:52 +1100)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/compiler/glsl/link_varyings.cpp
src/compiler/glsl/link_varyings.h
src/mesa/main/mtypes.h
src/mesa/main/shader_query.cpp

index b091eaf55128899dc4b18619b4b8dff8887f378e..a3b7e1c65c7ac36a3d944f93378661acb9c1e7df 100644 (file)
@@ -725,8 +725,9 @@ tfeedback_decl::get_num_outputs() const
 bool
 tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
                       struct gl_transform_feedback_info *info,
-                      unsigned buffer, const unsigned max_outputs,
-                      bool *explicit_stride, bool has_xfb_qualifiers) const
+                      unsigned buffer, unsigned buffer_index,
+                      const unsigned max_outputs, bool *explicit_stride,
+                      bool has_xfb_qualifiers) const
 {
    assert(!this->next_buffer_separator);
 
@@ -823,6 +824,7 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
                                                          this->orig_name);
    info->Varyings[info->NumVarying].Type = this->type;
    info->Varyings[info->NumVarying].Size = this->size;
+   info->Varyings[info->NumVarying].BufferIndex = buffer_index;
    info->NumVarying++;
 
    return true;
@@ -976,8 +978,8 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
       /* GL_SEPARATE_ATTRIBS */
       for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
          if (!tfeedback_decls[i].store(ctx, prog, &prog->LinkedTransformFeedback,
-                                       num_buffers, num_outputs, NULL,
-                                       has_xfb_qualifiers))
+                                       num_buffers, num_buffers, num_outputs,
+                                       NULL, has_xfb_qualifiers))
             return false;
 
          buffers |= 1 << num_buffers;
@@ -1008,6 +1010,7 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
              buffer != tfeedback_decls[i].get_buffer()) {
             /* we have moved to the next buffer so reset stream id */
             buffer_stream_id = -1;
+            num_buffers++;
          }
 
          if (tfeedback_decls[i].is_next_buffer_separator()) {
@@ -1036,11 +1039,11 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
          } else {
             buffer = num_buffers;
          }
-         buffers |= 1 << num_buffers;
+         buffers |= 1 << buffer;
 
          if (!tfeedback_decls[i].store(ctx, prog,
                                        &prog->LinkedTransformFeedback,
-                                       num_buffers, num_outputs,
+                                       buffer, num_buffers, num_outputs,
                                        explicit_stride, has_xfb_qualifiers))
             return false;
       }
index 9ea79f04fa8d07b444e6e0c478aef0a4713e9a19..543b80ff29b49815faa97b431ae0193070286496 100644 (file)
@@ -98,8 +98,8 @@ public:
    unsigned get_num_outputs() const;
    bool store(struct gl_context *ctx, struct gl_shader_program *prog,
               struct gl_transform_feedback_info *info, unsigned buffer,
-              const unsigned max_outputs, bool *explicit_stride,
-              bool has_xfb_qualifiers) const;
+              unsigned buffer_index, const unsigned max_outputs,
+              bool *explicit_stride, bool has_xfb_qualifiers) const;
    const tfeedback_candidate *find_candidate(gl_shader_program *prog,
                                              hash_table *tfeedback_candidates);
 
index 320297cdfe979251ed9e2490037cee3dd066520a..33923d195c949d838f4ac787562870474dad7db0 100644 (file)
@@ -1618,6 +1618,7 @@ struct gl_transform_feedback_varying_info
 {
    char *Name;
    GLenum Type;
+   GLint BufferIndex;
    GLint Size;
    GLint Offset;
 };
index 15cc49afbfc2d684eef1aed24b57027e4aaeb4ed..ee2eeab0f8dcedc490126e1059c6933779c94475 100644 (file)
@@ -1322,6 +1322,12 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
       default:
          goto invalid_operation;
       }
+
+   case GL_TRANSFORM_FEEDBACK_BUFFER_INDEX:
+      VALIDATE_TYPE(GL_TRANSFORM_FEEDBACK_VARYING);
+      *val = RESOURCE_XFV(res)->BufferIndex;
+      return 1;
+
    default:
       goto invalid_enum;
    }