diff options
author | Marek Olšák <[email protected]> | 2011-08-04 06:11:45 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-08-16 09:15:11 +0200 |
commit | c6fec83726d3435a800f0a4e3ded89628b1a504f (patch) | |
tree | f18a0320b1c97e2d2698f834444b9c5c0ae748b2 | |
parent | 5229ba494b4b3f19085d13131a37626b914d4014 (diff) |
r600g: merge radeon_bo with r600_bo
Reviewed-by: Alex Deucher <[email protected]>
-rw-r--r-- | src/gallium/drivers/r600/r600.h | 2 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/Makefile | 1 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/SConscript | 1 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_bo.c | 28 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_hw_context.c | 21 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_priv.h | 34 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_bo.c | 80 |
7 files changed, 33 insertions, 134 deletions
diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h index 0c70fe2bb0a..a8626d1d2ec 100644 --- a/src/gallium/drivers/r600/r600.h +++ b/src/gallium/drivers/r600/r600.h @@ -242,7 +242,7 @@ struct r600_context { unsigned init_dwords; unsigned creloc; - struct radeon_bo **bo; + struct r600_bo **bo; u32 *pm4; unsigned pm4_cdwords; diff --git a/src/gallium/winsys/r600/drm/Makefile b/src/gallium/winsys/r600/drm/Makefile index e5b58d6cf87..5ad183d78ae 100644 --- a/src/gallium/winsys/r600/drm/Makefile +++ b/src/gallium/winsys/r600/drm/Makefile @@ -6,7 +6,6 @@ LIBNAME = r600winsys C_SOURCES = \ evergreen_hw_context.c \ - radeon_bo.c \ radeon_pciid.c \ r600_bo.c \ r600_drm.c \ diff --git a/src/gallium/winsys/r600/drm/SConscript b/src/gallium/winsys/r600/drm/SConscript index 3665b6eaeef..ca51b52ea72 100644 --- a/src/gallium/winsys/r600/drm/SConscript +++ b/src/gallium/winsys/r600/drm/SConscript @@ -4,7 +4,6 @@ env = env.Clone() r600_sources = [ 'evergreen_hw_context.c', - 'radeon_bo.c', 'radeon_pciid.c', 'r600_bo.c', 'r600_drm.c', diff --git a/src/gallium/winsys/r600/drm/r600_bo.c b/src/gallium/winsys/r600/drm/r600_bo.c index 184efcc0e9a..b40508665b7 100644 --- a/src/gallium/winsys/r600/drm/r600_bo.c +++ b/src/gallium/winsys/r600/drm/r600_bo.c @@ -33,7 +33,7 @@ struct r600_bo *r600_bo(struct radeon *radeon, unsigned binding, unsigned usage) { struct r600_bo *bo; - struct radeon_bo *rbo; + struct pb_buffer *pb; uint32_t initial_domain, domains; /* Staging resources particpate in transfers and blits only @@ -61,14 +61,15 @@ struct r600_bo *r600_bo(struct radeon *radeon, } } - rbo = radeon_bo(radeon, 0, size, alignment, binding, initial_domain); - if (rbo == NULL) { + pb = radeon->ws->buffer_create(radeon->ws, size, alignment, binding, initial_domain); + if (!pb) { return NULL; } bo = calloc(1, sizeof(struct r600_bo)); bo->domains = domains; - bo->bo = rbo; + bo->buf = pb; + bo->cs_buf = radeon->ws->buffer_get_cs_handle(pb); pipe_reference_init(&bo->reference, 1); return bo; @@ -77,17 +78,18 @@ struct r600_bo *r600_bo(struct radeon *radeon, struct r600_bo *r600_bo_handle(struct radeon *radeon, struct winsys_handle *whandle, unsigned *stride, unsigned *array_mode) { + struct pb_buffer *pb; struct r600_bo *bo = calloc(1, sizeof(struct r600_bo)); - struct radeon_bo *rbo; - rbo = bo->bo = radeon_bo(radeon, whandle->handle, 0, 0, 0, 0); - if (rbo == NULL) { + pb = bo->buf = radeon->ws->buffer_from_handle(radeon->ws, whandle, stride, NULL); + if (!pb) { free(bo); return NULL; } pipe_reference_init(&bo->reference, 1); bo->domains = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; + bo->cs_buf = radeon->ws->buffer_get_cs_handle(pb); if (stride) *stride = whandle->stride; @@ -95,7 +97,7 @@ struct r600_bo *r600_bo_handle(struct radeon *radeon, struct winsys_handle *whan if (array_mode) { enum radeon_bo_layout micro, macro; - radeon->ws->buffer_get_tiling(rbo->buf, µ, ¯o); + radeon->ws->buffer_get_tiling(bo->buf, µ, ¯o); if (macro == RADEON_LAYOUT_TILED) *array_mode = V_0280A0_ARRAY_2D_TILED_THIN1; @@ -109,22 +111,22 @@ struct r600_bo *r600_bo_handle(struct radeon *radeon, struct winsys_handle *whan void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, struct radeon_winsys_cs *cs, unsigned usage) { - return radeon->ws->buffer_map(bo->bo->buf, cs, usage); + return radeon->ws->buffer_map(bo->buf, cs, usage); } void r600_bo_unmap(struct radeon *radeon, struct r600_bo *bo) { - radeon->ws->buffer_unmap(bo->bo->buf); + radeon->ws->buffer_unmap(bo->buf); } void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo) { - radeon_bo_reference(radeon, &bo->bo, NULL); + pb_reference(&bo->buf, NULL); free(bo); } boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *bo, - unsigned stride, struct winsys_handle *whandle) + unsigned stride, struct winsys_handle *whandle) { - return radeon->ws->buffer_get_handle(bo->bo->buf, stride, whandle); + return radeon->ws->buffer_get_handle(bo->buf, stride, whandle); } diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c index b2da3eb0458..38713aad1fe 100644 --- a/src/gallium/winsys/r600/drm/r600_hw_context.c +++ b/src/gallium/winsys/r600/drm/r600_hw_context.c @@ -951,11 +951,8 @@ void r600_context_flush_all(struct r600_context *ctx, unsigned flush_flags) } void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags, - unsigned flush_mask, struct r600_bo *rbo) + unsigned flush_mask, struct r600_bo *bo) { - struct radeon_bo *bo; - - bo = rbo->bo; /* if bo has already been flushed */ if (!(~bo->last_flush & flush_flags)) { bo->last_flush &= flush_mask; @@ -987,11 +984,11 @@ void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags, } else { ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_SYNC, 3, ctx->predicate_drawing); ctx->pm4[ctx->pm4_cdwords++] = flush_flags; - ctx->pm4[ctx->pm4_cdwords++] = (bo->size + 255) >> 8; + ctx->pm4[ctx->pm4_cdwords++] = (bo->buf->base.size + 255) >> 8; ctx->pm4[ctx->pm4_cdwords++] = 0x00000000; ctx->pm4[ctx->pm4_cdwords++] = 0x0000000A; ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing); - ctx->pm4[ctx->pm4_cdwords++] = r600_context_bo_reloc(ctx, rbo); + ctx->pm4[ctx->pm4_cdwords++] = r600_context_bo_reloc(ctx, bo); } bo->last_flush = (bo->last_flush | flush_flags) & flush_mask; } @@ -1107,7 +1104,7 @@ void r600_context_pipe_state_set_resource(struct r600_context *ctx, struct r600_ if (state == NULL) { block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_RESOURCE_DIRTY); if (block->reloc[1].bo) - block->reloc[1].bo->bo->binding &= ~BO_BOUND_TEXTURE; + block->reloc[1].bo->binding &= ~BO_BOUND_TEXTURE; r600_bo_reference(ctx->radeon, &block->reloc[1].bo, NULL); r600_bo_reference(ctx->radeon, &block->reloc[2].bo, NULL); @@ -1130,11 +1127,11 @@ void r600_context_pipe_state_set_resource(struct r600_context *ctx, struct r600_ if (!dirty) { if (is_vertex) { - if (block->reloc[1].bo->bo->buf != state->bo[0]->bo->buf) + if (block->reloc[1].bo->buf != state->bo[0]->buf) dirty |= R600_BLOCK_STATUS_RESOURCE_DIRTY; } else { - if ((block->reloc[1].bo->bo->buf != state->bo[0]->bo->buf) || - (block->reloc[2].bo->bo->buf != state->bo[1]->bo->buf)) + if ((block->reloc[1].bo->buf != state->bo[0]->buf) || + (block->reloc[2].bo->buf != state->bo[1]->buf)) dirty |= R600_BLOCK_STATUS_RESOURCE_DIRTY; } } @@ -1150,7 +1147,7 @@ void r600_context_pipe_state_set_resource(struct r600_context *ctx, struct r600_ /* TEXTURE RESOURCE */ r600_bo_reference(ctx->radeon, &block->reloc[1].bo, state->bo[0]); r600_bo_reference(ctx->radeon, &block->reloc[2].bo, state->bo[1]); - state->bo[0]->bo->binding |= BO_BOUND_TEXTURE; + state->bo[0]->binding |= BO_BOUND_TEXTURE; } if (is_vertex) @@ -1515,7 +1512,7 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags) /* restart */ for (int i = 0; i < ctx->creloc; i++) { ctx->bo[i]->last_flush = 0; - radeon_bo_reference(ctx->radeon, &ctx->bo[i], NULL); + r600_bo_reference(ctx->radeon, &ctx->bo[i], NULL); } ctx->creloc = 0; ctx->pm4_dirty_cdwords = 0; diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h index 1f311c4d5e3..82deeb8496e 100644 --- a/src/gallium/winsys/r600/drm/r600_priv.h +++ b/src/gallium/winsys/r600/drm/r600_priv.h @@ -60,21 +60,15 @@ struct r600_reg { }; #define BO_BOUND_TEXTURE 1 -struct radeon_bo { - struct pipe_reference reference; - struct pb_buffer *buf; - struct radeon_winsys_cs_handle *cs_buf; - unsigned size; - - unsigned last_flush; - unsigned binding; -}; struct r600_bo { struct pipe_reference reference; /* this must be the first member for the r600_bo_reference inline to work */ /* DO NOT MOVE THIS ^ */ + struct pb_buffer *buf; + struct radeon_winsys_cs_handle *cs_buf; unsigned domains; - struct radeon_bo *bo; + unsigned last_flush; + unsigned binding; }; /* @@ -83,14 +77,6 @@ struct r600_bo { unsigned radeon_family_from_device(unsigned device); /* - * radeon_bo.c - */ -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); - -/* * r600_hw_context.c */ void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags, @@ -112,18 +98,14 @@ int r600_resource_init(struct r600_context *ctx, struct r600_range *range, unsig static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r600_bo *rbo) { - struct radeon_bo *bo = rbo->bo; - unsigned reloc_index; - - assert(bo != NULL); - - reloc_index = ctx->radeon->ws->cs_add_reloc(ctx->cs, bo->cs_buf, - rbo->domains, rbo->domains); + unsigned reloc_index = + ctx->radeon->ws->cs_add_reloc(ctx->cs, rbo->cs_buf, + rbo->domains, rbo->domains); if (reloc_index >= ctx->creloc) ctx->creloc = reloc_index+1; - radeon_bo_reference(ctx->radeon, &ctx->bo[reloc_index], bo); + r600_bo_reference(ctx->radeon, &ctx->bo[reloc_index], rbo); return reloc_index * 4; } diff --git a/src/gallium/winsys/r600/drm/radeon_bo.c b/src/gallium/winsys/r600/drm/radeon_bo.c deleted file mode 100644 index 1d3766e55b5..00000000000 --- a/src/gallium/winsys/r600/drm/radeon_bo.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2010 Jerome Glisse <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Jerome Glisse - */ -#define _FILE_OFFSET_BITS 64 -#include "r600_priv.h" -#include "util/u_hash_table.h" -#include "util/u_memory.h" -#include "radeon_drm.h" -#include "xf86drm.h" -#include <sys/mman.h> -#include <errno.h> - -#include "state_tracker/drm_driver.h" - -struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle, - unsigned size, unsigned alignment, unsigned bind, - unsigned initial_domain) -{ - struct radeon_bo *bo; - struct winsys_handle whandle = {}; - whandle.handle = handle; - - bo = calloc(1, sizeof(*bo)); - if (bo == NULL) { - return NULL; - } - pipe_reference_init(&bo->reference, 1); - - if (handle) { - bo->buf = radeon->ws->buffer_from_handle(radeon->ws, &whandle, NULL, &size); - } else { - bo->buf = radeon->ws->buffer_create(radeon->ws, size, alignment, bind, initial_domain); - } - if (!bo->buf) { - FREE(bo); - return NULL; - } - bo->cs_buf = radeon->ws->buffer_get_cs_handle(bo->buf); - bo->size = size; - return bo; -} - -static void radeon_bo_destroy(struct radeon *radeon, struct radeon_bo *bo) -{ - pb_reference(&bo->buf, NULL); - FREE(bo); -} - -void radeon_bo_reference(struct radeon *radeon, - struct radeon_bo **dst, - struct radeon_bo *src) -{ - struct radeon_bo *old = *dst; - if (pipe_reference(&(*dst)->reference, &src->reference)) { - radeon_bo_destroy(radeon, old); - } - *dst = src; -} |