Ideally we should fix this in libtxc_dxtn, but there is no central repository for that library, no versioning, and no official releases, and I am pretty sure that nobody would update that lib just to get this fix. Putting this fix in Mesa ensures that it will find its way to users, which is important.<br>
<br>Marek<br><br><div class="gmail_quote">On Wed, Feb 16, 2011 at 4:18 AM, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
This is a workaround for a bug in libtxc_dxtn.<br>
<br>
Fixes:<br>
- piglit/GL_EXT_texture_compression_s3tc/fbo-generatemipmap-formats<br>
---<br>
src/gallium/auxiliary/util/u_format_s3tc.c | 16 ++++++++++++++--<br>
1 files changed, 14 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c<br>
index bb989c2..31288e3 100644<br>
--- a/src/gallium/auxiliary/util/u_format_s3tc.c<br>
+++ b/src/gallium/auxiliary/util/u_format_s3tc.c<br>
@@ -416,8 +416,20 @@ util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,<br>
uint8_t tmp[4][4][4]; /* [bh][bw][comps] */<br>
for(j = 0; j < bh; ++j) {<br>
for(i = 0; i < bw; ++i) {<br>
- for(k = 0; k < comps; ++k) {<br>
- tmp[j][i][k] = src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps + k];<br>
+ const uint8_t *srcp = &src[(y + j)*src_stride/sizeof(*src) + (x + i)*comps];<br>
+ /* Workaround for a bug in libtxc_dxtn.<br>
+ * If the color is (0,0,0,0), it is compressed as (0,0,0,1),<br>
+ * which is incorrect. Any other (x,y,z,0) color is compressed<br>
+ * correctly as (0,0,0,0), so let's use (1,0,0,0). */<br>
+ if (srcp[0] == 0 && srcp[1] == 0 && srcp[2] == 0 && srcp[3] == 0) {<br>
+ tmp[j][i][0] = 255;<br>
+ tmp[j][i][1] = 0;<br>
+ tmp[j][i][2] = 0;<br>
+ tmp[j][i][3] = 0;<br>
+ } else {<br>
+ for(k = 0; k < comps; ++k) {<br>
+ tmp[j][i][k] = srcp[k];<br>
+ }<br>
}<br>
}<br>
}<br>
<font color="#888888">--<br>
1.7.1<br>
<br>
</font></blockquote></div><br>