diff options
author | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2014-02-23 23:14:30 +0200 |
---|---|---|
committer | Topi Pohjolainen <topi.pohjolainen@intel.com> | 2016-05-19 23:35:59 +0300 |
commit | a25d63d44352173a1f300defb84e771f28d898e1 (patch) | |
tree | 7043eedefd2da1573912c133d6fbf59f6a128f71 | |
parent | 1e38407baefb1e2fda9c6aa09eb47d9da8c760a4 (diff) |
util: Refactor data generation for depth levels
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
-rw-r--r-- | tests/util/piglit-util-gl.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c index 89abc3a45..bb58d6a7b 100644 --- a/tests/util/piglit-util-gl.c +++ b/tests/util/piglit-util-gl.c @@ -2641,6 +2641,29 @@ GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, int a) return tex; } +static void +generate_depth_layer(GLenum internalformat, int w, int h, int layer, void *data) +{ + int x, y; + float *f = data, *f2 = data; + unsigned int *i = data; + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) { + float val = (float)(x) / (w - 1); + + if (internalformat == GL_DEPTH_STENCIL_EXT || + internalformat == GL_DEPTH24_STENCIL8_EXT) { + i[y * w + x] = 0xffffff00 * val; + } else if (internalformat == GL_DEPTH32F_STENCIL8) { + f2[(y * w + x)*2] = val; + } else { + f[y * w + x] = val; + } + } + } +} + /** * Create a depth texture. The depth texture will be a gradient which varies * from 0.0 at the left side to 1.0 at the right side. For a 2D array texture, @@ -2658,9 +2681,7 @@ GLuint 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, layer; + int size, level, layer; GLuint tex; GLenum type, format; @@ -2685,29 +2706,16 @@ piglit_depth_texture(GLenum target, GLenum internalformat, int w, int h, int d, internalformat == GL_DEPTH24_STENCIL8_EXT) { format = GL_DEPTH_STENCIL_EXT; type = GL_UNSIGNED_INT_24_8_EXT; - i = data; } else if (internalformat == GL_DEPTH32F_STENCIL8) { format = GL_DEPTH_STENCIL; type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV; - f2 = data; } else { format = GL_DEPTH_COMPONENT; type = GL_FLOAT; - f = data; } for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) { - for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) { - float val = (float)(x) / (w - 1); - if (f) - f[y * w + x] = val; - else if (f2) - f2[(y * w + x)*2] = val; - else - i[y * w + x] = 0xffffff00 * val; - } - } + generate_depth_layer(internalformat, w, h, 0, data); switch (target) { case GL_TEXTURE_1D: |