[Piglit] [PATCH 4/7] util: add 1D and texture array support to piglit_depth_texture

Marek Olšák maraeo at gmail.com
Mon Sep 5 14:49:04 PDT 2011


---
 tests/fbo/fbo-generatemipmap-formats.c |    4 +-
 tests/shaders/shader_runner.c          |    4 +-
 tests/util/piglit-util-gl.c            |   54 ++++++++++++++++++++++++--------
 tests/util/piglit-util.h               |    2 +-
 4 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/tests/fbo/fbo-generatemipmap-formats.c b/tests/fbo/fbo-generatemipmap-formats.c
index 4f9e916..be52380 100644
--- a/tests/fbo/fbo-generatemipmap-formats.c
+++ b/tests/fbo/fbo-generatemipmap-formats.c
@@ -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;
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index a52e042..3e9431b 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -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);
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index b6ddf25..48472a7 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -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;
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 567b8c9..683caad 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -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);
 
-- 
1.7.4.1



More information about the Piglit mailing list