<div dir="ltr">On 3 September 2013 15:52, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
tests/all.tests | 1 +<br>
.../gl-3.2/layered-rendering/CMakeLists.gl.txt | 1 +<br>
tests/spec/gl-3.2/layered-rendering/gl-layer.c | 243 +++++++++++++++++++++<br>
3 files changed, 245 insertions(+)<br>
create mode 100644 tests/spec/gl-3.2/layered-rendering/gl-layer.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 877253d..59fb0e2 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -752,6 +752,7 @@ spec['!OpenGL 3.2/layered-rendering/blit'] = concurrent_test('gl-3.2-layered-ren<br>
spec['!OpenGL 3.2/layered-rendering/clear-color'] = concurrent_test('gl-3.2-layered-rendering-clear-color')<br>
spec['!OpenGL 3.2/layered-rendering/framebuffertexture-buffer-textures'] = concurrent_test('gl-3.2-layered-rendering-framebuffertexture-buffer-textures')<br>
spec['!OpenGL 3.2/layered-rendering/readpixels'] = concurrent_test('gl-3.2-layered-rendering-readpixels')<br>
+spec['!OpenGL 3.2/layered-rendering/gl-layer'] = concurrent_test('gl-3.2-layered-rendering-gl-layer')<br>
<br>
spec['!OpenGL 3.3/minmax'] = concurrent_test('gl-3.3-minmax')<br>
spec['!OpenGL 3.3/required-renderbuffer-attachment-formats'] = concurrent_test('gl-3.0-required-renderbuffer-attachment-formats 33')<br>
diff --git a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt<br>
index 2a66253..9a26b34 100644<br>
--- a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt<br>
+++ b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt<br>
@@ -13,4 +13,5 @@ piglit_add_executable (gl-3.2-layered-rendering-blit blit.c)<br>
piglit_add_executable (gl-3.2-layered-rendering-clear-color clear-color.c)<br>
piglit_add_executable (gl-3.2-layered-rendering-framebuffertexture-buffer-textures framebuffertexture-buffer-textures.c)<br>
piglit_add_executable (gl-3.2-layered-rendering-readpixels readpixels.c)<br>
+piglit_add_executable (gl-3.2-layered-rendering-gl-layer gl-layer.c)<br>
# vim: ft=cmake:<br>
diff --git a/tests/spec/gl-3.2/layered-rendering/gl-layer.c b/tests/spec/gl-3.2/layered-rendering/gl-layer.c<br>
new file mode 100644<br>
index 0000000..fe557b2<br>
--- /dev/null<br>
+++ b/tests/spec/gl-3.2/layered-rendering/gl-layer.c<br>
@@ -0,0 +1,243 @@<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>
+/** @file gl-layer.c<br>
+ *<br>
+ * Section 4.4.7(Framebuffer Objects) From GL spec 3.2 core:<br>
+ *<br>
+ * When rendering to a layered framebuffer, each fragment generated by<br>
+ * the GL is assigned a layer number. The layer number for a fragment<br>
+ * is zero if<br>
+ *<br>
+ * - geometry shaders are disabled, or<br>
+ *<br>
+ * - The current geometry shader does not statically assign a<br>
+ * value to the built-in output variable gl_Layer.<br>
+ *<br>
+ *<br>
+ * Test<br>
+ * Draw a rect onto a layered texture with two different programs. One<br>
+ * program will contain a geometry shader that doesn't assign a value to<br>
+ * gl_Layer, while the other program will not contain a geometry shader.<br>
+ *<br>
+ * End Result<br>
+ * The first layer of both textures used while have their values be green or<br>
+ * (0, 1, 0), and the remaining layers will be not set.<br>
+ */<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>
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+const char *vs_source = {<br>
+ "#version 150\n"<br>
+ "in vec4 piglit_vertex;\n"<br>
+ "out vec4 vert;\n"<br>
+ "void main() {\n"<br>
+ " gl_Position = piglit_vertex;\n"<br>
+ " vert = piglit_vertex;\n"<br>
+ "}\n"<br>
+};<br>
+<br>
+const char *gs_source = {<br>
+ "#version 150\n"<br>
+ "layout(triangles) in;\n"<br>
+ "layout(triangles, max_vertices = 3) out;\n"<br>
+ "in vec4 vert[3];\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " for(int i = 0; i < 3; i++) {\n"<br>
+ " gl_Position = vert[i];\n"<br>
+ " EmitVertex();\n"<br>
+ " }\n"<br>
+ "}\n"<br>
+};<br>
+<br>
+const char *fs_source = {<br>
+ "#version 150\n"<br>
+ "void main() {\n"<br>
+ " gl_FragColor = vec4(0, 1, 0, 1);\n"<br>
+ "}\n"<br>
+};<br>
+<br>
+GLint build_program(const char *vs_source, const char *gs_source,<br>
+ const char *fs_source)<br>
+{<br>
+ GLuint vs = 0, gs = 0, fs = 0, prog;<br>
+<br>
+ if(vs_source)<br>
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);<br>
+ if(gs_source)<br>
+ gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gs_source);<br>
+ if(fs_source)<br>
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);<br>
+<br>
+ piglit_require_GLSL();<br>
+<br>
+ prog = glCreateProgram();<br>
+<br>
+ if (vs)<br>
+ glAttachShader(prog, vs);<br>
+ if (gs)<br>
+ glAttachShader(prog, gs);<br>
+ if (fs)<br>
+ glAttachShader(prog, fs);<br>
+<br>
+ glLinkProgram(prog);<br>
+<br>
+ if(!piglit_link_check_status(prog)) {<br>
+ glDeleteProgram(prog);<br>
+ prog = 0;<br>
+ }<br>
+<br>
+ if(!prog)<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+<br>
+ if(fs)<br>
+ glDeleteShader(fs);<br>
+ if(gs)<br>
+ glDeleteShader(gs);<br>
+ if(vs)<br>
+ glDeleteShader(vs);<br>
+<br>
+ return prog;<br>
+}<br></blockquote><div><br></div><div>This function seems a lot more general-purpose than what we need for this particular test (in particular, in this test, gs is the only string that will ever be null).<br><br></div><div>
If you want to make a separate patch that puts this function (suitably renamed) into tests/util/piglit-shader.c, I'd be happy with it as is (in fact, I'd be delighted--there are other geometry shader tests that could use this function, and it would be nice to share some code).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+bool<br>
+probe_texture_layered_rbg(GLuint texture, int x, int y, int z,<br>
+ int w, int h, int d, float *expected)<br></blockquote><div><br></div><div>I think you mean "probe_texture_layered_rgb".<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+{<br>
+ int k;<br>
+ GLuint fbo;<br>
+<br>
+ glGenFramebuffers(1, &fbo);<br>
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);<br>
+<br>
+ for(k = 0; k < d; k++ ) {<br>
+ glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
+ texture, 0, z + k);<br>
+<br>
+ if(!piglit_probe_rect_rgb(0, 0, w, h, &expected[k*3])) {<br>
+ printf("Layer: %i\n", z + k);<br>
+ return false;<br>
+ }<br>
+ }<br>
+<br>
+ return true;<br>
+}<br>
+<br>
+<br>
+static GLuint fbo[2];<br>
+static GLint program[2];<br>
+static GLuint texture[2];<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ int i;<br>
+ GLuint fboStatus;<br>
+<br>
+ program[0] = build_program(vs_source, gs_source, fs_source);<br>
+ program[1] = build_program(vs_source, NULL, fs_source);<br>
+<br>
+ glGenFramebuffers(2, fbo);<br>
+ glGenTextures(2, texture);<br>
+<br>
+ for( i = 0; i < 2; i++) {<br>
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo[i]);<br>
+<br>
+ glBindTexture(GL_TEXTURE_2D_ARRAY, texture[i]);<br>
+ glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br>
+ glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br>
+ glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT);<br>
+ glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);<br>
+ glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 10,<br>
+ 10, 2, 0, GL_RGB, GL_FLOAT, NULL);<br>
+<br>
+ glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
+ texture[i], 0);<br>
+<br>
+ fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);<br>
+ if(fboStatus != GL_FRAMEBUFFER_COMPLETE) {<br>
+ printf("Framebuffer Status: %s\n",<br>
+ piglit_get_gl_enum_name(fboStatus));<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+ }<br>
+<br>
+ if(!piglit_check_gl_error(GL_NO_ERROR)) {<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+}<br></blockquote><div><br></div><div>Since the test doesn't actually do any rendering to the screen, there's no need to separate piglit_init() and piglit_display(). I have a minor preference to just merge them into one function, as you did in patch 1. But I don't have terribly strong feelings about that.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ int i;<br>
+ bool pass = true;<br>
+ float expected[] = {<br>
+ 0.0, 1.0, 0.0,<br>
+ 0.0, 0.0, 0.0<br>
+ };<br>
+<br>
+ for( i = 0; i < 2; i++) {<br>
+ glUseProgram(program[i]);<br>
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo[i]);<br>
+<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+<br>
+ piglit_draw_rect(-1, -1, 2, 2);<br>
+<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+<br>
+ pass = probe_texture_layered_rbg(texture[i], 0, 0, 0,<br>
+ 10, 10, 2, expected) && pass;<br>
+ }<br>
+<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo[0]);<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ glBlitFramebuffer(0, 0, 10, 10,<br>
+ 0, 0, piglit_width/2, piglit_height,<br>
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo[1]);<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ glBlitFramebuffer(0, 0, 10, 10,<br>
+ piglit_width/2, 0, piglit_width, piglit_height,<br>
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+ piglit_present_results();<br>
+<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
+<br>
<span class=""><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>