<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Dec 3, 2018 at 1:50 PM Erik Faye-Lund <<a href="mailto:erik.faye-lund@collabora.com">erik.faye-lund@collabora.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">On Mon, 2018-12-03 at 13:31 +0200, andrey simiklit wrote:<br>
> Hello,<br>
> <br>
> Thanks for review.<br>
> I will fix all these issues and provide v2 shortly :)<br>
> <br>
> Thanks,<br>
> Andrii.<br>
> <br>
> On Mon, Dec 3, 2018 at 12:37 PM Erik Faye-Lund <<br>
> <a href="mailto:erik.faye-lund@collabora.com" target="_blank">erik.faye-lund@collabora.com</a>> wrote:<br>
> > Just a few nits, do with them as you like. The test itself looks<br>
> > good<br>
> > to me :)<br>
> > <br>
> > Reviewed-by: Erik Faye-Lund <<a href="mailto:erik.faye-lund@collabora.com" target="_blank">erik.faye-lund@collabora.com</a>><br>
> > <br>
> > On Tue, 2018-10-23 at 16:44 +0300, <a href="mailto:asimiklit.work@gmail.com" target="_blank">asimiklit.work@gmail.com</a> wrote:<br>
> > > 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>
> > > ++++++++++++++++++++++<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'],<br>
> > > run_concurrent=False)<br>
> > > add_msaa_visual_plain_tests(g, ['read-front', 'clear-front-<br>
> > > first'],<br>
> > > diff --git a/tests/texturing/CMakeLists.gl.txt<br>
> > > 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-<br>
> > > miptree.c)<br>
> > > <br>
> > > # vim: ft=cmake:<br>
> > > diff --git a/tests/texturing/tex-upside-down-miptree.c<br>
> > > 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<br>
> > > obtaining a<br>
> > > + * copy of this software and associated documentation files (the<br>
> > > "Software"),<br>
> > > + * to deal in the Software without restriction, including<br>
> > without<br>
> > > limitation<br>
> > > + * the rights to use, copy, modify, merge, publish, distribute,<br>
> > > sublicense,<br>
> > > + * and/or sell copies of the Software, and to permit persons to<br>
> > whom<br>
> > > the<br>
> > > + * Software is furnished to do so, subject to the following<br>
> > > conditions:<br>
> > > + *<br>
> > > + * The above copyright notice and this permission notice<br>
> > (including<br>
> > > the next<br>
> > > + * paragraph) shall be included in all copies or substantial<br>
> > > portions of the<br>
> > > + * Software.<br>
> > > + *<br>
> > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY<br>
> > KIND,<br>
> > > EXPRESS OR<br>
> > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> > > MERCHANTABILITY,<br>
> > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO<br>
> > > EVENT SHALL<br>
> > > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,<br>
> > DAMAGES<br>
> > > OR OTHER<br>
> > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR<br>
> > OTHERWISE,<br>
> > > ARISING<br>
> > > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> > > 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<br>
> > miptree<br>
> > > 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>
> > Just a suggestion:<br>
> > <br>
> > Since you already did the hassle of using shaders, perhaps you<br>
> > could<br>
> > get this text to work on GLES 2?<br>
> > <br>
<br>
Turning my brain back on for a second: This isn't going to work, I<br>
think. GLES 2 doesn't support changing the base-level.<br>
<br></blockquote></div><br>Oh, it is good news for me (I don't know why I didn't check it before starting to work on it)<br>because I was stuck a bit on this porting to the gles2 with some other stuff )))<br>Thanks for pointing out.<br>I will fix just other issues :)<br><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> > > +<br>
> > > + config.window_visual = PIGLIT_GL_VISUAL_RGBA |<br>
> > > 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,<br>
> > > 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>
> > > + <br>
> > <br>
> > > oneby255 * 128.0,<br>
> > > + <br>
> > <br>
> > > oneby255 * 64.0,<br>
> > > + <br>
> > <br>
> > > oneby255 * 32.0 };<br>
> > > + GLint tex;<br>
> > > + int pos = 0;<br>
> > > + GLuint prog;<br>
> > > +<br>
> > > + piglit_ortho_projection(piglit_width, piglit_height,<br>
> > GL_FALSE);<br>
> > > + piglit_require_GLSL_version(110);<br>
> > <br>
> > I would put this require in piglit_init instead...<br>
> > <br>
> > > + prog = piglit_build_simple_program(NULL, fragShaderText);<br>
> > <br>
> > I would also build the shader in the init-function...<br>
> > <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,<br>
> > GL_TEXTURE_BASE_LEVEL,<br>
> > > level);<br>
> > > + glClear(GL_COLOR_BUFFER_BIT);<br>
> > > + /* If we the draw_rect function doesn't cause<br>
> > > crash/assertion<br>
> > > + * it means everything is okay and test will be<br>
> > 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,<br>
> > GL_RGBA,<br>
> > > 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,<br>
> > > GL_LINEAR);<br>
> > > + glClearColor(0.5, 0.5, 0.5, 0.0);<br>
> > > + piglit_ortho_projection(piglit_width, piglit_height,<br>
> > GL_FALSE);<br>
> > <br>
> > What does glClearColor and piglit_ortho_projection have to do with<br>
> > setting up a texture?<br>
> > <br>
> > You seem to be setting up the projection matrix at a later point<br>
> > anyway...<br>
> > <br>
> > > +}<br>
> > > +<br>
> > > +<br>
> > > +void<br>
> > > +piglit_init(int argc, char **argv)<br>
> > > +{<br>
> > > + setup_texture();<br>
> > > +}<br>
> > <br>
<br>
</blockquote></div></div></div></div></div>