[v2,09/15] nv_conditional_render: add helpers to compile useful programs

Submitted by Erik Faye-Lund on Nov. 7, 2018, 9:14 p.m.

Details

Message ID 20181107211420.7355-10-erik.faye-lund@collabora.com
State New
Headers show

Not browsing as part of any series.

Patch hide | download patch | download mbox

diff --git a/tests/spec/nv_conditional_render/common.c b/tests/spec/nv_conditional_render/common.c
index f47c9939d..f17d10cc6 100644
--- a/tests/spec/nv_conditional_render/common.c
+++ b/tests/spec/nv_conditional_render/common.c
@@ -43,6 +43,42 @@  fill_tex(int level, int w, int h, const unsigned char *color)
 	free(data);
 }
 
+static const char *vs_source =
+	"attribute vec4 piglit_vertex;\n"
+	"attribute vec4 piglit_texcoord;\n"
+	"varying vec2 uv;\n"
+	"void main()\n"
+	"{\n"
+	"  gl_Position = piglit_vertex;\n"
+	"  uv = piglit_texcoord.xy;\n"
+	"}\n";
+
+static const char *fs_source_green =
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
+	"}\n";
+
+static const char *fs_source_texture =
+	"uniform sampler2D tex;\n"
+	"varying mediump vec2 uv;\n"
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = texture2D(tex, uv);\n"
+	"}\n";
+
+GLint
+build_green_program()
+{
+	return piglit_build_simple_program(vs_source, fs_source_green);
+}
+
+GLint
+build_texture_program()
+{
+	return piglit_build_simple_program(vs_source, fs_source_texture);
+}
+
 void
 gen_queries(GLsizei n, GLuint *ids)
 {
diff --git a/tests/spec/nv_conditional_render/common.h b/tests/spec/nv_conditional_render/common.h
index d50063c28..d03d012dd 100644
--- a/tests/spec/nv_conditional_render/common.h
+++ b/tests/spec/nv_conditional_render/common.h
@@ -30,6 +30,12 @@ 
 void
 fill_tex(int level, int w, int h, const unsigned char *color);
 
+GLint
+build_green_program();
+
+GLint
+build_texture_program();
+
 void
 gen_queries(GLsizei n, GLuint *ids);