Mesa (master): mesa: Record transform feedback strides/ offsets in linker output.

Paul Berry stereotype441 at kemper.freedesktop.org
Tue Dec 20 23:41:21 UTC 2011


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Tue Dec  6 14:16:59 2011 -0800

mesa: Record transform feedback strides/offsets in linker output.

This patch adds two new fields to the gl_transform_feedback_info
struct:

- BufferStride records the total number of components (per vertex)
  that transform feedback is being instructed to store in each buffer.

- Outputs[i].DstOffset records the offset within the interleaved
  structure of each transform feedback output.

These values are needed by the i965 gen6 and r600g back-ends, so it
seems better to have the linker provide them rather than force each
back-end to compute them independently.

Also, DstOffset helps pave the way for supporting
ARB_transform_feedback3, which allows the transform feedback output to
contain holes between attributes by specifying
gl_SkipComponents{1,2,3,4} as the varying name.

Reviewed-by: Marek Olšák <maraeo at gmail.com>

---

 src/glsl/linker.cpp    |    5 ++++-
 src/mesa/main/mtypes.h |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index b8a7126..6587008 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1598,7 +1598,9 @@ tfeedback_decl::store(struct gl_shader_program *prog,
       info->Outputs[info->NumOutputs].OutputRegister = this->location + v;
       info->Outputs[info->NumOutputs].NumComponents = this->vector_elements;
       info->Outputs[info->NumOutputs].OutputBuffer = buffer;
+      info->Outputs[info->NumOutputs].DstOffset = info->BufferStride[buffer];
       ++info->NumOutputs;
+      info->BufferStride[buffer] += this->vector_elements;
    }
    return true;
 }
@@ -1863,7 +1865,8 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
                      tfeedback_decl *tfeedback_decls)
 {
    unsigned total_tfeedback_components = 0;
-   prog->LinkedTransformFeedback.NumOutputs = 0;
+   memset(&prog->LinkedTransformFeedback, 0,
+          sizeof(prog->LinkedTransformFeedback));
    for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
       unsigned buffer =
          prog->TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS ? i : 0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0e29dc0..93bf04e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1821,7 +1821,17 @@ struct gl_transform_feedback_info {
       unsigned OutputRegister;
       unsigned OutputBuffer;
       unsigned NumComponents;
+
+      /** offset (in DWORDs) of this output within the interleaved structure */
+      unsigned DstOffset;
    } Outputs[MAX_PROGRAM_OUTPUTS];
+
+   /**
+    * Total number of components stored in each buffer.  This may be used by
+    * hardware back-ends to determine the correct stride when interleaving
+    * multiple transform feedback outputs in the same buffer.
+    */
+   unsigned BufferStride[MAX_FEEDBACK_ATTRIBS];
 };
 
 /**




More information about the mesa-commit mailing list