dri/nv04: Mipmapping fixes.
authorFrancisco Jerez <currojerez@riseup.net>
Tue, 14 Sep 2010 23:56:04 +0000 (01:56 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 16 Sep 2010 17:44:21 +0000 (19:44 +0200)
src/mesa/drivers/dri/nouveau/nouveau_texture.c
src/mesa/drivers/dri/nouveau/nv04_state_tex.c

index 442f4e899ee8c9f342f8b43d49c4f50da49b30c2..d86f78b43714ea7ce3e6b3c1fe4fa6c0743c7c40 100644 (file)
@@ -178,15 +178,21 @@ nouveau_choose_tex_format(GLcontext *ctx, GLint internalFormat,
 }
 
 static GLboolean
-teximage_fits(struct gl_texture_object *t, int level)
+teximage_fits(GLcontext *ctx, struct gl_texture_object *t, int level)
 {
        struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level];
        struct gl_texture_image *ti = t->Image[0][level];
 
-       return ti && to_nouveau_teximage(ti)->surface.bo &&
-               (t->Target == GL_TEXTURE_RECTANGLE ||
-                (s->bo && s->format == ti->TexFormat &&
-                 s->width == ti->Width && s->height == ti->Height));
+       if (!ti || !to_nouveau_teximage(ti)->surface.bo)
+               return GL_FALSE;
+
+       if (context_chipset(ctx) < 0x10 &&
+           level == t->BaseLevel && (s->offset & 0x7f))
+               return GL_FALSE;
+
+       return t->Target == GL_TEXTURE_RECTANGLE ||
+               (s->bo && s->format == ti->TexFormat &&
+                s->width == ti->Width && s->height == ti->Height);
 }
 
 static GLboolean
@@ -196,7 +202,7 @@ validate_teximage(GLcontext *ctx, struct gl_texture_object *t,
 {
        struct gl_texture_image *ti = t->Image[0][level];
 
-       if (teximage_fits(t, level)) {
+       if (teximage_fits(ctx, t, level)) {
                struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
                struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
 
@@ -284,8 +290,8 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t)
        struct nouveau_texture *nt = to_nouveau_texture(t);
        int i, last = get_last_level(t);
 
-       if (!teximage_fits(t, t->BaseLevel) ||
-           !teximage_fits(t, last))
+       if (!teximage_fits(ctx, t, t->BaseLevel) ||
+           !teximage_fits(ctx, t, last))
                return GL_FALSE;
 
        if (nt->dirty) {
@@ -308,8 +314,8 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t)
 void
 nouveau_texture_reallocate(GLcontext *ctx, struct gl_texture_object *t)
 {
-       if (!teximage_fits(t, t->BaseLevel) ||
-           !teximage_fits(t, get_last_level(t))) {
+       if (!teximage_fits(ctx, t, t->BaseLevel) ||
+           !teximage_fits(ctx, t, get_last_level(t))) {
                texture_dirty(t);
                relayout_texture(ctx, t);
                nouveau_texture_validate(ctx, t);
@@ -371,7 +377,7 @@ nouveau_teximage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
        }
 
        if (level == t->BaseLevel) {
-               if (!teximage_fits(t, level))
+               if (!teximage_fits(ctx, t, level))
                        relayout_texture(ctx, t);
                nouveau_texture_validate(ctx, t);
        }
index 6d8762b7d1ebb4f74d2594e94c0773f3a3f91e5c..4ac8327b87128f030dc071ac51d3559b6c68b8a9 100644 (file)
@@ -103,7 +103,7 @@ nv04_emit_tex_obj(GLcontext *ctx, int emit)
                                        0, 15) + 1;
 
                        lod_bias = CLAMP(ctx->Texture.Unit[i].LodBias +
-                                        t->LodBias, 0, 15);
+                                        t->LodBias, -16, 15) * 8;
                }
 
                format |= get_wrap_mode(t->WrapT) << 28 |
@@ -117,7 +117,7 @@ nv04_emit_tex_obj(GLcontext *ctx, int emit)
                        nvgl_filter_mode(t->MagFilter) << 28 |
                        log2i(t->MaxAnisotropy) << 27 |
                        nvgl_filter_mode(t->MinFilter) << 24 |
-                       lod_bias << 16;
+                       (lod_bias & 0xff) << 16;
 
        } else {
                s = &to_nv04_context(ctx)->dummy_texture;
@@ -134,7 +134,7 @@ nv04_emit_tex_obj(GLcontext *ctx, int emit)
        if (nv04_mtex_engine(fahrenheit)) {
                nouveau_bo_markl(bctx, fahrenheit,
                                 NV04_MULTITEX_TRIANGLE_OFFSET(i),
-                                s->bo, 0, bo_flags);
+                                s->bo, s->offset, bo_flags);
 
                nouveau_bo_mark(bctx, fahrenheit,
                                NV04_MULTITEX_TRIANGLE_FORMAT(i),
@@ -149,7 +149,7 @@ nv04_emit_tex_obj(GLcontext *ctx, int emit)
        } else {
                nouveau_bo_markl(bctx, fahrenheit,
                                 NV04_TEXTURED_TRIANGLE_OFFSET,
-                                s->bo, 0, bo_flags);
+                                s->bo, s->offset, bo_flags);
 
                nouveau_bo_mark(bctx, fahrenheit,
                                NV04_TEXTURED_TRIANGLE_FORMAT,