1 #include "pipe/p_context.h"
2 #include "pipe/p_util.h"
4 #include "nv30_context.h"
7 struct nouveau_resource
*object
;
13 static inline struct nv30_query
*
14 nv30_query(struct pipe_query
*pipe
)
16 return (struct nv30_query
*)pipe
;
19 static struct pipe_query
*
20 nv30_query_create(struct pipe_context
*pipe
, unsigned query_type
)
24 q
= CALLOC(1, sizeof(struct nv30_query
));
27 return (struct pipe_query
*)q
;
31 nv30_query_destroy(struct pipe_context
*pipe
, struct pipe_query
*pq
)
33 struct nv30_context
*nv30
= nv30_context(pipe
);
34 struct nv30_query
*q
= nv30_query(pq
);
37 nv30
->nvws
->res_free(&q
->object
);
42 nv30_query_begin(struct pipe_context
*pipe
, struct pipe_query
*pq
)
44 struct nv30_context
*nv30
= nv30_context(pipe
);
45 struct nv30_query
*q
= nv30_query(pq
);
47 assert(q
->type
== PIPE_QUERY_OCCLUSION_COUNTER
);
49 if (nv30
->nvws
->res_alloc(nv30
->query_heap
, 1, NULL
, &q
->object
))
51 nv30
->nvws
->notifier_reset(nv30
->query
, q
->object
->start
);
53 BEGIN_RING(rankine
, NV34TCL_QUERY_RESET
, 1);
55 BEGIN_RING(rankine
, NV34TCL_QUERY_UNK17CC
, 1);
62 nv30_query_end(struct pipe_context
*pipe
, struct pipe_query
*pq
)
64 struct nv30_context
*nv30
= nv30_context(pipe
);
65 struct nv30_query
*q
= nv30_query(pq
);
67 BEGIN_RING(rankine
, NV34TCL_QUERY_GET
, 1);
68 OUT_RING ((0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT
) |
69 ((q
->object
->start
* 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT
));
74 nv30_query_result(struct pipe_context
*pipe
, struct pipe_query
*pq
,
75 boolean wait
, uint64
*result
)
77 struct nv30_context
*nv30
= nv30_context(pipe
);
78 struct nv30_query
*q
= nv30_query(pq
);
79 struct nouveau_winsys
*nvws
= nv30
->nvws
;
81 assert(q
->object
&& q
->type
== PIPE_QUERY_OCCLUSION_COUNTER
);
86 status
= nvws
->notifier_status(nv30
->query
, q
->object
->start
);
87 if (status
!= NV_NOTIFY_STATE_STATUS_COMPLETED
) {
90 nvws
->notifier_wait(nv30
->query
, q
->object
->start
,
91 NV_NOTIFY_STATE_STATUS_COMPLETED
,
95 q
->result
= nvws
->notifier_retval(nv30
->query
,
98 nvws
->res_free(&q
->object
);
106 nv30_init_query_functions(struct nv30_context
*nv30
)
108 nv30
->pipe
.create_query
= nv30_query_create
;
109 nv30
->pipe
.destroy_query
= nv30_query_destroy
;
110 nv30
->pipe
.begin_query
= nv30_query_begin
;
111 nv30
->pipe
.end_query
= nv30_query_end
;
112 nv30
->pipe
.get_query_result
= nv30_query_result
;