[Piglit] [PATCH] main: Added a test for CopyTextureSubImage3D(CUBE_MAP).

Laura Ekstrand laura at jlekstrand.net
Wed Mar 18 13:08:48 PDT 2015


---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 .../arb_direct_state_access/copytexture-cubemap.c  | 149 +++++++++++++++++++++
 3 files changed, 151 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/copytexture-cubemap.c

diff --git a/tests/all.py b/tests/all.py
index a955238..d87bb19 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4249,6 +4249,7 @@ with profile.group_manager(
     g(['arb_direct_state_access-clearnamedframebuffer'], 'clearnamedframebuffer')
     g(['arb_direct_state_access-drawbuffers'], 'drawbuffers')
     g(['arb_direct_state_access-drawbuffers-multi'], 'drawbuffers-multi')
+    g(['arb_direct_state_access-copytexture-cubemap'], 'copytexture-cubemap')
 
 with profile.group_manager(
         PiglitGLTest,
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
index b1fe6c4..f118398 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -57,4 +57,5 @@ piglit_add_executable (arb_direct_state_access-create-programpipelines create-pr
 piglit_add_executable (arb_direct_state_access-create-queries create-queries.c)
 piglit_add_executable (arb_direct_state_access-texture-buffer-range texture-buffer-range.c)
 piglit_add_executable (arb_direct_state_access-create-framebuffers create-framebuffers.c)
+piglit_add_executable (arb_direct_state_access-copytexture-cubemap copytexture-cubemap.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_direct_state_access/copytexture-cubemap.c b/tests/spec/arb_direct_state_access/copytexture-cubemap.c
new file mode 100644
index 0000000..a9541f4
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/copytexture-cubemap.c
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/** @file copytexture-cubemap.c
+ *
+ * Tests to make sure the glCopyTextureSubImage3D(effective target
+ * GL_TEXTURE_CUBE_MAP) works.
+ */
+
+#include "piglit-util-gl.h"
+#include "dsa-utils.h"
+
+#define FORMAT GL_RGBA
+#define INTFORMAT GL_RGBA8
+#define WIDTH 32
+#define HEIGHT 32
+#define IMAGE_SIZE (WIDTH * HEIGHT * 4)
+#define BORDER 4
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 20;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA |
+		PIGLIT_GL_VISUAL_DOUBLE;
+
+	config.window_width = 7 * WIDTH + 6 * BORDER;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static bool global_pass = true;
+static int face = 3;
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_direct_state_access");
+	piglit_require_extension("GL_ARB_texture_storage");
+
+	srand(0);
+
+	if (argc == 2) {
+		int input_face = atoi(argv[1]);
+		if ((input_face >= 0) && (input_face < 6))
+			face = input_face;
+		else
+			printf("Unrecognized face %d.\n", input_face);
+	}
+
+	printf("Testing with cube map face %s (%d).\n",
+	       piglit_get_gl_enum_name(GL_TEXTURE_CUBE_MAP_POSITIVE_X +
+	       face), face);
+
+	glClearColor(0.94f, 0.45f, 0.05f, 1.0f); /* Orange */
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	GLuint tex2D, texcube, fbo;
+	int i;
+	GLfloat *exp = malloc(IMAGE_SIZE * sizeof(GLfloat));
+	GLfloat *face_data =  malloc(IMAGE_SIZE * sizeof(GLfloat));
+	GLubyte *data = malloc(IMAGE_SIZE * 6);
+	memset(data, 123, IMAGE_SIZE * 6);
+
+	/* Set up the window */
+	glClear(GL_COLOR_BUFFER_BIT);
+	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+	/* Draw an rgbw image in the framebuffer */
+	tex2D = piglit_rgbw_texture(INTFORMAT, WIDTH, HEIGHT, false, false,
+				    GL_UNSIGNED_BYTE);
+	glEnable(GL_TEXTURE_2D);
+	glBindTexture(GL_TEXTURE_2D, tex2D);
+	piglit_draw_rect_tex(0, 0, WIDTH, HEIGHT, 0, 0, 1, 1);
+	global_pass = piglit_check_gl_error(GL_NO_ERROR) && global_pass;
+
+	/* Create a cube map texture with it */
+	glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &texcube);
+	glTextureStorage2D(texcube, 1, INTFORMAT, WIDTH, HEIGHT);
+	glTextureSubImage3D(texcube, 0, 0, 0, 0, WIDTH, HEIGHT, 6, FORMAT,
+			    GL_UNSIGNED_BYTE, data);
+	glCopyTextureSubImage3D(texcube, 0, 0, 0, face, 0, 0, WIDTH, HEIGHT);
+	global_pass = piglit_check_gl_error(GL_NO_ERROR) && global_pass;
+
+	/* Show cube texture on screen */
+	glCreateFramebuffers(1, &fbo);
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
+	for (i = 0; i < 6; ++i) {
+		glFramebufferTexture2D(GL_READ_FRAMEBUFFER,
+				       GL_COLOR_ATTACHMENT0,
+				       GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
+				       texcube, 0);
+		if (!glCheckFramebufferStatus(GL_READ_FRAMEBUFFER))
+			return PIGLIT_FAIL;
+
+		glBlitNamedFramebuffer(fbo, piglit_winsys_fbo,
+				       0, 0, WIDTH, HEIGHT,
+				       (i + 1) * (WIDTH + BORDER), 0,
+				       (i + 2) * WIDTH + (i + 1) * BORDER,
+				       HEIGHT, GL_COLOR_BUFFER_BIT,
+				       GL_NEAREST);
+	}
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+	global_pass = piglit_check_gl_error(GL_NO_ERROR) && global_pass;
+
+	/* Check the resulting image. */
+	glReadPixels(0, 0, WIDTH, HEIGHT, FORMAT, GL_FLOAT, exp);
+	glReadPixels((face + 1) * (WIDTH + BORDER), 0, WIDTH, HEIGHT, FORMAT,
+		     GL_FLOAT, face_data);
+	global_pass = piglit_compare_images_color(0, 0, WIDTH, HEIGHT,
+						  4, piglit_tolerance,
+						  exp, face_data)
+						  && global_pass;
+
+	if (!piglit_automatic)
+		piglit_present_results();
+
+
+	/* Clean up. */
+	glDeleteTextures(1, &tex2D);
+	glDeleteTextures(1, &texcube);
+	free(data);
+	free(exp);
+	free(face_data);
+
+	return global_pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
2.1.0



More information about the Piglit mailing list