OSDN Git Service

nv50: support non-normalized texture coords
authorBen Skeggs <bskeggs@redhat.com>
Sat, 6 Jun 2009 00:57:19 +0000 (10:57 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Sat, 6 Jun 2009 06:24:08 +0000 (16:24 +1000)
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_tex.c

index c3ffdcc..1a72baf 100644 (file)
@@ -63,6 +63,11 @@ struct nv50_rasterizer_stateobj {
        struct nouveau_stateobj *so;
 };
 
+struct nv50_sampler_stateobj {
+       bool normalized;
+       unsigned tsc[8];
+};
+
 struct nv50_miptree_level {
        int *image_offset;
        unsigned pitch;
@@ -141,7 +146,7 @@ struct nv50_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
-       unsigned *sampler[PIPE_MAX_SAMPLERS];
+       struct nv50_sampler_stateobj *sampler[PIPE_MAX_SAMPLERS];
        unsigned sampler_nr;
        struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS];
        unsigned miptree_nr;
index 9d41ef5..116866a 100644 (file)
@@ -136,7 +136,8 @@ static void *
 nv50_sampler_state_create(struct pipe_context *pipe,
                          const struct pipe_sampler_state *cso)
 {
-       unsigned *tsc = CALLOC(8, sizeof(unsigned));
+       struct nv50_sampler_stateobj *sso = CALLOC(1, sizeof(*sso));
+       unsigned *tsc = sso->tsc;
        float limit;
 
        tsc[0] = (0x00026000 |
@@ -209,7 +210,8 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        tsc[2] |= ((int)CLAMP(cso->max_lod, 0.0, 15.0) << 20) |
                  ((int)CLAMP(cso->min_lod, 0.0, 15.0) << 8);
 
-       return (void *)tsc;
+       sso->normalized = cso->normalized_coords;
+       return (void *)sso;
 }
 
 static void
index a0106fc..0caf4b4 100644 (file)
@@ -295,12 +295,12 @@ viewport_uptodate:
                so_data  (so, NV50_CB_TSC);
                so_method(so, tesla, 0x40000f04, nv50->sampler_nr * 8);
                for (i = 0; i < nv50->sampler_nr; i++)
-                       so_datap (so, nv50->sampler[i], 8);
+                       so_datap (so, nv50->sampler[i]->tsc, 8);
                so_ref(so, &nv50->state.tsc_upload);
                so_ref(NULL, &so);
        }
 
-       if (nv50->dirty & NV50_NEW_TEXTURE)
+       if (nv50->dirty & (NV50_NEW_TEXTURE | NV50_NEW_SAMPLER))
                nv50_tex_validate(nv50);
 
        if (nv50->dirty & NV50_NEW_ARRAYS)
index 8bb8139..8f553f5 100644 (file)
@@ -27,7 +27,7 @@
 
 static int
 nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
-                  struct nv50_miptree *mt)
+                  struct nv50_miptree *mt, int unit)
 {
        switch (mt->base.format) {
        case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -120,7 +120,10 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
 
        so_reloc(so, mt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW |
                     NOUVEAU_BO_RD, 0, 0);
-       so_data (so, 0xd0005000 | mt->bo->tile_mode << 22);
+       if (nv50->sampler[unit]->normalized)
+               so_data (so, 0xd0005000 | mt->bo->tile_mode << 22);
+       else
+               so_data (so, 0x5001d000 | mt->bo->tile_mode << 22);
        so_data (so, 0x00300000);
        so_data (so, mt->base.width[0]);
        so_data (so, (mt->base.last_level << 28) |
@@ -145,7 +148,7 @@ nv50_tex_validate(struct nv50_context *nv50)
        for (unit = 0; unit < nv50->miptree_nr; unit++) {
                struct nv50_miptree *mt = nv50->miptree[unit];
 
-               if (nv50_tex_construct(nv50, so, mt)) {
+               if (nv50_tex_construct(nv50, so, mt, unit)) {
                        NOUVEAU_ERR("failed tex validate\n");
                        so_ref(NULL, &so);
                        return;