summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/r600
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys/r600')
-rw-r--r--src/gallium/winsys/r600/drm/r600_bo.c4
-rw-r--r--src/gallium/winsys/r600/drm/r600_drm.c16
-rw-r--r--src/gallium/winsys/r600/drm/r600_priv.h10
-rw-r--r--src/gallium/winsys/r600/drm/radeon_bo.c77
4 files changed, 24 insertions, 83 deletions
diff --git a/src/gallium/winsys/r600/drm/r600_bo.c b/src/gallium/winsys/r600/drm/r600_bo.c
index 9e6c7cc7639..8cf1d809235 100644
--- a/src/gallium/winsys/r600/drm/r600_bo.c
+++ b/src/gallium/winsys/r600/drm/r600_bo.c
@@ -68,7 +68,7 @@ struct r600_bo *r600_bo(struct radeon *radeon,
initial_domain = RADEON_GEM_DOMAIN_VRAM;
break;
}
- rbo = radeon_bo(radeon, 0, size, alignment, initial_domain);
+ rbo = radeon_bo(radeon, 0, size, alignment, binding, initial_domain);
if (rbo == NULL) {
return NULL;
}
@@ -93,7 +93,7 @@ struct r600_bo *r600_bo_handle(struct radeon *radeon, struct winsys_handle *whan
struct radeon_bo *rbo;
unsigned tiling_flags;
- rbo = bo->bo = radeon_bo(radeon, whandle->handle, 0, 0, 0);
+ rbo = bo->bo = radeon_bo(radeon, whandle->handle, 0, 0, 0, 0);
if (rbo == NULL) {
free(bo);
return NULL;
diff --git a/src/gallium/winsys/r600/drm/r600_drm.c b/src/gallium/winsys/r600/drm/r600_drm.c
index 1cf905f2575..f2e46d3d0d9 100644
--- a/src/gallium/winsys/r600/drm/r600_drm.c
+++ b/src/gallium/winsys/r600/drm/r600_drm.c
@@ -233,18 +233,6 @@ static int radeon_init_fence(struct radeon *radeon)
return 0;
}
-#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-
-static unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
struct radeon *radeon_create(struct radeon_winsys *ws)
{
int r;
@@ -327,8 +315,6 @@ struct radeon *radeon_create(struct radeon_winsys *ws)
return NULL;
}
- radeon->bo_handles = util_hash_table_create(handle_hash, handle_compare);
- pipe_mutex_init(radeon->bo_handles_mutex);
return radeon;
}
@@ -337,8 +323,6 @@ struct radeon *radeon_destroy(struct radeon *radeon)
if (radeon == NULL)
return NULL;
- util_hash_table_destroy(radeon->bo_handles);
- pipe_mutex_destroy(radeon->bo_handles_mutex);
if (radeon->fence_bo) {
r600_bo_reference(radeon, &radeon->fence_bo, NULL);
}
diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h
index ee3df9c93f9..621c7eb2158 100644
--- a/src/gallium/winsys/r600/drm/r600_priv.h
+++ b/src/gallium/winsys/r600/drm/r600_priv.h
@@ -50,10 +50,6 @@ struct radeon {
unsigned num_tile_pipes;
unsigned backend_map;
boolean backend_map_valid;
-
- /* List of buffer handles and its mutex. */
- struct util_hash_table *bo_handles;
- pipe_mutex bo_handles_mutex;
};
/* these flags are used in register flags and added into block flags */
@@ -75,9 +71,10 @@ struct r600_reg {
#define BO_BOUND_TEXTURE 1
struct radeon_bo {
struct pipe_reference reference;
+ struct pb_buffer *buf;
+
unsigned handle;
unsigned size;
- unsigned alignment;
int map_count;
void *data;
struct list_head fencedlist;
@@ -87,7 +84,6 @@ struct radeon_bo {
struct r600_reloc *reloc;
unsigned reloc_id;
unsigned last_flush;
- unsigned name;
unsigned binding;
};
@@ -124,7 +120,7 @@ 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 initial_domain);
+ unsigned size, unsigned alignment, unsigned bind, unsigned initial_domain);
void radeon_bo_reference(struct radeon *radeon, struct radeon_bo **dst,
struct radeon_bo *src);
int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo);
diff --git a/src/gallium/winsys/r600/drm/radeon_bo.c b/src/gallium/winsys/r600/drm/radeon_bo.c
index 4e61c942a26..7ff4806c056 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo.c
@@ -26,6 +26,7 @@
#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>
@@ -68,22 +69,16 @@ static void radeon_bo_fixed_unmap(struct radeon *radeon, struct radeon_bo *bo)
}
}
+#include "state_tracker/drm_driver.h"
+
struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
- unsigned size, unsigned alignment, unsigned initial_domain)
+ unsigned size, unsigned alignment, unsigned bind,
+ unsigned initial_domain)
{
struct radeon_bo *bo;
- int r;
+ struct winsys_handle whandle = {};
+ whandle.handle = handle;
- if (handle) {
- pipe_mutex_lock(radeon->bo_handles_mutex);
- bo = util_hash_table_get(radeon->bo_handles,
- (void *)(uintptr_t)handle);
- if (bo) {
- struct radeon_bo *b = NULL;
- radeon_bo_reference(radeon, &b, bo);
- goto done;
- }
- }
bo = calloc(1, sizeof(*bo));
if (bo == NULL) {
return NULL;
@@ -91,69 +86,35 @@ struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
bo->size = size;
bo->handle = handle;
pipe_reference_init(&bo->reference, 1);
- bo->alignment = alignment;
LIST_INITHEAD(&bo->fencedlist);
if (handle) {
- struct drm_gem_open open_arg;
-
- memset(&open_arg, 0, sizeof(open_arg));
- open_arg.name = handle;
- r = drmIoctl(radeon->info.fd, DRM_IOCTL_GEM_OPEN, &open_arg);
- if (r != 0) {
- free(bo);
+ unsigned size;
+ bo->buf = radeon->ws->buffer_from_handle(radeon->ws, &whandle, NULL, &size);
+ if (!bo->buf) {
+ FREE(bo);
return NULL;
}
- bo->name = handle;
- bo->handle = open_arg.handle;
- bo->size = open_arg.size;
+ bo->handle = radeon->ws->trans_get_buffer_handle(bo->buf);
+ bo->size = size;
bo->shared = TRUE;
} else {
- struct drm_radeon_gem_create args = {};
-
- args.size = size;
- args.alignment = alignment;
- args.initial_domain = initial_domain;
- args.flags = 0;
- args.handle = 0;
- r = drmCommandWriteRead(radeon->info.fd, DRM_RADEON_GEM_CREATE,
- &args, sizeof(args));
- bo->handle = args.handle;
- if (r) {
- fprintf(stderr, "Failed to allocate :\n");
- fprintf(stderr, " size : %d bytes\n", size);
- fprintf(stderr, " alignment : %d bytes\n", alignment);
- free(bo);
+ bo->buf = radeon->ws->buffer_create(radeon->ws, size, alignment, bind, initial_domain);
+ if (!bo->buf) {
+ FREE(bo);
return NULL;
}
+ bo->handle = radeon->ws->trans_get_buffer_handle(bo->buf);
}
-
- if (handle)
- util_hash_table_set(radeon->bo_handles, (void *)(uintptr_t)handle, bo);
-done:
- if (handle)
- pipe_mutex_unlock(radeon->bo_handles_mutex);
-
return bo;
}
static void radeon_bo_destroy(struct radeon *radeon, struct radeon_bo *bo)
{
- struct drm_gem_close args;
-
- if (bo->name) {
- pipe_mutex_lock(radeon->bo_handles_mutex);
- util_hash_table_remove(radeon->bo_handles,
- (void *)(uintptr_t)bo->name);
- pipe_mutex_unlock(radeon->bo_handles_mutex);
- }
LIST_DEL(&bo->fencedlist);
radeon_bo_fixed_unmap(radeon, bo);
- memset(&args, 0, sizeof(args));
- args.handle = bo->handle;
- drmIoctl(radeon->info.fd, DRM_IOCTL_GEM_CLOSE, &args);
- memset(bo, 0, sizeof(struct radeon_bo));
- free(bo);
+ pb_reference(&bo->buf, NULL);
+ FREE(bo);
}
void radeon_bo_reference(struct radeon *radeon,