summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/r600/drm/r600_drm.c
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2011-01-11 14:29:33 -0500
committerJerome Glisse <jglisse@redhat.com>2011-01-11 14:34:25 -0500
commit63b9790a55038c262b57c846a5f7067ea33fc60f (patch)
treecd0b2aed9fff38657f4ac0e3a044fc9cab65b3d9 /src/gallium/winsys/r600/drm/r600_drm.c
parent483f5662225046d5a1e283a151cc85562f5057fb (diff)
r600g: move user fence into base radeon structure
This avoid any issue when context is free and we still try to access fence through radeon structure. Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Diffstat (limited to 'src/gallium/winsys/r600/drm/r600_drm.c')
-rw-r--r--src/gallium/winsys/r600/drm/r600_drm.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gallium/winsys/r600/drm/r600_drm.c b/src/gallium/winsys/r600/drm/r600_drm.c
index 36ec583cce..ee262c3ea5 100644
--- a/src/gallium/winsys/r600/drm/r600_drm.c
+++ b/src/gallium/winsys/r600/drm/r600_drm.c
@@ -30,6 +30,7 @@
#include <sys/ioctl.h>
#include "util/u_inlines.h"
#include "util/u_debug.h"
+#include <pipebuffer/pb_bufmgr.h>
#include "r600.h"
#include "r600_priv.h"
#include "r600_drm_public.h"
@@ -125,6 +126,18 @@ static int radeon_drm_get_tiling(struct radeon *radeon)
return 0;
}
+static int radeon_init_fence(struct radeon *radeon)
+{
+ radeon->fence = 1;
+ radeon->fence_bo = r600_bo(radeon, 4096, 0, 0, 0);
+ if (radeon->fence_bo == NULL) {
+ return -ENOMEM;
+ }
+ radeon->cfence = r600_bo_map(radeon, radeon->fence_bo, PB_USAGE_UNSYNCHRONIZED, NULL);
+ *radeon->cfence = 0;
+ return 0;
+}
+
static struct radeon *radeon_new(int fd, unsigned device)
{
struct radeon *radeon;
@@ -198,6 +211,11 @@ static struct radeon *radeon_new(int fd, unsigned device)
if (radeon->bomgr == NULL) {
return NULL;
}
+ r = radeon_init_fence(radeon);
+ if (r) {
+ radeon_decref(radeon);
+ return NULL;
+ }
return radeon;
}
@@ -214,6 +232,10 @@ struct radeon *radeon_decref(struct radeon *radeon)
return NULL;
}
+ if (radeon->fence_bo) {
+ r600_bo_reference(radeon, &radeon->fence_bo, NULL);
+ }
+
if (radeon->bomgr)
r600_bomgr_destroy(radeon->bomgr);