Commit 8c9ea79d authored by Nicolai Hähnle's avatar Nicolai Hähnle
Browse files

New test bug/r300-readcache

This tests against a particular problem of the r300 driver, related to a
readcache coherency problem.

Note that while I had first found this problem via glean/texCube, the fact
that I did find the problem there was pure chance, because the bug depends
on the exact coordinate of the glReadPixels call (and thus on the window
position). This new test loops through many coordinates to make sure the
window coordinates are irrelevant.
parent 67cf70cc
......@@ -66,6 +66,7 @@ bugs = Group()
bugs['fdo9833'] = PlainExecTest([testBinDir + 'fdo9833', '-auto'])
bugs['fdo10370'] = PlainExecTest([testBinDir + 'fdo10370', '-auto'])
bugs['fdo14575'] = PlainExecTest([testBinDir + 'fdo14575', '-auto'])
bugs['r300-readcache'] = PlainExecTest([testBinDir + 'r300-readcache'])
texturing = Group()
texturing['cubemap'] = PlainExecTest([testBinDir + 'cubemap', '-auto'])
......
......@@ -3,6 +3,7 @@ include_directories(
${OPENGL_INCLUDE_PATH}
${GLUT_INCLUDE_DIR}
${piglit_SOURCE_DIR}/tests/mesa/util
${piglit_SOURCE_DIR}/tests/util
)
link_directories (
......@@ -15,8 +16,10 @@ link_libraries (
${GLUT_glut_LIBRARY}
${TIFF_LIBRARY}
mesautil
piglitutil
)
add_executable (fdo9833 fdo9833.c)
add_executable (fdo10370 fdo10370.c)
add_executable (fdo14575 fdo14575.c)
add_executable (r300-readcache r300-readcache.c)
/**
* @file r300-readcache.c
*
* Test case for an odd problem in Radeon on-chip readcache.
*
* Basically, on some particular access patterns, the read cache misses the
* fact that the framebuffer has changed, and a glReadPixels returns stale
* data.
*
* The test works by repeatedly rendering a square in different colors,
* and testing after each run that a number of pixel locations return the
* right color.
*
* @note By the nature of the test, it makes no sense to have a demo mode,
* so this test is always automatic.
*/
#include "GL/glut.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include "piglit-util.h"
static int Width = 100, Height = 100;
static GLfloat colors[8][3] = {
{ 1.0, 1.0, 1.0 },
{ 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 },
{ 0.5, 0.0, 0.0 },
{ 0.0, 0.5, 0.0 },
{ 0.0, 0.0, 0.5 },
{ 0.0, 0.0, 0.0 }
};
static void Display(void)
{
int x, y, color, i, comp;
/* x and y range chosen to cover a wide range of memory;
* Actually, only the x coordinate should matter, but who knows... */
for(y = 0; y < 8; ++y) {
for(x = 0; x < 32; ++x) {
for(color = 0; color < 8; ++color) {
glColor3fv(colors[color]);
glBegin(GL_QUADS);
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
glVertex2f(-1, 1);
glEnd();
for(i = 0; i < 2; ++i) {
GLfloat result[3];
glReadPixels(x + (i ^ ((color/2)&1))*10, y,
1, 1, GL_RGB, GL_FLOAT, result);
for(comp = 0; comp < 3; ++comp) {
if (fabs(colors[color][comp] - result[comp]) > 0.01) {
printf("(x,y) = (%i,%i), color=%i, expected: %f %f %f got %f %f %f\n",
x, y, color,
colors[color][0], colors[color][1], colors[color][2],
result[0], result[1], result[2]);
piglit_report_result(PIGLIT_FAILURE);
}
}
}
}
}
}
piglit_report_result(PIGLIT_SUCCESS);
}
static void init()
{
glViewport(0, 0, Width, Height);
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(Width, Height);
glutCreateWindow(argv[0]);
glutDisplayFunc(Display);
init();
glutMainLoop();
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment