[Piglit] [PATCH 1/2] arb_color_buffer_float/render: refactor code for easier debugging
Brian Paul
brianp at vmware.com
Wed Sep 28 13:13:14 PDT 2011
If you have to debug a failing case in this test it's now a simple
matter to add a new call to test_one() passing just the parameters
you're interested in.
---
tests/spec/arb_color_buffer_float/render.c | 264 +++++++++++++++-------------
1 files changed, 140 insertions(+), 124 deletions(-)
diff --git a/tests/spec/arb_color_buffer_float/render.c b/tests/spec/arb_color_buffer_float/render.c
index 172e9a5..c871bce 100644
--- a/tests/spec/arb_color_buffer_float/render.c
+++ b/tests/spec/arb_color_buffer_float/render.c
@@ -80,10 +80,135 @@ const char *fp_strings[] = {
unsigned vps[2];
unsigned fps[4];
-GLboolean test()
+GLboolean test_one(unsigned vert_clamp, unsigned frag_clamp, unsigned semantic,
+ unsigned blend, unsigned logicop, unsigned vpmode, unsigned fpmode)
{
GLfloat probe[4];
- GLboolean pass = GL_TRUE;
+ char test_name[4096];
+ unsigned clamped = (semantic == 0 && (clamp_enums[vert_clamp] == GL_TRUE || (clamp_enums[vert_clamp] == GL_FIXED_ONLY_ARB && fixed))) || clamp_enums[frag_clamp] == GL_TRUE || (clamp_enums[frag_clamp] == GL_FIXED_ONLY_ARB && fixed);
+ float *expected;
+ GLboolean cpass;
+ GLboolean opass;
+
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+
+ sprintf(test_name, "%s: Attrib %s VertClamp %s FragClamp %s Blending %s LogicOp %s %s %s Fog %s (expecting %sclamping)",
+ format_name,
+ semantic ? "TEXCOORD0" : "COLOR ",
+ clamp_strings[vert_clamp],
+ clamp_strings[frag_clamp],
+ blend_strings[blend],
+ logicop ? "Yes" : "No ",
+ vpmode ? "ARB_vp" : "ffvp ",
+ fpmode ? "ARB_fp" : "fffp ",
+ test_fog ? "Yes" : "No ",
+ clamped ? "" : "no ");
+ if (!sanity) {
+ glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, clamp_enums[vert_clamp]);
+ glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, clamp_enums[frag_clamp]);
+ }
+
+ glColor4f(0.1f, 0.2f, 0.3f, 0.4f);
+ glTexCoord4f(0.5f, 0.6f, 0.7f, 0.8f);
+
+ if (vpmode) {
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vps[semantic]);
+ glEnable(GL_VERTEX_PROGRAM_ARB);
+ }
+ else {
+ if (semantic == 0)
+ glColor4f(pixels[0], pixels[1], pixels[2], pixels[3]);
+ else
+ glTexCoord4f(pixels[0], pixels[1], pixels[2], pixels[3]);
+ }
+
+ if (fpmode) {
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fps[semantic + (test_fog ? 2 : 0)]);
+ glEnable(GL_FRAGMENT_PROGRAM_ARB);
+ }
+ else {
+ if (test_fog)
+ glEnable(GL_FOG);
+ }
+
+ glClearColor(0.5, 0.5, 0.5, 0.5);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ if (blend) {
+ glEnable(GL_BLEND);
+ glBlendFunc(blend_src[blend], blend_dst[blend]);
+ glBlendColor(2.0f, 2.0f, 2.0f, 2.0f);
+ }
+
+ if (logicop)
+ glEnable(GL_COLOR_LOGIC_OP);
+
+ piglit_draw_rect(-1, -1, 1, 1);
+
+ if (logicop)
+ glDisable(GL_COLOR_LOGIC_OP);
+ if (blend)
+ glDisable(GL_BLEND);
+ if (vpmode)
+ glDisable(GL_VERTEX_PROGRAM_ARB);
+ if (fpmode)
+ glDisable(GL_FRAGMENT_PROGRAM_ARB);
+ else if (test_fog)
+ glDisable(GL_FOG);
+
+ if (blend == 2 && !logicop) {
+ if (fixed_snorm)
+ expected = clamped ? clamped_pixels : signed_clamped_pixels;
+ else if (fixed)
+ expected = clamped_pixels;
+ else
+ expected = clamped ? clamped_pixels_mul_2 : pixels_mul_2;
+ }
+ else if (blend == 3 && !logicop) {
+ if (fixed_snorm)
+ expected = clamped ? clamped_pixels_plus_half_signed_clamped : signed_clamped_pixels_plus_half_signed_clamped;
+ else if (fixed)
+ expected = clamped_pixels_plus_half_clamped;
+ else
+ expected = clamped ? clamped_pixels_plus_half : pixels_plus_half;
+ }
+ else {
+ expected = clamped ? clamped_pixels :
+ fixed_snorm ? signed_clamped_pixels :
+ fixed ? clamped_pixels :
+ pixels;
+ }
+
+ opass = cpass = piglit_probe_pixel_rgba_silent(0, 0, expected, probe);
+
+ if (nvidia_driver && clamped && !(semantic == 0 && clamp_enums[vert_clamp] == GL_TRUE) && clamp_enums[frag_clamp] == GL_TRUE && !fixed && fpmode && (!blend || logicop || format == GL_RGBA16F_ARB)) {
+ printf("nVidia driver known *** MAJOR BUG ***: they don't clamp fragment program results with ARB_fp on either fp32 with no blending or fp16!\n");
+ opass = GL_TRUE;
+ }
+ if (nvidia_driver && clamped && !fixed && !fpmode && semantic == 0 && clamp_enums[vert_clamp] != GL_TRUE && clamp_enums[frag_clamp] == GL_TRUE) {
+ printf("nVidia driver known *** MAJOR BUG ***: they don't clamp fragment program results with fffp, vertex clamp off and fragment clamp on fp16/fp32!\n");
+ opass = GL_TRUE;
+ }
+
+ if (test_fog && fpmode) {
+ //printf("Unclear specification on GL_ARB_fog_*\n");
+ opass = GL_TRUE;
+ }
+
+ if (!opass) {
+ printf("%s: %s\n", (cpass ? "PASS" : (opass ? "XFAIL" : "FAIL")), test_name);
+ printf(" Expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]);
+ printf(" Observed: %f %f %f %f\n", probe[0], probe[1], probe[2], probe[3]);
+
+ }
+
+ return opass;
+}
+
+
+GLboolean test(void)
+{
+ GLboolean all_pass = GL_TRUE;
int npass = 0, total = 0;
unsigned semantic, blend, logicop, vpmode, fpmode;
unsigned vpmodes = 1 + !!GLEW_ARB_vertex_program;
@@ -100,144 +225,35 @@ GLboolean test()
for (vpmode = 0; vpmode < vpmodes; ++vpmode)
for (fpmode = 0; fpmode < fpmodes; ++fpmode)
{
- char test_name[4096];
- unsigned clamped = (semantic == 0 && (clamp_enums[vert_clamp] == GL_TRUE || (clamp_enums[vert_clamp] == GL_FIXED_ONLY_ARB && fixed))) || clamp_enums[frag_clamp] == GL_TRUE || (clamp_enums[frag_clamp] == GL_FIXED_ONLY_ARB && fixed);
- float *expected;
- GLboolean cpass;
- GLboolean opass;
+ GLboolean pass;
if (!fpmode && semantic)
continue;
- sprintf(test_name, "%s: Attrib %s VertClamp %s FragClamp %s Blending %s LogicOp %s %s %s Fog %s (expecting %sclamping)",
- format_name,
- semantic ? "TEXCOORD0" : "COLOR ",
- clamp_strings[vert_clamp],
- clamp_strings[frag_clamp],
- blend_strings[blend],
- logicop ? "Yes" : "No ",
- vpmode ? "ARB_vp" : "ffvp ",
- fpmode ? "ARB_fp" : "fffp ",
- test_fog ? "Yes" : "No ",
- clamped ? "" : "no ");
- if (!sanity) {
- glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, clamp_enums[vert_clamp]);
- glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, clamp_enums[frag_clamp]);
- }
-
- glColor4f(0.1f, 0.2f, 0.3f, 0.4f);
- glTexCoord4f(0.5f, 0.6f, 0.7f, 0.8f);
-
- if (vpmode)
- {
- glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vps[semantic]);
- glEnable(GL_VERTEX_PROGRAM_ARB);
- }
- else
- {
- if (semantic == 0)
- glColor4f(pixels[0], pixels[1], pixels[2], pixels[3]);
- else
- glTexCoord4f(pixels[0], pixels[1], pixels[2], pixels[3]);
- }
-
- if (fpmode)
- {
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fps[semantic + (test_fog ? 2 : 0)]);
- glEnable(GL_FRAGMENT_PROGRAM_ARB);
- }
- else
- {
- if (test_fog)
- glEnable(GL_FOG);
- }
-
- glClearColor(0.5, 0.5, 0.5, 0.5);
- glClear(GL_COLOR_BUFFER_BIT);
-
- if (blend)
- {
- glEnable(GL_BLEND);
- glBlendFunc(blend_src[blend], blend_dst[blend]);
- glBlendColor(2.0f, 2.0f, 2.0f, 2.0f);
- }
- if (logicop)
- glEnable(GL_COLOR_LOGIC_OP);
-
- piglit_draw_rect(-1, -1, 1, 1);
-
- if (logicop)
- glDisable(GL_COLOR_LOGIC_OP);
- if (blend)
- glDisable(GL_BLEND);
- if (vpmode)
- glDisable(GL_VERTEX_PROGRAM_ARB);
- if (fpmode)
- glDisable(GL_FRAGMENT_PROGRAM_ARB);
- else if (test_fog)
- glDisable(GL_FOG);
-
- if (blend == 2 && !logicop)
- {
- if (fixed_snorm)
- expected = clamped ? clamped_pixels : signed_clamped_pixels;
- else if (fixed)
- expected = clamped_pixels;
- else
- expected = clamped ? clamped_pixels_mul_2 : pixels_mul_2;
- }
- else if (blend == 3 && !logicop)
- {
- if (fixed_snorm)
- expected = clamped ? clamped_pixels_plus_half_signed_clamped : signed_clamped_pixels_plus_half_signed_clamped;
- else if (fixed)
- expected = clamped_pixels_plus_half_clamped;
- else
- expected = clamped ? clamped_pixels_plus_half : pixels_plus_half;
- }
- else
- expected = clamped ? clamped_pixels :
- fixed_snorm ? signed_clamped_pixels :
- fixed ? clamped_pixels :
- pixels;
-
- opass = cpass = piglit_probe_pixel_rgba_silent(0, 0, expected, probe);
+ pass = test_one(vert_clamp, frag_clamp, semantic,
+ blend, logicop, vpmode, fpmode);
- if (nvidia_driver && clamped && !(semantic == 0 && clamp_enums[vert_clamp] == GL_TRUE) && clamp_enums[frag_clamp] == GL_TRUE && !fixed && fpmode && (!blend || logicop || format == GL_RGBA16F_ARB))
- {
- printf("nVidia driver known *** MAJOR BUG ***: they don't clamp fragment program results with ARB_fp on either fp32 with no blending or fp16!\n");
- opass = GL_TRUE;
- }
- if (nvidia_driver && clamped && !fixed && !fpmode && semantic == 0 && clamp_enums[vert_clamp] != GL_TRUE && clamp_enums[frag_clamp] == GL_TRUE)
- {
- printf("nVidia driver known *** MAJOR BUG ***: they don't clamp fragment program results with fffp, vertex clamp off and fragment clamp on fp16/fp32!\n");
- opass = GL_TRUE;
+ if (pass) {
+ npass++;
}
- if (test_fog && fpmode)
- {
- //printf("Unclear specification on GL_ARB_fog_*\n");
- opass = GL_TRUE;
+ else {
+ printf("Re-running failed test\n");
+ pass = test_one(vert_clamp, frag_clamp, semantic,
+ blend, logicop, vpmode, fpmode);
}
- if (!opass) {
- printf("%s: %s\n", (cpass ? "PASS" : (opass ? "XFAIL" : "FAIL")), test_name);
- printf(" Expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]);
- printf(" Observed: %f %f %f %f\n", probe[0], probe[1], probe[2], probe[3]);
-
- } else {
- npass++;
- }
total++;
- pass = opass && pass;
+ all_pass = all_pass && pass;
}
printf("Summary: %i/%i passed.\n", npass, total);
- return pass;
+ return all_pass;
}
+
unsigned
-init()
+init(void)
{
if (GLEW_ARB_vertex_program)
{
--
1.7.3.4
More information about the Piglit
mailing list