<div dir="ltr">On 26 August 2013 11:49, Jacob Penner <span dir="ltr"><<a href="mailto:jkpenner91@gmail.com" target="_blank">jkpenner91@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 .../layered-rendering/framebuffer-layer-complete.c | 168 +++++++++++++++++++++<br>
 1 file changed, 168 insertions(+)<br>
 create mode 100644 tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c<br>
<br>
diff --git a/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c<br>
new file mode 100644<br>
index 0000000..fa36f42<br>
--- /dev/null<br>
+++ b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c<br>
@@ -0,0 +1,168 @@<br>
+/*<br>
+ * Copyright © 2013 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+<br>
+/** @file framebuffer-layer-complete.c<br>
+ *<br>
+ * Section 4.4.4(FRAMEBUFFER OBJECTS) From GL spec 3.2 core:<br>
+ * If any framebuffer attachment is layered, all populated attachments must be<br>
+ * layered. Additionally, all populated color attachments must be from textures<br>
+ * of the same target.<br></blockquote><div><br></div><div>It looks like this test only verifies the sentence starting "Additionally...".  We really need to verify the other case too, by trying to create a framebuffer in which one attachment is layered and another attachment isn't.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_compat_version = 32;<br>
+       config.supports_gl_core_version = 32;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+const int texWidth = 30;<br>
+const int texHeight = 30;<br>
+const int texDepth = 2;<br>
+<br>
+void<br>
+create_bind_texture(GLenum textureType, GLuint *texture) {<br></blockquote><div><br></div><div>As in patch 3, the texture should be returned in a return value rather than using a pointer.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+       glGenTextures(1, texture);<br>
+       glBindTexture(textureType, *texture);<br>
+<br>
+       switch(textureType) {<br>
+       case GL_TEXTURE_2D:<br>
+               glTexParameteri(textureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br>
+               glTexParameteri(textureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br>
+               glTexParameteri(textureType, GL_TEXTURE_WRAP_S, GL_REPEAT);<br>
+               glTexParameteri(textureType, GL_TEXTURE_WRAP_T, GL_REPEAT);<br>
+               glTexImage2D(textureType, 0, GL_RGB, texWidth, texHeight,<br>
+                            0, GL_RGB, GL_FLOAT, NULL);<br>
+               break;<br>
+       case GL_TEXTURE_3D:<br>
+               glTexParameteri(textureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br>
+               glTexParameteri(textureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br>
+               glTexParameteri(textureType, GL_TEXTURE_WRAP_S, GL_REPEAT);<br>
+               glTexParameteri(textureType, GL_TEXTURE_WRAP_T, GL_REPEAT);<br>
+               glTexParameteri(textureType, GL_TEXTURE_WRAP_R, GL_REPEAT);<br>
+               glTexImage3D(textureType, 0, GL_RGB, texWidth, texHeight,<br>
+                            texDepth, 0, GL_RGB, GL_FLOAT, NULL);<br>
+               break;<br>
+       default:<br>
+               glDeleteTextures(1, texture);<br>
+               *texture = 0;<br>
+               break;<br></blockquote><div><br></div><div>It looks like we never expect the default case of this switch statement to be taken (i.e. it would only happen if there were a bug elsewhere in the test).  Usually when that's the case it's better to do something like this:<br>
<br></div><div>default:<br></div><div>   printf("Unexpected textureType in create_bind_texture()\n");<br></div><div>   piglit_report_result(PIGLIT_FAIL);<br></div><div>   break;<br><br>That way, if anyone ever modifies the test in a way that causes the default case to be taken, they'll find out their mistake by getting an obvious piglit failure.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       }<br>
+}<br>
+<br>
+void<br>
+attach_texture(GLenum framebuffer, GLenum attachment, GLenum textureType,<br>
+              GLuint texture)<br>
+{<br>
+       switch(textureType) {<br>
+               case GL_TEXTURE_2D:<br>
+                       glFramebufferTexture2D(framebuffer, attachment,<br>
+                                              textureType, texture, 0);<br>
+                       break;<br>
+               case GL_TEXTURE_3D:<br>
+                       glFramebufferTexture(framebuffer, attachment,<br>
+                                            texture, 0);<br>
+                       break;<br>
+       }<br>
+}<br>
+<br>
+bool<br>
+CheckFramebufferStatus(GLenum expected) {<br>
+       GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);<br>
+       if(status != expected) {<br>
+               printf("Expected Framebuffer status '%s', got '%s'\n",<br>
+                      piglit_get_gl_enum_name(expected),<br>
+                      piglit_get_gl_enum_name(status));<br>
+               return false;<br>
+       }<br>
+       return true;<br>
+}<br>
+<br>
+bool<br>
+test_fb_incomplete_layer_targets(GLenum texOneType, GLenum texTwoType,<br>
+                                GLenum expectedFbStatus)<br>
+{<br>
+       bool pass = true;<br>
+       GLuint fbo, texture[2];<br>
+<br>
+       glGenTextures(2, texture);<br>
+<br>
+       glGenFramebuffers(1, &fbo);<br>
+       glBindFramebuffer(GL_FRAMEBUFFER, fbo);<br>
+<br>
+       /* Setup texture one */<br>
+       create_bind_texture(texOneType, &texture[0]);<br>
+       attach_texture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
+                      texOneType, texture[0]);<br>
+<br>
+       /* Setup texture two */<br>
+       create_bind_texture(texTwoType, &texture[1]);<br>
+       attach_texture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,<br>
+                      texTwoType, texture[1]);<br>
+<br>
+       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+<br>
+       /* Check for expected fb status */<br>
+       pass = CheckFramebufferStatus(expectedFbStatus) && pass;<br>
+<br>
+       /* Clean up */<br>
+       glBindFramebuffer(GL_FRAMEBUFFER, 0);<br>
+       glDeleteFramebuffers(1, &fbo);<br>
+       glDeleteTextures(2, texture);<br>
+<br>
+       return pass;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       bool pass = true;<br>
+<br>
+       pass = test_fb_incomplete_layer_targets(GL_TEXTURE_2D, GL_TEXTURE_2D,<br>
+                       GL_FRAMEBUFFER_COMPLETE)<br>
+                       && pass;<br>
+<br>
+       pass = test_fb_incomplete_layer_targets(GL_TEXTURE_3D, GL_TEXTURE_2D,<br>
+                       GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS)<br>
+                       && pass;<br>
+<br>
+       pass = test_fb_incomplete_layer_targets(GL_TEXTURE_2D,  GL_TEXTURE_3D,<br>
+                       GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS)<br>
+                       && pass;<br>
+<br>
+       pass = test_fb_incomplete_layer_targets(GL_TEXTURE_3D,  GL_TEXTURE_3D,<br>
+                       GL_FRAMEBUFFER_COMPLETE)<br>
+                       && pass;<br></blockquote><div><br></div><div>I don't think we need all four of the above test cases.  It should be sufficient to do one 2D/2D test and one 3D/2D test.<br><br></div><div>
(Then, as I mentioned above, we should add a third test case to verify that mixing layered and unlayered attachments causes the framebuffer to be incomplete).<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+<br>
+       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       /* Unreachable */<br>
+       return PIGLIT_FAIL;<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>