X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=inline;f=src%2Fgallium%2Fdrivers%2Fnvfx%2Fnvfx_query.c;h=3cd6bf1e477d6870a96afecdf5ed90779549322f;hb=1465dc26a540e2b6f8a055cf0ab48f774a3775bf;hp=acbaf75a2368a6c0d15a250379294e81870d9231;hpb=f0f04cd12db156ec53b7ea46fae27199af121f90;p=mesa.git diff --git a/src/gallium/drivers/nvfx/nvfx_query.c b/src/gallium/drivers/nvfx/nvfx_query.c index acbaf75a236..3cd6bf1e477 100644 --- a/src/gallium/drivers/nvfx/nvfx_query.c +++ b/src/gallium/drivers/nvfx/nvfx_query.c @@ -3,6 +3,7 @@ #include "nvfx_context.h" struct nvfx_query { + struct list_head list; struct nouveau_resource *object; unsigned type; boolean ready; @@ -23,6 +24,8 @@ nvfx_query_create(struct pipe_context *pipe, unsigned query_type) q = CALLOC(1, sizeof(struct nvfx_query)); q->type = query_type; + assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER); + return (struct pipe_query *)q; } @@ -32,7 +35,10 @@ nvfx_query_destroy(struct pipe_context *pipe, struct pipe_query *pq) struct nvfx_query *q = nvfx_query(pq); if (q->object) + { nouveau_resource_free(&q->object); + LIST_DEL(&q->list); + } FREE(q); } @@ -44,54 +50,67 @@ nvfx_query_begin(struct pipe_context *pipe, struct pipe_query *pq) struct nvfx_screen *screen = nvfx->screen; struct nouveau_channel *chan = screen->base.channel; struct nouveau_grobj *eng3d = screen->eng3d; + uint64_t tmp; - assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER); + assert(!nvfx->query); /* Happens when end_query() is called, then another begin_query() * without querying the result in-between. For now we'll wait for * the existing query to notify completion, but it could be better. */ - if (q->object) { - uint64_t tmp; + if (q->object) pipe->get_query_result(pipe, pq, 1, &tmp); + + while (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object)) + { + struct nvfx_query* oldestq; + assert(!LIST_IS_EMPTY(&nvfx->screen->query_list)); + oldestq = LIST_ENTRY(struct nvfx_query, nvfx->screen->query_list.next, list); + pipe->get_query_result(pipe, (struct pipe_query*)oldestq, 1, &tmp); } - if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object)) - assert(0); + LIST_ADDTAIL(&q->list, &nvfx->screen->query_list); + nouveau_notifier_reset(nvfx->screen->query, q->object->start); - BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1); - OUT_RING (chan, 1); - BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1); - OUT_RING (chan, 1); + BEGIN_RING(chan, eng3d, NV30_3D_QUERY_RESET, 1); + OUT_RING(chan, 1); + BEGIN_RING(chan, eng3d, NV30_3D_QUERY_ENABLE, 1); + OUT_RING(chan, 1); q->ready = FALSE; + + nvfx->query = pq; } static void nvfx_query_end(struct pipe_context *pipe, struct pipe_query *pq) { struct nvfx_context *nvfx = nvfx_context(pipe); - struct nvfx_screen *screen = nvfx->screen; - struct nouveau_channel *chan = screen->base.channel; - struct nouveau_grobj *eng3d = screen->eng3d; + struct nouveau_channel *chan = nvfx->screen->base.channel; + struct nouveau_grobj *eng3d = nvfx->screen->eng3d; struct nvfx_query *q = nvfx_query(pq); - BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1); - OUT_RING (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) | - ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT)); + assert(nvfx->query == pq); + + BEGIN_RING(chan, eng3d, NV30_3D_QUERY_GET, 1); + OUT_RING (chan, (0x01 << NV30_3D_QUERY_GET_UNK24__SHIFT) | + ((q->object->start * 32) << NV30_3D_QUERY_GET_OFFSET__SHIFT)); + BEGIN_RING(chan, eng3d, NV30_3D_QUERY_ENABLE, 1); + OUT_RING(chan, 0); FIRE_RING(chan); + + nvfx->query = 0; } static boolean nvfx_query_result(struct pipe_context *pipe, struct pipe_query *pq, - boolean wait, uint64_t *result) + boolean wait, void *vresult) { + uint64_t *result = (uint64_t *)vresult; struct nvfx_context *nvfx = nvfx_context(pipe); struct nvfx_query *q = nvfx_query(pq); - assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER); - if (!q->ready) { unsigned status; @@ -110,6 +129,7 @@ nvfx_query_result(struct pipe_context *pipe, struct pipe_query *pq, q->object->start); q->ready = TRUE; nouveau_resource_free(&q->object); + LIST_DEL(&q->list); } *result = q->result;