/* when increasing ndwords, bump the max limit too */
assert(ndwords <= R600_MAX_DRAW_CS_DWORDS);
- /* queries need some special values */
- if (ctx->num_query_running) {
+ /* queries need some special values
+ * (this is non-zero if any query is active) */
+ if (ctx->num_cs_dw_queries_suspend) {
r600_context_reg(ctx,
R_028004_DB_COUNT_CONTROL,
S_028004_PERFECT_ZPASS_COUNTS(1),
* data blocks for current query are stored sequentially from
* results_start to results_end, with wrapping on the buffer end */
struct r600_resource *buffer;
+ /* The number of dwords for begin_query or end_query. */
+ unsigned num_cs_dw;
/* linked list of queries */
struct list_head list;
};
/* The list of active queries. Only one query of each type can be active. */
struct list_head active_query_list;
+ unsigned num_cs_dw_queries_suspend;
- unsigned num_query_running;
unsigned backend_mask;
unsigned max_db; /* for OQ */
unsigned num_dest_buffers;
num_dw += R600_MAX_DRAW_CS_DWORDS;
}
+ /* Count in queries_suspend. */
+ num_dw += ctx->num_cs_dw_queries_suspend;
+
/* Flush if there's not enough space. */
if (num_dw > ctx->pm4_ndwords) {
r600_context_flush(ctx, RADEON_FLUSH_ASYNC);
/* when increasing ndwords, bump the max limit too */
assert(ndwords <= R600_MAX_DRAW_CS_DWORDS);
- /* queries need some special values */
- if (ctx->num_query_running) {
+ /* queries need some special values
+ * (this is non-zero if any query is active) */
+ if (ctx->num_cs_dw_queries_suspend) {
if (ctx->screen->family >= CHIP_RV770) {
r600_context_reg(ctx,
R_028D0C_DB_RENDER_CONTROL,
void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
{
- unsigned required_space, new_results_end;
-
- switch (query->type) {
- case PIPE_QUERY_OCCLUSION_COUNTER:
- required_space = 12; /* 6 for begin, 6 for end */
- break;
- case PIPE_QUERY_TIME_ELAPSED:
- required_space = 16; /* 8 for begin, 8 for end */
- break;
- default:
- assert(0);
- return;
- }
+ unsigned new_results_end;
- r600_need_cs_space(ctx, required_space, TRUE);
+ r600_need_cs_space(ctx, query->num_cs_dw * 2, TRUE);
new_results_end = (query->results_end + query->result_size) % query->buffer->b.b.b.width0;
ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, 0);
ctx->pm4[ctx->pm4_cdwords++] = r600_context_bo_reloc(ctx, query->buffer, RADEON_USAGE_WRITE);
- ctx->num_query_running++;
+ ctx->num_cs_dw_queries_suspend += query->num_cs_dw;
}
void r600_query_end(struct r600_context *ctx, struct r600_query *query)
ctx->pm4[ctx->pm4_cdwords++] = r600_context_bo_reloc(ctx, query->buffer, RADEON_USAGE_WRITE);
query->results_end = (query->results_end + query->result_size) % query->buffer->b.b.b.width0;
- ctx->num_query_running--;
+ ctx->num_cs_dw_queries_suspend -= query->num_cs_dw;
}
void r600_query_predication(struct r600_context *ctx, struct r600_query *query, int operation,
switch (query_type) {
case PIPE_QUERY_OCCLUSION_COUNTER:
query->result_size = 16 * ctx->max_db;
+ query->num_cs_dw = 6;
break;
case PIPE_QUERY_TIME_ELAPSED:
query->result_size = 16;
+ query->num_cs_dw = 8;
break;
default:
assert(0);