[Piglit] [PATCH 2/4] ATI_fs: add render tests
Miklós Máté
mtmkls at gmail.com
Wed Nov 22 00:04:04 UTC 2017
On 21/11/17 21:17, Eric Anholt wrote:
> Miklós Máté <mtmkls at gmail.com> writes:
>
>> These mainly check the state machine. Compiler checks will come later.
>>
>> Signed-off-by: Miklós Máté <mtmkls at gmail.com>
>> ---
>> 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 000000000..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 expected results */
>> +
>> + for (u=0; u<3; u++) {
>> + result1p3[u] = color1[u]+color3[u];
>> + result2p3[u] = color2[u]+color3[u];
>> + result4p3[u] = color4[u]+color3[u];
>> + }
>> +
>> + check_gl_error(GL_NO_ERROR);
>> +}
>> diff --git a/tests/spec/ati_fragment_shader/render-default.c b/tests/spec/ati_fragment_shader/render-default.c
>> new file mode 100644
>> index 000000000..314a21810
>> --- /dev/null
>> +++ b/tests/spec/ati_fragment_shader/render-default.c
>> @@ -0,0 +1,81 @@
>> +/* TODO license header */
>> +
>> +/**
>> + * Tests rendering with GL_ATI_fragment_shader: enable, disable, default 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
>> +
>> +static const float color[] = {0.2, 0.3, 0.8};
>> +static const float texcoord[] = {0.2, 0.7, 0.4};
>> +
>> +#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;
>> + GLuint tex;
>> +
>> + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
>> +
>> + glClearColor(1.0, 0.0, 0.0, 1.0);
>> + glClear(GL_COLOR_BUFFER_BIT);
>> +
>> + glColor3fv(color);
>> + glTexCoord3fv(texcoord);
>> +
>> + //TODO swrast: passtexcoord only works when there is a bound texture AND texturing is enabled
> Could we use /* */ for consistency?
This comment is not meant to be final, just a reminder for me that this
has to be fixed in swrast.
>
>> + /*glEnable(GL_TEXTURE_2D);
>> + glGenTextures(1, &tex);
>> + glBindTexture(GL_TEXTURE_2D, tex);
>> + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_FLOAT, (void*)color);
>> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
>> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
>> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
>> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
>> + check_gl_error(GL_NO_ERROR);*/
>> +
>> +
>> + glDisable(GL_FRAGMENT_SHADER_ATI);
>> + piglit_draw_rect(0, 0, piglit_width/4, piglit_height);
>> + glEnable(GL_FRAGMENT_SHADER_ATI);
>> + piglit_draw_rect(piglit_width/4, 0, piglit_width/4, piglit_height);
>> + glDisable(GL_FRAGMENT_SHADER_ATI);
>> + piglit_draw_rect(2*piglit_width/4, 0, piglit_width/4, piglit_height);
>> + glEnable(GL_FRAGMENT_SHADER_ATI);
>> + piglit_draw_rect(3*piglit_width/4, 0, piglit_width/4, piglit_height);
>> +
>> + pass = pass && piglit_probe_rect_rgb(0, 0, piglit_width/4, piglit_height, color);
>> + pass = pass && piglit_probe_rect_rgb(piglit_width/4, 0, piglit_width/4, piglit_height, texcoord);
>> + pass = pass && piglit_probe_rect_rgb(2*piglit_width/4, 0, piglit_width/4, piglit_height, color);
>> + pass = pass && piglit_probe_rect_rgb(3*piglit_width/4, 0, piglit_width/4, piglit_height, texcoord);
>> +
>> + piglit_present_results();
>> +
>> + check_gl_error(GL_NO_ERROR);
>> +
>> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + piglit_require_extension("GL_ATI_fragment_shader");
>> +
>> + /* create a default shader that does something different than fixed-function */
>> + glBeginFragmentShaderATI();
>> + glPassTexCoordATI(GL_REG_1_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
>> + 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);
>> +}
>> diff --git a/tests/spec/ati_fragment_shader/render-fog.c b/tests/spec/ati_fragment_shader/render-fog.c
>> new file mode 100644
>> index 000000000..a7b72c502
>> --- /dev/null
>> +++ b/tests/spec/ati_fragment_shader/render-fog.c
>> @@ -0,0 +1,95 @@
>> +/* TODO license header */
>> +
>> +/**
>> + * Tests rendering with GL_ATI_fragment_shader: using fog.
>> + */
>> +
>> +#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.2, 0.3, 0.8};
>> +static const float color2[] = {0.9, 0.8, 0.3};
>> +
>> +static float resultLin[] = {0.0, 0.0, 0.0};
>> +static float resultExp[] = {0.0, 0.0, 0.0};
>> +static float resultEx2[] = {0.0, 0.0, 0.0};
>> +
>> +static const float z = 0.8;
>> +static const float dens = 0.4;
>> +
>> +#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);
>> +
>> + glColor3fv(color2);
>> +
>> + glFogfv(GL_FOG_COLOR, color1);
>> + glFogf(GL_FOG_DENSITY, dens);
>> + glFogf(GL_FOG_START, 0.0);
>> + glFogf(GL_FOG_END, 1.0);
>> + glHint(GL_FOG_HINT, GL_NICEST);
>> +
>> + glEnable(GL_FRAGMENT_SHADER_ATI);
>> + glEnable(GL_FOG);
>> + glFogi(GL_FOG_MODE, GL_LINEAR);
>> + piglit_draw_rect_z(z, 0, 0, piglit_width/4, piglit_height);
>> + glFogi(GL_FOG_MODE, GL_EXP);
>> + piglit_draw_rect_z(z, piglit_width/4, 0, piglit_width/4, piglit_height);
>> + glFogi(GL_FOG_MODE, GL_EXP2);
>> + piglit_draw_rect_z(z, 2*piglit_width/4, 0, piglit_width/4, piglit_height);
>> + glDisable(GL_FOG);
>> + piglit_draw_rect_z(z, 3*piglit_width/4, 0, piglit_width/4, piglit_height);
>> + glDisable(GL_FRAGMENT_SHADER_ATI);
>> +
>> + pass = pass && piglit_probe_rect_rgb(0, 0, piglit_width/4, piglit_height, resultLin);
>> + pass = pass && piglit_probe_rect_rgb(piglit_width/4, 0, piglit_width/4, piglit_height, resultExp);
>> + pass = pass && piglit_probe_rect_rgb(2*piglit_width/4, 0, piglit_width/4, piglit_height, resultEx2);
>> + pass = pass && piglit_probe_rect_rgb(3*piglit_width/4, 0, piglit_width/4, piglit_height, color2);
>> +
>> + piglit_present_results();
>> +
>> + check_gl_error(GL_NO_ERROR);
>> +
>> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + unsigned u;
>> + float f;
>> +
>> + piglit_require_extension("GL_ATI_fragment_shader");
>> +
>> + glBeginFragmentShaderATI();
>> + glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
>> + GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);
>> + glEndFragmentShaderATI();
>> +
>> + /* compute the expected results */
>> +
>> + for (u=0; u<3; u++) {
>> + f = (1.0-z)/(1.0-0.0);
>> + resultLin[u] = f*color2[u] + (1.0-f)*color1[u];
>> + f = exp(-dens*z);
>> + resultExp[u] = f*color2[u] + (1.0-f)*color1[u];
>> + f = exp(-pow(dens*z,2.0));
>> + resultEx2[u] = f*color2[u] + (1.0-f)*color1[u];
>> + }
>> +
>> + check_gl_error(GL_NO_ERROR);
>> +}
>> 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 000000000..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?
MM
More information about the Piglit
mailing list