nouveau: place static buffers in VRAM if preferred by the driver
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Thu, 17 May 2012 12:43:47 +0000 (14:43 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Thu, 17 May 2012 13:24:58 +0000 (15:24 +0200)
src/gallium/drivers/nouveau/nouveau_buffer.c
src/gallium/drivers/nouveau/nouveau_screen.c
src/gallium/drivers/nouveau/nouveau_screen.h
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nvc0/nvc0_screen.c

index c396e3c3986fd533b75291d3a09fbc8a412b2845..d04ac2f9f1c8329abeb247b893533b628b4891cf 100644 (file)
@@ -363,10 +363,31 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
    pipe_reference_init(&buffer->base.reference, 1);
    buffer->base.screen = pscreen;
 
-   if ((buffer->base.bind & screen->sysmem_bindings) == screen->sysmem_bindings)
-      ret = nouveau_buffer_allocate(screen, buffer, 0);
-   else
-      ret = nouveau_buffer_allocate(screen, buffer, NOUVEAU_BO_GART);
+   if (buffer->base.bind &
+       (screen->vidmem_bindings & screen->sysmem_bindings)) {
+      switch (buffer->base.usage) {
+      case PIPE_USAGE_DEFAULT:
+      case PIPE_USAGE_IMMUTABLE:
+      case PIPE_USAGE_STATIC:
+         buffer->domain = NOUVEAU_BO_VRAM;
+         break;
+      case PIPE_USAGE_DYNAMIC:
+      case PIPE_USAGE_STAGING:
+      case PIPE_USAGE_STREAM:
+         buffer->domain = NOUVEAU_BO_GART;
+         break;
+      default:
+         assert(0);
+         break;
+      }
+   } else {
+      if (buffer->base.bind & screen->vidmem_bindings)
+         buffer->domain = NOUVEAU_BO_VRAM;
+      else
+      if (buffer->base.bind & screen->sysmem_bindings)
+         buffer->domain = NOUVEAU_BO_GART;
+   }
+   ret = nouveau_buffer_allocate(screen, buffer, buffer->domain);
 
    if (ret == FALSE)
       goto fail;
index 7437779997754590230b5739c8898f0c47270f78..9baa68ce15166ee24c85aef45716d50d1be8fc9f 100644 (file)
@@ -148,6 +148,16 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
 
        util_format_s3tc_init();
 
+       screen->lowmem_bindings = PIPE_BIND_GLOBAL; /* gallium limit */
+       screen->vidmem_bindings =
+               PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL |
+               PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_CURSOR |
+               PIPE_BIND_SAMPLER_VIEW |
+               PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE |
+               PIPE_BIND_GLOBAL;
+       screen->sysmem_bindings =
+               PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT;
+
        memset(&mm_config, 0, sizeof(mm_config));
 
        screen->mm_GART = nouveau_mm_create(dev,
index 4ca286bfe8da60ba145d4ff83f3200dcee1a5999..5a3cfab92e993f90f9813e39ab83f8e7ec7916c1 100644 (file)
@@ -17,7 +17,13 @@ struct nouveau_screen {
        struct nouveau_client *client;
        struct nouveau_pushbuf *pushbuf;
 
-       unsigned sysmem_bindings;
+       unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */
+       unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */
+       unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */
+       /*
+        * For bindings with (vidmem & sysmem) bits set set, PIPE_USAGE_* decides
+        * placement.
+        */
 
        uint16_t class_3d;
 
index f5120e74c5ff4137e7141da03fb42c878aca7be6..67de8c03f45fc7bcb958b2809115f35345e6cd52 100644 (file)
@@ -371,14 +371,18 @@ nv30_screen_create(struct nouveau_device *dev)
 
    screen->base.fence.emit = nv30_screen_fence_emit;
    screen->base.fence.update = nv30_screen_fence_update;
-   screen->base.sysmem_bindings = PIPE_BIND_CONSTANT_BUFFER;
-   if (oclass != NV40_3D_CLASS)
-      screen->base.sysmem_bindings |= PIPE_BIND_INDEX_BUFFER;
 
    ret = nouveau_screen_init(&screen->base, dev);
    if (ret)
       FAIL_SCREEN_INIT("nv30_screen_init failed: %d\n", ret);
 
+   screen->base.vidmem_bindings |= PIPE_BIND_VERTEX_BUFFER;
+   screen->base.sysmem_bindings |= PIPE_BIND_VERTEX_BUFFER;
+   if (oclass == NV40_3D_CLASS) {
+      screen->base.vidmem_bindings |= PIPE_BIND_INDEX_BUFFER;
+      screen->base.sysmem_bindings |= PIPE_BIND_INDEX_BUFFER;
+   }
+
    fifo = screen->base.channel->data;
    push = screen->base.pushbuf;
    push->rsvd_kick = 16;
index d7efa35338179d1b2194f22f0d99375e82b4170e..9567abbf352f080313cee6c9af520a83370a9f47 100644 (file)
@@ -532,12 +532,18 @@ nv50_screen_create(struct nouveau_device *dev)
       return NULL;
    pscreen = &screen->base.base;
 
-   screen->base.sysmem_bindings = PIPE_BIND_CONSTANT_BUFFER;
-
    ret = nouveau_screen_init(&screen->base, dev);
    if (ret)
       FAIL_SCREEN_INIT("nouveau_screen_init failed: %d\n", ret);
 
+   /* TODO: Prevent FIFO prefetch before transfer of index buffers and
+    *  admit them to VRAM.
+    */
+   screen->base.vidmem_bindings |= PIPE_BIND_CONSTANT_BUFFER |
+      PIPE_BIND_VERTEX_BUFFER;
+   screen->base.sysmem_bindings |=
+      PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER;
+
    screen->base.pushbuf->user_priv = screen;
    screen->base.pushbuf->rsvd_kick = 5;
 
index 0717ac8f7251be9ce7ddb64843f7645b62ef4803..49d611844717d7bf1b4896911cc7f369f2148423 100644 (file)
@@ -418,8 +418,6 @@ nvc0_screen_create(struct nouveau_device *dev)
       return NULL;
    pscreen = &screen->base.base;
 
-   screen->base.sysmem_bindings = PIPE_BIND_CONSTANT_BUFFER;
-
    ret = nouveau_screen_init(&screen->base, dev);
    if (ret) {
       nvc0_screen_destroy(pscreen);
@@ -429,6 +427,11 @@ nvc0_screen_create(struct nouveau_device *dev)
    push = screen->base.pushbuf;
    push->user_priv = screen;
 
+   screen->base.vidmem_bindings |= PIPE_BIND_CONSTANT_BUFFER |
+      PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER;
+   screen->base.sysmem_bindings |=
+      PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER;
+
    pscreen->destroy = nvc0_screen_destroy;
    pscreen->context_create = nvc0_create;
    pscreen->is_format_supported = nvc0_screen_is_format_supported;