[Piglit] [PATCH 08/10] sso: Add a utility function to compile a vertex shader program w/XFB

Ian Romanick idr at freedesktop.org
Sun Apr 27 14:12:11 PDT 2014


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 .../spec/arb_separate_shader_objects/sso-common.c  | 27 ++++++++++++++++++++++
 .../spec/arb_separate_shader_objects/sso-common.h  |  5 ++++
 2 files changed, 32 insertions(+)

diff --git a/tests/spec/arb_separate_shader_objects/sso-common.c b/tests/spec/arb_separate_shader_objects/sso-common.c
index c73c741..29ae23f 100644
--- a/tests/spec/arb_separate_shader_objects/sso-common.c
+++ b/tests/spec/arb_separate_shader_objects/sso-common.c
@@ -75,3 +75,30 @@ configure_transform_feedback_object(GLuint *xfb, GLuint *buf)
 	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, *xfb);
 	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, *buf);
 }
+
+/**
+ * Create a separable vertex shader program with transform feedback output
+ *
+ * A vertex shader must be created using the "traditional" API because
+ * \c glTransformFeedbackVaryings must be called before linking.  There is no
+ * way to do that with \c glCreateShaderProgramv.
+ */
+bool
+CreateShaderProgram_with_xfb(const char *source,
+			     const char **varyings,
+			     unsigned num_varyings,
+			     GLuint *vs_prog)
+{
+	GLuint vs = piglit_compile_shader_text(GL_VERTEX_SHADER, source);
+
+	*vs_prog = glCreateProgram();
+	glAttachShader(*vs_prog, vs);
+
+	glProgramParameteri(*vs_prog, GL_PROGRAM_SEPARABLE, GL_TRUE);
+	glTransformFeedbackVaryings(*vs_prog, num_varyings, varyings,
+				    GL_INTERLEAVED_ATTRIBS);
+	glLinkProgram(*vs_prog);
+	glDeleteShader(vs);
+
+	return piglit_link_check_status(*vs_prog);
+}
diff --git a/tests/spec/arb_separate_shader_objects/sso-common.h b/tests/spec/arb_separate_shader_objects/sso-common.h
index 627df4c..af6e610 100644
--- a/tests/spec/arb_separate_shader_objects/sso-common.h
+++ b/tests/spec/arb_separate_shader_objects/sso-common.h
@@ -28,4 +28,9 @@ unsigned pick_a_glsl_version(void);
 
 void configure_transform_feedback_object(GLuint *xfb, GLuint *buf);
 
+bool CreateShaderProgram_with_xfb(const char *source,
+				  const char **varyings,
+				  unsigned num_varyings,
+				  GLuint *vs_prog);
+
 #endif /* SSO_COMMON_H */
-- 
1.8.1.4



More information about the Piglit mailing list