Commit cc500f69 authored by Marek Olšák's avatar Marek Olšák

util: add 1D and texture array support to piglit_depth_texture

parent b535a162
......@@ -71,8 +71,8 @@ create_tex(GLenum internalformat, GLenum baseformat, GLenum basetype)
GLenum type, format;
if ((baseformat == GL_DEPTH_COMPONENT) || (baseformat == GL_DEPTH_STENCIL)) {
tex = piglit_depth_texture(internalformat,
tex_width, tex_height, GL_FALSE);
tex = piglit_depth_texture(GL_TEXTURE_2D, internalformat,
tex_width, tex_height, 1, GL_FALSE);
assert(glGetError() == 0);
if (baseformat == GL_DEPTH_STENCIL) {
format = GL_DEPTH_STENCIL;
......
......@@ -1011,8 +1011,8 @@ piglit_display(void)
"texture shadow2D %d ( %d , %d )",
&tex, &w, &h) == 3) {
glActiveTexture(GL_TEXTURE0 + tex);
piglit_depth_texture(GL_DEPTH_COMPONENT,
w, h, GL_FALSE);
piglit_depth_texture(GL_TEXTURE_2D, GL_DEPTH_COMPONENT,
w, h, 1, GL_FALSE);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
......
......@@ -976,28 +976,28 @@ piglit_rgbw_texture(GLenum format, int w, int h, GLboolean mip,
}
GLuint
piglit_depth_texture(GLenum internalformat, int w, int h, GLboolean mip)
piglit_depth_texture(GLenum target, GLenum internalformat, int w, int h, int d, GLboolean mip)
{
void *data;
float *f = NULL, *f2 = NULL;
unsigned int *i = NULL;
int size, x, y, level;
int size, x, y, level, layer;
GLuint tex;
GLenum type, format;
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);
glBindTexture(target, tex);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (mip) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
}
data = malloc(w * h * 4 * sizeof(GLfloat));
......@@ -1029,10 +1029,38 @@ piglit_depth_texture(GLenum internalformat, int w, int h, GLboolean mip)
i[y * w + x] = 0xffffff00 * val;
}
}
glTexImage2D(GL_TEXTURE_2D, level,
internalformat,
w, h, 0,
format, type, data);
switch (target) {
case GL_TEXTURE_1D:
glTexImage1D(target, level,
internalformat,
w, 0,
format, type, data);
break;
case GL_TEXTURE_1D_ARRAY:
case GL_TEXTURE_2D:
glTexImage2D(target, level,
internalformat,
w, h, 0,
format, type, data);
break;
case GL_TEXTURE_2D_ARRAY:
glTexImage3D(target, level,
internalformat,
w, h, d, 0,
format, type, NULL);
for (layer = 0; layer < d; layer++) {
glTexSubImage3D(target, level,
0, 0, layer, w, h, 1,
format, type, data);
}
break;
default:
assert(0);
}
if (!mip)
break;
......
......@@ -191,7 +191,7 @@ GLuint piglit_checkerboard_texture(GLuint tex, unsigned level,
const float *black, const float *white);
GLuint piglit_rgbw_texture(GLenum format, int w, int h, GLboolean mip,
GLboolean alpha, GLenum basetype);
GLuint piglit_depth_texture(GLenum format, int w, int h, GLboolean mip);
GLuint piglit_depth_texture(GLenum target, GLenum format, int w, int h, int d, GLboolean mip);
extern float piglit_tolerance[4];
void piglit_set_tolerance_for_bits(int rbits, int gbits, int bbits, int abits);
......
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