<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi all,</div><div><br></div>Have somebody some suggestions for this test?<br>This patch is needed to test an issue (assertion in mesa) which will be fixed by this mesa patch:<br><a href="https://patchwork.freedesktop.org/patch/254397/">https://patchwork.freedesktop.org/patch/254397/</a><div><br></div><div>Regards,</div><div>Andrii.<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 23, 2018 at 4:44 PM <<a href="mailto:asimiklit.work@gmail.com">asimiklit.work@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Andrii Simiklit <<a href="mailto:andrii.simiklit@globallogic.com" target="_blank">andrii.simiklit@globallogic.com</a>><br>
<br>
Test that usage of upside down miptree doesn't cause assertion<br>
<br>
The miptree:<br>
<br>
level 0 = 1x1<br>
level 1 = 2x2<br>
level 2 = 4x4<br>
...<br>
level n = NxN<br>
<br>
should be acceptable for case when we don't use a min filter.<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=107987" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=107987</a><br>
Signed-off-by: Andrii Simiklit <<a href="mailto:andrii.simiklit@globallogic.com" target="_blank">andrii.simiklit@globallogic.com</a>><br>
---<br>
 tests/opengl.py                           |   1 +<br>
 tests/texturing/CMakeLists.gl.txt         |   1 +<br>
 tests/texturing/tex-upside-down-miptree.c | 171 ++++++++++++++++++++++<br>
 3 files changed, 173 insertions(+)<br>
 create mode 100644 tests/texturing/tex-upside-down-miptree.c<br>
<br>
diff --git a/tests/opengl.py b/tests/opengl.py<br>
index f7e408cd5..f6a38e40e 100644<br>
--- a/tests/opengl.py<br>
+++ b/tests/opengl.py<br>
@@ -704,6 +704,7 @@ with profile.test_list.group_manager(<br>
     g(['getteximage-targets', '1D'])<br>
     g(['getteximage-targets', '2D'])<br>
     g(['teximage-scale-bias'])<br>
+    g(['tex-upside-down-miptree'])<br>
     add_msaa_visual_plain_tests(g, ['draw-pixels'])<br>
     add_msaa_visual_plain_tests(g, ['read-front'], run_concurrent=False)<br>
     add_msaa_visual_plain_tests(g, ['read-front', 'clear-front-first'],<br>
diff --git a/tests/texturing/CMakeLists.gl.txt b/tests/texturing/CMakeLists.gl.txt<br>
index e5d41e432..02b572c79 100644<br>
--- a/tests/texturing/CMakeLists.gl.txt<br>
+++ b/tests/texturing/CMakeLists.gl.txt<br>
@@ -98,5 +98,6 @@ piglit_add_executable (texture-al texture-al.c)<br>
 piglit_add_executable (texture-rg texture-rg.c)<br>
 piglit_add_executable (teximage-colors teximage-colors.c)<br>
 piglit_add_executable (zero-tex-coord zero-tex-coord.c)<br>
+piglit_add_executable (tex-upside-down-miptree tex-upside-down-miptree.c)<br>
<br>
 # vim: ft=cmake:<br>
diff --git a/tests/texturing/tex-upside-down-miptree.c b/tests/texturing/tex-upside-down-miptree.c<br>
new file mode 100644<br>
index 000000000..2d10fb49a<br>
--- /dev/null<br>
+++ b/tests/texturing/tex-upside-down-miptree.c<br>
@@ -0,0 +1,171 @@<br>
+/*<br>
+ * Copyright (c) 2018 Andrii Simiklit<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>
+ * Authors:<br>
+ *    Andrii Simiklit <<a href="mailto:asimiklit.work@gmail.com" target="_blank">asimiklit.work@gmail.com</a>><br>
+ *<br>
+ */<br>
+<br>
+/**<br>
+ * Test what there no an assertion when we use upside down miptree and<br>
+ * GL_TEXTURE_MIN_FILTER is GL_LINEAR, base level is not 0<br>
+ * Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=107987" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=107987</a><br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+#define TW 64<br>
+#define TH 64<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_compat_version = 10;<br>
+<br>
+       config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;<br>
+       config.khr_no_error_support = PIGLIT_NO_ERRORS;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static unsigned nlevels = 0;<br>
+<br>
+static void<br>
+get_rect_bounds(int pos, int *x, int *y, int *w, int *h)<br>
+{<br>
+       *x = pos * (piglit_width / 3) + 5;<br>
+       *y = 5;<br>
+       *w = piglit_width / 3 - 10;<br>
+       *h = piglit_height - 10;<br>
+}<br>
+<br>
+<br>
+static void<br>
+draw_rect(int pos)<br>
+{<br>
+       int x, y, w, h;<br>
+       get_rect_bounds(pos, &x, &y, &w, &h);<br>
+       piglit_draw_rect_tex(x, y, w, h, 0, 0, 1, 1);<br>
+}<br>
+<br>
+<br>
+static GLboolean<br>
+probe_pos(int pos, const GLfloat expected[4])<br>
+{<br>
+       int x, y, w, h;<br>
+       get_rect_bounds(pos, &x, &y, &w, &h);<br>
+       return piglit_probe_rect_rgba(x, y, w, h, expected);<br>
+}<br>
+<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       GLboolean pass = GL_TRUE;<br>
+       unsigned level;<br>
+       static const char *fragShaderText =<br>
+               "uniform sampler2D tex;\n"<br>
+               "void main()\n"<br>
+               "{\n"<br>
+               "   gl_FragColor = texture2D(tex, gl_TexCoord[0].xy).rgba;\n"<br>
+               "}\n";<br>
+       const GLfloat oneby255 = (1.0 / 255.0);<br>
+       const GLfloat expected[4] = { oneby255 * 255.0,<br>
+                                                                                       oneby255 * 128.0,<br>
+                                                                                       oneby255 * 64.0,<br>
+                                                                                       oneby255 * 32.0 };<br>
+       GLint tex;<br>
+       int pos = 0;<br>
+       GLuint prog;<br>
+<br>
+       piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);<br>
+       piglit_require_GLSL_version(110);<br>
+       prog = piglit_build_simple_program(NULL, fragShaderText);<br>
+       glUseProgram(prog);<br>
+       tex = glGetUniformLocation(prog, "tex");<br>
+       glUniform1i(tex, 0);<br>
+<br>
+       for(level = 1; level < nlevels && pass; ++level)<br>
+       {<br>
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, level);<br>
+               glClear(GL_COLOR_BUFFER_BIT);<br>
+               /* If we the draw_rect function doesn't cause crash/assertion<br>
+               * it means everything is okay and test will be marked<br>
+               * as pass<br>
+               */<br>
+               draw_rect(pos);<br>
+               /** Just in case we check it<br>
+                */<br>
+               pass = pass && probe_pos(pos, expected);<br>
+       }<br>
+<br>
+       glUseProgram(0);<br>
+       glDeleteProgram(prog);<br>
+       piglit_present_results();<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
+<br>
+<br>
+static void<br>
+setup_texture(void)<br>
+{<br>
+       GLuint t;<br>
+       GLubyte img[TH][TW][4];<br>
+       int i, j, w, h;<br>
+<br>
+       for (i = 0; i < TH; i++) {<br>
+               for (j = 0; j < TW; j++) {<br>
+                       img[i][j][0] = 255;<br>
+                       img[i][j][1] = 128;<br>
+                       img[i][j][2] = 64;<br>
+                       img[i][j][3] = 32;<br>
+               }<br>
+       }<br>
+<br>
+       /* make an abnormal upside down miptree<br>
+        */<br>
+       glGenTextures(1, &t);<br>
+       glBindTexture(GL_TEXTURE_2D, t);<br>
+       w = TW;<br>
+       h = TH;<br>
+       for (nlevels = 0; w > 0 && h > 0; nlevels++) {<br>
+               w /= 2;<br>
+               h /= 2;<br>
+       }<br>
+       w = TW;<br>
+       h = TH;<br>
+       for (i = 0; w > 0 && h > 0; i++) {<br>
+               glTexImage2D(GL_TEXTURE_2D, nlevels - 1 - i, GL_RGBA, w, h, 0,<br>
+                               GL_RGBA, GL_UNSIGNED_BYTE, img);<br>
+               w /= 2;<br>
+               h /= 2;<br>
+       }<br>
+<br>
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br>
+       glClearColor(0.5, 0.5, 0.5, 0.0);<br>
+       piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       setup_texture();<br>
+}<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div></div></div>