Permalink
Browse files

nouveau: switch to libdrm_nouveau-2.0

  • Loading branch information...
1 parent b4fcbe4 commit 9ccdab4ece21e75f43712fb7186920d6c1707817 Christoph Bumiller committed with Apr 6, 2012
Showing with 3,715 additions and 3,434 deletions.
  1. +1 −1 configure.ac
  2. +1 −0 src/gallium/drivers/nouveau/Makefile.sources
  3. +53 −37 src/gallium/drivers/nouveau/nouveau_buffer.c
  4. +7 −29 src/gallium/drivers/nouveau/nouveau_buffer.h
  5. +4 −0 src/gallium/drivers/nouveau/nouveau_context.h
  6. +2 −3 src/gallium/drivers/nouveau/nouveau_fence.c
  7. +123 −0 src/gallium/drivers/nouveau/nouveau_heap.c
  8. +52 −0 src/gallium/drivers/nouveau/nouveau_heap.h
  9. +12 −11 src/gallium/drivers/nouveau/nouveau_mm.c
  10. +2 −1 src/gallium/drivers/nouveau/nouveau_mm.h
  11. +38 −111 src/gallium/drivers/nouveau/nouveau_screen.c
  12. +4 −44 src/gallium/drivers/nouveau/nouveau_screen.h
  13. +7 −2 src/gallium/drivers/nouveau/nouveau_statebuf.h
  14. +113 −76 src/gallium/drivers/nouveau/nouveau_video.c
  15. +56 −2 src/gallium/drivers/nouveau/nouveau_video.h
  16. +51 −18 src/gallium/drivers/nouveau/nouveau_winsys.h
  17. +34 −33 src/gallium/drivers/nouveau/nv_m2mf.xml.h
  18. +175 −145 src/gallium/drivers/nouveau/nv_object.xml.h
  19. +92 −66 src/gallium/drivers/nv50/nv50_3d.xml.h
  20. +66 −84 src/gallium/drivers/nv50/nv50_context.c
  21. +31 −21 src/gallium/drivers/nv50/nv50_context.h
  22. +36 −33 src/gallium/drivers/nv50/nv50_miptree.c
  23. +4 −3 src/gallium/drivers/nv50/nv50_program.c
  24. +1 −1 src/gallium/drivers/nv50/nv50_program.h
  25. +29 −29 src/gallium/drivers/nv50/nv50_push.c
  26. +62 −66 src/gallium/drivers/nv50/nv50_query.c
  27. +5 −6 src/gallium/drivers/nv50/nv50_resource.h
  28. +251 −250 src/gallium/drivers/nv50/nv50_screen.c
  29. +9 −18 src/gallium/drivers/nv50/nv50_screen.h
  30. +133 −122 src/gallium/drivers/nv50/nv50_shader_state.c
  31. +20 −11 src/gallium/drivers/nv50/nv50_state.c
  32. +121 −123 src/gallium/drivers/nv50/nv50_state_validate.c
  33. +4 −6 src/gallium/drivers/nv50/nv50_stateobj.h
  34. +204 −201 src/gallium/drivers/nv50/nv50_surface.c
  35. +62 −67 src/gallium/drivers/nv50/nv50_tex.c
  36. +137 −115 src/gallium/drivers/nv50/nv50_transfer.c
  37. +163 −171 src/gallium/drivers/nv50/nv50_vbo.c
  38. +80 −62 src/gallium/drivers/nv50/nv50_winsys.h
  39. +31 −10 src/gallium/drivers/nvc0/nvc0_3d.xml.h
  40. +66 −81 src/gallium/drivers/nvc0/nvc0_context.c
  41. +29 −31 src/gallium/drivers/nvc0/nvc0_context.h
  42. +42 −39 src/gallium/drivers/nvc0/nvc0_miptree.c
  43. +20 −10 src/gallium/drivers/nvc0/nvc0_program.c
  44. +2 −1 src/gallium/drivers/nvc0/nvc0_program.h
  45. +38 −38 src/gallium/drivers/nvc0/nvc0_push.c
  46. +92 −96 src/gallium/drivers/nvc0/nvc0_query.c
  47. +248 −256 src/gallium/drivers/nvc0/nvc0_screen.c
  48. +8 −12 src/gallium/drivers/nvc0/nvc0_screen.h
  49. +108 −108 src/gallium/drivers/nvc0/nvc0_shader_state.c
  50. +13 −7 src/gallium/drivers/nvc0/nvc0_state.c
  51. +158 −164 src/gallium/drivers/nvc0/nvc0_state_validate.c
  52. +2 −4 src/gallium/drivers/nvc0/nvc0_stateobj.h
  53. +198 −202 src/gallium/drivers/nvc0/nvc0_surface.c
  54. +47 −53 src/gallium/drivers/nvc0/nvc0_tex.c
  55. +109 −148 src/gallium/drivers/nvc0/nvc0_transfer.c
  56. +172 −130 src/gallium/drivers/nvc0/nvc0_vbo.c
  57. +86 −71 src/gallium/drivers/nvc0/nvc0_winsys.h
  58. +1 −5 src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
View
@@ -39,7 +39,7 @@ LIBDRM_REQUIRED=2.4.24
LIBDRM_RADEON_REQUIRED=2.4.31
LIBDRM_INTEL_REQUIRED=2.4.32
LIBDRM_NVVIEUX_REQUIRED=2.4.33
-LIBDRM_NOUVEAU_REQUIRED=0.6
+LIBDRM_NOUVEAU_REQUIRED=2.4.33
DRI2PROTO_REQUIRED=2.6
GLPROTO_REQUIRED=1.4.14
LIBDRM_XORG_REQUIRED=2.4.24
@@ -3,4 +3,5 @@ C_SOURCES := \
nouveau_fence.c \
nouveau_mm.c \
nouveau_buffer.c \
+ nouveau_heap.c \
nouveau_video.c
@@ -49,6 +49,9 @@ nouveau_buffer_allocate(struct nouveau_screen *screen,
}
}
buf->domain = domain;
+ if (buf->bo)
+ buf->address = buf->bo->offset + buf->offset;
+
return TRUE;
}
@@ -112,10 +115,9 @@ nouveau_buffer_download(struct nouveau_context *nv, struct nv04_resource *buf,
nv->copy_data(nv, bounce, offset, NOUVEAU_BO_GART,
buf->bo, buf->offset + start, NOUVEAU_BO_VRAM, size);
- if (nouveau_bo_map_range(bounce, offset, size, NOUVEAU_BO_RD))
+ if (nouveau_bo_map(bounce, NOUVEAU_BO_RD, nv->screen->client))
return FALSE;
- memcpy(buf->data + start, bounce->map, size);
- nouveau_bo_unmap(bounce);
+ memcpy(buf->data + start, (uint8_t *)bounce->map + offset, size);
buf->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING;
@@ -147,10 +149,8 @@ nouveau_buffer_upload(struct nouveau_context *nv, struct nv04_resource *buf,
if (!bounce)
return FALSE;
- nouveau_bo_map_range(bounce, offset, size,
- NOUVEAU_BO_WR | NOUVEAU_BO_NOSYNC);
- memcpy(bounce->map, buf->data + start, size);
- nouveau_bo_unmap(bounce);
+ nouveau_bo_map(bounce, 0, nv->screen->client);
+ memcpy((uint8_t *)bounce->map + offset, buf->data + start, size);
nv->copy_data(nv, buf->bo, buf->offset + start, NOUVEAU_BO_VRAM,
bounce, offset, NOUVEAU_BO_GART, size);
@@ -246,34 +246,27 @@ static void *
nouveau_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
+ struct nouveau_context *nv = nouveau_context(pipe);
struct nouveau_transfer *xfr = nouveau_transfer(transfer);
struct nv04_resource *buf = nv04_resource(transfer->resource);
struct nouveau_bo *bo = buf->bo;
uint8_t *map;
int ret;
uint32_t offset = xfr->base.box.x;
- uint32_t flags;
+ uint32_t flags = 0;
if (buf->domain != NOUVEAU_BO_GART)
return buf->data + offset;
- if (buf->mm)
- flags = NOUVEAU_BO_NOSYNC | NOUVEAU_BO_RDWR;
- else
+ if (!buf->mm)
flags = nouveau_screen_transfer_flags(xfr->base.usage);
offset += buf->offset;
- ret = nouveau_bo_map_range(buf->bo, offset, xfr->base.box.width, flags);
+ ret = nouveau_bo_map(buf->bo, flags, nv->screen->client);
if (ret)
return NULL;
- map = bo->map;
-
- /* Unmap right now. Since multiple buffers can share a single nouveau_bo,
- * not doing so might make future maps fail or trigger "reloc while mapped"
- * errors. For now, mappings to userspace are guaranteed to be persistent.
- */
- nouveau_bo_unmap(bo);
+ map = (uint8_t *)bo->map + offset;
if (buf->mm) {
if (xfr->base.usage & PIPE_TRANSFER_DONTBLOCK) {
@@ -294,6 +287,7 @@ nouveau_buffer_transfer_flush_region(struct pipe_context *pipe,
struct pipe_transfer *transfer,
const struct pipe_box *box)
{
+#if 0
struct nv04_resource *res = nv04_resource(transfer->resource);
struct nouveau_bo *bo = res->bo;
unsigned offset = res->offset + transfer->box.x + box->x;
@@ -303,17 +297,43 @@ nouveau_buffer_transfer_flush_region(struct pipe_context *pipe,
return;
/* XXX: maybe need to upload for VRAM buffers here */
-
- nouveau_screen_bo_map_flush_range(pipe->screen, bo, offset, box->width);
+#endif
}
static void
nouveau_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
- /* we've called nouveau_bo_unmap right after map */
}
+
+void *
+nouveau_resource_map_offset(struct nouveau_context *nv,
+ struct nv04_resource *res, uint32_t offset,
+ uint32_t flags)
+{
+ if ((res->domain == NOUVEAU_BO_VRAM) &&
+ (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING))
+ nouveau_buffer_download(nv, res, 0, res->base.width0);
+
+ if ((res->domain != NOUVEAU_BO_GART) ||
+ (res->status & NOUVEAU_BUFFER_STATUS_USER_MEMORY))
+ return res->data + offset;
+
+ if (res->mm) {
+ unsigned rw;
+ rw = (flags & NOUVEAU_BO_WR) ? PIPE_TRANSFER_WRITE : PIPE_TRANSFER_READ;
+ nouveau_buffer_sync(res, rw);
+ if (nouveau_bo_map(res->bo, 0, NULL))
+ return NULL;
+ } else {
+ if (nouveau_bo_map(res->bo, flags, nv->screen->client))
+ return NULL;
+ }
+ return (uint8_t *)res->bo->map + res->offset + offset;
+}
+
+
const struct u_resource_vtbl nouveau_buffer_vtbl =
{
u_default_resource_get_handle, /* get_handle */
@@ -387,18 +407,17 @@ nouveau_user_buffer_create(struct pipe_screen *pscreen, void *ptr,
/* Like download, but for GART buffers. Merge ? */
static INLINE boolean
-nouveau_buffer_data_fetch(struct nv04_resource *buf, struct nouveau_bo *bo,
- unsigned offset, unsigned size)
+nouveau_buffer_data_fetch(struct nouveau_context *nv, struct nv04_resource *buf,
+ struct nouveau_bo *bo, unsigned offset, unsigned size)
{
if (!buf->data) {
buf->data = MALLOC(size);
if (!buf->data)
return FALSE;
}
- if (nouveau_bo_map_range(bo, offset, size, NOUVEAU_BO_RD))
+ if (nouveau_bo_map(bo, NOUVEAU_BO_RD, nv->screen->client))
return FALSE;
- memcpy(buf->data, bo->map, size);
- nouveau_bo_unmap(bo);
+ memcpy(buf->data, (uint8_t *)bo->map + offset, size);
return TRUE;
}
@@ -420,20 +439,18 @@ nouveau_buffer_migrate(struct nouveau_context *nv,
if (new_domain == NOUVEAU_BO_GART && old_domain == 0) {
if (!nouveau_buffer_allocate(screen, buf, new_domain))
return FALSE;
- ret = nouveau_bo_map_range(buf->bo, buf->offset, size, NOUVEAU_BO_WR |
- NOUVEAU_BO_NOSYNC);
+ ret = nouveau_bo_map(buf->bo, 0, nv->screen->client);
if (ret)
return ret;
- memcpy(buf->bo->map, buf->data, size);
- nouveau_bo_unmap(buf->bo);
+ memcpy((uint8_t *)buf->bo->map + buf->offset, buf->data, size);
FREE(buf->data);
} else
if (old_domain != 0 && new_domain != 0) {
struct nouveau_mm_allocation *mm = buf->mm;
if (new_domain == NOUVEAU_BO_VRAM) {
/* keep a system memory copy of our data in case we hit a fallback */
- if (!nouveau_buffer_data_fetch(buf, buf->bo, buf->offset, size))
+ if (!nouveau_buffer_data_fetch(nv, buf, buf->bo, buf->offset, size))
return FALSE;
if (nouveau_mesa_debug)
debug_printf("migrating %u KiB to VRAM\n", size / 1024);
@@ -469,7 +486,8 @@ nouveau_buffer_migrate(struct nouveau_context *nv,
* the vertex indices ...
*/
boolean
-nouveau_user_buffer_upload(struct nv04_resource *buf,
+nouveau_user_buffer_upload(struct nouveau_context *nv,
+ struct nv04_resource *buf,
unsigned base, unsigned size)
{
struct nouveau_screen *screen = nouveau_screen(buf->base.screen);
@@ -481,12 +499,10 @@ nouveau_user_buffer_upload(struct nv04_resource *buf,
if (!nouveau_buffer_reallocate(screen, buf, NOUVEAU_BO_GART))
return FALSE;
- ret = nouveau_bo_map_range(buf->bo, buf->offset + base, size,
- NOUVEAU_BO_WR | NOUVEAU_BO_NOSYNC);
+ ret = nouveau_bo_map(buf->bo, 0, nv->screen->client);
if (ret)
return FALSE;
- memcpy(buf->bo->map, buf->data + base, size);
- nouveau_bo_unmap(buf->bo);
+ memcpy((uint8_t *)buf->bo->map + buf->offset + base, buf->data + base, size);
return TRUE;
}
@@ -28,6 +28,8 @@ struct nv04_resource {
struct pipe_resource base;
const struct u_resource_vtbl *vtbl;
+ uint64_t address; /* virtual address (nv50+) */
+
uint8_t *data;
struct nouveau_bo *bo;
uint32_t offset;
@@ -52,33 +54,9 @@ boolean
nouveau_buffer_migrate(struct nouveau_context *,
struct nv04_resource *, unsigned domain);
-/* XXX: wait for fence (atm only using this for vertex push) */
-static INLINE void *
-nouveau_resource_map_offset(struct nouveau_context *pipe,
- struct nv04_resource *res, uint32_t offset,
- uint32_t flags)
-{
- void *map;
-
- if ((res->domain == NOUVEAU_BO_VRAM) &&
- (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING))
- nouveau_buffer_download(pipe, res, 0, res->base.width0);
-
- if ((res->domain != NOUVEAU_BO_GART) ||
- (res->status & NOUVEAU_BUFFER_STATUS_USER_MEMORY))
- return res->data + offset;
-
- if (res->mm)
- flags |= NOUVEAU_BO_NOSYNC;
-
- if (nouveau_bo_map_range(res->bo, res->offset + offset,
- res->base.width0, flags))
- return NULL;
-
- map = res->bo->map;
- nouveau_bo_unmap(res->bo);
- return map;
-}
+void *
+nouveau_resource_map_offset(struct nouveau_context *, struct nv04_resource *,
+ uint32_t offset, uint32_t flags);
static INLINE void
nouveau_resource_unmap(struct nv04_resource *res)
@@ -108,7 +86,7 @@ nouveau_user_buffer_create(struct pipe_screen *screen, void *ptr,
unsigned bytes, unsigned usage);
boolean
-nouveau_user_buffer_upload(struct nv04_resource *, unsigned base,
- unsigned size);
+nouveau_user_buffer_upload(struct nouveau_context *, struct nv04_resource *,
+ unsigned base, unsigned size);
#endif
@@ -3,10 +3,14 @@
#include "pipe/p_context.h"
+struct nouveau_pushbuf;
+
struct nouveau_context {
struct pipe_context pipe;
struct nouveau_screen *screen;
+ struct nouveau_pushbuf *pushbuf;
+
boolean vbo_dirty;
boolean cb_dirty;
@@ -23,10 +23,9 @@
#include "util/u_double_list.h"
#include "nouveau_screen.h"
+#include "nouveau_winsys.h"
#include "nouveau_fence.h"
-#include "nouveau/nouveau_pushbuf.h"
-
#ifdef PIPE_OS_UNIX
#include <sched.h>
#endif
@@ -197,7 +196,7 @@ nouveau_fence_wait(struct nouveau_fence *fence)
nouveau_fence_new(screen, &screen->fence.current, FALSE);
}
if (fence->state < NOUVEAU_FENCE_STATE_FLUSHED)
- FIRE_RING(screen->channel);
+ nouveau_pushbuf_kick(screen->pushbuf, screen->pushbuf->channel);
do {
nouveau_fence_update(screen, FALSE);
Oops, something went wrong.

0 comments on commit 9ccdab4

Please sign in to comment.