Commit 5f559344 authored by Anuj Phogat's avatar Anuj Phogat

util: Add functions to probe int, uint rgba buffer data

Added functions are piglit_probe_rect_color_rgba_int() and
piglit_probe_rect_color_rgba_uint(). These functions are useful to probe
color data from integer buffers.
Signed-off-by: Anuj Phogat's avatarAnuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent b2362fe3
......@@ -173,6 +173,33 @@ simple_probe(bool color, const float *color_value,
return pass;
}
/* Read pixel color values from float, integer or unsigned integer color
* buffer types
*/
bool
probe_rect_color(int x, int y, int w, int h, GLenum type,
const GLvoid *refcolor)
{
if (type == GL_FLOAT)
return piglit_probe_rect_rgba(x, y,
w, h,
(const float*)refcolor);
else if (type == GL_UNSIGNED_INT)
return piglit_probe_rect_rgba_uint(x, y,
w, h,
(const unsigned int*)
refcolor);
else if (type == GL_INT)
return piglit_probe_rect_rgba_int(x, y,
w, h,
(const int*)refcolor);
else
assert(type == GL_INT ||
type == GL_UNSIGNED_INT ||
type == GL_FLOAT);
return true;
}
enum piglit_result
piglit_display(void)
{
......
......@@ -31,3 +31,7 @@ extern bool
simple_probe(bool color, const float *color_value,
bool stencil, int stencil_value,
bool depth, float depth_value);
extern bool
probe_rect_color(int x, int y, int width, int height,
GLenum type, const GLvoid *refcolor);
......@@ -141,6 +141,71 @@ piglit_probe_rect_rgba(int x, int y, int w, int h, const float *expected)
return 1;
}
int
piglit_probe_rect_rgba_int(int x, int y, int w, int h, const int *expected)
{
int i, j, p;
GLint *probe;
GLint *pixels = malloc(w*h*4*sizeof(int));
glReadPixels(x, y, w, h, GL_RGBA_INTEGER, GL_INT, pixels);
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
probe = &pixels[(j*w+i)*4];
for (p = 0; p < 4; ++p) {
if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%d,%d)\n", x+i, y+j);
printf(" Expected: %d %d %d %d\n",
expected[0], expected[1], expected[2], expected[3]);
printf(" Observed: %d %d %d %d\n",
probe[0], probe[1], probe[2], probe[3]);
free(pixels);
return 0;
}
}
}
}
free(pixels);
return 1;
}
int
piglit_probe_rect_rgba_uint(int x, int y, int w, int h,
const unsigned int *expected)
{
int i, j, p;
GLuint *probe;
GLuint *pixels = malloc(w*h*4*sizeof(unsigned int));
glReadPixels(x, y, w, h, GL_RGBA_INTEGER, GL_UNSIGNED_INT, pixels);
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
probe = &pixels[(j*w+i)*4];
for (p = 0; p < 4; ++p) {
if (fabs(probe[p] - expected[p]) >= piglit_tolerance[p]) {
printf("Probe at (%d,%d)\n", x+i, y+j);
printf(" Expected: %u %u %u %u\n",
expected[0], expected[1], expected[2], expected[3]);
printf(" Observed: %u %u %u %u\n",
probe[0], probe[1], probe[2], probe[3]);
free(pixels);
return 0;
}
}
}
}
free(pixels);
return 1;
}
int
piglit_probe_image_rgb(int x, int y, int w, int h, const float *image)
{
......
......@@ -193,6 +193,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_rect_rgba_int(int x, int y, int w, int h, const int* expected);
int piglit_probe_rect_rgba_uint(int x, int y, int w, int h, const unsigned int* 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_rect_rgb(int target, int level, int x, int y,
......
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