[Piglit] [PATCH 8/8] arb_texture_view: Add test for rendering with format change

Chris Forbes chrisf at ijw.co.nz
Fri Feb 21 12:03:07 PST 2014


---
 tests/all.py                                    |   1 +
 tests/spec/arb_texture_view/CMakeLists.gl.txt   |   1 +
 tests/spec/arb_texture_view/rendering-formats.c | 127 ++++++++++++++++++++++++
 3 files changed, 129 insertions(+)
 create mode 100644 tests/spec/arb_texture_view/rendering-formats.c

diff --git a/tests/all.py b/tests/all.py
index 8d0a985..e3839bd 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1968,6 +1968,7 @@ arb_texture_view['queries'] = concurrent_test('arb_texture_view-queries')
 arb_texture_view['rendering-target'] = concurrent_test('arb_texture_view-rendering-target')
 arb_texture_view['rendering-levels'] = concurrent_test('arb_texture_view-rendering-levels')
 arb_texture_view['rendering-layers'] = concurrent_test('arb_texture_view-rendering-layers')
+arb_texture_view['rendering-formats'] = concurrent_test('arb_texture_view-rendering-formats')
 arb_texture_view['lifetime-format'] = concurrent_test('arb_texture_view-lifetime-format')
 arb_texture_view['getteximage-srgb'] = concurrent_test('arb_texture_view-getteximage-srgb')
 arb_texture_view['texsubimage-levels'] = concurrent_test('arb_texture_view-texsubimage-levels')
diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
index 1bb29a1..d154224 100644
--- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
@@ -24,5 +24,6 @@ piglit_add_executable(arb_texture_view-texsubimage-layers texsubimage-layers.c c
 piglit_add_executable(arb_texture_view-clear-into-view-2d clear-into-view-2d.c common.c)
 piglit_add_executable(arb_texture_view-clear-into-view-2d-array clear-into-view-2d-array.c common.c)
 piglit_add_executable(arb_texture_view-clear-into-view-layered clear-into-view-layered.c common.c)
+piglit_add_executable(arb_texture_view-rendering-formats rendering-formats.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/arb_texture_view/rendering-formats.c b/tests/spec/arb_texture_view/rendering-formats.c
new file mode 100644
index 0000000..c1ef804
--- /dev/null
+++ b/tests/spec/arb_texture_view/rendering-formats.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright © 2014 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.
+ *
+ * Author: Chris Forbes <chrisf at ijw.co.nz>
+ */
+
+/**
+ *  \file
+ *  This tests that texturing from a view works when the view has a different
+ *  internalformat to the original texture.
+ */
+
+#include "piglit-util-gl-common.h"
+#include "common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 30;
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+#define TEX_SIZE 64
+
+const float green[] = {0.0f, 1.0f, 0.0f, 0.0f};
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	glViewport(0, 0, TEX_SIZE, TEX_SIZE);
+	glClearColor(0.2, 0.2, 0.2, 0.2);
+	glClear(GL_COLOR_BUFFER_BIT);
+	piglit_draw_rect(-1, -1, 2, 2);
+	pass = piglit_probe_rect_rgba(0, 0, TEX_SIZE, TEX_SIZE, green) && pass;
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint tex, view, prog;
+	int x, y;
+	float *data, *p;
+
+	piglit_require_extension("GL_ARB_texture_storage");
+	piglit_require_extension("GL_ARB_texture_view");
+
+	glGenTextures(1, &tex);
+	glBindTexture(GL_TEXTURE_2D, tex);
+	glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F,
+		TEX_SIZE, TEX_SIZE);
+
+	/* fill with some float values with easily-identifiable binary
+	 * representations */
+	p = data = malloc(sizeof(float) * 4 * TEX_SIZE * TEX_SIZE);
+	for (x = 0; x < TEX_SIZE; x++)
+		for (y = 0; y < TEX_SIZE; y++) {
+			*p++ = 1.0f;
+			*p++ = 0.25f;
+			*p++ = -1.0f;
+			*p++ = 0.0f;
+		}
+
+	glTexSubImage2D(GL_TEXTURE_2D, 0,
+			0, 0, TEX_SIZE, TEX_SIZE,
+			GL_RGBA, GL_FLOAT,
+			data);
+
+	/* make an unsigned integer view */
+	glGenTextures(1, &view);
+	glTextureView(view, GL_TEXTURE_2D, tex, GL_RGBA32UI,
+			0, 1, 0, 1);
+	glBindTexture(GL_TEXTURE_2D, view);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+	/* shader to test with */
+	prog = piglit_build_simple_program(
+			"#version 130\n"
+			"out vec2 tc;\n"
+			"void main() { \n"
+			"	gl_Position = gl_Vertex;\n"
+			"	tc = gl_Vertex.xy;\n"
+			"}\n",
+
+			"#version 130\n"
+			"uniform usampler2D s;\n"
+			"in vec2 tc;\n"
+			"void main() { \n"
+			"	if (texture(s, tc) == uvec4(\n"
+			"		0x3f800000u,\n"
+			"		0x3e800000u,\n"
+			"		0xbf800000u,\n"
+			"		0x00000000u)) {\n"
+			"		gl_FragColor = vec4(0,1,0,0);\n"
+			"	} else {\n"
+			"		gl_FragColor = vec4(1,0,0,0);\n"
+			"	}\n"
+			"}\n");
+
+	glUseProgram(prog);
+	glUniform1i(glGetUniformLocation(prog, "s"), 0);
+}
-- 
1.8.5.4



More information about the Piglit mailing list