OSDN Git Service

nv50: do tsc/tic upload + stub out shader TEX stuff
authorBen Skeggs <skeggsb@gmail.com>
Fri, 13 Jun 2008 02:09:46 +0000 (12:09 +1000)
committerBen Skeggs <skeggsb@gmail.com>
Sun, 29 Jun 2008 05:46:18 +0000 (15:46 +1000)
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_program.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c

index 19ec492..5214ce1 100644 (file)
@@ -44,6 +44,8 @@
 #define NV50_NEW_FRAGPROG      (1 << 10)
 #define NV50_NEW_FRAGPROG_CB   (1 << 11)
 #define NV50_NEW_ARRAYS                (1 << 12)
+#define NV50_NEW_SAMPLER       (1 << 13)
+#define NV50_NEW_TEXTURE       (1 << 14)
 
 struct nv50_blend_stateobj {
        struct pipe_blend_state pipe;
@@ -60,6 +62,17 @@ struct nv50_rasterizer_stateobj {
        struct nouveau_stateobj *so;
 };
 
+struct nv50_miptree {
+       struct pipe_texture base;
+       struct pipe_buffer *buffer;
+};
+
+static INLINE struct nv50_miptree *
+nv50_miptree(struct pipe_texture *pt)
+{
+       return (struct nv50_miptree *)pt;
+}
+
 struct nv50_context {
        struct pipe_context pipe;
 
@@ -84,6 +97,10 @@ struct nv50_context {
        unsigned vtxbuf_nr;
        struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
        unsigned vtxelt_nr;
+       unsigned *sampler[PIPE_MAX_SAMPLERS];
+       unsigned sampler_nr;
+       struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS];
+       unsigned miptree_nr;
 };
 
 static INLINE struct nv50_context *
index 459e0ff..cdd9884 100644 (file)
@@ -5,17 +5,6 @@
 
 #include "nv50_context.h"
 
-struct nv50_miptree {
-       struct pipe_texture base;
-       struct pipe_buffer *buffer;
-};
-
-static INLINE struct nv50_miptree *
-nv50_miptree(struct pipe_texture *pt)
-{
-       return (struct nv50_miptree *)pt;
-}
-
 static struct pipe_texture *
 nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
 {
index 39597c5..5eec68e 100644 (file)
@@ -828,6 +828,8 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src)
                case TGSI_FILE_IMMEDIATE:
                        r = &pc->immd[src->SrcRegister.Index * 4 + c];
                        break;
+               case TGSI_FILE_SAMPLER:
+                       break;
                default:
                        assert(0);
                        break;
@@ -1130,6 +1132,8 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                        emit_sub(pc, dst[c], src[0][c], src[1][c]);
                }
                break;
+       case TGSI_OPCODE_TEX:
+               break;
        case TGSI_OPCODE_XPD:
                temp = alloc_temp(pc, NULL);
                if (mask & (1 << 0)) {
@@ -1226,6 +1230,8 @@ nv50_program_tx_prep(struct nv50_pc *pc)
                                if (pc->param_nr < (last + 1))
                                        pc->param_nr = last + 1;
                                break;
+                       case TGSI_FILE_SAMPLER:
+                               break;
                        default:
                                NOUVEAU_ERR("bad decl file %d\n",
                                            d->Declaration.File);
index d76cce9..b9cecb7 100644 (file)
@@ -28,6 +28,7 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                break;
        case PIPE_TEXTURE:
                switch (format) {
+               case PIPE_FORMAT_A8R8G8B8_UNORM:
                case PIPE_FORMAT_I8_UNORM:
                        return TRUE;
                default:
index 0129b0f..f36299d 100644 (file)
@@ -1,6 +1,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
 
 #include "nv50_context.h"
 
@@ -85,23 +86,47 @@ static void *
 nv50_sampler_state_create(struct pipe_context *pipe,
                          const struct pipe_sampler_state *cso)
 {
-       return NULL;
+       unsigned *tsc = CALLOC(8, sizeof(unsigned));
+
+       tsc[0] = 0x00024080;
+       tsc[1] = 0x00000062;
+
+       return (void *)tsc;
 }
 
 static void
 nv50_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
 {
+       struct nv50_context *nv50 = nv50_context(pipe);
+       int i;
+
+       nv50->sampler_nr = nr;
+       for (i = 0; i < nv50->sampler_nr; i++)
+               nv50->sampler[i] = sampler[i];
+
+       nv50->dirty |= NV50_NEW_SAMPLER;
 }
 
 static void
 nv50_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
 {
+       FREE(hwcso);
 }
 
 static void
 nv50_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
                         struct pipe_texture **pt)
 {
+       struct nv50_context *nv50 = nv50_context(pipe);
+       int i;
+
+       for (i = 0; i < nr; i++)
+               pipe_texture_reference(&nv50->miptree[i], pt[i]);
+       for (i = nr; i < nv50->miptree_nr; i++)
+               pipe_texture_reference(&nv50->miptree[i], NULL);
+
+       nv50->miptree_nr = nr;
+       nv50->dirty |= NV50_NEW_TEXTURE;
 }
 
 static void *
index a3f399a..63c1756 100644 (file)
@@ -178,6 +178,39 @@ nv50_state_validate(struct nv50_context *nv50)
                so_ref(NULL, &so);
        }
 
+       if (nv50->dirty & NV50_NEW_SAMPLER) {
+               int i;
+
+               BEGIN_RING(tesla, 0x0f00, 1);
+               OUT_RING  ((NV50_CB_TSC << 0) | (0 << 8));
+               BEGIN_RING(tesla, 0x40000f04, nv50->sampler_nr * 8);
+               for (i = 0; i < nv50->sampler_nr; i++)
+                       OUT_RINGp(nv50->sampler[i], 8);
+       }
+
+       if (nv50->dirty & NV50_NEW_TEXTURE) {
+               int i;
+
+               BEGIN_RING(tesla, 0x0f00, 1);
+               OUT_RING  ((NV50_CB_TIC << 0) | (0 << 8));
+               BEGIN_RING(tesla, 0x40000f04, nv50->miptree_nr * 8);
+               for (i = 0; i < nv50->sampler_nr; i++) {
+                       struct nv50_miptree *mt = nv50->miptree[i];
+
+                       OUT_RING  (0x2a712488);
+                       OUT_RELOCl(mt->buffer, 0,
+                                  NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW);
+                       OUT_RING  (0xd0c05000);
+                       OUT_RING  (0x00300000);
+                       OUT_RING  (mt->base.width[0]);
+                       OUT_RING  ((mt->base.depth[0] << 16) |
+                                   mt->base.height[0]);
+                       OUT_RING  (0x03000000);
+                       OUT_RELOCh(mt->buffer, 0,
+                                  NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH);
+               }
+       }
+
        if (nv50->dirty & NV50_NEW_ARRAYS)
                nv50_vbo_validate(nv50);