static bool
test_mipmap_tree(void)
{
	bool pass = true;
	int layer, level;

	for (level = 0; level < TEX_LEVELS; level++) {
		int size = TEX_SIZE >> level;
		float *observed;

		/* With a compressed texture, skip checking the second and
		 * third last levels, because one DXTC block cannot contain
		 * more than 2 colors.
		 *
		 * However, always test the last level, which should only
		 * contain one color, which is the average of all 4.
		 */
		if (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT &&
		    level >= TEX_LEVELS-3 && level <= TEX_LEVELS-2)
			continue;

		if (test_array) {
			observed = malloc(num_layers * size * size * 4 * sizeof(float));
			glGetTexImage(target, level, GL_RGBA, GL_FLOAT, observed);

			for (layer = 0; layer < num_layers; layer++) {
				pass = pass && test_face(layer % 6, level, layer / 6,
							 observed + layer * size * size * 4);
			}

			free(observed);
		}
		else {
			for (layer = 0; layer < num_layers; layer++) {
				observed = malloc(size * size * 4 * sizeof(float));
				glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer,
					      level, GL_RGBA, GL_FLOAT, observed);

				pass = pass && test_face(layer, level, 0, observed);

				free(observed);
			}
		}
	}

	return pass;
}
enum piglit_result
piglit_display(void)
{
	GLuint i;
	bool pass = true;
	for (i = 0; i < 6; i++) {
		pass = test_face(i) && pass;
	}
	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}