summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Pohjolainen <topi.pohjolainen@intel.com>2014-02-23 23:14:30 +0200
committerTopi Pohjolainen <topi.pohjolainen@intel.com>2016-04-27 09:47:36 +0300
commit495fbbce0c0c5805a0d93103a0123e05119d7df7 (patch)
treefb0531312c5cfe5da767f17426c07b46fd5c004f
parent1a5ca6bd985973c4f534b03a2bf4b804e06e298c (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.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index b288a67b0..5e96c3306 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -2624,6 +2624,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,
@@ -2641,9 +2664,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;
@@ -2668,29 +2689,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: