1 #include "pipe/p_context.h"
3 #include "nv40_context.h"
7 nv40_query_object_find(struct nv40_context
*nv40
, struct pipe_query_object
*q
)
11 for (id
= 0; id
< nv40
->num_query_objects
; id
++) {
12 if (nv40
->query_objects
[id
] == q
)
20 nv40_query_begin(struct pipe_context
*pipe
, struct pipe_query_object
*q
)
22 struct nv40_context
*nv40
= (struct nv40_context
*)pipe
;
25 assert(q
->type
== PIPE_QUERY_OCCLUSION_COUNTER
);
27 id
= nv40_query_object_find(nv40
, NULL
);
29 nv40
->query_objects
[id
] = q
;
31 nv40
->nvws
->notifier_reset(nv40
->query
, id
);
34 BEGIN_RING(curie
, NV40TCL_QUERY_RESET
, 1);
36 BEGIN_RING(curie
, NV40TCL_QUERY_UNK17CC
, 1);
41 nv40_query_update(struct pipe_context
*pipe
, struct pipe_query_object
*q
)
43 struct nv40_context
*nv40
= (struct nv40_context
*)pipe
;
46 id
= nv40_query_object_find(nv40
, q
);
49 if (nv40
->nvws
->notifier_status(nv40
->query
, id
) == 0) {
51 q
->count
= nv40
->nvws
->notifier_retval(nv40
->query
, id
);
52 nv40
->query_objects
[id
] = NULL
;
57 nv40_query_wait(struct pipe_context
*pipe
, struct pipe_query_object
*q
)
59 nv40_query_update(pipe
, q
);
61 struct nv40_context
*nv40
= (struct nv40_context
*)pipe
;
64 id
= nv40_query_object_find(nv40
, q
);
67 nv40
->nvws
->notifier_wait(nv40
->query
, id
, 0, 0);
68 nv40_query_update(pipe
, q
);
74 nv40_query_end(struct pipe_context
*pipe
, struct pipe_query_object
*q
)
76 struct nv40_context
*nv40
= (struct nv40_context
*)pipe
;
79 id
= nv40_query_object_find(nv40
, q
);
82 BEGIN_RING(curie
, NV40TCL_QUERY_GET
, 1);
83 OUT_RING ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT
) |
84 ((id
* 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT
));
87 /*XXX: Some apps spin waiting for GL_QUERY_RESULT_AVAILABLE_ARB.
88 * Core mesa won't ask the driver to update the query object's
89 * status in this case, so the app waits forever.. fix this some
93 nv40_query_update(pipe
, q
);
95 nv40_query_wait(pipe
, q
);
100 nv40_init_query_functions(struct nv40_context
*nv40
)
102 nv40
->pipe
.begin_query
= nv40_query_begin
;
103 nv40
->pipe
.end_query
= nv40_query_end
;
104 nv40
->pipe
.wait_query
= nv40_query_wait
;