i965/gs: implement EndPrimitive() functionality in the visitor.
[mesa.git] / src / mesa / drivers / dri / nouveau / nv20_state_tex.c
index 799510daa69f1e087f5d2f0219006e9a6d29feaf..ffbc2dfe09c90b3d76a4f4bca0959b893999d714 100644 (file)
@@ -31,6 +31,7 @@
 #include "nv20_3d.xml.h"
 #include "nouveau_util.h"
 #include "nv20_driver.h"
+#include "main/samplerobj.h"
 
 void
 nv20_emit_tex_gen(struct gl_context *ctx, int emit)
@@ -108,6 +109,16 @@ get_tex_format_pot(struct gl_texture_image *ti)
        case MESA_FORMAT_L8:
                return NV20_3D_TEX_FORMAT_FORMAT_L8;
 
+       case MESA_FORMAT_RGB_DXT1:
+       case MESA_FORMAT_RGBA_DXT1:
+               return NV20_3D_TEX_FORMAT_FORMAT_DXT1;
+
+       case MESA_FORMAT_RGBA_DXT3:
+               return NV20_3D_TEX_FORMAT_FORMAT_DXT3;
+
+       case MESA_FORMAT_RGBA_DXT5:
+               return NV20_3D_TEX_FORMAT_FORMAT_DXT5;
+
        default:
                assert(0);
        }
@@ -153,6 +164,7 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
        struct gl_texture_object *t;
        struct nouveau_surface *s;
        struct gl_texture_image *ti;
+       const struct gl_sampler_object *sa;
        uint32_t tx_format, tx_filter, tx_wrap, tx_enable;
 
        PUSH_RESET(push, BUFCTX_TEX(i));
@@ -168,6 +180,7 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
        t = ctx->Texture.Unit[i]._Current;
        s = &to_nouveau_texture(t)->surfaces[t->BaseLevel];
        ti = t->Image[0][t->BaseLevel];
+       sa = _mesa_get_samplerobj(ctx, i);
 
        if (!nouveau_texture_validate(ctx, t))
                return;
@@ -180,16 +193,16 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
                | NV20_3D_TEX_FORMAT_NO_BORDER
                | 1 << 16;
 
-       tx_wrap = nvgl_wrap_mode(t->Sampler.WrapR) << 16
-               | nvgl_wrap_mode(t->Sampler.WrapT) << 8
-               | nvgl_wrap_mode(t->Sampler.WrapS) << 0;
+       tx_wrap = nvgl_wrap_mode(sa->WrapR) << 16
+               | nvgl_wrap_mode(sa->WrapT) << 8
+               | nvgl_wrap_mode(sa->WrapS) << 0;
 
-       tx_filter = nvgl_filter_mode(t->Sampler.MagFilter) << 24
-               | nvgl_filter_mode(t->Sampler.MinFilter) << 16
+       tx_filter = nvgl_filter_mode(sa->MagFilter) << 24
+               | nvgl_filter_mode(sa->MinFilter) << 16
                | 2 << 12;
 
        tx_enable = NV20_3D_TEX_ENABLE_ENABLE
-               | log2i(t->Sampler.MaxAnisotropy) << 4;
+               | log2i(sa->MaxAnisotropy) << 4;
 
        if (t->Target == GL_TEXTURE_RECTANGLE) {
                BEGIN_NV04(push, NV20_3D(TEX_NPOT_PITCH(i)), 1);
@@ -202,11 +215,11 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
                tx_format |= get_tex_format_pot(ti);
        }
 
-       if (t->Sampler.MinFilter != GL_NEAREST &&
-           t->Sampler.MinFilter != GL_LINEAR) {
-               int lod_min = t->Sampler.MinLod;
-               int lod_max = MIN2(t->Sampler.MaxLod, t->_MaxLambda);
-               int lod_bias = t->Sampler.LodBias
+       if (sa->MinFilter != GL_NEAREST &&
+           sa->MinFilter != GL_LINEAR) {
+               int lod_min = sa->MinLod;
+               int lod_max = MIN2(sa->MaxLod, t->_MaxLambda);
+               int lod_bias = sa->LodBias
                        + ctx->Texture.Unit[i].LodBias;
 
                lod_max = CLAMP(lod_max, 0, 15);