Commit f5abad7e authored by Kenneth Graunke's avatar Kenneth Graunke

shader_runner: Add ability to create textures with per-miplevel colors.

For basic mipmapped texture testing, it's often useful to create
textures where each miplevel has a unique color.

The next commit will use this to simplify an existing test case, and
subsequent commits will introduce new tests based on this functionality.
Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
parent bfb1daf1
......@@ -1264,6 +1264,10 @@ piglit_display(void)
glActiveTexture(GL_TEXTURE0 + tex);
piglit_rgbw_texture(GL_RGBA, w, h, GL_FALSE, GL_FALSE, GL_UNSIGNED_NORMALIZED);
glEnable(GL_TEXTURE_2D);
} else if (sscanf(line, "texture miptree %d", &tex) == 1) {
glActiveTexture(GL_TEXTURE0 + tex);
piglit_miptree_texture();
glEnable(GL_TEXTURE_2D);
} else if (sscanf(line,
"texture checkerboard %d %d ( %d , %d ) "
"( %f , %f , %f , %f ) "
......
......@@ -958,6 +958,45 @@ piglit_checkerboard_texture(GLuint tex, unsigned level,
return tex;
}
/**
* Generates a 8x8 mipmapped texture whose layers contain solid r, g, b, and w.
*/
GLuint
piglit_miptree_texture()
{
GLfloat *data;
int size, i, level;
GLuint tex;
const float color_wheel[4][4] = {
{1, 0, 0, 1}, /* red */
{0, 1, 0, 1}, /* green */
{0, 0, 1, 1}, /* blue */
{1, 1, 1, 1}, /* white */
};
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST_MIPMAP_NEAREST);
for (level = 0; level < 4; ++level) {
size = 8 >> level;
data = malloc(size*size*4*sizeof(GLfloat));
for (i = 0; i < size * size; ++i) {
memcpy(data + 4 * i, color_wheel[level],
4 * sizeof(GLfloat));
}
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,
size, size, 0, GL_RGBA, GL_FLOAT, data);
free(data);
}
return tex;
}
/**
* Generates a texture with the given internalFormat, w, h with a
* teximage of r, g, b w quadrants.
......
......@@ -255,6 +255,7 @@ GLuint piglit_checkerboard_texture(GLuint tex, unsigned level,
unsigned width, unsigned height,
unsigned horiz_square_size, unsigned vert_square_size,
const float *black, const float *white);
GLuint piglit_miptree_texture(void);
GLuint piglit_rgbw_texture(GLenum format, int w, int h, GLboolean mip,
GLboolean alpha, GLenum basetype);
GLuint piglit_depth_texture(GLenum target, GLenum format, int w, int h, int d, GLboolean mip);
......
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