nouveau: in some cases don't create the buffer in local mem initially.
authorBen Skeggs <skeggsb@gmail.com>
Fri, 4 Apr 2008 02:39:45 +0000 (12:39 +1000)
committerBen Skeggs <skeggsb@gmail.com>
Fri, 4 Apr 2008 02:55:57 +0000 (12:55 +1000)
src/gallium/drivers/nouveau/nouveau_winsys.h
src/gallium/drivers/nv10/nv10_screen.c
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv40/nv40_miptree.c
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/winsys/dri/nouveau/nouveau_context.c
src/gallium/winsys/dri/nouveau/nouveau_context.h
src/gallium/winsys/dri/nouveau/nouveau_pushbuf.c
src/gallium/winsys/dri/nouveau/nouveau_winsys_pipe.c

index 2a5305f7ce4eddcde5a25c4109422989254559fa..fbde7adc6ad41916146d4f86e50db3c4437b0d2a 100644 (file)
 #include "nouveau/nouveau_resource.h"
 #include "nouveau/nouveau_pushbuf.h"
 
+#define NOUVEAU_CAP_HW_VTXBUF (0xbeef0000)
+#define NOUVEAU_CAP_HW_IDXBUF (0xbeef0001)
+
+#define NOUVEAU_BUFFER_USAGE_TEXTURE (1 << 16)
+
 struct nouveau_winsys {
        struct nouveau_context *nv;
 
index 80676ead1a9036621f9fdd195663535b4531eaa1..45fbde62ea2d0698856bdba9296f3d2ba4dfb19d 100644 (file)
@@ -50,6 +50,9 @@ nv10_screen_get_param(struct pipe_screen *screen, int param)
                return 0;
        case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
                return 12;
+       case NOUVEAU_CAP_HW_VTXBUF:
+       case NOUVEAU_CAP_HW_IDXBUF:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index 3ca50e4fbf46d24707917b43c0638176714a5267..c7487b37bc077b69e677a102812abde006206781 100644 (file)
@@ -50,6 +50,9 @@ nv30_screen_get_param(struct pipe_screen *screen, int param)
                return 10;
        case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
                return 13;
+       case NOUVEAU_CAP_HW_VTXBUF:
+       case NOUVEAU_CAP_HW_IDXBUF:
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index 502edc16298f926155997d37e5e77684e6fcf4e2..1b19217223215bee5543b915c862a75d0ce9384d 100644 (file)
@@ -68,7 +68,9 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
 
        nv40_miptree_layout(mt);
 
-       mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL,
+       mt->buffer = ws->buffer_create(ws, 256,
+                                      PIPE_BUFFER_USAGE_PIXEL |
+                                      NOUVEAU_BUFFER_USAGE_TEXTURE,
                                       mt->total_size);
        if (!mt->buffer) {
                FREE(mt);
index e98005f749f24fb0abd8e04779bf603ba6da97d4..a408d7262f3089577355740220e8447597a7bed7 100644 (file)
@@ -27,6 +27,8 @@ nv40_screen_get_vendor(struct pipe_screen *pscreen)
 static int
 nv40_screen_get_param(struct pipe_screen *pscreen, int param)
 {
+       struct nv40_screen *screen = nv40_screen(pscreen);
+
        switch (param) {
        case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
                return 16;
@@ -54,6 +56,12 @@ nv40_screen_get_param(struct pipe_screen *pscreen, int param)
                return 10;
        case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
                return 13;
+       case NOUVEAU_CAP_HW_VTXBUF:
+               return 1;
+       case NOUVEAU_CAP_HW_IDXBUF:
+               if (screen->curie->grclass == NV40TCL)
+                       return 1;
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index 586373a5c4bcfa41aaf375cca8e89272c4f3c26f..adb724b9b7a0ffbbeaee6d17fb73583bdcb0c852 100644 (file)
@@ -63,6 +63,9 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param)
                return 10;
        case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
                return 13;
+       case NOUVEAU_CAP_HW_VTXBUF:     
+       case NOUVEAU_CAP_HW_IDXBUF:     
+               return 0;
        default:
                NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
                return 0;
index cf1d83b18f40c6f988fed960dd15879300254e81..aaeaebd27188d563c69e631781cb0753fbf92eb1 100644 (file)
@@ -7,6 +7,7 @@
 #include "state_tracker/st_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_context.h"
+#include "pipe/p_screen.h"
 
 #include "nouveau_context.h"
 #include "nouveau_dri.h"
@@ -133,7 +134,7 @@ nouveau_context_create(const __GLcontextModes *glVis,
                /* G80 */
                break;
        default:
-               NOUVEAU_ERR("Unsupported chipset: NV%02x\n", nv->chipset);
+               NOUVEAU_ERR("Unsupported chipset: NV%02x\n", (int)nv->chipset);
                return GL_FALSE;
        }
 
@@ -255,9 +256,17 @@ nouveau_context_create(const __GLcontextModes *glVis,
        }
 
        if (!getenv("NOUVEAU_FORCE_SOFTPIPE")) {
+               struct pipe_screen *pscreen;
+
                pipe = nouveau_pipe_create(nv);
                if (!pipe)
                        NOUVEAU_ERR("Couldn't create hw pipe\n");
+               pscreen = nvc->pscreen;
+
+               nv->cap.hw_vertex_buffer =
+                       pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF);
+               nv->cap.hw_index_buffer =
+                       pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF);
        }
 
        if (!pipe) {
index 92f551855a4db30b24a243ba1e384a34e9487ce9..acb58fab44801c94b0884f39260035d56c973d29 100644 (file)
@@ -56,6 +56,11 @@ struct nouveau_context {
        struct nouveau_screen *nv_screen;
        struct pipe_surface *frontbuffer;
 
+       struct {
+               int hw_vertex_buffer;
+               int hw_index_buffer;
+       } cap;
+
        /* Hardware context */
        struct nouveau_channel_context *nvc;
        int pctx_id;
index 2e3ac5492fc16e68000c077c55ec2005941c7e93..78919bdee8c203a62c62d20f04aa520f280b218e 100644 (file)
@@ -137,6 +137,8 @@ nouveau_pushbuf_flush(struct nouveau_channel *chan, unsigned min)
        if (nvpb->base.remaining == nvpb->size)
                return 0;
 
+       nouveau_fence_flush(chan);
+
        nvpb->size -= nvpb->base.remaining;
        nvchan->dma->cur += nvpb->size;
        nvchan->dma->free -= nvpb->size;
index b1bf9c521aa414bff8e9aef58ca2361929234f6b..849e38d22b6bdb2d4beb5e54007f783053f4d2cb 100644 (file)
@@ -79,9 +79,10 @@ nouveau_pipe_bo_create(struct pipe_winsys *pws, unsigned alignment,
                       unsigned usage, unsigned size)
 {
        struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws;
-       struct nouveau_device *dev = nvpws->nv->nv_screen->device;
+       struct nouveau_context *nv = nvpws->nv;
+       struct nouveau_device *dev = nv->nv_screen->device;
        struct nouveau_pipe_buffer *nvbuf;
-       uint32_t flags = 0;
+       uint32_t flags;
 
        nvbuf = calloc(1, sizeof(*nvbuf));
        if (!nvbuf)
@@ -92,6 +93,23 @@ nouveau_pipe_bo_create(struct pipe_winsys *pws, unsigned alignment,
        nvbuf->base.size = size;
 
        flags = NOUVEAU_BO_LOCAL;
+
+       if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+               if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
+                       flags |= NOUVEAU_BO_GART;
+               flags |= NOUVEAU_BO_VRAM;
+       }
+
+       if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+               if (nv->cap.hw_vertex_buffer)
+                       flags |= NOUVEAU_BO_GART;
+       }
+
+       if (usage & PIPE_BUFFER_USAGE_INDEX) {
+               if (nv->cap.hw_index_buffer)
+                       flags |= NOUVEAU_BO_GART;
+       }
+
        if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) {
                free(nvbuf);
                return NULL;