It saves a few libdrm calls and unnecessary flushes.
if (!checked[vbi]) {
vbuf = &r300->vertex_buffer[vbi];
- if (r300->context.is_resource_referenced(&r300->context,
- vbuf->buffer,
- 0, 0)) {
+ if (r300->rws->is_buffer_referenced(r300->rws,
+ r300_buffer(vbuf->buffer)->buf,
+ R300_REF_CS | R300_REF_HW)) {
/* It's a very bad idea to map it... */
return FALSE;
}
if (r300_buffer_is_user_buffer(buf))
return PIPE_UNREFERENCED;
- if (r300->rws->is_buffer_referenced(r300->rws, rbuf->buf))
+ if (r300->rws->is_buffer_referenced(r300->rws, rbuf->buf, R300_REF_CS))
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
return PIPE_UNREFERENCED;
struct r300_context *r300 = r300_context(context);
struct r300_texture *rtex = (struct r300_texture *)texture;
- if (r300->rws->is_buffer_referenced(r300->rws, rtex->buffer))
+ if (r300->rws->is_buffer_referenced(r300->rws, rtex->buffer, R300_REF_CS))
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
return PIPE_UNREFERENCED;
R300_VID_TEX3D_MIP_BUG,
};
+enum r300_reference_domain { /* bitfield */
+ R300_REF_CS = 1,
+ R300_REF_HW = 2
+};
+
struct r300_winsys_screen {
void (*destroy)(struct r300_winsys_screen *ws);
struct winsys_handle *whandle);
boolean (*is_buffer_referenced)(struct r300_winsys_screen *winsys,
- struct r300_winsys_buffer *buffer);
-
-
+ struct r300_winsys_buffer *buffer,
+ enum r300_reference_domain domain);
};
struct r300_winsys_screen *
boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
struct winsys_handle *whandle);
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf);
+boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf,
+ enum r300_reference_domain domain);
#endif
}
}
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf)
+boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf,
+ enum r300_reference_domain domain)
{
struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
- uint32_t domain;
+ uint32_t tmp;
+
+ if (domain & R300_REF_CS) {
+ if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
+ return TRUE;
+ }
+ }
+
+ if (domain & R300_REF_HW) {
+ if (radeon_bo_is_busy(buf->bo, &tmp)) {
+ return TRUE;
+ }
+ }
- return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) ||
- radeon_bo_is_busy(buf->bo, &domain));
+ return FALSE;
}
}
static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen *rws,
- struct r300_winsys_buffer *buf)
+ struct r300_winsys_buffer *buf,
+ enum r300_reference_domain domain)
{
struct pb_buffer *_buf = radeon_pb_buffer(buf);
- return radeon_drm_bufmgr_is_buffer_referenced(_buf);
+ return radeon_drm_bufmgr_is_buffer_referenced(_buf, domain);
}
static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws,