unsigned init_dwords;
unsigned creloc;
- struct radeon_bo **bo;
+ struct r600_bo **bo;
u32 *pm4;
unsigned pm4_cdwords;
C_SOURCES = \
evergreen_hw_context.c \
- radeon_bo.c \
radeon_pciid.c \
r600_bo.c \
r600_drm.c \
r600_sources = [
'evergreen_hw_context.c',
- 'radeon_bo.c',
'radeon_pciid.c',
'r600_bo.c',
'r600_drm.c',
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
}
}
- 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;
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;
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;
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);
}
}
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;
} 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;
}
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);
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;
}
}
/* 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)
/* 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;
};
#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;
};
/*
*/
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
*/
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;
}
+++ /dev/null
-/*
- * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
- *
- * 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;
-}