<p dir="ltr">All.py?</p>
<div class="gmail_quote">On Oct 31, 2015 21:02, "Ilia Mirkin" <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I appear to never have checked this in... any objections?<br>
<br>
On Wed, Sep 24, 2014 at 12:53 AM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br>
> This points out a bug in the mesa/st ARB_texture_view patch which leaks<br>
> out to all layered rendering onto immutable 3d textures.<br>
><br>
> Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>><br>
> ---<br>
><br>
> This is a copy of the gl-layer-render test with glTexStorage patched<br>
> in instead of glTexImage.<br>
><br>
>  .../gl-3.2/layered-rendering/CMakeLists.gl.txt     |   1 +<br>
>  .../layered-rendering/gl-layer-render-storage.c    | 303 +++++++++++++++++++++<br>
>  2 files changed, 304 insertions(+)<br>
>  create mode 100644 tests/spec/gl-3.2/layered-rendering/gl-layer-render-storage.c<br>
><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 a5628dc..adc99ae 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>
> @@ -26,4 +26,5 @@ piglit_add_executable (gl-3.2-layered-rendering-gl-layer gl-layer.c)<br>
>  piglit_add_executable (gl-3.2-layered-rendering-gl-layer-cube-map gl-layer-cube-map.c)<br>
>  piglit_add_executable (gl-3.2-layered-rendering-gl-layer-not-layered gl-layer-not-layered.c)<br>
>  piglit_add_executable (gl-3.2-layered-rendering-gl-layer-render gl-layer-render.c)<br>
> +piglit_add_executable (gl-3.2-layered-rendering-gl-layer-render-storage gl-layer-render-storage.c)<br>
>  # vim: ft=cmake:<br>
> diff --git a/tests/spec/gl-3.2/layered-rendering/gl-layer-render-storage.c b/tests/spec/gl-3.2/layered-rendering/gl-layer-render-storage.c<br>
> new file mode 100644<br>
> index 0000000..01f8a7b<br>
> --- /dev/null<br>
> +++ b/tests/spec/gl-3.2/layered-rendering/gl-layer-render-storage.c<br>
> @@ -0,0 +1,303 @@<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-render.c<br>
> + * Section 4.12.4(Geometry Shaders) From GL spec 3.2 core:<br>
> + * "Geometry shaders can be used to render to one of several different layers<br>
> + * of cube map textures, three-dimensional textures, or one-or two-dimensional<br>
> + * texture arrays.<br>
> + *<br>
> + * The layer to render to is specified by writing to the built-in output<br>
> + * variable gl_Layer."<br>
> + */<br>
> +<br>
> +#include "piglit-util-gl.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>
> +GLenum textureType[] = {<br>
> +       GL_TEXTURE_3D,<br>
> +       GL_TEXTURE_CUBE_MAP,<br>
> +       GL_TEXTURE_1D_ARRAY,<br>
> +       GL_TEXTURE_2D_ARRAY,<br>
> +       GL_TEXTURE_2D_MULTISAMPLE_ARRAY<br>
> +};<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(triangle_strip, max_vertices = 3) out;\n"<br>
> +       "in vec4 vert[3];\n"<br>
> +       "uniform int layer;\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>
> +       "               gl_Layer = layer;\n"<br>
> +       "               EmitVertex();\n"<br>
> +       "       }\n"<br>
> +       "}\n"<br>
> +};<br>
> +<br>
> +const char *fs_source = {<br>
> +       "#version 150\n"<br>
> +       "uniform vec3 color;\n"<br>
> +       "void main() {\n"<br>
> +       "       gl_FragColor = vec4(<a href="http://color.xyz" rel="noreferrer" target="_blank">color.xyz</a>, 1.);\n"<br>
> +       "}\n"<br>
> +};<br>
> +<br>
> +static GLuint layer_uniform;<br>
> +static GLuint color_uniform;<br>
> +<br>
> +GLuint<br>
> +create_bind_texture(GLenum textureType) {<br>
> +       int i;<br>
> +       GLuint texture;<br>
> +       glGenTextures(1, &texture);<br>
> +       glBindTexture(textureType, texture);<br>
> +<br>
> +       switch(textureType) {<br>
> +       case GL_TEXTURE_1D_ARRAY:<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>
> +               glTexStorage2D(textureType, 1, GL_RGB8, 6, 6);<br>
> +               break;<br>
> +       case GL_TEXTURE_3D:<br>
> +       case GL_TEXTURE_2D_ARRAY:<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>
> +               glTexStorage3D(textureType, 1, GL_RGB8, 6, 6, 6);<br>
> +               break;<br>
> +       case GL_TEXTURE_CUBE_MAP:<br>
> +               glTexStorage2D(textureType, 1, GL_RGB8, 6, 6);<br>
> +               break;<br>
> +       case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:<br>
> +               glTexStorage3DMultisample(textureType, 4, GL_RGB8,<br>
> +                                       6, 6, 6, GL_FALSE);<br>
> +               break;<br>
> +       }<br>
> +<br>
> +       return texture;<br>
> +}<br>
> +<br>
> +bool check_framebuffer_status(GLenum target, GLenum expected) {<br>
> +       GLenum observed = glCheckFramebufferStatus(target);<br>
> +       if(expected != observed) {<br>
> +               printf("Unexpected framebuffer status!\n"<br>
> +                      "  Observed: %s\n  Expected: %s\n",<br>
> +                      piglit_get_gl_enum_name(observed),<br>
> +                      piglit_get_gl_enum_name(expected));<br>
> +               return false;<br>
> +       }<br>
> +       return true;<br>
> +}<br>
> +<br>
> +/* Take a framebuffer object, that has a GL_TEXTURE_2D_MULTISAMPLE<br>
> + * or a layer of a GL_TEXTURE_2D_MULTISAMPLE_ARRAY attached to<br>
> + * color attachment 0. Then blit that framebuffer object to<br>
> + * a new fbo that has a GL_TEXTURE_2D attached. Finally<br>
> + * attach the new GL_TEXTURE_2D to the original fbo.<br>
> + */<br>
> +void<br>
> +ConvertMultiSample2DToTexture2D(GLuint fboRead) {<br>
> +       GLuint fboDraw, texture;<br>
> +<br>
> +       glGenFramebuffers(1, &fboDraw);<br>
> +       glGenTextures(1, &texture);<br>
> +<br>
> +       glBindFramebuffer(GL_READ_FRAMEBUFFER, fboRead);<br>
> +       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboDraw);<br>
> +<br>
> +       texture = create_bind_texture(GL_TEXTURE_2D);<br>
> +       glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
> +                              GL_TEXTURE_2D, texture, 0);<br>
> +<br>
> +       if(!check_framebuffer_status(GL_DRAW_FRAMEBUFFER,<br>
> +                                    GL_FRAMEBUFFER_COMPLETE) ||<br>
> +          !check_framebuffer_status(GL_READ_FRAMEBUFFER,<br>
> +                                    GL_FRAMEBUFFER_COMPLETE)) {<br>
> +<br>
> +               piglit_report_result(PIGLIT_FAIL);<br>
> +       }<br>
> +<br>
> +       glBlitFramebuffer(0, 0, 6, 6, 0, 0, 6, 6,<br>
> +                         GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
> +<br>
> +       if(!piglit_check_gl_error(GL_NO_ERROR)) {<br>
> +               glDeleteTextures(1, &texture);<br>
> +               piglit_report_result(PIGLIT_FAIL);<br>
> +       }<br>
> +<br>
> +       glBindFramebuffer(GL_FRAMEBUFFER, fboRead);<br>
> +       glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
> +                              GL_TEXTURE_2D, texture, 0);<br>
> +<br>
> +       glDeleteFramebuffers(1, &fboDraw);<br>
> +<br>
> +       if(!piglit_check_gl_error(GL_NO_ERROR)) {<br>
> +               glDeleteTextures(1, &texture);<br>
> +               piglit_report_result(PIGLIT_FAIL);<br>
> +       }<br>
> +}<br>
> +<br>
> +<br>
> +bool<br>
> +probe_texture_layered_rbg(GLenum textureType, GLuint texture, int x, int y,<br>
> +                         int z, int w, int h, int d, float *expected)<br>
> +{<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>
> +               if(textureType == GL_TEXTURE_CUBE_MAP) {<br>
> +                       glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
> +                               GL_TEXTURE_CUBE_MAP_POSITIVE_X+k+z, texture, 0);<br>
> +               } else {<br>
> +                       glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
> +                                         texture, 0, k+z);<br>
> +               }<br>
> +<br>
> +               if(textureType == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {<br>
> +                       ConvertMultiSample2DToTexture2D(fbo);<br>
> +               }<br>
> +<br>
> +               if(!piglit_probe_rect_rgb(0, 0, w, h, &expected[k*3])) {<br>
> +                       printf("Layer: %i\n", k);<br>
> +                       return false;<br>
> +               }<br>
> +       }<br>
> +       return true;<br>
> +}<br>
> +<br>
> +<br>
> +<br>
> +void<br>
> +piglit_init(int argc, char **argv)<br>
> +{<br>
> +       int i, j;<br>
> +       bool pass = true;<br>
> +       GLuint fbo, texture, program;<br>
> +<br>
> +       float colors[6*3] = {<br>
> +               0, 0, 1,<br>
> +               0, 1, 0,<br>
> +               0, 1, 1,<br>
> +               1, 0, 0,<br>
> +               1, 0, 1,<br>
> +               1, 1, 0<br>
> +       };<br>
> +<br>
> +       program = piglit_build_simple_program_multiple_shaders(<br>
> +                                       GL_VERTEX_SHADER, vs_source,<br>
> +                                       GL_GEOMETRY_SHADER, gs_source,<br>
> +                                       GL_FRAGMENT_SHADER, fs_source,<br>
> +                                       0);<br>
> +       glUseProgram(program);<br>
> +<br>
> +       /* Retrieve index from vs */<br>
> +       color_uniform = glGetUniformLocation(program, "color");<br>
> +       layer_uniform = glGetUniformLocation(program, "layer");<br>
> +<br>
> +       /* Gen textures */<br>
> +       for(i = 0; i < ARRAY_SIZE(textureType); i++) {<br>
> +               printf("Texture Type: %s\n",<br>
> +                       piglit_get_gl_enum_name(textureType[i]));<br>
> +               glGenFramebuffers(1, &fbo);<br>
> +               glBindFramebuffer(GL_FRAMEBUFFER, fbo);<br>
> +<br>
> +               texture = create_bind_texture(textureType[i]);<br>
> +               glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
> +                                    texture, 0);<br>
> +<br>
> +               if(!check_framebuffer_status(GL_FRAMEBUFFER,<br>
> +                                            GL_FRAMEBUFFER_COMPLETE) ||<br>
> +                  !piglit_check_gl_error(GL_NO_ERROR)) {<br>
> +                       printf("Texture Type: %s. Error with setup\n",<br>
> +                             piglit_get_gl_enum_name(textureType[i]));<br>
> +                       piglit_report_result(PIGLIT_FAIL);<br>
> +               }<br>
> +<br>
> +               /* draw quad on each layer with set color*/<br>
> +               for(j = 0; j < 6; j++) {<br>
> +                       glUniform1i(layer_uniform, j);<br>
> +                       glUniform3fv(color_uniform, 1, &colors[j*3]);<br>
> +<br>
> +                       piglit_draw_rect(-1, -1, 2, 2);<br>
> +               }<br>
> +<br>
> +               if(textureType[i] == GL_TEXTURE_1D_ARRAY) {<br>
> +                       pass = probe_texture_layered_rbg(textureType[i], texture,<br>
> +                                                0, 0, 0, 6, 1, 6, colors)<br>
> +                              && pass;<br>
> +               } else {<br>
> +                       pass = probe_texture_layered_rbg(textureType[i], texture,<br>
> +                                        0, 0, 0, 6, 6, 6, colors)<br>
> +                              && pass;<br>
> +               }<br>
> +<br>
> +               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
> +<br>
> +               /* Clean up */<br>
> +               glDeleteTextures(1, &texture);<br>
> +               glDeleteFramebuffers(1, &fbo);<br>
> +       }<br>
> +<br>
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
> +<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>
> --<br>
> 1.8.5.5<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" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</blockquote></div>