r600g: merge radeon_bo with r600_bo
authorMarek Olšák <maraeo@gmail.com>
Thu, 4 Aug 2011 04:11:45 +0000 (06:11 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 16 Aug 2011 07:15:11 +0000 (09:15 +0200)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/drivers/r600/r600.h
src/gallium/winsys/r600/drm/Makefile
src/gallium/winsys/r600/drm/SConscript
src/gallium/winsys/r600/drm/r600_bo.c
src/gallium/winsys/r600/drm/r600_hw_context.c
src/gallium/winsys/r600/drm/r600_priv.h
src/gallium/winsys/r600/drm/radeon_bo.c [deleted file]

index 0c70fe2bb0ac2814a45fdfd736ddac7f840ca51f..a8626d1d2ec19c2d2d9a3d1648aca91d4f4ec84f 100644 (file)
@@ -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;
index e5b58d6cf8784b3f9ee7f32d1e6ce2652ffad74a..5ad183d78ae485e39ecfe5e26759fe959643e4e4 100644 (file)
@@ -6,7 +6,6 @@ LIBNAME = r600winsys
 
 C_SOURCES = \
        evergreen_hw_context.c \
-       radeon_bo.c \
        radeon_pciid.c \
        r600_bo.c \
        r600_drm.c \
index 3665b6eaeefc132e7e63357cd626d8eed7400ddc..ca51b52ea7233892301924de5f3645c3587152df 100644 (file)
@@ -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',
index 184efcc0e9a6a3d266de53bc6d3c9370e57ea656..b40508665b7b7b5dc7753a9e0ecb1bf6519de128 100644 (file)
@@ -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, &micro, &macro);
+               radeon->ws->buffer_get_tiling(bo->buf, &micro, &macro);
 
                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);
 }
index b2da3eb0458381842f96c9ef4f0b7e237b3730ee..38713aad1fec15ae0e32b887f491093c1a99e6b2 100644 (file)
@@ -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;
index 1f311c4d5e3e0c75a321dfd3aa8a41cd7557fc73..82deeb8496e188cf4f621afd90a92131312305ee 100644 (file)
@@ -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;
 };
 
 /*
@@ -82,14 +76,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
  */
@@ -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 (file)
index 1d3766e..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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;
-}