[Piglit] [PATCH 3/4] ATI_fs: add some api tests

Miklós Máté mtmkls at gmail.com
Tue Nov 21 00:04:23 UTC 2017


Signed-off-by: Miklós Máté <mtmkls at gmail.com>
---
 tests/spec/ati_fragment_shader/api-alphafirst.c | 52 ++++++++++++++++++++
 tests/spec/ati_fragment_shader/api-gen.c        | 65 +++++++++++++++++++++++++
 2 files changed, 117 insertions(+)
 create mode 100644 tests/spec/ati_fragment_shader/api-alphafirst.c
 create mode 100644 tests/spec/ati_fragment_shader/api-gen.c

diff --git a/tests/spec/ati_fragment_shader/api-alphafirst.c b/tests/spec/ati_fragment_shader/api-alphafirst.c
new file mode 100644
index 000000000..027d2864f
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/api-alphafirst.c
@@ -0,0 +1,52 @@
+/* TODO license header */
+
+/**
+ * Tests API for GL_ATI_fragment_shader.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	/* UNREACHED */
+	return PIGLIT_FAIL;
+}
+
+#define check_gl_error(err) if (!piglit_check_gl_error(err)) piglit_report_result(PIGLIT_FAIL)
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ATI_fragment_shader");
+
+	/* Create a shader pass beginning with an alpha instruction */
+
+	glBeginFragmentShaderATI();
+	check_gl_error(GL_NO_ERROR);
+	glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+			GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);
+	check_gl_error(GL_NO_ERROR);
+	glEndFragmentShaderATI();
+	check_gl_error(GL_NO_ERROR);
+
+	glBeginFragmentShaderATI();
+	glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+			GL_REG_1_ATI, GL_NONE, GL_NONE);
+	glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+	check_gl_error(GL_NO_ERROR);
+	glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+			GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);
+	check_gl_error(GL_NO_ERROR);
+	glEndFragmentShaderATI();
+	check_gl_error(GL_NO_ERROR);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/api-gen.c b/tests/spec/ati_fragment_shader/api-gen.c
new file mode 100644
index 000000000..e9ca9a6b2
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/api-gen.c
@@ -0,0 +1,65 @@
+/* TODO license header */
+
+/**
+ * Tests basic API functionality for GL_ATI_fragment_shader.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	/* UNREACHED */
+	return PIGLIT_FAIL;
+}
+
+#define check_gl_error(err) if (!piglit_check_gl_error(err)) piglit_report_result(PIGLIT_FAIL)
+
+void
+piglit_init(int argc, char **argv)
+{
+	unsigned id;
+
+	piglit_require_extension("GL_ATI_fragment_shader");
+
+	/* Test GenFragmentShadersATI() */
+
+	id = glGenFragmentShadersATI(3);
+	check_gl_error(GL_NO_ERROR);
+	if (id == 0)
+		piglit_report_result(PIGLIT_FAIL);
+
+	glDeleteFragmentShaderATI(id);
+	check_gl_error(GL_NO_ERROR);
+	glDeleteFragmentShaderATI(id+1);
+	check_gl_error(GL_NO_ERROR);
+	glDeleteFragmentShaderATI(id+2);
+	check_gl_error(GL_NO_ERROR);
+
+	/* gen a few more, leave them hanging */
+	id = glGenFragmentShadersATI(3);
+	check_gl_error(GL_NO_ERROR);
+
+	/* bind allocates the name, no need for gen */
+	glBindFragmentShaderATI(42);
+	check_gl_error(GL_NO_ERROR);
+	glDeleteFragmentShaderATI(42);
+	check_gl_error(GL_NO_ERROR);
+
+	/* bind an other one, leave it hanging */
+	glBindFragmentShaderATI(43);
+	check_gl_error(GL_NO_ERROR);
+
+	/* try to delete a non-existent one */
+	glDeleteFragmentShaderATI(id+8);
+	check_gl_error(GL_NO_ERROR);
+
+	piglit_report_result(PIGLIT_PASS);
+}
-- 
2.15.0.rc0



More information about the Piglit mailing list