[Piglit] [PATCH 5/7] util: Add stencil support to piglit_depth_texture()

Topi Pohjolainen topi.pohjolainen at intel.com
Thu Apr 28 19:17:08 UTC 2016


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 tests/fbo/fbo-generatemipmap-formats.c |  2 +-
 tests/shaders/shader_runner.c          | 10 +++++-----
 tests/util/piglit-util-gl.c            | 32 ++++++++++++++++++++++++++------
 tests/util/piglit-util-gl.h            |  3 ++-
 4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/tests/fbo/fbo-generatemipmap-formats.c b/tests/fbo/fbo-generatemipmap-formats.c
index a1b39aa..af65857 100644
--- a/tests/fbo/fbo-generatemipmap-formats.c
+++ b/tests/fbo/fbo-generatemipmap-formats.c
@@ -82,7 +82,7 @@ create_tex(GLenum internalformat, GLenum baseformat, GLenum basetype)
 	if ((baseformat == GL_DEPTH_COMPONENT) || (baseformat == GL_DEPTH_STENCIL)) {
 		tex = piglit_depth_texture(GL_TEXTURE_2D, internalformat,
 					   tex_width, tex_height, 1, GL_FALSE,
-					   DEPTH_GRAD_X);
+					   DEPTH_GRAD_X, DEPTH_CONST_ZERO);
 		if (!piglit_check_gl_error(GL_NO_ERROR))
 		        piglit_report_result(PIGLIT_FAIL);
 		if (internalformat == GL_DEPTH32F_STENCIL8) {
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index c11a418..ccbc250 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3170,7 +3170,7 @@ piglit_display(void)
 			glActiveTexture(GL_TEXTURE0 + tex);
 			piglit_depth_texture(GL_TEXTURE_2D, GL_DEPTH_COMPONENT,
 					     w, h, 1, GL_FALSE,
-					     DEPTH_GRAD_X);
+					     DEPTH_GRAD_X, DEPTH_CONST_ZERO);
 			glTexParameteri(GL_TEXTURE_2D,
 					GL_TEXTURE_COMPARE_MODE,
 					GL_COMPARE_R_TO_TEXTURE);
@@ -3186,7 +3186,7 @@ piglit_display(void)
 			glActiveTexture(GL_TEXTURE0 + tex);
 			piglit_depth_texture(GL_TEXTURE_RECTANGLE, GL_DEPTH_COMPONENT,
 					     w, h, 1, GL_FALSE,
-					     DEPTH_GRAD_X);
+					     DEPTH_GRAD_X, DEPTH_CONST_ZERO);
 			glTexParameteri(GL_TEXTURE_RECTANGLE,
 					GL_TEXTURE_COMPARE_MODE,
 					GL_COMPARE_R_TO_TEXTURE);
@@ -3199,7 +3199,7 @@ piglit_display(void)
 			glActiveTexture(GL_TEXTURE0 + tex);
 			piglit_depth_texture(GL_TEXTURE_1D, GL_DEPTH_COMPONENT,
 					     w, 1, 1, GL_FALSE,
-					     DEPTH_GRAD_X);
+					     DEPTH_GRAD_X, DEPTH_CONST_ZERO);
 			glTexParameteri(GL_TEXTURE_1D,
 					GL_TEXTURE_COMPARE_MODE,
 					GL_COMPARE_R_TO_TEXTURE);
@@ -3212,7 +3212,7 @@ piglit_display(void)
 			glActiveTexture(GL_TEXTURE0 + tex);
 			piglit_depth_texture(GL_TEXTURE_1D_ARRAY, GL_DEPTH_COMPONENT,
 					     w, l, 1, GL_FALSE,
-					     DEPTH_GRAD_X);
+					     DEPTH_GRAD_X, DEPTH_CONST_ZERO);
 			glTexParameteri(GL_TEXTURE_1D_ARRAY,
 					GL_TEXTURE_COMPARE_MODE,
 					GL_COMPARE_R_TO_TEXTURE);
@@ -3225,7 +3225,7 @@ piglit_display(void)
 			glActiveTexture(GL_TEXTURE0 + tex);
 			piglit_depth_texture(GL_TEXTURE_2D_ARRAY, GL_DEPTH_COMPONENT,
 					     w, h, l, GL_FALSE,
-					     DEPTH_GRAD_X);
+					     DEPTH_GRAD_X, DEPTH_CONST_ZERO);
 			glTexParameteri(GL_TEXTURE_2D_ARRAY,
 					GL_TEXTURE_COMPARE_MODE,
 					GL_COMPARE_R_TO_TEXTURE);
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 9280d1a..f944e41 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -2627,6 +2627,7 @@ GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, int a)
 static void
 generate_depth_layer(GLenum internalformat, int w, int h,
 		     enum depth_value_base depth_base,
+		     enum depth_value_base stencil_base,
 		     int layer, void *data)
 {
 	int x, y;
@@ -2636,6 +2637,9 @@ generate_depth_layer(GLenum internalformat, int w, int h,
 	if (depth_base == DEPTH_GRAD_EVEN_LAYER_X_ODD_Y)
 		depth_base = layer % 2 ? DEPTH_GRAD_Y : DEPTH_GRAD_X;
 
+	if (stencil_base == DEPTH_GRAD_EVEN_LAYER_X_ODD_Y)
+		stencil_base = layer % 2 ? DEPTH_GRAD_Y : DEPTH_GRAD_X;
+
 	for (y = 0; y < h; y++) {
 		for (x = 0; x < w; x++) {
 			float val;
@@ -2658,6 +2662,21 @@ generate_depth_layer(GLenum internalformat, int w, int h,
 			if (internalformat == GL_DEPTH_STENCIL_EXT ||
 			    internalformat == GL_DEPTH24_STENCIL8_EXT) {
 				i[y * w + x] = 0xffffff00 * val;
+				i[y * w + x] &= 0xffffff00;
+
+				switch (stencil_base) {
+				case DEPTH_CONST_ZERO:
+					break;
+				case DEPTH_GRAD_X:
+					i[y * w + x] += ((x * 255) / w);
+					break;
+				case DEPTH_GRAD_Y:
+					i[y * w + x] += ((y * 255) / h);
+					break;
+				case DEPTH_GRAD_EVEN_LAYER_X_ODD_Y:
+					assert(!"should be X or Y");
+					break;
+				}
 			} else if (internalformat == GL_DEPTH32F_STENCIL8) {
 				f2[(y * w + x)*2] = val;
 			} else {
@@ -2671,7 +2690,7 @@ static void
 setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
 		  GLenum type, int w, int h, int d,
 		  enum depth_value_base depth_base,
-		  int level)
+		  enum depth_value_base stencil_base, int level)
 {
 	int layer;
 	void *data = malloc(w * h * 4 * sizeof(GLfloat));
@@ -2679,7 +2698,7 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
 	switch (target) {
 	case GL_TEXTURE_1D:
 		generate_depth_layer(internalformat, w, h,
-				     depth_base, 0, data);
+				     depth_base, stencil_base, 0, data);
 		glTexImage1D(target, level,
 			     internalformat,
 			     w, 0,
@@ -2690,7 +2709,7 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
 	case GL_TEXTURE_2D:
 	case GL_TEXTURE_RECTANGLE:
 		generate_depth_layer(internalformat, w, h,
-				     depth_base, 0, data);
+				     depth_base, stencil_base, 0, data);
 		glTexImage2D(target, level,
 			     internalformat,
 			     w, h, 0,
@@ -2704,7 +2723,7 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
 			     format, type, NULL);
 		for (layer = 0; layer < d; layer++) {
 			generate_depth_layer(internalformat, w, h,
-					     depth_base, layer,
+					     depth_base, stencil_base, layer,
 					     data);
 			glTexSubImage3D(target, level,
 					0, 0, layer, w, h, 1,
@@ -2734,7 +2753,8 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
  */
 GLuint
 piglit_depth_texture(GLenum target, GLenum internalformat, int w, int h, int d, 
-		     GLboolean mip, enum depth_value_base depth_base)
+		     GLboolean mip, enum depth_value_base depth_base,
+		     enum depth_value_base stencil_base)
 {
 	int size, level;
 	GLuint tex;
@@ -2770,7 +2790,7 @@ piglit_depth_texture(GLenum target, GLenum internalformat, int w, int h, int d,
 
 	for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {
 		setup_depth_level(target, internalformat, format, type,
-                                  w, h, d, depth_base, level);
+                                  w, h, d, depth_base, stencil_base, level);
 
 		if (!mip)
 			break;
diff --git a/tests/util/piglit-util-gl.h b/tests/util/piglit-util-gl.h
index 8a57610..318e1d1 100644
--- a/tests/util/piglit-util-gl.h
+++ b/tests/util/piglit-util-gl.h
@@ -278,7 +278,8 @@ GLuint piglit_rgbw_texture(GLenum internalFormat, int w, int h, GLboolean mip,
 		    GLboolean alpha, GLenum basetype);
 GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, int a);
 GLuint piglit_depth_texture(GLenum target, GLenum format, int w, int h, int d,
-                            GLboolean mip, enum depth_value_base depth);
+                            GLboolean mip, enum depth_value_base depth,
+                            enum depth_value_base stencil);
 GLuint piglit_array_texture(GLenum target, GLenum format, int w, int h, int d, GLboolean mip);
 GLuint piglit_multisample_texture(GLenum target, GLenum tex,
 				  GLenum internalFormat,
-- 
2.5.5



More information about the Piglit mailing list