Re: [Piglit] [PATCH 2/4] ATI_fs: add render tests

2017-11-21 Thread Eric Anholt
Miklós Máté  writes:

> On 21/11/17 21:17, Eric Anholt wrote:
>> Miklós Máté  writes:
>>> diff --git a/tests/spec/ati_fragment_shader/render-notexture.c 
>>> b/tests/spec/ati_fragment_shader/render-notexture.c
>>> new file mode 100644
>>> index 0..2d9aefe09
>>> --- /dev/null
>>> +++ b/tests/spec/ati_fragment_shader/render-notexture.c
>>> @@ -0,0 +1,71 @@
>>> +/* TODO license header */
>>> +
>>> +/**
>>> + * Tests rendering with GL_ATI_fragment_shader: when no texture is bound
>>> + * - glPassTexCoordATI() should work as normal
>>> + * - glSampleMapATI() should return all zeros (technically this is 
>>> undefined)
>> I don't think that would be undefined -- you'd have the default texture
>> object used, which would sample as zeroes.
>
> Should I test the right hand side to be black then?

I think so.


signature.asc
Description: PGP signature
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 2/4] ATI_fs: add render tests

2017-11-21 Thread Miklós Máté

On 21/11/17 21:17, Eric Anholt wrote:

Miklós Máté  writes:


These mainly check the state machine. Compiler checks will come later.

Signed-off-by: Miklós Máté 
---
  tests/spec/ati_fragment_shader/render-constants.c  |  98 +++
  tests/spec/ati_fragment_shader/render-default.c|  81 +
  tests/spec/ati_fragment_shader/render-fog.c|  95 +++
  tests/spec/ati_fragment_shader/render-notexture.c  |  71 +++
  tests/spec/ati_fragment_shader/render-precedence.c | 118 ++
  tests/spec/ati_fragment_shader/render-sources.c| 132 +
  tests/spec/ati_fragment_shader/render-textargets.c |  89 ++
  7 files changed, 684 insertions(+)
  create mode 100644 tests/spec/ati_fragment_shader/render-constants.c
  create mode 100644 tests/spec/ati_fragment_shader/render-default.c
  create mode 100644 tests/spec/ati_fragment_shader/render-fog.c
  create mode 100644 tests/spec/ati_fragment_shader/render-notexture.c
  create mode 100644 tests/spec/ati_fragment_shader/render-precedence.c
  create mode 100644 tests/spec/ati_fragment_shader/render-sources.c
  create mode 100644 tests/spec/ati_fragment_shader/render-textargets.c

diff --git a/tests/spec/ati_fragment_shader/render-constants.c 
b/tests/spec/ati_fragment_shader/render-constants.c
new file mode 100644
index 0..6e1e4fd8c
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/render-constants.c
@@ -0,0 +1,98 @@
+/* TODO license header */
+
+/**
+ * Tests rendering with GL_ATI_fragment_shader:
+ * - using local and global constants
+ * - updating global constants
+ */
+
+#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
+
+static const float color1[] = {0.4, 0.2, 0.6};
+static const float color2[] = {0.7, 0.2, 0.3};
+static const float color3[] = {0.1, 0.7, 0.2};
+static const float color4[] = {0.8, 0.1, 0.7};
+
+static float result1p3[] = {0.0, 0.0, 0.0};
+static float result2p3[] = {0.0, 0.0, 0.0};
+static float result4p3[] = {0.0, 0.0, 0.0};
+
+#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
piglit_report_result(PIGLIT_FAIL)
+
+enum piglit_result
+piglit_display(void)
+{
+   bool pass = true;
+
+   piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+   glClearColor(1.0, 0.0, 0.0, 1.0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   glEnable(GL_FRAGMENT_SHADER_ATI);
+   glSetFragmentShaderConstantATI(GL_CON_7_ATI, color2);
+   glSetFragmentShaderConstantATI(GL_CON_4_ATI, color3);
+   glBindFragmentShaderATI(13);

Could we get some top-level variables with names instead of "13" and
"42"?

OK, I'll do that.



+   piglit_draw_rect(0, 0, piglit_width/4, piglit_height); /* 2+3 */

In general, we ask for spaces around binary operators in the code, so

piglit_draw_rect(0, 0, piglit_width / 4, piglit_height); /* 2+3 */

here and elsewhere in your tests.


+   glBindFragmentShaderATI(42);
+   piglit_draw_rect(piglit_width/4, 0, piglit_width/4, piglit_height); /* 
1+3 */
+   glBindFragmentShaderATI(13);
+   glSetFragmentShaderConstantATI(GL_CON_7_ATI, color4);
+   piglit_draw_rect(2*piglit_width/4, 0, piglit_width/4, piglit_height); 
/* 4+3 */
+   glBindFragmentShaderATI(42);
+   piglit_draw_rect(3*piglit_width/4, 0, piglit_width/4, piglit_height); 
/*1+3 */
+   glDisable(GL_FRAGMENT_SHADER_ATI);
+
+   pass = pass && piglit_probe_rect_rgb(0, 0, piglit_width/4, 
piglit_height, result2p3);
+   pass = pass && piglit_probe_rect_rgb(piglit_width/4, 0, piglit_width/4, 
piglit_height, result1p3);
+   pass = pass && piglit_probe_rect_rgb(2*piglit_width/4, 0, 
piglit_width/4, piglit_height, result4p3);
+   pass = pass && piglit_probe_rect_rgb(3*piglit_width/4, 0, 
piglit_width/4, piglit_height, result1p3);
+
+   piglit_present_results();
+
+   check_gl_error(GL_NO_ERROR);
+
+   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+   unsigned u;
+
+   piglit_require_extension("GL_ATI_fragment_shader");
+
+   /* create identical shaders, but one of them has a local constant */
+
+   glBindFragmentShaderATI(13);
+   glBeginFragmentShaderATI();
+   glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+   GL_CON_7_ATI, GL_NONE, GL_NONE,
+   GL_CON_4_ATI, GL_NONE, GL_NONE);
+   glEndFragmentShaderATI();
+
+   glBindFragmentShaderATI(42);
+   glBeginFragmentShaderATI();
+   glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+   GL_CON_7_ATI, GL_NONE, GL_NONE,
+   GL_CON_4_ATI, GL_NONE, GL_NONE);
+   glSetFragmentShaderConstantATI(GL_CON_7_ATI, color1);
+   glEndFragmentShaderATI();
+
+   /* compute the expecte

Re: [Piglit] [PATCH 2/4] ATI_fs: add render tests

2017-11-21 Thread Eric Anholt
Miklós Máté  writes:

> These mainly check the state machine. Compiler checks will come later.
>
> Signed-off-by: Miklós Máté 
> ---
>  tests/spec/ati_fragment_shader/render-constants.c  |  98 +++
>  tests/spec/ati_fragment_shader/render-default.c|  81 +
>  tests/spec/ati_fragment_shader/render-fog.c|  95 +++
>  tests/spec/ati_fragment_shader/render-notexture.c  |  71 +++
>  tests/spec/ati_fragment_shader/render-precedence.c | 118 ++
>  tests/spec/ati_fragment_shader/render-sources.c| 132 
> +
>  tests/spec/ati_fragment_shader/render-textargets.c |  89 ++
>  7 files changed, 684 insertions(+)
>  create mode 100644 tests/spec/ati_fragment_shader/render-constants.c
>  create mode 100644 tests/spec/ati_fragment_shader/render-default.c
>  create mode 100644 tests/spec/ati_fragment_shader/render-fog.c
>  create mode 100644 tests/spec/ati_fragment_shader/render-notexture.c
>  create mode 100644 tests/spec/ati_fragment_shader/render-precedence.c
>  create mode 100644 tests/spec/ati_fragment_shader/render-sources.c
>  create mode 100644 tests/spec/ati_fragment_shader/render-textargets.c
>
> diff --git a/tests/spec/ati_fragment_shader/render-constants.c 
> b/tests/spec/ati_fragment_shader/render-constants.c
> new file mode 100644
> index 0..6e1e4fd8c
> --- /dev/null
> +++ b/tests/spec/ati_fragment_shader/render-constants.c
> @@ -0,0 +1,98 @@
> +/* TODO license header */
> +
> +/**
> + * Tests rendering with GL_ATI_fragment_shader:
> + * - using local and global constants
> + * - updating global constants
> + */
> +
> +#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
> +
> +static const float color1[] = {0.4, 0.2, 0.6};
> +static const float color2[] = {0.7, 0.2, 0.3};
> +static const float color3[] = {0.1, 0.7, 0.2};
> +static const float color4[] = {0.8, 0.1, 0.7};
> +
> +static float result1p3[] = {0.0, 0.0, 0.0};
> +static float result2p3[] = {0.0, 0.0, 0.0};
> +static float result4p3[] = {0.0, 0.0, 0.0};
> +
> +#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
> piglit_report_result(PIGLIT_FAIL)
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + bool pass = true;
> +
> + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> +
> + glClearColor(1.0, 0.0, 0.0, 1.0);
> + glClear(GL_COLOR_BUFFER_BIT);
> +
> + glEnable(GL_FRAGMENT_SHADER_ATI);
> + glSetFragmentShaderConstantATI(GL_CON_7_ATI, color2);
> + glSetFragmentShaderConstantATI(GL_CON_4_ATI, color3);
> + glBindFragmentShaderATI(13);

Could we get some top-level variables with names instead of "13" and
"42"?

> + piglit_draw_rect(0, 0, piglit_width/4, piglit_height); /* 2+3 */

In general, we ask for spaces around binary operators in the code, so

piglit_draw_rect(0, 0, piglit_width / 4, piglit_height); /* 2+3 */

here and elsewhere in your tests.

> + glBindFragmentShaderATI(42);
> + piglit_draw_rect(piglit_width/4, 0, piglit_width/4, piglit_height); /* 
> 1+3 */
> + glBindFragmentShaderATI(13);
> + glSetFragmentShaderConstantATI(GL_CON_7_ATI, color4);
> + piglit_draw_rect(2*piglit_width/4, 0, piglit_width/4, piglit_height); 
> /* 4+3 */
> + glBindFragmentShaderATI(42);
> + piglit_draw_rect(3*piglit_width/4, 0, piglit_width/4, piglit_height); 
> /*1+3 */
> + glDisable(GL_FRAGMENT_SHADER_ATI);
> +
> + pass = pass && piglit_probe_rect_rgb(0, 0, piglit_width/4, 
> piglit_height, result2p3);
> + pass = pass && piglit_probe_rect_rgb(piglit_width/4, 0, piglit_width/4, 
> piglit_height, result1p3);
> + pass = pass && piglit_probe_rect_rgb(2*piglit_width/4, 0, 
> piglit_width/4, piglit_height, result4p3);
> + pass = pass && piglit_probe_rect_rgb(3*piglit_width/4, 0, 
> piglit_width/4, piglit_height, result1p3);
> +
> + piglit_present_results();
> +
> + check_gl_error(GL_NO_ERROR);
> +
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + unsigned u;
> +
> + piglit_require_extension("GL_ATI_fragment_shader");
> +
> + /* create identical shaders, but one of them has a local constant */
> +
> + glBindFragmentShaderATI(13);
> + glBeginFragmentShaderATI();
> + glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
> + GL_CON_7_ATI, GL_NONE, GL_NONE,
> + GL_CON_4_ATI, GL_NONE, GL_NONE);
> + glEndFragmentShaderATI();
> +
> + glBindFragmentShaderATI(42);
> + glBeginFragmentShaderATI();
> + glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
> + GL_CON_7_ATI, GL_NONE, GL_NONE,
> + GL_CON_4_ATI, GL_NONE, GL_NONE);
> + glSetFragmentShaderConstantATI(GL_CON