Hello!

I don't know of an existing test or bug report about this issue.

The problem is that a texture is only finalized when bound to a texture unit 
for rendering from. The texture generation code (st_TexImage) does not 
necessarily create a pipe_resource for the texture (or attach the same pipe 
resource to the texture object and all texture images in said texture 
object).

For texture complete textures this can happen if gallium's texture generation 
code thinks there will be no further mipmap levels when specifying the first 
mipmap. Then it will only allocate enough memory for one mipmap and the next 
call to st_TexImage will release the pipe resource from the texture object to 
create a new one. Now the first mipmap has a different pipe resource than the 
texture object.
The attached piglit patch tries to demonstrate this.

For texture incomplete textures this can also happen if one specifies 
different texture images that are incompatible to one another for one texture 
object. The texture images can't share a pipe resource and so only one of 
them can use the same pipe resource as the texture object.
By the way: If one attaches two incompatible texture images from one texture 
object gallium will still fail silently. I'll submit a patch to mark these 
cases as fbo incomplete.

Fabian

On Tuesday 05 April 2011 02:56:51 Brian Paul wrote:
> On 04/02/2011 11:41 AM, Fabian Bieler wrote:
>
>
> Does this fix a specific bug or do you have a test program that
> demonstrates the issue?  The patch looks OK on the surface but I'd
> like to know a bit more about what's going on.
>
> -Brian


From 4d9bea4a8d0065098cee89049dbac5e10b82db66 Mon Sep 17 00:00:00 2001
From: Fabian Bieler <der.f...@gmx.net>
Date: Tue, 5 Apr 2011 08:42:47 +0200
Subject: [PATCH] fbo-clear-formats: Add depth clearing

Also remove setting of texture min filter prior to clearing to confuse gallium's mipmap generation code
---
 tests/fbo/fbo-clear-formats.c |   91 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 87 insertions(+), 4 deletions(-)

diff --git a/tests/fbo/fbo-clear-formats.c b/tests/fbo/fbo-clear-formats.c
index 57c9162..84f1201 100644
--- a/tests/fbo/fbo-clear-formats.c
+++ b/tests/fbo/fbo-clear-formats.c
@@ -123,8 +123,67 @@ do_rgba_clear(GLenum format, GLuint tex, int level, int size)
 static bool
 do_depth_clear(GLenum format, GLuint tex, int level, int size)
 {
-	/* XXX: FINISHME */
-	return false;
+	GLuint fb;
+	GLenum status;
+	int x;
+
+	glGenFramebuffersEXT(1, &fb);
+	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
+
+	glDrawBuffer(GL_NONE);
+	glReadBuffer(GL_NONE);
+
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+				  GL_DEPTH_ATTACHMENT_EXT,
+				  GL_TEXTURE_2D,
+				  tex,
+				  level);
+
+	status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+	if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+		if (!level)
+			printf(" - FBO incomplete\n");
+		return false;
+	} else {
+		if (!level)
+			printf("\n");
+	}
+
+	glEnable(GL_SCISSOR_TEST);
+
+#if 1
+	for (x = 0; x < size; x++) {
+		float val = (x + 0.5) / (size);
+		glScissor(x, 0, 1, size);
+		glClearDepth(val);
+		glClear(GL_DEPTH_BUFFER_BIT);
+	}
+#else
+	glScissor(0, 0, size / 2, size / 2);
+	glClearDepth(0.0);
+	glClear(GL_DEPTH_BUFFER_BIT);
+
+	glScissor(size / 2, 0, size / 2, size / 2);
+	glClearDepth(0.25);
+	glClear(GL_DEPTH_BUFFER_BIT);
+
+	glScissor(0, size / 2, size / 2, size / 2);
+	glClearDepth(0.5);
+	glClear(GL_DEPTH_BUFFER_BIT);
+
+	glScissor(size / 2, size / 2, size / 2, size / 2);
+	glClearDepth(1.0);
+	glClear(GL_DEPTH_BUFFER_BIT);
+#endif
+
+	glDisable(GL_SCISSOR_TEST);
+
+	glDeleteFramebuffersEXT(1, &fb);
+
+	glDrawBuffer(GL_BACK);
+	glReadBuffer(GL_BACK);
+
+	return true;
 }
 
 static bool
@@ -150,8 +209,9 @@ create_tex(GLenum internalformat, GLenum baseformat)
 
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
 			GL_LINEAR);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
-			GL_LINEAR_MIPMAP_NEAREST);
+	//confuse gallium's texture generation code
+	//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+			//GL_LINEAR_MIPMAP_NEAREST);
 
 	for (level = 0, dim = TEX_WIDTH; dim > 0; level++, dim /= 2) {
 		glTexImage2D(GL_TEXTURE_2D, level, internalformat,
@@ -240,12 +300,35 @@ test_mipmap_drawing(int x, int y, int dim, int level, GLuint internalformat)
 				 GL_TEXTURE_BLUE_SIZE, &b_size);
 
 	if (d_size) {
+#if 1
 		for (x1 = x; x1 < x + dim; x1++) {
 			float val = (x1 - x + 0.5) / (dim);
 			float color[3] = {val, val, val};
 			pass = pass && piglit_probe_rect_rgb(x1, y, 1, dim,
 							     color);
 		}
+#else
+		r[0] = 0.0;
+		r[1] = 0.0;
+		r[2] = 0.0;
+
+		g[0] = 0.25;
+		g[1] = 0.25;
+		g[2] = 0.25;
+
+		b[0] = 0.5;
+		b[1] = 0.5;
+		b[2] = 0.5;
+
+		w[0] = 1.0;
+		w[1] = 1.0;
+		w[2] = 1.0;
+
+		pass = pass && piglit_probe_rect_rgb(x1, y1, half, half, r);
+		pass = pass && piglit_probe_rect_rgb(x2, y1, half, half, g);
+		pass = pass && piglit_probe_rect_rgb(x1, y2, half, half, b);
+		pass = pass && piglit_probe_rect_rgb(x2, y2, half, half, w);
+#endif
 		return pass;
 	}
 
-- 
1.7.4.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to