2 * Copyright © 2008 Nicolai Hähnle
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * @file read-cache-stress-test.c
27 * Test case for an odd problem in Radeon R300 on-chip readcache.
29 * Basically, on some particular access patterns, the read cache misses the
30 * fact that the framebuffer has changed, and a glReadPixels returns stale
33 * The test works by repeatedly rendering a square in different colors,
34 * and testing after each run that a number of pixel locations return the
37 * @note By the nature of the test, it makes no sense to have a demo mode,
38 * so this test is always automatic.
41 #include "piglit-util-gl.h"
43 PIGLIT_GL_TEST_CONFIG_BEGIN
45 config
.supports_gl_compat_version
= 11;
47 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGB
;
48 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
50 PIGLIT_GL_TEST_CONFIG_END
52 static GLfloat colors
[8][3] = {
63 enum piglit_result
piglit_display(void)
65 int x
, y
, color
, i
, comp
;
66 /* x and y range chosen to cover a wide range of memory;
67 * Actually, only the x coordinate should matter, but who knows... */
68 for(y
= 0; y
< 8; ++y
) {
69 for(x
= 0; x
< 32; ++x
) {
70 for(color
= 0; color
< 8; ++color
) {
71 glColor3fv(colors
[color
]);
79 for(i
= 0; i
< 2; ++i
) {
81 glReadPixels(x
+ (i
^ ((color
/2)&1))*10, y
,
82 1, 1, GL_RGB
, GL_FLOAT
, result
);
84 for(comp
= 0; comp
< 3; ++comp
) {
85 if (fabs(colors
[color
][comp
] - result
[comp
]) > 0.01) {
86 printf("(x,y) = (%i,%i), color=%i, expected: %f %f %f got %f %f %f\n",
88 colors
[color
][0], colors
[color
][1], colors
[color
][2],
89 result
[0], result
[1], result
[2]);
101 void piglit_init(int argc
, char **argv
)
106 piglit_automatic
= GL_TRUE
;
108 glViewport(0, 0, piglit_width
, piglit_height
);