diff options
author | Dave Airlie <airlied@redhat.com> | 2010-09-17 12:47:49 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-09-17 15:29:31 +1000 |
commit | 7c1fcc41be15b6d648f84c8c1870a3a00575a48f (patch) | |
tree | ae08a7619787a20116ef12fc836e2e4a3f568711 /src/gallium/winsys/r600/drm/radeon_ws_bo.c | |
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/r600/drm/radeon_ws_bo.c')
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_ws_bo.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/gallium/winsys/r600/drm/radeon_ws_bo.c b/src/gallium/winsys/r600/drm/radeon_ws_bo.c index c789f8780f..422e298a8d 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); } |