[Mesa-dev] [PATCH 3/7] mesa: Add gl_transform_feedback_info::ComponentOffset.

Paul Berry stereotype441 at gmail.com
Thu Dec 29 09:16:24 PST 2011


When using transform feedback, there are three circumstances in which
it is useful for Mesa to instruct a driver to stream out just a
portion of a varying slot (rather than the whole vec4):

(a) When a varying is smaller than a vec4, Mesa needs to instruct the
driver to stream out just the first one, two, or three components of
the varying slot.

(b) In the future, when we implement varying packing, some varyings
will be offset within the vec4, so Mesa will have to instruct the
driver to stream out an arbitrary contiguous subset of the components
of the varying slot (e.g. .yzw or .yz).

(c) On drivers that set gl_shader_compiler_options::LowerClipDistance,
if the client requests that an element of gl_ClipDistance be streamed
out using transform feedback, Mesa will have to instruct the driver to
stream out a single component of one of the gl_ClipDistance varying
slots.

Previous to this patch, only (a) was possible, since
gl_transform_feedback_info specified only the number of components of
the varying slot to stream out.  This patch adds
gl_transform_feedback_info::ComponentOffset, which indicates which
components should be streamed out.
---
 src/glsl/linker.cpp    |    1 +
 src/mesa/main/mtypes.h |    7 +++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 6587008..452d8b5 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1599,6 +1599,7 @@ tfeedback_decl::store(struct gl_shader_program *prog,
       info->Outputs[info->NumOutputs].NumComponents = this->vector_elements;
       info->Outputs[info->NumOutputs].OutputBuffer = buffer;
       info->Outputs[info->NumOutputs].DstOffset = info->BufferStride[buffer];
+      info->Outputs[info->NumOutputs].ComponentOffset = 0;
       ++info->NumOutputs;
       info->BufferStride[buffer] += this->vector_elements;
    }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 107371e..d520f98 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1828,6 +1828,13 @@ struct gl_transform_feedback_info {
 
       /** offset (in DWORDs) of this output within the interleaved structure */
       unsigned DstOffset;
+
+      /**
+       * Offset into the output register of the data to output.  For example,
+       * if NumComponents is 2 and ComponentOffset is 1, then the data to
+       * offset is in the y and z components of the output register.
+       */
+      unsigned ComponentOffset;
    } Outputs[MAX_PROGRAM_OUTPUTS];
 
    /**
-- 
1.7.6.4



More information about the mesa-dev mailing list