1 #include "pipe/p_context.h"
3 #include "nv40_context.h"
6 struct nouveau_resource
*object
;
12 static INLINE
struct nv40_query
*
13 nv40_query(struct pipe_query
*pipe
)
15 return (struct nv40_query
*)pipe
;
18 static struct pipe_query
*
19 nv40_query_create(struct pipe_context
*pipe
, unsigned query_type
)
23 q
= CALLOC(1, sizeof(struct nv40_query
));
26 return (struct pipe_query
*)q
;
30 nv40_query_destroy(struct pipe_context
*pipe
, struct pipe_query
*pq
)
32 struct nv40_context
*nv40
= nv40_context(pipe
);
33 struct nv40_query
*q
= nv40_query(pq
);
36 nv40
->nvws
->res_free(&q
->object
);
41 nv40_query_begin(struct pipe_context
*pipe
, struct pipe_query
*pq
)
43 struct nv40_context
*nv40
= nv40_context(pipe
);
44 struct nv40_query
*q
= nv40_query(pq
);
46 assert(q
->type
== PIPE_QUERY_OCCLUSION_COUNTER
);
48 if (nv40
->nvws
->res_alloc(nv40
->hw
->query_heap
, 1, NULL
, &q
->object
))
50 nv40
->nvws
->notifier_reset(nv40
->hw
->query
, q
->object
->start
);
52 BEGIN_RING(curie
, NV40TCL_QUERY_RESET
, 1);
54 BEGIN_RING(curie
, NV40TCL_QUERY_UNK17CC
, 1);
61 nv40_query_end(struct pipe_context
*pipe
, struct pipe_query
*pq
)
63 struct nv40_context
*nv40
= nv40_context(pipe
);
64 struct nv40_query
*q
= nv40_query(pq
);
66 BEGIN_RING(curie
, NV40TCL_QUERY_GET
, 1);
67 OUT_RING ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT
) |
68 ((q
->object
->start
* 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT
));
73 nv40_query_result(struct pipe_context
*pipe
, struct pipe_query
*pq
,
74 boolean wait
, uint64
*result
)
76 struct nv40_context
*nv40
= nv40_context(pipe
);
77 struct nv40_query
*q
= nv40_query(pq
);
78 struct nouveau_winsys
*nvws
= nv40
->nvws
;
80 assert(q
->object
&& q
->type
== PIPE_QUERY_OCCLUSION_COUNTER
);
85 status
= nvws
->notifier_status(nv40
->hw
->query
,
87 if (status
!= NV_NOTIFY_STATE_STATUS_COMPLETED
) {
90 nvws
->notifier_wait(nv40
->hw
->query
, q
->object
->start
,
91 NV_NOTIFY_STATE_STATUS_COMPLETED
,
95 q
->result
= nvws
->notifier_retval(nv40
->hw
->query
,
98 nvws
->res_free(&q
->object
);
106 nv40_init_query_functions(struct nv40_context
*nv40
)
108 nv40
->pipe
.create_query
= nv40_query_create
;
109 nv40
->pipe
.destroy_query
= nv40_query_destroy
;
110 nv40
->pipe
.begin_query
= nv40_query_begin
;
111 nv40
->pipe
.end_query
= nv40_query_end
;
112 nv40
->pipe
.get_query_result
= nv40_query_result
;