summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nvc0/nvc0_buffer.c
diff options
context:
space:
mode:
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>2011-01-15 12:18:52 +0100
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>2011-01-15 12:18:52 +0100
commit1ae982adfd8144d11334895c39aca65dd30ad946 (patch)
tree3094c3dcbbcef33d49ea62189c4f0b9d33063fd6 /src/gallium/drivers/nvc0/nvc0_buffer.c
parentb50d02e2e0729de101fd0acddeac21cca038786e (diff)
nvc0: update user vbufs on each draw call
This is required in case set_vertex_buffers is not called again.
Diffstat (limited to 'src/gallium/drivers/nvc0/nvc0_buffer.c')
-rw-r--r--src/gallium/drivers/nvc0/nvc0_buffer.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/gallium/drivers/nvc0/nvc0_buffer.c b/src/gallium/drivers/nvc0/nvc0_buffer.c
index dad69e17ef..ea3e642a44 100644
--- a/src/gallium/drivers/nvc0/nvc0_buffer.c
+++ b/src/gallium/drivers/nvc0/nvc0_buffer.c
@@ -59,6 +59,18 @@ release_allocation(struct nvc0_mm_allocation **mm, struct nvc0_fence *fence)
(*mm) = NULL;
}
+static INLINE boolean
+nvc0_buffer_reallocate(struct nvc0_screen *screen, struct nvc0_resource *buf,
+ unsigned domain)
+{
+ nouveau_bo_ref(NULL, &buf->bo);
+
+ if (buf->mm)
+ release_allocation(&buf->mm, buf->fence);
+
+ return nvc0_buffer_allocate(screen, buf, domain);
+}
+
static void
nvc0_buffer_destroy(struct pipe_screen *pscreen,
struct pipe_resource *presource)
@@ -372,8 +384,9 @@ nvc0_user_buffer_create(struct pipe_screen *pscreen,
return &buffer->base;
}
+/* Like download, but for GART buffers. Merge ? */
static INLINE boolean
-nvc0_buffer_fetch_data(struct nvc0_resource *buf,
+nvc0_buffer_data_fetch(struct nvc0_resource *buf,
struct nouveau_bo *bo, unsigned offset, unsigned size)
{
if (!buf->data) {
@@ -419,7 +432,7 @@ nvc0_buffer_migrate(struct nvc0_context *nvc0,
if (new_domain == NOUVEAU_BO_VRAM) {
/* keep a system memory copy of our data in case we hit a fallback */
- if (!nvc0_buffer_fetch_data(buf, buf->bo, buf->offset, size))
+ if (!nvc0_buffer_data_fetch(buf, buf->bo, buf->offset, size))
return FALSE;
debug_printf("migrating %u KiB to VRAM\n", size / 1024);
}
@@ -450,19 +463,22 @@ nvc0_buffer_migrate(struct nvc0_context *nvc0,
}
/* Migrate data from glVertexAttribPointer(non-VBO) user buffers to GART.
- * MUST NOT FLUSH THE PUSH BUFFER, we could be in the middle of a method.
+ * We'd like to only allocate @size bytes here, but then we'd have to rebase
+ * the vertex indices ...
*/
boolean
-nvc0_migrate_vertices(struct nvc0_resource *buf, unsigned base, unsigned size)
+nvc0_user_buffer_upload(struct nvc0_resource *buf, unsigned base, unsigned size)
{
struct nvc0_screen *screen = nvc0_screen(buf->base.screen);
int ret;
- assert(buf->data && !buf->domain);
+ assert(buf->status & NVC0_BUFFER_STATUS_USER_MEMORY);
- if (!nvc0_buffer_allocate(screen, buf, NOUVEAU_BO_GART))
+ buf->base.width0 = base + size;
+ if (!nvc0_buffer_reallocate(screen, buf, NOUVEAU_BO_GART))
return FALSE;
- ret = nouveau_bo_map_range(buf->bo, base + buf->offset, size,
+
+ ret = nouveau_bo_map_range(buf->bo, buf->offset + base, size,
NOUVEAU_BO_WR | NOUVEAU_BO_NOSYNC);
if (ret)
return FALSE;