On 06/06/2016 10:05 AM, Ilia Mirkin wrote:
On Mon, Jun 6, 2016 at 11:37 AM, Brian Paul <bri...@vmware.com> wrote:
On 06/05/2016 12:24 AM, Ilia Mirkin wrote:
In the case where we can't guess the base level size, just use the first
image's dims. The width0/height0/depth0 on stObj may not have been set
at this point. Observed in a trace that set up levels 2..9 of a 2d
texture,
and set the base level to 2, with height 1. This made the guess logic
always bail.
Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
Cc: "12.0" <mesa-sta...@lists.freedesktop.org>
---
src/mesa/state_tracker/st_cb_texture.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_texture.c
b/src/mesa/state_tracker/st_cb_texture.c
index d38f24c..1dd1ef6 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2463,9 +2463,9 @@ st_finalize_texture(struct gl_context *ctx,
firstImage->base.Depth2,
firstImage->base.Level,
&width, &height, &depth)) {
- width = stObj->width0;
- height = stObj->height0;
- depth = stObj->depth0;
+ width = stObj->width0 = firstImage->base.Width2;
+ height = stObj->height0 = firstImage->base.Height2;
+ depth = stObj->depth0 = firstImage->base.Depth2;
} else {
/* The width/height/depth may have been previously reset in
* guess_and_alloc_texture. */
Does this fix a crash or glitch or something else?
The state tracker's texture code is pretty delicate so I'd like to fully
understand the change.
Yes, this fixes a trace that was supplied by someone on IRC. The
situation was that the texture only ever had levels 2..9 (or 10?) set,
and its base level was set to 2. And each level was Nx1 (but
GL_TEXTURE_2D). So all the guessing logic always bailed, which means
that the stObj->width/height/depth were set to 0, which caused asserts
on the next line. (And I assume it wouldn't have rendered correctly
either, but it can be hard to tell in a large scene.)
Maybe we should have a piglit test for this?
I can try to whip something up, not sure when I'll get to it though.
Definitely not today, and probably not for a few at least.
I whipped up a piglet test. No assertion with your patch, but still
incorrect rendering. The textured quad is drawn black instead of gray.
Works w/ NVIDIA driver.
I'm attaching the patch if you want to use it to investigate further. I
have to get back to other things.
-Brian
>From 1f1287d9709fe01901ed2c6be817a25f8d7d6578 Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Mon, 6 Jun 2016 10:49:36 -0600
Subject: [PATCH] gl-1.2-texture-base-level: new test to exercise a Mesa state
tracker bug
If we define texture levels 2, 3, etc with all image heights being one,
we hit an assertion in the Mesa/gallium state tracker because it's
unable to guess the base mipmap level size.
---
tests/all.py | 1 +
tests/spec/CMakeLists.txt | 1 +
tests/spec/gl-1.2/CMakeLists.gl.txt | 13 +++++
tests/spec/gl-1.2/CMakeLists.txt | 1 +
tests/spec/gl-1.2/texture-base-level.c | 104 +++++++++++++++++++++++++++++++++
5 files changed, 120 insertions(+)
create mode 100644 tests/spec/gl-1.2/CMakeLists.gl.txt
create mode 100644 tests/spec/gl-1.2/CMakeLists.txt
create mode 100644 tests/spec/gl-1.2/texture-base-level.c
diff --git a/tests/all.py b/tests/all.py
index 94169f2..d7524b0 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -888,6 +888,7 @@ with profile.group_manager(
g(['glinfo'])
g(['gl-1.1-xor'])
g(['gl-1.1-xor-copypixels'])
+ g(['gl-1.2-texture-base-level'])
g(['hiz'], run_concurrent=False)
g(['infinite-spot-light'], run_concurrent=False)
g(['line-aa-width'], run_concurrent=False)
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 27c60c4..111b8c2 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -104,6 +104,7 @@ add_subdirectory (glsl-1.50)
add_subdirectory (glsl-es-3.00)
add_subdirectory (gl-1.0)
add_subdirectory (gl-1.1)
+add_subdirectory (gl-1.2)
add_subdirectory (gl-1.4)
add_subdirectory (gl-1.5)
add_subdirectory (gl-2.0)
diff --git a/tests/spec/gl-1.2/CMakeLists.gl.txt b/tests/spec/gl-1.2/CMakeLists.gl.txt
new file mode 100644
index 0000000..029c54b
--- /dev/null
+++ b/tests/spec/gl-1.2/CMakeLists.gl.txt
@@ -0,0 +1,13 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (gl-1.2-texture-base-level texture-base-level.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/gl-1.2/CMakeLists.txt b/tests/spec/gl-1.2/CMakeLists.txt
new file mode 100644
index 0000000..4a012b9
--- /dev/null
+++ b/tests/spec/gl-1.2/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
\ No newline at end of file
diff --git a/tests/spec/gl-1.2/texture-base-level.c b/tests/spec/gl-1.2/texture-base-level.c
new file mode 100644
index 0000000..a84b250
--- /dev/null
+++ b/tests/spec/gl-1.2/texture-base-level.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Test a texture construction / base level issue in Mesa/gallium state tracker.
+ * The texture images are defined for levels 2, 3, ... and the height of
+ * all images is one.
+ * Mesa was asserting in this case.
+ *
+ * Brian Paul
+ * 6 June 2016
+ */
+
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+ config.supports_gl_compat_version = 12;
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+PIGLIT_GL_TEST_CONFIG_END
+
+
+const GLubyte gray = 220;
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ const int width0 = 512;
+ const int height = 1;
+ const int base_level = 2;
+ GLuint tex;
+ int level;
+ int nr_bytes;
+ GLubyte *texdata;
+
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+
+ nr_bytes = (width0 >> base_level) * height * 4 * sizeof(GLubyte);
+ texdata = malloc(nr_bytes);
+ memset(texdata, gray, nr_bytes);
+
+ for (level = base_level; ; level++) {
+ int width = width0 >> level;
+ if (width == 0)
+ break;
+ printf("level %d: %d x %d\n", level, width, height);
+ glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, width, height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texdata);
+ }
+
+ free(texdata);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_level);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+ const float exp_color[4] = {gray / 255.0f, gray / 255.0f,
+ gray / 255.0f, gray / 255.0f};
+ bool pass;
+
+ glClearColor(1, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glEnable(GL_TEXTURE_2D);
+
+ piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1);
+
+ pass = piglit_probe_pixel_rgba(piglit_width / 2, piglit_height / 2,
+ exp_color);
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
--
1.9.1
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev