aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/transformfeedback.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-08-24 14:47:15 +0200
committerSamuel Pitoiset <[email protected]>2017-08-25 11:35:30 +0200
commita5319d9fde79937ac467007951f358ab1a08176b (patch)
treeb8fbd37ad0b8c40b4c0885aa52942f4df6189fd7 /src/mesa/main/transformfeedback.c
parent4b5140d20bd0461acf90c92060d8a6180555c78a (diff)
mesa: add transform_feedback_varyings() helper
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main/transformfeedback.c')
-rw-r--r--src/mesa/main/transformfeedback.c63
1 files changed, 37 insertions, 26 deletions
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index b2cf30cedbd..b529834fc70 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -832,6 +832,42 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
* This function specifies the transform feedback outputs to be written
* to the feedback buffer(s), and in what order.
*/
+static ALWAYS_INLINE void
+transform_feedback_varyings(struct gl_context *ctx,
+ struct gl_shader_program *shProg, GLsizei count,
+ const GLchar *const *varyings, GLenum bufferMode)
+{
+ GLint i;
+
+ /* free existing varyings, if any */
+ for (i = 0; i < (GLint) shProg->TransformFeedback.NumVarying; i++) {
+ free(shProg->TransformFeedback.VaryingNames[i]);
+ }
+ free(shProg->TransformFeedback.VaryingNames);
+
+ /* allocate new memory for varying names */
+ shProg->TransformFeedback.VaryingNames =
+ malloc(count * sizeof(GLchar *));
+
+ if (!shProg->TransformFeedback.VaryingNames) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTransformFeedbackVaryings()");
+ return;
+ }
+
+ /* Save the new names and the count */
+ for (i = 0; i < count; i++) {
+ shProg->TransformFeedback.VaryingNames[i] = strdup(varyings[i]);
+ }
+ shProg->TransformFeedback.NumVarying = count;
+
+ shProg->TransformFeedback.BufferMode = bufferMode;
+
+ /* No need to invoke FLUSH_VERTICES or flag NewTransformFeedback since
+ * the varyings won't be used until shader link time.
+ */
+}
+
+
void GLAPIENTRY
_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
const GLchar * const *varyings,
@@ -907,32 +943,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
}
}
- /* free existing varyings, if any */
- for (i = 0; i < (GLint) shProg->TransformFeedback.NumVarying; i++) {
- free(shProg->TransformFeedback.VaryingNames[i]);
- }
- free(shProg->TransformFeedback.VaryingNames);
-
- /* allocate new memory for varying names */
- shProg->TransformFeedback.VaryingNames =
- malloc(count * sizeof(GLchar *));
-
- if (!shProg->TransformFeedback.VaryingNames) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTransformFeedbackVaryings()");
- return;
- }
-
- /* Save the new names and the count */
- for (i = 0; i < count; i++) {
- shProg->TransformFeedback.VaryingNames[i] = strdup(varyings[i]);
- }
- shProg->TransformFeedback.NumVarying = count;
-
- shProg->TransformFeedback.BufferMode = bufferMode;
-
- /* No need to invoke FLUSH_VERTICES or flag NewTransformFeedback since
- * the varyings won't be used until shader link time.
- */
+ transform_feedback_varyings(ctx, shProg, count, varyings, bufferMode);
}