summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/r600/drm/radeon_ws_bo.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-09-16 20:22:09 +1000
committerDave Airlie <airlied@redhat.com>2010-09-17 10:57:49 +1000
commitf70f79f6f6027bdf2f7de09bb39e12a24420f338 (patch)
tree8ee84c9ddd557fddc10ee11837108eb23768235d /src/gallium/winsys/r600/drm/radeon_ws_bo.c
parentec9d838aa56d2c4bc5649d7c26ac61abb6c4b9bb (diff)
r600g: attempt to abstract kernel bos from pipe driver.
introduce an abstraction layer between kernel bos and the winsys BOs. this is to allow plugging in pb manager with minimal disruption to pipe driver.
Diffstat (limited to 'src/gallium/winsys/r600/drm/radeon_ws_bo.c')
-rw-r--r--src/gallium/winsys/r600/drm/radeon_ws_bo.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/gallium/winsys/r600/drm/radeon_ws_bo.c b/src/gallium/winsys/r600/drm/radeon_ws_bo.c
new file mode 100644
index 0000000000..c789f8780f
--- /dev/null
+++ b/src/gallium/winsys/r600/drm/radeon_ws_bo.c
@@ -0,0 +1,63 @@
+#include <malloc.h>
+#include "radeon_priv.h"
+
+struct radeon_ws_bo *radeon_ws_bo(struct radeon *radeon,
+ unsigned size, unsigned alignment)
+{
+ struct radeon_ws_bo *ws_bo = calloc(1, sizeof(struct radeon_ws_bo));
+
+ ws_bo->bo = radeon_bo(radeon, 0, size, alignment, NULL);
+ if (!ws_bo->bo) {
+ free(ws_bo);
+ return NULL;
+ }
+
+ pipe_reference_init(&ws_bo->reference, 1);
+ return ws_bo;
+}
+
+struct radeon_ws_bo *radeon_ws_bo_handle(struct radeon *radeon,
+ unsigned handle)
+{
+ struct radeon_ws_bo *ws_bo = calloc(1, sizeof(struct radeon_ws_bo));
+
+ ws_bo->bo = radeon_bo(radeon, handle, 0, 0, NULL);
+ if (!ws_bo->bo) {
+ free(ws_bo);
+ return NULL;
+ }
+ pipe_reference_init(&ws_bo->reference, 1);
+ return ws_bo;
+}
+
+void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo)
+{
+ radeon_bo_map(radeon, bo->bo);
+ return bo->bo->data;
+}
+
+void radeon_ws_bo_unmap(struct radeon *radeon, struct radeon_ws_bo *bo)
+{
+ radeon_bo_unmap(radeon, bo->bo);
+}
+
+static void radeon_ws_bo_destroy(struct radeon *radeon, struct radeon_ws_bo *bo)
+{
+ radeon_bo_reference(radeon, &bo->bo, NULL);
+ free(bo);
+}
+
+void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst,
+ struct radeon_ws_bo *src)
+{
+ struct radeon_ws_bo *old = *dst;
+ if (pipe_reference(&(*dst)->reference, &src->reference)) {
+ radeon_ws_bo_destroy(radeon, old);
+ }
+ *dst = src;
+}
+
+int radeon_ws_bo_wait(struct radeon *radeon, struct radeon_ws_bo *bo)
+{
+ return radeon_bo_wait(radeon, bo->bo);
+}