nouveau/fence: rework nouveau_fence_emit so we can call it on emitted fences

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10752>
This commit is contained in:
Karol Herbst 2021-05-07 15:01:18 +02:00 committed by Marge Bot
parent 060d055ac5
commit 54f285901d
2 changed files with 6 additions and 8 deletions

View file

@ -60,7 +60,9 @@ nouveau_fence_emit(struct nouveau_fence *fence)
{
struct nouveau_screen *screen = fence->screen;
assert(fence->state == NOUVEAU_FENCE_STATE_AVAILABLE);
assert(fence->state != NOUVEAU_FENCE_STATE_EMITTING);
if (fence->state >= NOUVEAU_FENCE_STATE_EMITTED)
return;
/* set this now, so that if fence.emit triggers a flush we don't recurse */
fence->state = NOUVEAU_FENCE_STATE_EMITTING;
@ -190,10 +192,6 @@ nouveau_fence_kick(struct nouveau_fence *fence)
if (fence->state < NOUVEAU_FENCE_STATE_EMITTED) {
PUSH_SPACE(screen->pushbuf, 8);
/* The space allocation might trigger a flush, which could emit the
* current fence. So check again.
*/
if (fence->state < NOUVEAU_FENCE_STATE_EMITTED)
nouveau_fence_emit(fence);
}

View file

@ -420,7 +420,7 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0,
/* If the fence guarding this query has not been emitted, that makes a lot
* of the following logic more complicated.
*/
if (hq->is64bit && hq->fence->state < NOUVEAU_FENCE_STATE_EMITTED)
if (hq->is64bit)
nouveau_fence_emit(hq->fence);
/* We either need to compute a 32- or 64-bit difference between 2 values,
@ -642,7 +642,7 @@ nvc0_hw_query_fifo_wait(struct nvc0_context *nvc0, struct nvc0_query *q)
unsigned offset = hq->offset;
/* ensure the query's fence has been emitted */
if (hq->is64bit && hq->fence->state < NOUVEAU_FENCE_STATE_EMITTED)
if (hq->is64bit)
nouveau_fence_emit(hq->fence);
PUSH_SPACE(push, 5);