Marek,

I'm not sure I agree here. If there's a bug in the lib, it should be fixed there, not tried to be worked around (correctly or not). And the bug has been there for years so it can't be suddenly that important. One version of the library is for instance cgit.freedesktop.org/~cbrill/libtxc_dxtn/ you could try to get a fix in there.

Roland


On 02/16/2011 03:43 AM, Marek Olšák wrote:
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.

Marek

On Wed, Feb 16, 2011 at 4:18 AM, Marek Olšák <mar...@gmail.com
<mailto:mar...@gmail.com>> wrote:

    This is a workaround for a bug in libtxc_dxtn.

    Fixes:
    - piglit/GL_EXT_texture_compression_s3tc/fbo-generatemipmap-formats
    ---
      src/gallium/auxiliary/util/u_format_s3tc.c |   16 ++++++++++++++--
      1 files changed, 14 insertions(+), 2 deletions(-)

    diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c
    b/src/gallium/auxiliary/util/u_format_s3tc.c
    index bb989c2..31288e3 100644
    --- a/src/gallium/auxiliary/util/u_format_s3tc.c
    +++ b/src/gallium/auxiliary/util/u_format_s3tc.c
    @@ -416,8 +416,20 @@ util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t
    *dst_row, unsigned dst_stride,
              uint8_t tmp[4][4][4];  /* [bh][bw][comps] */
              for(j = 0; j < bh; ++j) {
                 for(i = 0; i < bw; ++i) {
    -               for(k = 0; k < comps; ++k) {
    -                  tmp[j][i][k] = src[(y +
    j)*src_stride/sizeof(*src) + (x + i)*comps + k];
    +               const uint8_t *srcp = &src[(y +
    j)*src_stride/sizeof(*src) + (x + i)*comps];
    +               /* Workaround for a bug in libtxc_dxtn.
    +                * If the color is (0,0,0,0), it is compressed as
    (0,0,0,1),
    +                * which is incorrect. Any other (x,y,z,0) color is
    compressed
    +                * correctly as (0,0,0,0), so let's use (1,0,0,0). */
    +               if (srcp[0] == 0 && srcp[1] == 0 && srcp[2] == 0 &&
    srcp[3] == 0) {
    +                  tmp[j][i][0] = 255;
    +                  tmp[j][i][1] = 0;
    +                  tmp[j][i][2] = 0;
    +                  tmp[j][i][3] = 0;
    +               } else {
    +                  for(k = 0; k < comps; ++k) {
    +                     tmp[j][i][k] = srcp[k];
    +                  }
                    }
                 }
              }
    --
    1.7.1



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

Reply via email to