2 * Copyright © 2007 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
31 #include "dri_bufmgr.h"
33 /** @file dri_bufmgr.c
35 * Convenience functions for buffer management methods.
39 dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
40 unsigned int alignment)
42 return bufmgr->bo_alloc(bufmgr, name, size, alignment);
46 dri_bo_reference(dri_bo *bo)
48 bo->bufmgr->bo_reference(bo);
52 dri_bo_unreference(dri_bo *bo)
57 bo->bufmgr->bo_unreference(bo);
61 dri_bo_map(dri_bo *buf, int write_enable)
63 return buf->bufmgr->bo_map(buf, write_enable);
67 dri_bo_unmap(dri_bo *buf)
69 return buf->bufmgr->bo_unmap(buf);
73 dri_bo_subdata(dri_bo *bo, unsigned long offset,
74 unsigned long size, const void *data)
77 if (bo->bufmgr->bo_subdata)
78 return bo->bufmgr->bo_subdata(bo, offset, size, data);
79 if (size == 0 || data == NULL)
82 ret = dri_bo_map(bo, 1);
85 memcpy((unsigned char *)bo->virtual + offset, data, size);
91 dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
92 unsigned long size, void *data)
95 if (bo->bufmgr->bo_subdata)
96 return bo->bufmgr->bo_get_subdata(bo, offset, size, data);
98 if (size == 0 || data == NULL)
101 ret = dri_bo_map(bo, 0);
104 memcpy(data, (unsigned char *)bo->virtual + offset, size);
110 dri_bo_wait_rendering(dri_bo *bo)
112 bo->bufmgr->bo_wait_rendering(bo);
116 dri_bufmgr_destroy(dri_bufmgr *bufmgr)
118 bufmgr->destroy(bufmgr);
121 void *dri_process_relocs(dri_bo *batch_buf)
123 return batch_buf->bufmgr->process_relocs(batch_buf);
126 void dri_post_submit(dri_bo *batch_buf)
128 batch_buf->bufmgr->post_submit(batch_buf);
132 dri_bufmgr_set_debug(dri_bufmgr *bufmgr, int enable_debug)
134 bufmgr->debug = enable_debug;
138 dri_bufmgr_check_aperture_space(dri_bo *bo)
140 return bo->bufmgr->check_aperture_space(bo);