mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
mesa: treat unsupported queries as dummies
It's legal in OpenGL to start a query even if the result will have zero valid bits. It's not enough to just report zero bits, We need to also prevent calling down into the driver with these invalid queries. Because ARB_ES3_compatibility adds ANY_SAMPLES_PASSED and ANY_SAMPLES_PASSED_CONSERVATIVE to the set of queries that support zero bits, we also need to check for the corresponding indices. Fixes:0186e9e1c5("mesa: always support occlusion queries") Reviewed-by: Soroush Kashani <soroush.kashani@imgtec.com> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19750> (cherry picked from commit1b1e8873fe)
This commit is contained in:
parent
22325e5f7c
commit
19e4daa0d1
4 changed files with 36 additions and 7 deletions
|
|
@ -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"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 **
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue