1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/**
* @file getteximage-simple.c
*
* Extremely basic test to check whether image data can be retrieved.
*
* Note that the texture is used in a full frame of rendering before
* the readback, to ensure that buffer manager related code for uploading
* texture images is executed before the readback.
*
* This used to crash for R300+bufmgr.
*/
#include "piglit-util-gl-common.h"
PIGLIT_GL_TEST_CONFIG_BEGIN
config.window_width = 100;
config.window_height = 100;
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
PIGLIT_GL_TEST_CONFIG_END
static GLubyte data[4096]; /* 64*16*4 */
static int test_getteximage(void)
{
GLubyte compare[4096];
int i;
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, compare);
for(i = 0; i < 4096; ++i) {
if (data[i] != compare[i]) {
printf("GetTexImage() returns incorrect data in byte %i\n", i);
printf(" corresponding to (%i,%i) channel %i\n", i / 64, (i / 4) % 16, i % 4);
printf(" expected: %i\n", data[i]);
printf(" got: %i\n", compare[i]);
return 0;
}
}
return 1;
}
enum piglit_result
piglit_display(void)
{
int pass;
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(1, 0);
glVertex2f(1, 0);
glTexCoord2f(1, 1);
glVertex2f(1, 1);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
glEnd();
piglit_present_results();
pass = test_getteximage();
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
void piglit_init(int argc, char **argv)
{
int i;
for(i = 0; i < 4096; ++i)
data[i] = rand() & 0xff;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
piglit_gen_ortho_projection(0.0, 1.0, 0.0, 1.0, -2.0, 6.0, GL_FALSE);
}
|