[Piglit] [PATCH V3] KHR image from texture test
Eric Anholt
eric at anholt.net
Tue Jan 29 16:22:31 PST 2013
Abdiel Janulgue <abdiel.janulgue at linux.intel.com> writes:
> +#define TEXTURE_SIZE 64
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_es_version = 20;
> +
> + config.window_width = 448;
> + config.window_height = 448;
> + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
I would still like the window width/height to be expressed in terms of
TEXTURE_SIZE for clarity of what's going on with these magic numbers.
> +static void
> +set_face_image(int level, GLenum face, int size, int color)
> +{
> + GLfloat *color1 = colors[color];
> + GLfloat *color2 = colors[(color + 1) % ARRAY_SIZE(colors)];
> + GLfloat *tex;
> + int x, y;
> +
> + tex = malloc(size * size * 4 * sizeof(GLfloat));
> +
> + for (y = 0; y < size; y++) {
> + for (x = 0; x < size; x++) {
> + GLfloat *chosen_color;
> +
> + if (y >= (size / 2) || x >= (size / 2))
> + chosen_color = color1;
> + else
> + chosen_color = color2;
> +
> + tex[(y * size + x) * 4 + 0] = chosen_color[0];
> + tex[(y * size + x) * 4 + 1] = chosen_color[1];
> + tex[(y * size + x) * 4 + 2] = chosen_color[2];
Looks like tex[(y * size + x) * 4 + 3] is not getting set, which is used
by the teximage2d call. A memcpy would probably be easier. (this is
the only substantive review I have for this patch, the rest is just
nitpicky style crap)
> +static bool
> +test_results(int x, int y, int size, int color)
> +{
> + GLfloat *color1 = colors[color];
> + GLfloat *color2 = colors[(color + 1) % ARRAY_SIZE(colors)];
> + bool pass = true;
> +
> + if (size == 1) {
> + pass = pass && piglit_probe_rect_rgba(x, y,
> + size/2, size/2, color1);
> + } else {
> + pass = pass && piglit_probe_rect_rgba(x, y,
> + size/2, size/2,
> + color2);
> + pass = pass && piglit_probe_rect_rgba(x + size/2, y,
> + size/2, size, color1);
> + pass = pass & piglit_probe_rect_rgba(x, y + size/2,
> + size/2,size/2,color1);
this one is & instead of && which is inconsistent.
> + }
> +
> + return pass;
> +}
> +
> +static bool
> +test_2d_texture(int texture_size)
> +{
> + int color = ARRAY_SIZE(colors) - 1;
> + int level, y = 0, size = 1;
> + bool pass = true;
> +
> + for (level = texture_size; level > 0; level >>= 1) {
> + pass = test_results(0, y, size, color) && pass;
> + y += TEXTURE_SIZE;
> + size *=2;
> + color--;
> + }
> +
> + return pass;
> +}
A line of whitespace after this function before the next would be nice
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130130/39e4909d/attachment.pgp>
More information about the Piglit
mailing list