[Piglit] [PATCH] fbo-viewport: fix false error caused by slight rounding differences
Nicolai Hähnle
nhaehnle at gmail.com
Fri Sep 29 12:09:21 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
This test compares rendering to the window system framebuffer with
rendering to an FBO, and it does so by rendering rotated quads. There
can be slight differences in rounding if the Y axis is flipped between
those buffers causing rendering differences which are permitted by GL.
Change the test to render axis-aligned quads in each viewport instead.
This should still catch any error with flipped Ys, and there are no
rounding issues since pixels are fully covered by quads.
---
tests/fbo/fbo-viewport.c | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/tests/fbo/fbo-viewport.c b/tests/fbo/fbo-viewport.c
index 82d9f04f4..b2e351ce1 100644
--- a/tests/fbo/fbo-viewport.c
+++ b/tests/fbo/fbo-viewport.c
@@ -36,80 +36,65 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 10;
config.window_width = 500;
config.window_height = 500;
config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
config.khr_no_error_support = PIGLIT_NO_ERRORS;
PIGLIT_GL_TEST_CONFIG_END
/**
- * Draw some simple quads in a bunch of viewports which tile the window.
+ * Draw full-viewport quads in a bunch of viewports which tile the window.
* Note that viewports extend beyond the edges of the window too.
*/
static void
draw_test_image(void)
{
int vx, vy, vw = 200, vh = 200;
glClear(GL_COLOR_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-1, 1, -1, 1, 3, 9.5);
-
- /* Draw some quads at an odd rotation.
- * Note that we want near/far frustum clipping.
- */
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glTranslatef(0, 1, -6.20);
- glRotatef(-60, 1, 0, 0);
- glRotatef(30, 0, 0, 1);
- glScalef(3.5, 3.5, 3.5);
-
/* loop over viewports */
+ int i = 1;
for (vy = -50; vy < piglit_height; vy += vh+10) {
- for (vx = -30; vx < piglit_width; vx += vw+10) {
+ for (vx = -30; vx < piglit_width; vx += vw+10, ++i) {
glViewport(vx, vy, vw, vh);
glBegin(GL_QUADS);
- glColor3f(1, 0, 0);
+ glColor3f((i % 4) / 3.0, ((i / 4) % 4) / 3.0, 0.0);
glVertex2f(-1, -1);
glVertex2f( 0, -1);
glVertex2f( 0, 0);
glVertex2f(-1, 0);
- glColor3f(0, 1, 0);
+ glColor3f((i % 4) / 3.0, ((i / 4) % 4) / 3.0, 0.333);
glVertex2f( 0, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 0);
glVertex2f( 0, 0);
- glColor3f(0, 0, 1);
- glVertex2f(-1, 0);
+ glColor3f((i % 4) / 3.0, ((i / 4) % 4) / 3.0, 0.666);
glVertex2f( 0, 0);
+ glVertex2f( 1, 0);
+ glVertex2f( 1, 1);
glVertex2f( 0, 1);
- glVertex2f(-1, 1);
- glColor3f(1, 1, 1);
+ glColor3f((i % 4) / 3.0, ((i / 4) % 4) / 3.0, 1.0);
+ glVertex2f(-1, 0);
glVertex2f( 0, 0);
- glVertex2f( 1, 0);
- glVertex2f( 1, 1);
glVertex2f( 0, 1);
+ glVertex2f(-1, 1);
glEnd();
}
}
-
- glPopMatrix();
}
enum piglit_result
piglit_display(void)
{
GLubyte *win_image, *fbo_image;
GLuint fbo, rb;
bool pass = true;
--
2.11.0
More information about the Piglit
mailing list