-#include "radeon_priv.h"
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_double_list.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
+/*
+ * Copyright 2010 Dave Airlie
+ *
+ * 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:
+ * Dave Airlie
+ */
+#include <util/u_inlines.h>
+#include <util/u_memory.h>
+#include <util/u_double_list.h>
+#include <pipebuffer/pb_buffer.h>
+#include <pipebuffer/pb_bufmgr.h>
+#include "r600_priv.h"
struct radeon_bo_pb {
struct pb_buffer b;
{
struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
- LIST_DEL(&buf->maplist);
-
- if (buf->bo->data != NULL) {
+ /* If this buffer is on the list of buffers to unmap,
+ * do the unmapping now.
+ */
+ if (!LIST_IS_EMPTY(&buf->maplist))
radeon_bo_unmap(buf->mgr->radeon, buf->bo);
- }
+
+ LIST_DEL(&buf->maplist);
radeon_bo_reference(buf->mgr->radeon, &buf->bo, NULL);
FREE(buf);
}
struct pipe_context *pctx = ctx;
if (flags & PB_USAGE_UNSYNCHRONIZED) {
- if (!buf->bo->data && radeon_bo_map(buf->mgr->radeon, buf->bo)) {
+ if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
}
LIST_DELINIT(&buf->maplist);
uint32_t domain;
if (radeon_bo_busy(buf->mgr->radeon, buf->bo, &domain))
return NULL;
- }
-
- if (buf->bo->data != NULL) {
- if (radeon_bo_wait(buf->mgr->radeon, buf->bo)) {
- return NULL;
- }
- } else {
if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
}
- if (radeon_bo_wait(buf->mgr->radeon, buf->bo)) {
- radeon_bo_unmap(buf->mgr->radeon, buf->bo);
- return NULL;
- }
+ goto out;
}
+ if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
+ return NULL;
+ }
+ if (radeon_bo_wait(buf->mgr->radeon, buf->bo)) {
+ radeon_bo_unmap(buf->mgr->radeon, buf->bo);
+ return NULL;
+ }
+out:
LIST_DELINIT(&buf->maplist);
return buf->bo->data;
}
struct radeon_bo_pb *bo;
struct radeon_bo *hw_bo;
- hw_bo = radeon_bo(radeon, handle, 0, 0, NULL);
+ hw_bo = radeon_bo(radeon, handle, 0, 0);
if (hw_bo == NULL)
return NULL;
struct radeon_bo_pbmgr *mgr = radeon_bo_pbmgr(_mgr);
struct radeon *radeon = mgr->radeon;
struct radeon_bo_pb *bo;
- uint32_t domain;
bo = CALLOC_STRUCT(radeon_bo_pb);
if (!bo)
LIST_INITHEAD(&bo->maplist);
- bo->bo = radeon_bo(radeon, 0, size,
- desc->alignment, NULL);
+ bo->bo = radeon_bo(radeon, 0, size, desc->alignment);
if (bo->bo == NULL)
goto error2;
return &bo->b;