diff options
author | Dave Airlie <[email protected]> | 2010-09-17 12:47:49 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2010-09-17 15:29:31 +1000 |
commit | 7c1fcc41be15b6d648f84c8c1870a3a00575a48f (patch) | |
tree | ae08a7619787a20116ef12fc836e2e4a3f568711 /src/gallium/winsys | |
parent | 0dbcf3b014ff05843bc71235652cd4a0e089bbc9 (diff) |
r600g: move constant buffer creation behind winsys abstraction.
this paves the way for moving to pb bufmgrs now.
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon.c | 5 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_ctx.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_priv.h | 2 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_ws_bo.c | 43 |
4 files changed, 42 insertions, 10 deletions
diff --git a/src/gallium/winsys/r600/drm/radeon.c b/src/gallium/winsys/r600/drm/radeon.c index ccf60605ed8..2135b07ab63 100644 --- a/src/gallium/winsys/r600/drm/radeon.c +++ b/src/gallium/winsys/r600/drm/radeon.c @@ -29,6 +29,11 @@ enum radeon_family radeon_get_family(struct radeon *radeon) return radeon->family; } +void radeon_set_mem_constant(struct radeon *radeon, boolean state) +{ + radeon->use_mem_constant = state; +} + static int radeon_get_device(struct radeon *radeon) { struct drm_radeon_info info; diff --git a/src/gallium/winsys/r600/drm/radeon_ctx.c b/src/gallium/winsys/r600/drm/radeon_ctx.c index d6e58451b85..a57163be03e 100644 --- a/src/gallium/winsys/r600/drm/radeon_ctx.c +++ b/src/gallium/winsys/r600/drm/radeon_ctx.c @@ -360,7 +360,7 @@ void radeon_ctx_dump_bof(struct radeon_ctx *ctx, const char *file) goto out_err; bof_decref(handle); handle = NULL; - data = radeon_ws_bo_map(ctx->radeon, ctx->bo[i]); + data = radeon_ws_bo_map(ctx->radeon, ctx->bo[i], 0, NULL); blob = bof_blob(ctx->bo[i]->bo->size, data); radeon_ws_bo_unmap(ctx->radeon, ctx->bo[i]); if (blob == NULL) diff --git a/src/gallium/winsys/r600/drm/radeon_priv.h b/src/gallium/winsys/r600/drm/radeon_priv.h index 6bd8d9850f5..49fe1a6ead1 100644 --- a/src/gallium/winsys/r600/drm/radeon_priv.h +++ b/src/gallium/winsys/r600/drm/radeon_priv.h @@ -86,11 +86,13 @@ struct radeon { unsigned nstype; struct radeon_stype_info *stype; unsigned max_states; + boolean use_mem_constant; /* true for evergreen */ }; struct radeon_ws_bo { struct pipe_reference reference; struct radeon_bo *bo; + struct pb_buffer *pb; }; extern struct radeon *radeon_new(int fd, unsigned device); diff --git a/src/gallium/winsys/r600/drm/radeon_ws_bo.c b/src/gallium/winsys/r600/drm/radeon_ws_bo.c index c789f8780f9..422e298a8db 100644 --- a/src/gallium/winsys/r600/drm/radeon_ws_bo.c +++ b/src/gallium/winsys/r600/drm/radeon_ws_bo.c @@ -1,15 +1,28 @@ #include <malloc.h> +#include <pipe/p_screen.h> +#include <pipebuffer/pb_bufmgr.h> #include "radeon_priv.h" struct radeon_ws_bo *radeon_ws_bo(struct radeon *radeon, - unsigned size, unsigned alignment) + unsigned size, unsigned alignment, unsigned usage) { struct radeon_ws_bo *ws_bo = calloc(1, sizeof(struct radeon_ws_bo)); + struct pb_desc desc; - ws_bo->bo = radeon_bo(radeon, 0, size, alignment, NULL); - if (!ws_bo->bo) { - free(ws_bo); - return NULL; + if (radeon->use_mem_constant && (usage & PIPE_BIND_CONSTANT_BUFFER)) { + desc.alignment = alignment; + desc.usage = usage; + ws_bo->pb = pb_malloc_buffer_create(size, &desc); + if (ws_bo->pb == NULL) { + free(ws_bo); + return NULL; + } + } else { + ws_bo->bo = radeon_bo(radeon, 0, size, alignment, NULL); + if (!ws_bo->bo) { + free(ws_bo); + return NULL; + } } pipe_reference_init(&ws_bo->reference, 1); @@ -30,20 +43,28 @@ struct radeon_ws_bo *radeon_ws_bo_handle(struct radeon *radeon, return ws_bo; } -void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo) +void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo, unsigned usage, void *ctx) { + if (bo->pb) + return pb_map(bo->pb, usage, ctx); radeon_bo_map(radeon, bo->bo); return bo->bo->data; } void radeon_ws_bo_unmap(struct radeon *radeon, struct radeon_ws_bo *bo) { - radeon_bo_unmap(radeon, bo->bo); + if (bo->pb) + pb_unmap(bo->pb); + else + radeon_bo_unmap(radeon, bo->bo); } static void radeon_ws_bo_destroy(struct radeon *radeon, struct radeon_ws_bo *bo) { - radeon_bo_reference(radeon, &bo->bo, NULL); + if (bo->pb) + pb_reference(&bo->pb, NULL); + else + radeon_bo_reference(radeon, &bo->bo, NULL); free(bo); } @@ -51,6 +72,7 @@ void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst, struct radeon_ws_bo *src) { struct radeon_ws_bo *old = *dst; + if (pipe_reference(&(*dst)->reference, &src->reference)) { radeon_ws_bo_destroy(radeon, old); } @@ -59,5 +81,8 @@ void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst, int radeon_ws_bo_wait(struct radeon *radeon, struct radeon_ws_bo *bo) { - return radeon_bo_wait(radeon, bo->bo); + if (bo->pb) + return 0; + else + return radeon_bo_wait(radeon, bo->bo); } |