summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c')
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
index 4c34593..4b51a67 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
@@ -48,9 +48,12 @@ nvc0_hw_query_allocate(struct nvc0_context *nvc0, struct nvc0_query *q,
if (hq->mm) {
if (hq->state == NVC0_HW_QUERY_STATE_READY)
nouveau_mm_free(hq->mm);
- else
+ else {
+ pipe_mutex_lock(screen->base.push_mutex);
nouveau_fence_work(screen->base.fence.current,
nouveau_mm_free_work, hq->mm);
+ pipe_mutex_unlock(screen->base.push_mutex);
+ }
}
}
if (size) {
@@ -154,6 +157,7 @@ nvc0_hw_begin_query(struct nvc0_context *nvc0, struct nvc0_query *q)
}
hq->sequence++;
+ pipe_mutex_lock(nvc0->screen->base.push_mutex);
switch (q->type) {
case PIPE_QUERY_OCCLUSION_COUNTER:
case PIPE_QUERY_OCCLUSION_PREDICATE:
@@ -198,6 +202,7 @@ nvc0_hw_begin_query(struct nvc0_context *nvc0, struct nvc0_query *q)
default:
break;
}
+ pipe_mutex_unlock(nvc0->screen->base.push_mutex);
hq->state = NVC0_HW_QUERY_STATE_ACTIVE;
return ret;
}
@@ -221,6 +226,7 @@ nvc0_hw_end_query(struct nvc0_context *nvc0, struct nvc0_query *q)
}
hq->state = NVC0_HW_QUERY_STATE_ENDED;
+ pipe_mutex_lock(nvc0->screen->base.push_mutex);
switch (q->type) {
case PIPE_QUERY_OCCLUSION_COUNTER:
case PIPE_QUERY_OCCLUSION_PREDICATE:
@@ -276,6 +282,7 @@ nvc0_hw_end_query(struct nvc0_context *nvc0, struct nvc0_query *q)
default:
break;
}
+ pipe_mutex_unlock(nvc0->screen->base.push_mutex);
if (hq->is64bit)
nouveau_fence_ref(nvc0->screen->base.fence.current, &hq->fence);
}
@@ -298,16 +305,21 @@ nvc0_hw_get_query_result(struct nvc0_context *nvc0, struct nvc0_query *q,
nvc0_hw_query_update(nvc0->screen->base.client, q);
if (hq->state != NVC0_HW_QUERY_STATE_READY) {
+ pipe_mutex_lock(nvc0->screen->base.push_mutex);
if (!wait) {
if (hq->state != NVC0_HW_QUERY_STATE_FLUSHED) {
hq->state = NVC0_HW_QUERY_STATE_FLUSHED;
/* flush for silly apps that spin on GL_QUERY_RESULT_AVAILABLE */
PUSH_KICK(nvc0->base.pushbuf);
}
+ pipe_mutex_unlock(nvc0->screen->base.push_mutex);
return false;
}
- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->screen->base.client))
+ if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->screen->base.client)) {
+ pipe_mutex_unlock(nvc0->screen->base.push_mutex);
return false;
+ }
+ pipe_mutex_unlock(nvc0->screen->base.push_mutex);
NOUVEAU_DRV_STAT(&nvc0->screen->base, query_sync_count, 1);
}
hq->state = NVC0_HW_QUERY_STATE_READY;
@@ -374,6 +386,8 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0,
assert(!hq->funcs || !hq->funcs->get_query_result);
+ pipe_mutex_lock(nvc0->screen->base.push_mutex);
+
if (index == -1) {
/* TODO: Use a macro to write the availability of the query */
if (hq->state != NVC0_HW_QUERY_STATE_READY)
@@ -382,6 +396,7 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0,
nvc0->base.push_cb(&nvc0->base, buf, offset,
result_type >= PIPE_QUERY_TYPE_I64 ? 2 : 1,
ready);
+ pipe_mutex_unlock(nvc0->screen->base.push_mutex);
return;
}
@@ -469,6 +484,8 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0,
4 | NVC0_IB_ENTRY_1_NO_PREFETCH);
}
+ pipe_mutex_unlock(nvc0->screen->base.push_mutex);
+
if (buf->mm) {
nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence);
nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence_wr);