diff --git a/.pick_status.json b/.pick_status.json index 299f367ae8f..f52197291ad 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -913,7 +913,7 @@ "description": "mesa: treat unsupported queries as dummies", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "0186e9e1c51b1de5d47ac10854c048cb83e81f4b" }, diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index ccc4bcdb7b3..35619822ad1 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -124,6 +124,21 @@ target_to_index(const struct gl_query_object *q) return 0; } +static bool +query_type_is_dummy(struct gl_context *ctx, unsigned type) +{ + struct st_context *st = st_context(ctx); + switch (type) { + case PIPE_QUERY_OCCLUSION_COUNTER: + case PIPE_QUERY_OCCLUSION_PREDICATE: + case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE: + return !st->has_occlusion_query; + default: + break; + } + return false; +} + static void begin_query(struct gl_context *ctx, struct gl_query_object *q) { @@ -198,7 +213,12 @@ begin_query(struct gl_context *ctx, struct gl_query_object *q) if (q->pq_begin) ret = pipe->end_query(pipe, q->pq_begin); } else { - if (!q->pq) { + if (query_type_is_dummy(ctx, type)) { + /* starting a dummy-query; ignore */ + assert(!q->pq); + q->type = type; + ret = true; + } else if (!q->pq) { q->pq = pipe->create_query(pipe, type, target_to_index(q)); q->type = type; } @@ -237,7 +257,10 @@ end_query(struct gl_context *ctx, struct gl_query_object *q) q->type = PIPE_QUERY_TIMESTAMP; } - if (q->pq) + if (query_type_is_dummy(ctx, q->type)) { + /* ending a dummy-query; ignore */ + ret = true; + } else if (q->pq) ret = pipe->end_query(pipe, q->pq); if (!ret) { @@ -258,8 +281,10 @@ get_query_result(struct pipe_context *pipe, union pipe_query_result data; if (!q->pq) { - /* Only needed in case we failed to allocate the gallium query earlier. - * Return TRUE so we don't spin on this forever. + /* Needed in case we failed to allocate the gallium query earlier, or + * in the case of a dummy query. + * + * Return TRUE in either case so we don't spin on this forever. */ return TRUE; } @@ -431,8 +456,9 @@ store_query_result(struct gl_context *ctx, struct gl_query_object *q, index = 0; } - pipe->get_query_result_resource(pipe, q->pq, flags, result_type, index, - buf->buffer, offset); + if (q->pq) + pipe->get_query_result_resource(pipe, q->pq, flags, result_type, index, + buf->buffer, offset); } static struct gl_query_object ** diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index c90927d053b..c05f2b58e3b 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -610,6 +610,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, screen->get_param(screen, PIPE_CAP_MULTI_DRAW_INDIRECT); st->has_indirect_partial_stride = screen->get_param(screen, PIPE_CAP_MULTI_DRAW_INDIRECT_PARTIAL_STRIDE); + st->has_occlusion_query = + screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY); st->has_single_pipe_stat = screen->get_param(screen, PIPE_CAP_QUERY_PIPELINE_STATISTICS_SINGLE); st->has_indep_blend_func = diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index e90c170dcfb..61645f51206 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -150,6 +150,7 @@ struct st_context boolean has_half_float_packing; boolean has_multi_draw_indirect; boolean has_indirect_partial_stride; + boolean has_occlusion_query; boolean has_single_pipe_stat; boolean has_indep_blend_func; boolean needs_rgb_dst_alpha_override;