#include <stdlib.h>
#include <assert.h>
#include <pipebuffer/pb_bufmgr.h>
+#include "util/u_double_list.h"
#include "r600.h"
struct radeon {
unsigned alignment;
unsigned map_count;
void *data;
+ struct list_head fencedlist;
+ boolean shared;
};
struct r600_bo {
int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo);
int radeon_bo_busy(struct radeon *radeon, struct radeon_bo *bo, uint32_t *domain);
void radeon_bo_pbmgr_flush_maps(struct pb_manager *_mgr);
+int radeon_bo_fencelist(struct radeon *radeon, struct radeon_bo **bolist, uint32_t num_bo);
+
/* radeon_bo_pb.c */
struct radeon_bo *radeon_bo_pb_get_bo(struct pb_buffer *_buf);
}
bo->handle = open_arg.handle;
bo->size = open_arg.size;
+ bo->shared = TRUE;
} else {
struct drm_radeon_gem_create args;
if (ptr) {
memcpy(bo->data, ptr, size);
}
+ LIST_INITHEAD(&bo->fencedlist);
return bo;
}
{
struct drm_gem_close args;
+ LIST_DEL(&bo->fencedlist);
radeon_bo_fixed_unmap(radeon, bo);
memset(&args, 0, sizeof(args));
args.handle = bo->handle;
struct drm_radeon_gem_wait_idle args;
int ret;
+ if (LIST_IS_EMPTY(&bo->fencedlist) && !bo->shared)
+ return 0;
+
/* Zero out args to make valgrind happy */
memset(&args, 0, sizeof(args));
args.handle = bo->handle;
struct drm_radeon_gem_busy args;
int ret;
+ if (LIST_IS_EMPTY(&bo->fencedlist) && !bo->shared)
+ return 0;
+
memset(&args, 0, sizeof(args));
args.handle = bo->handle;
args.domain = 0;
ret = drmCommandWriteRead(radeon->fd, DRM_RADEON_GEM_BUSY,
&args, sizeof(args));
+ if (ret == 0) {
+ struct radeon_bo *entry, *tent;
+ LIST_FOR_EACH_ENTRY_SAFE(entry, tent, &bo->fencedlist, fencedlist) {
+ LIST_DELINIT(&entry->fencedlist);
+ }
+ }
*domain = args.domain;
return ret;
}
+
+int radeon_bo_fencelist(struct radeon *radeon, struct radeon_bo **bolist,
+ uint32_t num_bo)
+{
+ struct radeon_bo *first;
+ int i;
+
+ first = bolist[0];
+
+ if (!LIST_IS_EMPTY(&first->fencedlist))
+ LIST_DELINIT(&first->fencedlist);
+
+ LIST_INITHEAD(&first->fencedlist);
+
+ for (i = 1; i < num_bo; i++) {
+ if (!LIST_IS_EMPTY(&bolist[i]->fencedlist))
+ LIST_DELINIT(&bolist[i]->fencedlist);
+
+ LIST_ADDTAIL(&bolist[i]->fencedlist, &first->fencedlist);
+ }
+ return 0;
+}