[Piglit] [PATCH 1/4] ATI_fs: add api error tests
Miklós Máté
mtmkls at gmail.com
Tue Nov 21 00:04:21 UTC 2017
One for each paragraph in the Errors section of the spec.
Signed-off-by: Miklós Máté <mtmkls at gmail.com>
---
tests/spec/ati_fragment_shader/error01-genzero.c | 51 ++++
tests/spec/ati_fragment_shader/error02-inside.c | 59 +++++
tests/spec/ati_fragment_shader/error03-outside.c | 89 +++++++
tests/spec/ati_fragment_shader/error04-endshader.c | 93 ++++++++
tests/spec/ati_fragment_shader/error05-passes.c | 123 ++++++++++
.../spec/ati_fragment_shader/error06-regswizzle.c | 263 +++++++++++++++++++++
tests/spec/ati_fragment_shader/error07-instcount.c | 89 +++++++
tests/spec/ati_fragment_shader/error08-secondary.c | 82 +++++++
tests/spec/ati_fragment_shader/error09-allconst.c | 78 ++++++
tests/spec/ati_fragment_shader/error10-dotx.c | 115 +++++++++
.../spec/ati_fragment_shader/error11-invaliddst.c | 171 ++++++++++++++
.../spec/ati_fragment_shader/error12-invalidsrc.c | 151 ++++++++++++
.../spec/ati_fragment_shader/error13-invalidarg.c | 121 ++++++++++
.../spec/ati_fragment_shader/error14-invalidmod.c | 129 ++++++++++
14 files changed, 1614 insertions(+)
create mode 100644 tests/spec/ati_fragment_shader/error01-genzero.c
create mode 100644 tests/spec/ati_fragment_shader/error02-inside.c
create mode 100644 tests/spec/ati_fragment_shader/error03-outside.c
create mode 100644 tests/spec/ati_fragment_shader/error04-endshader.c
create mode 100644 tests/spec/ati_fragment_shader/error05-passes.c
create mode 100644 tests/spec/ati_fragment_shader/error06-regswizzle.c
create mode 100644 tests/spec/ati_fragment_shader/error07-instcount.c
create mode 100644 tests/spec/ati_fragment_shader/error08-secondary.c
create mode 100644 tests/spec/ati_fragment_shader/error09-allconst.c
create mode 100644 tests/spec/ati_fragment_shader/error10-dotx.c
create mode 100644 tests/spec/ati_fragment_shader/error11-invaliddst.c
create mode 100644 tests/spec/ati_fragment_shader/error12-invalidsrc.c
create mode 100644 tests/spec/ati_fragment_shader/error13-invalidarg.c
create mode 100644 tests/spec/ati_fragment_shader/error14-invalidmod.c
diff --git a/tests/spec/ati_fragment_shader/error01-genzero.c b/tests/spec/ati_fragment_shader/error01-genzero.c
new file mode 100644
index 000000000..a19fb2ffc
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error01-genzero.c
@@ -0,0 +1,51 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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 = 42;
+
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 1 of the Errors section:
+ *
+ * The error INVALID_VALUE is generated if GenFragmentShadersATI is
+ * called where <range> is zero.
+ */
+
+ id = glGenFragmentShadersATI(0);
+ check_gl_error(GL_INVALID_VALUE);
+
+ /* The spec also says that 0 is returned */
+ if (id != 0)
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* Note that the spec also says that no shaders are generated,
+ * but there is no way of testing that */
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error02-inside.c b/tests/spec/ati_fragment_shader/error02-inside.c
new file mode 100644
index 000000000..5dee70cf6
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error02-inside.c
@@ -0,0 +1,59 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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");
+
+ /*
+ * Paragraph 2 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated if GenFragmentShadersATI,
+ * BindFragmentShaderATI, DeleteFragmentShaderATI, or
+ * BeginFragmentShaderATI are specified inside a
+ * Begin/EndFragmentShaderATI pair.
+ */
+
+ glBeginFragmentShaderATI();
+
+ check_gl_error(GL_NO_ERROR);
+ glGenFragmentShadersATI(1);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glBindFragmentShaderATI(2);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glDeleteFragmentShaderATI(3);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_INVALID_OPERATION);
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error03-outside.c b/tests/spec/ati_fragment_shader/error03-outside.c
new file mode 100644
index 000000000..9a366c212
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error03-outside.c
@@ -0,0 +1,89 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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");
+
+ /*
+ * Paragraph 3 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated if EndFragmentShaderATI,
+ * PassTexCoordATI, SampleMapATI, ColorFragmentOp[1..3]ATI, or
+ * AlphaFragmentOp[1..3]ATI is specified outside a
+ * Begin/EndFragmentShaderATI pair.
+ */
+
+ check_gl_error(GL_NO_ERROR);
+ glEndFragmentShaderATI();
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE,
+ GL_REG_2_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp3ATI(GL_MAD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE,
+ GL_REG_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE,
+ GL_REG_2_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp3ATI(GL_MAD_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE,
+ GL_REG_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error04-endshader.c b/tests/spec/ati_fragment_shader/error04-endshader.c
new file mode 100644
index 000000000..a0801ff86
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error04-endshader.c
@@ -0,0 +1,93 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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");
+
+ /*
+ * Paragraph 4 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated by EndFragmentShaderATI if
+ * <argN> passed to ColorFragmentOp[1..3]ATI or
+ * AlphaFragmentOp[1..3]ATI is PRIMARY_COLOR_ARB or
+ * SECONDARY_INTERPOLATOR_ATI on the first pass of a two-pass shader,
+ * or if the shader cannot be compiled due to some other
+ * implementation-dependent limitation. EndFragmentShaderATI will
+ * still have a side-effect if this error is encountered: the
+ * Begin/EndFragmentShaderATI pair will be closed, and the current
+ * shader will be undefined.
+ */
+
+ /* use GL_PRIMARY_COLOR_ARB in the first pass */
+ glBeginFragmentShaderATI();
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glEndFragmentShaderATI();
+ check_gl_error(GL_INVALID_OPERATION);
+
+ /* see if EndFragmentShaderATI really ended the shader */
+ check_gl_error(GL_NO_ERROR);
+ glEndFragmentShaderATI();
+ check_gl_error(GL_INVALID_OPERATION);
+
+ /* use GL_SECONDARY_INTERPOLATOR_ATI in the first pass */
+ glBeginFragmentShaderATI();
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glEndFragmentShaderATI();
+ check_gl_error(GL_INVALID_OPERATION);
+
+ /* see if EndFragmentShaderATI really ended the shader */
+ check_gl_error(GL_NO_ERROR);
+ glEndFragmentShaderATI();
+ check_gl_error(GL_INVALID_OPERATION);
+
+ /* use them in a single-pass shader */
+ glBeginFragmentShaderATI();
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+
+ /* TODO what implementation-dependent limitation to check here? */
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error05-passes.c b/tests/spec/ati_fragment_shader/error05-passes.c
new file mode 100644
index 000000000..13b5b3471
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error05-passes.c
@@ -0,0 +1,123 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#include "piglit-util-gl.h"
+
+static struct piglit_gl_test_config *piglit_config;
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ piglit_config = &config;
+ 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)) return PIGLIT_FAIL
+
+static enum piglit_result
+too_many_passes(void *data)
+{
+ 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);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ 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);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ return PIGLIT_PASS;
+}
+
+static enum piglit_result
+same_reg_written_twice(void *data)
+{
+ glBeginFragmentShaderATI();
+ glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ return PIGLIT_PASS;
+}
+
+static const struct piglit_subtest subtests[] = {
+ {
+ "Too many passes",
+ "too-many-passes",
+ too_many_passes,
+ NULL
+ },
+ {
+ "Same reg written twice",
+ "same-reg-written-twice",
+ same_reg_written_twice,
+ NULL
+ },
+ {
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ }
+};
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 5 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated by PassTexCoordATI or
+ * SampleMapATI if two shader passes have already been specified, or if
+ * the same <dst> register is specified twice in the same pass.
+ */
+
+ piglit_report_result(piglit_run_selected_subtests(subtests,
+ piglit_config->selected_subtests,
+ piglit_config->num_selected_subtests,
+ PIGLIT_SKIP));
+}
diff --git a/tests/spec/ati_fragment_shader/error06-regswizzle.c b/tests/spec/ati_fragment_shader/error06-regswizzle.c
new file mode 100644
index 000000000..74a597ca9
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error06-regswizzle.c
@@ -0,0 +1,263 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#include "piglit-util-gl.h"
+
+static struct piglit_gl_test_config *piglit_config;
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ piglit_config = &config;
+ 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)) return PIGLIT_FAIL
+
+static enum piglit_result
+reg_src_in_first_pass(void *data)
+{
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ return PIGLIT_PASS;
+}
+
+static enum piglit_result
+stq_swizzle_on_reg(void *data)
+{
+ glBeginFragmentShaderATI();
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ 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);
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_DQ_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ 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);
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ 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);
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STQ_DQ_ATI);
+ check_gl_error(GL_INVALID_OPERATION);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+
+ return PIGLIT_PASS;
+}
+
+static bool
+check_swizzle_passtexcoord(unsigned src, unsigned swizzle1, unsigned swizzle2, unsigned error)
+{
+ bool ret = true;
+
+ 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, src, swizzle1);
+ if (!piglit_check_gl_error(GL_NO_ERROR)) ret = false;
+ glPassTexCoordATI(GL_REG_1_ATI, src, swizzle2);
+ if (!piglit_check_gl_error(error)) ret = false;
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+ if (!piglit_check_gl_error(GL_NO_ERROR)) ret = false;
+
+ return ret;
+}
+
+static enum piglit_result
+different_swizzle_on_same_tex_passtexcoord(void *data)
+{
+ bool pass = true;
+
+ pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_ATI, GL_INVALID_OPERATION);
+ pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR);
+ pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION);
+ pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STR_DR_ATI, GL_INVALID_OPERATION);
+ pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_NO_ERROR);
+ pass &= check_swizzle_passtexcoord(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_DR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION);
+ /* TODO check that using the same swizzle twice is not an error */
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+static bool
+check_swizzle_samplemap(unsigned src, unsigned swizzle1, unsigned swizzle2, unsigned error)
+{
+ bool ret = true;
+
+ 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, src, swizzle1);
+ if (!piglit_check_gl_error(GL_NO_ERROR)) ret = false;
+ glSampleMapATI(GL_REG_1_ATI, src, swizzle2);
+ if (!piglit_check_gl_error(error)) ret = false;
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+ if (!piglit_check_gl_error(GL_NO_ERROR)) ret = false;
+
+ return ret;
+}
+
+static enum piglit_result
+different_swizzle_on_same_tex_samplemap(void *data)
+{
+ bool pass = true;
+
+ pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_ATI, GL_INVALID_OPERATION);
+ pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR);
+ pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION);
+ pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STR_DR_ATI, GL_INVALID_OPERATION);
+ pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_NO_ERROR);
+ pass &= check_swizzle_samplemap(GL_TEXTURE0_ARB, GL_SWIZZLE_STR_DR_ATI, GL_SWIZZLE_STQ_DQ_ATI, GL_INVALID_OPERATION);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+static enum piglit_result
+different_swizzle_on_same_reg(void *data)
+{
+ bool pass = true;
+
+ pass &= check_swizzle_passtexcoord(GL_REG_0_ATI, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR);
+ pass &= check_swizzle_samplemap(GL_REG_0_ATI, GL_SWIZZLE_STR_ATI, GL_SWIZZLE_STR_DR_ATI, GL_NO_ERROR);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+static const struct piglit_subtest subtests[] = {
+ {
+ "REG source in first pass",
+ "reg-src-in-first-pass",
+ reg_src_in_first_pass,
+ NULL
+ },
+ {
+ "STQ swizzle on REG",
+ "stq-swizzle-on-reg",
+ stq_swizzle_on_reg,
+ NULL
+ },
+ {
+ "Different swizzle on the same TEX in PassTexCoord",
+ "different_swizzle_on_same_tex_passtexcoord",
+ different_swizzle_on_same_tex_passtexcoord,
+ NULL
+ },
+ {
+ "Different swizzle on the same TEX in SampleMap",
+ "different_swizzle_on_same_tex_samplemap",
+ different_swizzle_on_same_tex_samplemap,
+ NULL
+ },
+ {
+ "Different swizzle on the same REG",
+ "different_swizzle_on_same_reg",
+ different_swizzle_on_same_reg,
+ NULL
+ },
+ {
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ }
+};
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 6 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated by PassTexCoordATI or
+ * SampleMapATI if <coord> passed to PassTexCoordATI or <interp> passed
+ * to SampleMapATI is a register in the first pass, or a register with
+ * SWIZZLE_STQ_ATI or SWIZZLE_STQ_DQ_ATI <swizzle> in the second pass,
+ * or if different <swizzle> parameters are specified for the same
+ * <coord> or <interp> in the same pass.
+ */
+ /* Note that the spec is sloppy at the last part. Only STR and STQ are
+ * incompatible, but e.g. STR and STR_DR are not. This only applies to
+ * texture sources, but not to registers.
+ * See r200_fragshader.c:333
+ */
+
+ piglit_report_result(piglit_run_selected_subtests(subtests,
+ piglit_config->selected_subtests,
+ piglit_config->num_selected_subtests,
+ PIGLIT_SKIP));
+}
diff --git a/tests/spec/ati_fragment_shader/error07-instcount.c b/tests/spec/ati_fragment_shader/error07-instcount.c
new file mode 100644
index 000000000..dc019235f
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error07-instcount.c
@@ -0,0 +1,89 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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
+maxlength_shader(void)
+{
+ unsigned u;
+
+ for (u=0; u<8; u++) {
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ }
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 7 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated by ColorFragmentOp[1..3]ATI
+ * or AlphaFragmentOp[1..3]ATI if more than 8 instructions have been
+ * specified for a shader pass.
+ */
+
+ glBeginFragmentShaderATI();
+ maxlength_shader();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ maxlength_shader();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ maxlength_shader();
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+ maxlength_shader();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ maxlength_shader();
+ glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+ maxlength_shader();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error08-secondary.c b/tests/spec/ati_fragment_shader/error08-secondary.c
new file mode 100644
index 000000000..f886a5e95
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error08-secondary.c
@@ -0,0 +1,82 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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");
+
+ /*
+ * Paragraph 8 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated by ColorFragmentOp[1..3]ATI
+ * if <argN> is SECONDARY_INTERPOLATOR_ATI and <argNRep> is ALPHA, or
+ * by AlphaFragmentOp[1..3]ATI if <argN> is SECONDARY_INTERPOLATOR_ATI
+ * and <argNRep> is ALPHA or NONE, or by ColorFragmentOp2ATI if <op> is
+ * DOT4_ATI and <argN> is SECONDARY_INTERPOLATOR_ATI and <argNRep> is
+ * ALPHA or NONE.
+ */
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_SECONDARY_INTERPOLATOR_ATI, GL_ALPHA, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_SECONDARY_INTERPOLATOR_ATI, GL_ALPHA, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ /* DOT4 */
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_SECONDARY_INTERPOLATOR_ATI, GL_ALPHA, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error09-allconst.c b/tests/spec/ati_fragment_shader/error09-allconst.c
new file mode 100644
index 000000000..46def9fba
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error09-allconst.c
@@ -0,0 +1,78 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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");
+
+ /*
+ * Paragraph 9 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated by ColorFragmentOp3ATI or
+ * AlphaFragmentOp3ATI if all three <argN> parameters are constants,
+ * and all three are different.
+ */
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_CON_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_CON_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ /* No error if some of them are the same (not exhaustive test) */
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_CON_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_CON_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glEndFragmentShaderATI();
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error10-dotx.c b/tests/spec/ati_fragment_shader/error10-dotx.c
new file mode 100644
index 000000000..98f24dd3f
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error10-dotx.c
@@ -0,0 +1,115 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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");
+
+ /*
+ * Paragraph 10 of the Errors section:
+ *
+ * The error INVALID_OPERATION is generated by AlphaFragmentOp[2..3]ATI
+ * if <op> is DOT3_ATI, DOT4_ATI, or DOT2_ADD_ATI and there was no
+ * matching ColorFragmentOp[2..3]ATI immediately preceding, or if <op>
+ * is not DOT4_ATI and the immediately preceding ColorFragmentOp2ATI
+ * specifies an <op> of DOT4_ATI.
+ */
+
+ /* nothing before it */
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ /* mismatching color op before it */
+
+ glBeginFragmentShaderATI();
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_CON_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ /* after color DOT4 the alpha is not DOT4 */
+
+ glBeginFragmentShaderATI();
+ glColorFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_2_ATI, GL_NONE, GL_NONE,
+ GL_CON_3_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE,
+ GL_CON_2_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error(GL_INVALID_OPERATION);
+ glEndFragmentShaderATI();
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error11-invaliddst.c b/tests/spec/ati_fragment_shader/error11-invaliddst.c
new file mode 100644
index 000000000..d822414e7
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error11-invaliddst.c
@@ -0,0 +1,171 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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)) return false
+#define check_gl_error_enum(err, en) if (!piglit_check_gl_error(err)) \
+ { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); return false; }
+
+bool
+try_enum(unsigned e)
+{
+ printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e), e);
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(e, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(e, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, e, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, e, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ glEndFragmentShaderATI();
+
+ /* TODO check fragment ops with more arguments? */
+
+ return true;
+}
+
+/* Trying all possible enum values is overkill, only try ones that are
+ * used in fragment shaders, thus being common user errors.
+ * Note that some of them have the same numeric value. */
+static const unsigned enums[] = {
+ GL_CON_0_ATI,
+ GL_CON_1_ATI,
+ GL_CON_2_ATI,
+ GL_CON_3_ATI,
+ GL_CON_4_ATI,
+ GL_CON_5_ATI,
+ GL_CON_6_ATI,
+ GL_CON_7_ATI,
+ GL_MOV_ATI,
+ GL_ADD_ATI,
+ GL_MUL_ATI,
+ GL_SUB_ATI,
+ GL_DOT3_ATI,
+ GL_DOT4_ATI,
+ GL_MAD_ATI,
+ GL_LERP_ATI,
+ GL_CND_ATI,
+ GL_CND0_ATI,
+ GL_DOT2_ADD_ATI,
+ GL_SECONDARY_INTERPOLATOR_ATI,
+ GL_SWIZZLE_STR_ATI,
+ GL_SWIZZLE_STQ_ATI,
+ GL_SWIZZLE_STR_DR_ATI,
+ GL_SWIZZLE_STQ_DQ_ATI,
+ GL_SWIZZLE_STRQ_ATI,
+ GL_SWIZZLE_STRQ_DQ_ATI,
+ GL_RED_BIT_ATI,
+ GL_GREEN_BIT_ATI,
+ GL_BLUE_BIT_ATI,
+ GL_2X_BIT_ATI,
+ GL_4X_BIT_ATI,
+ GL_8X_BIT_ATI,
+ GL_HALF_BIT_ATI,
+ GL_QUARTER_BIT_ATI,
+ GL_EIGHTH_BIT_ATI,
+ GL_SATURATE_BIT_ATI,
+ GL_COMP_BIT_ATI,
+ GL_NEGATE_BIT_ATI,
+ GL_BIAS_BIT_ATI,
+ GL_TEXTURE0_ARB,
+ GL_TEXTURE1_ARB,
+ GL_TEXTURE2_ARB,
+ GL_TEXTURE3_ARB,
+ GL_TEXTURE4_ARB,
+ GL_TEXTURE5_ARB,
+ GL_TEXTURE6_ARB,
+ GL_TEXTURE7_ARB,
+ GL_PRIMARY_COLOR_ARB,
+ GL_NONE,
+ GL_RED,
+ GL_GREEN,
+ GL_BLUE,
+ GL_ALPHA,
+};
+
+void
+piglit_init(int argc, char **argv)
+{
+ int num_tex_units;
+ unsigned i;
+
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 11 of the Errors section:
+ *
+ * The error INVALID_ENUM is generated if <dst> passed to
+ * PassTexCoordATI, SampleMapATI, ColorFragmentOp[1..3]ATI, or
+ * AlphaFragmentOp[1..3]ATI is not a valid register or is greater than
+ * the number of texture units available on the implementation.
+ */
+
+ /* The spec defines the number of registers to be fixed at 6, even
+ * though the enum values are defined up to 31 in glext.h. According
+ * to the paragraph above, when an implementation has less than 6
+ * texture units, glSampleMapATI(GL_REG_5_ATI, ...) is invalid.
+ *
+ * However, Doom3 uses 6 textures and 6 texcoords, so an implementation
+ * that supports less than 6 textures is not able to run it. Let's fail
+ * if it's less than 6.
+ */
+
+ glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &num_tex_units);
+ if (num_tex_units < 6) {
+ printf("Max texture units %d < 6 is not enough for ATI_fragment_shader\n", num_tex_units);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /* Try some invalid enums */
+
+ for (i=0; i<ARRAY_SIZE(enums); i++)
+ if (!try_enum(enums[i]))
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error12-invalidsrc.c b/tests/spec/ati_fragment_shader/error12-invalidsrc.c
new file mode 100644
index 000000000..b1c74d0bc
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error12-invalidsrc.c
@@ -0,0 +1,151 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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)) return false
+#define check_gl_error_enum(err, en) if (!piglit_check_gl_error(err)) \
+ { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); return false; }
+
+bool
+try_enum(unsigned e)
+{
+ printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e), e);
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glPassTexCoordATI(GL_REG_0_ATI, e, GL_SWIZZLE_STR_ATI);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glSampleMapATI(GL_REG_0_ATI, e, GL_SWIZZLE_STR_ATI);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ /* note: Mesa requires at least 1 arith instruction per pass,
+ * but this is not in the spec */
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ GL_REG_1_ATI, GL_NONE, GL_NONE);
+ glEndFragmentShaderATI();
+
+ return true;
+}
+
+/* Trying all possible enum values is overkill, only try ones that are
+ * used in fragment shaders, thus being common user errors.
+ * Note that some of them have the same numeric value. */
+static const unsigned enums[] = {
+ GL_CON_0_ATI,
+ GL_CON_1_ATI,
+ GL_CON_2_ATI,
+ GL_CON_3_ATI,
+ GL_CON_4_ATI,
+ GL_CON_5_ATI,
+ GL_CON_6_ATI,
+ GL_CON_7_ATI,
+ GL_MOV_ATI,
+ GL_ADD_ATI,
+ GL_MUL_ATI,
+ GL_SUB_ATI,
+ GL_DOT3_ATI,
+ GL_DOT4_ATI,
+ GL_MAD_ATI,
+ GL_LERP_ATI,
+ GL_CND_ATI,
+ GL_CND0_ATI,
+ GL_DOT2_ADD_ATI,
+ GL_SECONDARY_INTERPOLATOR_ATI,
+ GL_SWIZZLE_STR_ATI,
+ GL_SWIZZLE_STQ_ATI,
+ GL_SWIZZLE_STR_DR_ATI,
+ GL_SWIZZLE_STQ_DQ_ATI,
+ GL_SWIZZLE_STRQ_ATI,
+ GL_SWIZZLE_STRQ_DQ_ATI,
+ GL_RED_BIT_ATI,
+ GL_GREEN_BIT_ATI,
+ GL_BLUE_BIT_ATI,
+ GL_2X_BIT_ATI,
+ GL_4X_BIT_ATI,
+ GL_8X_BIT_ATI,
+ GL_HALF_BIT_ATI,
+ GL_QUARTER_BIT_ATI,
+ GL_EIGHTH_BIT_ATI,
+ GL_SATURATE_BIT_ATI,
+ GL_COMP_BIT_ATI,
+ GL_NEGATE_BIT_ATI,
+ GL_BIAS_BIT_ATI,
+ GL_PRIMARY_COLOR_ARB,
+ GL_NONE,
+ GL_RED,
+ GL_GREEN,
+ GL_BLUE,
+ GL_ALPHA,
+};
+
+void
+piglit_init(int argc, char **argv)
+{
+ int num_tex_coords;
+
+ unsigned i;
+
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 12 of the Errors section:
+ *
+ * The error INVALID_ENUM is generated if <coord> passed to
+ * PassTexCoordATI or <interp> passed to SampleMapATI is not a valid
+ * register or texture unit, or the register or texture unit is greater
+ * than the number of texture units available on the implementation.
+ */
+
+ /* The spec lists texture coordinates up to GL_TEXTURE7_ARB.
+ * According to the above paragraph, when an implementation supports
+ * less than 8 texture coordinates
+ * glSampleMapATI(GL_REG_x_ATI, GL_TEXTURE7_ARB, ...) is invalid.
+ *
+ * Doom3 uses 6 textures and 6 texcoords, so an implementation
+ * that supports less than 6 texcoords is not able to run it. Let's
+ * fail if it's less than 6, and do some checks if it's less than 8.
+ */
+
+ glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &num_tex_coords);
+ if (num_tex_coords < 6) {
+ printf("Max texture coordinate interpolators %d < 6 is not enough for ATI_fragment_shader\n", num_tex_coords);
+ piglit_report_result(PIGLIT_FAIL);
+ } else if (num_tex_coords < 8) {
+ if (!try_enum(GL_TEXTURE7_ARB))
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /* Try some invalid enums */
+
+ for (i=0; i<ARRAY_SIZE(enums); i++)
+ if (!try_enum(enums[i]))
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error13-invalidarg.c b/tests/spec/ati_fragment_shader/error13-invalidarg.c
new file mode 100644
index 000000000..ce307df1a
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error13-invalidarg.c
@@ -0,0 +1,121 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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)) return false
+#define check_gl_error_enum(err, en) if (!piglit_check_gl_error(err)) \
+ { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); return false; }
+
+bool
+try_enum(unsigned e)
+{
+ printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e), e);
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+ e, GL_NONE, GL_NONE);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+ e, GL_NONE, GL_NONE);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ glEndFragmentShaderATI();
+
+ /* TODO check fragment ops with more arguments? */
+
+ return true;
+}
+
+/* Trying all possible enum values is overkill, only try ones that are
+ * used in fragment shaders, thus being common user errors.
+ * Note that some of them have the same numeric value. */
+static const unsigned enums[] = {
+ GL_MOV_ATI,
+ GL_ADD_ATI,
+ GL_MUL_ATI,
+ GL_SUB_ATI,
+ GL_DOT3_ATI,
+ GL_DOT4_ATI,
+ GL_MAD_ATI,
+ GL_LERP_ATI,
+ GL_CND_ATI,
+ GL_CND0_ATI,
+ GL_DOT2_ADD_ATI,
+ GL_SWIZZLE_STR_ATI,
+ GL_SWIZZLE_STQ_ATI,
+ GL_SWIZZLE_STR_DR_ATI,
+ GL_SWIZZLE_STQ_DQ_ATI,
+ GL_SWIZZLE_STRQ_ATI,
+ GL_SWIZZLE_STRQ_DQ_ATI,
+ /*GL_RED_BIT_ATI,*/
+ GL_GREEN_BIT_ATI,
+ GL_BLUE_BIT_ATI,
+ /*GL_2X_BIT_ATI,*/
+ GL_4X_BIT_ATI,
+ GL_8X_BIT_ATI,
+ GL_HALF_BIT_ATI,
+ GL_QUARTER_BIT_ATI,
+ GL_EIGHTH_BIT_ATI,
+ GL_SATURATE_BIT_ATI,
+ GL_COMP_BIT_ATI,
+ GL_NEGATE_BIT_ATI,
+ GL_BIAS_BIT_ATI,
+ GL_TEXTURE0_ARB,
+ GL_TEXTURE1_ARB,
+ GL_TEXTURE2_ARB,
+ GL_TEXTURE3_ARB,
+ GL_TEXTURE4_ARB,
+ GL_TEXTURE5_ARB,
+ GL_TEXTURE6_ARB,
+ GL_TEXTURE7_ARB,
+ /*GL_NONE,*/
+ GL_RED,
+ GL_GREEN,
+ GL_BLUE,
+ GL_ALPHA,
+};
+
+void
+piglit_init(int argc, char **argv)
+{
+ unsigned i = 0;
+
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 13 of the Errors section:
+ *
+ * The error INVALID_ENUM is generated if <argN> passed to
+ * ColorFragmentOp[1..3]ATI or AlphaFragmentOp[1..3]ATI is not a valid
+ * constant, interpolator, or register.
+ */
+
+ for (i=0; i<ARRAY_SIZE(enums); i++)
+ if (!try_enum(enums[i]))
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error14-invalidmod.c b/tests/spec/ati_fragment_shader/error14-invalidmod.c
new file mode 100644
index 000000000..791c37efd
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error14-invalidmod.c
@@ -0,0 +1,129 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#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)) return false
+#define check_gl_error_enum(err, en) if (!piglit_check_gl_error(err)) \
+ { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); return false; }
+#define check_gl_error_goodenum(err, en) if (!piglit_check_gl_error(err)) \
+ { printf("Enum %s 0x%x rejected\n", piglit_get_gl_enum_name(en), en); return false; }
+
+bool
+try_enum(unsigned e)
+{
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, e,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, e,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error_enum(GL_INVALID_ENUM, e);
+ glEndFragmentShaderATI();
+
+ /* TODO check fragment ops with more arguments? */
+
+ return true;
+}
+
+static const unsigned enums[] = {
+ GL_2X_BIT_ATI | GL_4X_BIT_ATI,
+ GL_2X_BIT_ATI | GL_8X_BIT_ATI,
+ GL_2X_BIT_ATI | GL_HALF_BIT_ATI,
+ GL_2X_BIT_ATI | GL_QUARTER_BIT_ATI,
+ GL_2X_BIT_ATI | GL_EIGHTH_BIT_ATI,
+ GL_4X_BIT_ATI | GL_8X_BIT_ATI,
+ GL_4X_BIT_ATI | GL_HALF_BIT_ATI,
+ GL_4X_BIT_ATI | GL_QUARTER_BIT_ATI,
+ GL_4X_BIT_ATI | GL_EIGHTH_BIT_ATI,
+ GL_8X_BIT_ATI | GL_HALF_BIT_ATI,
+ GL_8X_BIT_ATI | GL_QUARTER_BIT_ATI,
+ GL_8X_BIT_ATI | GL_EIGHTH_BIT_ATI,
+ GL_HALF_BIT_ATI | GL_QUARTER_BIT_ATI,
+ GL_HALF_BIT_ATI | GL_EIGHTH_BIT_ATI,
+ GL_QUARTER_BIT_ATI | GL_EIGHTH_BIT_ATI,
+};
+
+bool try_compatible_enum(unsigned e)
+{
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, e,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error_goodenum(GL_NO_ERROR, e);
+ glEndFragmentShaderATI();
+
+ glBeginFragmentShaderATI();
+ check_gl_error(GL_NO_ERROR);
+ glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, e,
+ GL_REG_0_ATI, GL_NONE, GL_NONE);
+ check_gl_error_goodenum(GL_NO_ERROR, e);
+ glEndFragmentShaderATI();
+
+ /* TODO check fragment ops with more arguments? */
+
+ return true;
+}
+
+static const unsigned good_enums[] = {
+ GL_2X_BIT_ATI | GL_SATURATE_BIT_ATI,
+ GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
+ GL_8X_BIT_ATI | GL_SATURATE_BIT_ATI,
+ GL_HALF_BIT_ATI | GL_SATURATE_BIT_ATI,
+ GL_QUARTER_BIT_ATI | GL_SATURATE_BIT_ATI,
+ GL_EIGHTH_BIT_ATI | GL_SATURATE_BIT_ATI,
+};
+
+void
+piglit_init(int argc, char **argv)
+{
+ unsigned i;
+
+ piglit_require_extension("GL_ATI_fragment_shader");
+
+ /*
+ * Paragraph 14 of the Errors section:
+ *
+ * The error INVALID_ENUM is generated if <dstMod> passed to
+ * ColorFragmentOp[1..3]ATI or AlphaFragmentOp[1..3]ATI contains
+ * multiple mutually exclusive modifier bits, not counting
+ * SATURATE_BIT_ATI.
+ */
+
+ for (i=0; i<ARRAY_SIZE(enums); i++) {
+ if (!try_enum(enums[i]))
+ piglit_report_result(PIGLIT_FAIL);
+ if (!try_enum(enums[i] | GL_SATURATE_BIT_ATI))
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /* test that all the mods are compatible with SATURATE */
+ for (i=0; i<ARRAY_SIZE(good_enums); i++)
+ if (!try_compatible_enum(good_enums[i]))
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(PIGLIT_PASS);
+}
--
2.15.0.rc0
More information about the Piglit
mailing list