summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura Ekstrand <laura@jlekstrand.net>2015-01-23 17:14:33 -0800
committerLaura Ekstrand <laura@jlekstrand.net>2015-03-09 16:20:44 -0700
commit923cae98d574d0a3fca763ac134edafe0793d5df (patch)
tree22c133a532a05f0895840292d459fee4a6f279d0
parent6c28fb25c8177097b57fb0b0d028ce5e38882019 (diff)
arb_direct_state_access: Testing NamedFramebufferRenderbuffer.
-rw-r--r--tests/all.py1
-rw-r--r--tests/spec/arb_direct_state_access/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_direct_state_access/namedframebufferrenderbuffer.c159
3 files changed, 161 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py
index 47edcfceb..873581e63 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4241,6 +4241,7 @@ with profile.group_manager(
g(['arb_direct_state_access-compressedtexturesubimage'], 'compressedtexturesubimage')
g(['arb_direct_state_access-create-buffers'], 'create-buffers')
g(['arb_direct_state_access-create-framebuffers'], 'create-framebuffers')
+ g(['arb_direct_state_access-namedframebufferrenderbuffer'], 'namedframebufferrenderbuffer')
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 ebf18b60b..41949f724 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -25,6 +25,7 @@ piglit_add_executable (arb_direct_state_access-unmapnamedbuffer-vbo unmapnamedbu
piglit_add_executable (arb_direct_state_access-flushmappednamedbufferrange flushmappednamedbufferrange.c)
piglit_add_executable (arb_direct_state_access-getnamedbufferparameter getnamedbufferparameter.c)
piglit_add_executable (arb_direct_state_access-getnamedbuffersubdata getnamedbuffersubdata.c)
+piglit_add_executable (arb_direct_state_access-namedframebufferrenderbuffer namedframebufferrenderbuffer.c)
piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c)
piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c)
piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c)
diff --git a/tests/spec/arb_direct_state_access/namedframebufferrenderbuffer.c b/tests/spec/arb_direct_state_access/namedframebufferrenderbuffer.c
new file mode 100644
index 000000000..df82400e5
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/namedframebufferrenderbuffer.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2012 VMware, Inc.
+ * 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.
+ */
+
+/**
+ * Test glViewport w/ FBOs.
+ * In Mesa, on-screen windows and user-created FBOs are stored differently
+ * (inverted). Make sure viewports are handled properly.
+ * Draw a test pattern (with many viewports) into the window, then draw the
+ * same thing into an FBO. Compare the images. They should be the same.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_width = 500;
+ config.window_height = 500;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/**
+ * Draw an rgbw texture in a bunch of viewports which tile the window.
+ * Note that viewports extend beyond the edges of the window too.
+ */
+static void
+draw_test_image(void)
+{
+ int vx, vy, vw = 200, vh = 200;
+ GLuint texture;
+
+ texture = piglit_rgbw_texture(GL_RGBA8, 32, 32, GL_FALSE, GL_FALSE,
+ GL_UNSIGNED_BYTE);
+ glBindTextureUnit(0, texture);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1, 1, -1, 1, 3, 9.5);
+
+ /* Draw some quads at an odd rotation.
+ * Note that we want near/far frustum clipping.
+ */
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslatef(0, 1, -6.20);
+ glRotatef(-60, 1, 0, 0);
+ glRotatef(30, 0, 0, 1);
+ glScalef(3.5, 3.5, 3.5);
+
+ /* loop over viewports */
+ for (vy = -50; vy < piglit_height; vy += vh+10) {
+ for (vx = -30; vx < piglit_width; vx += vw+10) {
+ glViewport(vx, vy, vw, vh);
+ piglit_draw_rect_tex(-1, -1, 1, 1, 0, 0, 1, 1);
+ }
+ }
+
+ glPopMatrix();
+
+ glDeleteTextures(1, &texture);
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+ GLubyte *win_image, *fbo_image;
+ GLuint fbo, rb;
+ bool pass = true;
+
+ win_image = (GLubyte *) malloc(piglit_width * piglit_height * 3);
+ fbo_image = (GLubyte *) malloc(piglit_width * piglit_height * 3);
+
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glCreateFramebuffers(1, &fbo);
+ glGenRenderbuffers(1, &rb);
+ glBindRenderbuffer(GL_RENDERBUFFER, rb);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA,
+ piglit_width, piglit_height);
+ glNamedFramebufferRenderbuffer(fbo, GL_COLOR_ATTACHMENT0,
+ GL_RENDERBUFFER, rb);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ assert(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) ==
+ GL_FRAMEBUFFER_COMPLETE_EXT);
+
+ /* draw reference image in the window */
+ glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo);
+ draw_test_image();
+ glReadPixels(0, 0, piglit_width, piglit_height,
+ GL_RGB, GL_UNSIGNED_BYTE, win_image);
+
+ /* draw test image in fbo */
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ draw_test_image();
+ glReadPixels(0, 0, piglit_width, piglit_height,
+ GL_RGB, GL_UNSIGNED_BYTE, fbo_image);
+
+ /* compare images */
+ if (memcmp(win_image, fbo_image, piglit_width * piglit_height * 3)) {
+ printf("Image comparison failed!\n");
+ pass = false;
+ }
+ else if (!piglit_automatic) {
+ printf("Image comparison passed.\n");
+ }
+
+ glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo);
+
+ piglit_present_results();
+
+ glDeleteRenderbuffers(1, &rb);
+ glDeleteFramebuffers(1, &fbo);
+ free(win_image);
+ free(fbo_image);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_ARB_direct_state_access");
+ piglit_require_extension("GL_ARB_framebuffer_object");
+ glClearColor(0.2, 0.2, 0.2, 0.0);
+ glEnable(GL_TEXTURE_2D);
+}