diff options
author | Marek Olšák <[email protected]> | 2011-08-04 04:27:48 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-08-16 09:15:11 +0200 |
commit | ab630b5768b0bfa4d7729d110ce4fb8f42e0cfb9 (patch) | |
tree | 7d0a55269acdcd9a79c8aeb93abf982ec6de02cd /src/gallium/winsys/r600/drm | |
parent | e2e1dc9e66ff348caa97b7b35e558d75c6cc6899 (diff) |
r600g: use buffer_map/unmap from radeon_winsys
This also drops the unneeded bo_busy/wait functions.
Reviewed-by: Alex Deucher <[email protected]>
Diffstat (limited to 'src/gallium/winsys/r600/drm')
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_bo.c | 40 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_hw_context.c | 10 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_priv.h | 27 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_bo.c | 69 |
4 files changed, 10 insertions, 136 deletions
diff --git a/src/gallium/winsys/r600/drm/r600_bo.c b/src/gallium/winsys/r600/drm/r600_bo.c index 0b2a9aabac3..184efcc0e9a 100644 --- a/src/gallium/winsys/r600/drm/r600_bo.c +++ b/src/gallium/winsys/r600/drm/r600_bo.c @@ -107,48 +107,14 @@ struct r600_bo *r600_bo_handle(struct radeon *radeon, struct winsys_handle *whan return bo; } -void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, void *ctx) +void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, struct radeon_winsys_cs *cs, unsigned usage) { - struct pipe_context *pctx = ctx; - - if (usage & PIPE_TRANSFER_UNSYNCHRONIZED) { - radeon_bo_map(radeon, bo->bo); - return (uint8_t *) bo->bo->data; - } - - if (p_atomic_read(&bo->bo->reference.count) > 1) { - if (usage & PIPE_TRANSFER_DONTBLOCK) { - return NULL; - } - if (ctx) { - pctx->flush(pctx, NULL); - } - } - - if (usage & PIPE_TRANSFER_DONTBLOCK) { - uint32_t domain; - - if (radeon_bo_busy(radeon, bo->bo, &domain)) - return NULL; - if (radeon_bo_map(radeon, bo->bo)) { - return NULL; - } - goto out; - } - - radeon_bo_map(radeon, bo->bo); - if (radeon_bo_wait(radeon, bo->bo)) { - radeon_bo_unmap(radeon, bo->bo); - return NULL; - } - -out: - return (uint8_t *) bo->bo->data; + return radeon->ws->buffer_map(bo->bo->buf, cs, usage); } void r600_bo_unmap(struct radeon *radeon, struct r600_bo *bo) { - radeon_bo_unmap(radeon, bo->bo); + radeon->ws->buffer_unmap(bo->bo->buf); } void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo) diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c index 760bfc591c0..0ebb5ed0385 100644 --- a/src/gallium/winsys/r600/drm/r600_hw_context.c +++ b/src/gallium/winsys/r600/drm/r600_hw_context.c @@ -74,7 +74,7 @@ void r600_get_backend_mask(struct r600_context *ctx) goto err; /* initialize buffer with zeroes */ - results = r600_bo_map(ctx->radeon, buffer, PB_USAGE_CPU_WRITE, NULL); + results = r600_bo_map(ctx->radeon, buffer, ctx->cs, PIPE_TRANSFER_WRITE); if (results) { memset(results, 0, ctx->max_db * 4 * 4); r600_bo_unmap(ctx->radeon, buffer); @@ -92,7 +92,7 @@ void r600_get_backend_mask(struct r600_context *ctx) r600_context_flush(ctx, 0); /* analyze results */ - results = r600_bo_map(ctx->radeon, buffer, PB_USAGE_CPU_READ, NULL); + results = r600_bo_map(ctx->radeon, buffer, ctx->cs, PIPE_TRANSFER_READ); if (results) { for(i = 0; i < ctx->max_db; i++) { /* at least highest bit will be set if backend is used */ @@ -1576,9 +1576,9 @@ static boolean r600_query_result(struct r600_context *ctx, struct r600_query *qu u32 *results, *current_result; if (wait) - results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_READ, NULL); + results = r600_bo_map(ctx->radeon, query->buffer, ctx->cs, PIPE_TRANSFER_READ); else - results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_DONTBLOCK | PIPE_TRANSFER_READ, NULL); + results = r600_bo_map(ctx->radeon, query->buffer, ctx->cs, PIPE_TRANSFER_DONTBLOCK | PIPE_TRANSFER_READ); if (!results) return FALSE; @@ -1646,7 +1646,7 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query) u32 *results; int i; - results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_WRITE, NULL); + results = r600_bo_map(ctx->radeon, query->buffer, ctx->cs, PIPE_TRANSFER_WRITE); if (results) { results = (u32*)((char*)results + query->results_end); memset(results, 0, query->result_size); diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h index 952f91df89a..90860f4e31b 100644 --- a/src/gallium/winsys/r600/drm/r600_priv.h +++ b/src/gallium/winsys/r600/drm/r600_priv.h @@ -66,8 +66,6 @@ struct radeon_bo { struct radeon_winsys_cs_handle *cs_buf; unsigned handle; unsigned size; - int map_count; - void *data; unsigned last_flush; unsigned binding; @@ -92,9 +90,6 @@ struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle, unsigned size, unsigned alignment, unsigned bind, unsigned initial_domain); void radeon_bo_reference(struct radeon *radeon, struct radeon_bo **dst, struct radeon_bo *src); -int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo); -int radeon_bo_busy(struct radeon *radeon, struct radeon_bo *bo, uint32_t *domain); -int radeon_bo_fixed_map(struct radeon *radeon, struct radeon_bo *bo); /* * r600_hw_context.c @@ -123,8 +118,8 @@ static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r6 assert(bo != NULL); - reloc_index = - ctx->radeon->ws->cs_add_reloc(ctx->cs, bo->cs_buf, rbo->domains, rbo->domains); + reloc_index = ctx->radeon->ws->cs_add_reloc(ctx->cs, bo->cs_buf, + rbo->domains, rbo->domains); if (reloc_index >= ctx->creloc) ctx->creloc = reloc_index+1; @@ -138,22 +133,4 @@ static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r6 */ void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo); - -/* - * radeon_bo.c - */ -static inline int radeon_bo_map(struct radeon *radeon, struct radeon_bo *bo) -{ - if (bo->map_count == 0 && !bo->data) - return radeon_bo_fixed_map(radeon, bo); - bo->map_count++; - return 0; -} - -static inline void radeon_bo_unmap(struct radeon *radeon, struct radeon_bo *bo) -{ - bo->map_count--; - assert(bo->map_count >= 0); -} - #endif diff --git a/src/gallium/winsys/r600/drm/radeon_bo.c b/src/gallium/winsys/r600/drm/radeon_bo.c index f2f53a14a58..14f8d340d67 100644 --- a/src/gallium/winsys/r600/drm/radeon_bo.c +++ b/src/gallium/winsys/r600/drm/radeon_bo.c @@ -32,43 +32,6 @@ #include <sys/mman.h> #include <errno.h> -int radeon_bo_fixed_map(struct radeon *radeon, struct radeon_bo *bo) -{ - struct drm_radeon_gem_mmap args; - void *ptr; - int r; - - /* Zero out args to make valgrind happy */ - memset(&args, 0, sizeof(args)); - args.handle = bo->handle; - args.offset = 0; - args.size = (uint64_t)bo->size; - r = drmCommandWriteRead(radeon->info.fd, DRM_RADEON_GEM_MMAP, - &args, sizeof(args)); - if (r) { - fprintf(stderr, "error mapping %p 0x%08X (error = %d)\n", - bo, bo->handle, r); - return r; - } - ptr = mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED, radeon->info.fd, args.addr_ptr); - if (ptr == MAP_FAILED) { - fprintf(stderr, "%s failed to map bo\n", __func__); - return -errno; - } - bo->data = ptr; - - bo->map_count++; - return 0; -} - -static void radeon_bo_fixed_unmap(struct radeon *radeon, struct radeon_bo *bo) -{ - if (bo->data) { - munmap(bo->data, bo->size); - bo->data = NULL; - } -} - #include "state_tracker/drm_driver.h" struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle, @@ -102,7 +65,6 @@ struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle, static void radeon_bo_destroy(struct radeon *radeon, struct radeon_bo *bo) { - radeon_bo_fixed_unmap(radeon, bo); pb_reference(&bo->buf, NULL); FREE(bo); } @@ -117,34 +79,3 @@ void radeon_bo_reference(struct radeon *radeon, } *dst = src; } - -int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo) -{ - struct drm_radeon_gem_wait_idle args; - int ret; - - /* Zero out args to make valgrind happy */ - memset(&args, 0, sizeof(args)); - args.handle = bo->handle; - do { - ret = drmCommandWriteRead(radeon->info.fd, DRM_RADEON_GEM_WAIT_IDLE, - &args, sizeof(args)); - } while (ret == -EBUSY); - return ret; -} - -int radeon_bo_busy(struct radeon *radeon, struct radeon_bo *bo, uint32_t *domain) -{ - struct drm_radeon_gem_busy args; - int ret; - - memset(&args, 0, sizeof(args)); - args.handle = bo->handle; - args.domain = 0; - - ret = drmCommandWriteRead(radeon->info.fd, DRM_RADEON_GEM_BUSY, - &args, sizeof(args)); - - *domain = args.domain; - return ret; -} |