static boolean nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq, boolean wait, union pipe_query_result *result) { struct nv30_screen *screen = nv30_screen(pipe->screen); struct nv30_query *q = nv30_query(pq); volatile uint32_t *ntfy0 = nv30_ntfy(screen, q->qo[0]); volatile uint32_t *ntfy1 = nv30_ntfy(screen, q->qo[1]); uint64_t *res64 = &result->u64; if (ntfy1) { while (ntfy1[3] & 0xff000000) { if (!wait) return FALSE; } switch (q->type) { case PIPE_QUERY_TIMESTAMP: q->result = *(uint64_t *)&ntfy1[0]; break; case PIPE_QUERY_TIME_ELAPSED: q->result = *(uint64_t *)&ntfy1[0] - *(uint64_t *)&ntfy0[0]; break; default: q->result = ntfy1[2]; break; } nv30_query_object_del(screen, &q->qo[0]); nv30_query_object_del(screen, &q->qo[1]); } *res64 = q->result; return TRUE; }
static struct nv30_query_object * nv30_query_object_new(struct nv30_screen *screen) { struct nv30_query_object *oq, *qo = CALLOC_STRUCT(nv30_query_object); volatile uint32_t *ntfy; if (!qo) return NULL; /* allocate a new hw query object, if no hw objects left we need to * spin waiting for one to become free */ while (nouveau_heap_alloc(screen->query_heap, 32, NULL, &qo->hw)) { oq = LIST_FIRST_ENTRY(struct nv30_query_object, &screen->queries, list); nv30_query_object_del(screen, &oq); } LIST_ADDTAIL(&qo->list, &screen->queries); ntfy = nv30_ntfy(screen, qo); ntfy[0] = 0x00000000; ntfy[1] = 0x00000000; ntfy[2] = 0x00000000; ntfy[3] = 0x01000000; return qo; }
static boolean nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq, boolean wait, union pipe_query_result *result) { struct nv30_screen *screen = nv30_screen(pipe->screen); struct nv30_query *q = nv30_query(pq); volatile uint32_t *ntfy0 = nv30_ntfy(screen, q->qo[0]); volatile uint32_t *ntfy1 = nv30_ntfy(screen, q->qo[1]); if (ntfy1) { while (ntfy1[3] & 0xff000000) { if (!wait) return false; } switch (q->type) { case PIPE_QUERY_TIMESTAMP: q->result = *(uint64_t *)&ntfy1[0]; break; case PIPE_QUERY_TIME_ELAPSED: q->result = *(uint64_t *)&ntfy1[0] - *(uint64_t *)&ntfy0[0]; break; default: q->result = ntfy1[2]; break; } nv30_query_object_del(screen, &q->qo[0]); nv30_query_object_del(screen, &q->qo[1]); } if (q->type == PIPE_QUERY_OCCLUSION_PREDICATE || q->type == PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE) result->b = !!q->result; else result->u64 = q->result; return true; }