On 06/03/15 04:01, Laura Ekstrand wrote:
---
  tests/all.py                                       |   1 +
  .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
  .../namedframebufferrenderbuffer.c                 | 159 +++++++++++++++++++++
  3 files changed, 161 insertions(+)
  create mode 100644 
tests/spec/arb_direct_state_access/namedframebufferrenderbuffer.c

diff --git a/tests/all.py b/tests/all.py
index cd85fc5..8e45442 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4028,6 +4028,7 @@ spec['ARB_direct_state_access']['unmapnamedbuffer-vbo'] = 
PiglitGLTest(['arb_dir
  spec['ARB_direct_state_access']['flushmappednamedbufferrange'] = 
PiglitGLTest(['arb_direct_state_access-flushmappednamedbufferrange'], 
run_concurrent=True)
  spec['ARB_direct_state_access']['getnamedbufferparameter'] = 
PiglitGLTest(['arb_direct_state_access-getnamedbufferparameter'], 
run_concurrent=True)
  spec['ARB_direct_state_access']['getnamedbuffersubdata'] = 
PiglitGLTest(['arb_direct_state_access-getnamedbuffersubdata'], 
run_concurrent=True)
+spec['ARB_direct_state_access']['namedframebufferrenderbuffer'] = 
PiglitGLTest(['arb_direct_state_access-namedframebufferrenderbuffer'], 
run_concurrent=True)
arb_shader_image_load_store = spec['ARB_shader_image_load_store']
  arb_shader_image_load_store['atomicity'] = 
PiglitGLTest(['arb_shader_image_load_store-atomicity'], run_concurrent=True)
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt 
b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
index a9b82eb..488ca18 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 0000000..df82400
--- /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;
20 minimum and ask for core = 32;
+
+       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);
+}

Sorry, you will have to rewrite the above code when you enable core = 32 as the fixed pipeline got deleted.
+
+
+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);
+}
Otherwise, the idea looks good to me.
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to