diff options
author | Laura Ekstrand <laura@jlekstrand.net> | 2014-10-10 17:23:06 -0700 |
---|---|---|
committer | Laura Ekstrand <laura@jlekstrand.net> | 2014-10-10 17:23:06 -0700 |
commit | 422ed34b7f943f87dd3367e5514c92238b3e02f3 (patch) | |
tree | ec3b9dc410c02f1a0388f2633b33dc1d39053960 | |
parent | d1cdd9dd8751b7d3518fe562281de7185e5324d1 (diff) |
OrthoPosRandTris complete. Now, just have to format to match Piglit style.
-rw-r--r-- | tests/glean/glean-todo | 14 | ||||
-rw-r--r-- | tests/spec/laura_orthpos/orthpos.c | 138 |
2 files changed, 145 insertions, 7 deletions
diff --git a/tests/glean/glean-todo b/tests/glean/glean-todo index 6a25fb180..d38efdbbf 100644 --- a/tests/glean/glean-todo +++ b/tests/glean/glean-todo @@ -2,15 +2,15 @@ Glean Test What to do Rationale Responsible Cpp File Assignment --------------------------------------------------------------------------------------------------------------------------------------------- blendFunc Push upstream tblend.cpp Laura Ekstrand fpexceptions Push upstream tfpexceptions.cpp Laura Ekstrand -glsl1 Find bugs tglsl1.cpp Laura Ekstrand +glsl1 Find bug in "texture2D(), with bias" tglsl1.cpp Laura Ekstrand logicOp Port - exactly the same as blendFunc port. tlogicop.cpp Juliet Fru? occluQry Port toccluqry.cpp Juliet Fru? -orthoPosRandTris Rewrite, if we even care about this... torthpos.cpp -orthoPosRandRects Rewrite, if we even care about this... torthpos.cpp -orthoPosTinyQuads Rewrite, if we even care about this... torthpos.cpp -orthoPosHLines Rewrite, if we even care about this... torthpos.cpp -orthoPosVLines Rewrite, if we even care about this... torthpos.cpp -orthoPosPoints Rewrite, if we even care about this... torthpos.cpp +orthoPosRandTris Push Upstream torthpos.cpp Laura Ekstrand +orthoPosRandRects Push Upstream torthpos.cpp Laura Ekstrand +orthoPosTinyQuads Push Upstream torthpos.cpp Laura Ekstrand +orthoPosHLines Push Upstream torthpos.cpp Laura Ekstrand +orthoPosVLines Push Upstream torthpos.cpp Laura Ekstrand +orthoPosPoints Push Upstream torthpos.cpp Laura Ekstrand paths Port tpaths.cpp Juliet Fru? pbo Port tpbo.cpp polygonOffset Port tpgos.cpp diff --git a/tests/spec/laura_orthpos/orthpos.c b/tests/spec/laura_orthpos/orthpos.c index cbd0a3534..b19e0a165 100644 --- a/tests/spec/laura_orthpos/orthpos.c +++ b/tests/spec/laura_orthpos/orthpos.c @@ -537,6 +537,142 @@ orthoPosTinyQuads() { return verifyOrthPos(img, imgBytes/windowSize, "Immediate-mode 1x1 quads"); } /* orthoPosTinyQuads */ +/** + * This test checks the positioning of axis-aligned rectangles + * under orthographic projection. (This is important for apps + * that want to use OpenGL for precise 2D drawing.) It fills in + * an entire rectangle with an array of smaller rects, drawing + * adjacent rects with different colors and with blending enabled. + * If there are gaps (pixels that are the background color, and + * thus haven't been filled), overlaps (pixels that show a blend + * of more than one color), or improper edges (pixels around the + * edge of the rectangle that haven't been filled, or pixels just + * outside the edge that have), then the test fails. + * + * This test generally fails for one of several reasons. First, + * the coordinate transformation process may have an incorrect bias; + * this usually will cause a bad edge. Second, the coordinate + * transformation process may round pixel coordinates incorrectly; + * this will usually cause gaps and/or overlaps. Third, the + * rectangle rasterization process may not be filling the correct + * pixels; this can cause gaps, overlaps, or bad edges. + */ +bool +orthoPosRandRects() { + /* + * Immediate-mode random axis-aligned rectangles + */ + + /* Draw the image */ + glClear(GL_COLOR_BUFFER_BIT); + subdivideRects(1, drawingSize + 1, 1, drawingSize + 1, + true, true); + + /* Read the image */ + glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img); + + /* Show the image */ + if (!piglit_automatic) { + piglit_present_results(); + } + + /* Check the results */ + return verifyOrthPos(img, imgBytes/windowSize, + "Immediate-mode random axis-aligned rectangles"); +} /* orthoPosRandRects */ + +/* Factory for generating random mesh just like Glean's RandomMesh2D class */ +float* +randomMesh2D(float minX, float maxX, int xPoints, + float minY, float maxY, int yPoints) +{ + int x, y, idx; + float* mesh = malloc(xPoints * yPoints * 2 * sizeof(float)); + double deltaX = 0.7 * (maxX - minX) / (xPoints - 1); + double deltaY = 0.7 * (maxY - minY) / (yPoints - 1); + float randNo; + + for (y = 0; y < yPoints; ++y) { + for (x = 0; x < xPoints; ++x) { + + idx = 2 * (xPoints * y + x); + + /* Generate an unperturbed, uniform mesh */ + mesh[idx + 0] = minX + (x * (maxX - minX)) / (xPoints - 1); + mesh[idx + 1] = minY + (y * (maxY - minY)) / (yPoints - 1); + + /* Perturb the interior points of the mesh */ + if ((x != 0) && (y != 0) && (x != xPoints - 1) && (y != yPoints - 1)) + { + randNo = (float) rand() / RAND_MAX; /* Float in range [0.0f, 1.0f] */ + mesh[idx + 0] += deltaX * (randNo - 0.5); + randNo = (float) rand() / RAND_MAX; + mesh[idx + 1] += deltaY * (randNo - 0.5); + } + } + } + + return mesh; +} + +/** + * This test checks the positioning of random triangles under + * orthographic projection. (This is important for apps that + * want to use OpenGL for precise 2D drawing.) It fills in an + * entire rectangle with an array of randomly-generated triangles, + * drawing adjacent triangles with different colors and with blending + * enabled. If there are gaps (pixels that are the background color, + * and thus haven't been filled), overlaps (pixels that show a blend + * of more than one color), or improper edges (pixels around the + * edge of the rectangle that haven't been filled, or pixels just + * outside the edge that have), then the test fails. + * + * This test generally fails for one of several reasons. First, + * the coordinate transformation process may have an incorrect bias; + * this usually will cause a bad edge. Second, the coordinate + * transformation process may round pixel coordinates incorrectly; + * this will usually cause gaps and/or overlaps. Third, the + * triangle rasterization process may not be filling the correct + * pixels; this can cause gaps, overlaps, or bad edges. + */ +bool +orthoPosRandTris() { + /* + * Immediate-mode random triangles + */ + int i, j; + int nPoints = 10; + float* mesh; + + /* Draw the image */ + glClear(GL_COLOR_BUFFER_BIT); + mesh = randomMesh2D(1, drawingSize + 1, nPoints, + 1, drawingSize + 1, nPoints); + for (i = nPoints - 1; i > 0; --i) { + glBegin(GL_TRIANGLE_STRIP); + for (j = 0; j < nPoints; ++j) { + glColor4f(1.0, 0.0, 0.0, 0.5); + glVertex2fv(mesh + 2 * (nPoints * i + j)); /* mesh[i, j] */ + glColor4f(0.0, 1.0, 0.0, 0.5); + glVertex2fv(mesh + 2 * (nPoints * (i - 1) + j)); /* mesh[i - 1, j] */ + } + glEnd(); + } + free(mesh); + + /* Read the image */ + glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img); + + /* Show the image */ + if (!piglit_automatic) { + piglit_present_results(); + } + + /* Check the results */ + return verifyOrthPos(img, imgBytes/windowSize, + "Immediate-mode random triangles"); +} /* orthoPosRandTris */ + enum piglit_result piglit_display(void) { @@ -546,6 +682,8 @@ piglit_display(void) pass &= orthoPosVLines(); pass &= orthoPosHLines(); pass &= orthoPosTinyQuads(); + pass &= orthoPosRandRects(); + pass &= orthoPosRandTris(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; } |