Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Mesa
piglit
Commits
2feecc80
Commit
2feecc80
authored
Mar 11, 2011
by
Marek Olšák
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util: add piglit_probe_image_rgb* functions
parent
119a037d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
tests/util/piglit-util-gl.c
tests/util/piglit-util-gl.c
+66
-0
tests/util/piglit-util.h
tests/util/piglit-util.h
+2
-0
No files found.
tests/util/piglit-util-gl.c
View file @
2feecc80
...
...
@@ -138,6 +138,72 @@ piglit_probe_rect_rgba(int x, int y, int w, int h, const float *expected)
return
1
;
}
int
piglit_probe_image_rgb
(
int
x
,
int
y
,
int
w
,
int
h
,
const
float
*
image
)
{
int
i
,
j
,
p
;
GLfloat
*
probe
;
GLfloat
*
pixels
=
malloc
(
w
*
h
*
3
*
sizeof
(
float
));
glReadPixels
(
x
,
y
,
w
,
h
,
GL_RGB
,
GL_FLOAT
,
pixels
);
for
(
j
=
0
;
j
<
h
;
j
++
)
{
for
(
i
=
0
;
i
<
w
;
i
++
)
{
const
float
*
expected
=
&
image
[(
j
*
w
+
i
)
*
3
];
probe
=
&
pixels
[(
j
*
w
+
i
)
*
3
];
for
(
p
=
0
;
p
<
3
;
++
p
)
{
if
(
fabs
(
probe
[
p
]
-
expected
[
p
])
>=
tolerance
[
p
])
{
printf
(
"Probe at (%i,%i)
\n
"
,
x
+
i
,
y
+
j
);
printf
(
" Expected: %f %f %f
\n
"
,
expected
[
0
],
expected
[
1
],
expected
[
2
]);
printf
(
" Observed: %f %f %f
\n
"
,
probe
[
0
],
probe
[
1
],
probe
[
2
]);
free
(
pixels
);
return
0
;
}
}
}
}
free
(
pixels
);
return
1
;
}
int
piglit_probe_image_rgba
(
int
x
,
int
y
,
int
w
,
int
h
,
const
float
*
image
)
{
int
i
,
j
,
p
;
GLfloat
*
probe
;
GLfloat
*
pixels
=
malloc
(
w
*
h
*
4
*
sizeof
(
float
));
glReadPixels
(
x
,
y
,
w
,
h
,
GL_RGBA
,
GL_FLOAT
,
pixels
);
for
(
j
=
0
;
j
<
h
;
j
++
)
{
for
(
i
=
0
;
i
<
w
;
i
++
)
{
const
float
*
expected
=
&
image
[(
j
*
w
+
i
)
*
4
];
probe
=
&
pixels
[(
j
*
w
+
i
)
*
4
];
for
(
p
=
0
;
p
<
4
;
++
p
)
{
if
(
fabs
(
probe
[
p
]
-
expected
[
p
])
>=
tolerance
[
p
])
{
printf
(
"Probe at (%i,%i)
\n
"
,
x
+
i
,
y
+
j
);
printf
(
" Expected: %f %f %f %f
\n
"
,
expected
[
0
],
expected
[
1
],
expected
[
2
],
expected
[
3
]);
printf
(
" Observed: %f %f %f %f
\n
"
,
probe
[
0
],
probe
[
1
],
probe
[
2
],
probe
[
3
]);
free
(
pixels
);
return
0
;
}
}
}
}
free
(
pixels
);
return
1
;
}
/**
* Read a pixel from the given location and compare its RGB value to the
* given expected values.
...
...
tests/util/piglit-util.h
View file @
2feecc80
...
...
@@ -103,6 +103,8 @@ int piglit_probe_pixel_rgb(int x, int y, const float* expected);
int
piglit_probe_pixel_rgba
(
int
x
,
int
y
,
const
float
*
expected
);
int
piglit_probe_rect_rgb
(
int
x
,
int
y
,
int
w
,
int
h
,
const
float
*
expected
);
int
piglit_probe_rect_rgba
(
int
x
,
int
y
,
int
w
,
int
h
,
const
float
*
expected
);
int
piglit_probe_image_rgb
(
int
x
,
int
y
,
int
w
,
int
h
,
const
float
*
image
);
int
piglit_probe_image_rgba
(
int
x
,
int
y
,
int
w
,
int
h
,
const
float
*
image
);
int
piglit_probe_texel_rgb
(
int
target
,
int
level
,
int
x
,
int
y
,
const
float
*
expected
);
int
piglit_probe_texel_rgba
(
int
target
,
int
level
,
int
x
,
int
y
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment