zink: refcount the correct query pool

otherwise the pool is freed before the query and zink will
give the vulkan driver NULL query pool which can make it crash.

this was seen when running the following cases with
primitivesGeneratedQueryWithRasterizerDiscard and color write
features disabled:
dEQP-GL45.functional.tessellation.invariance.outer_triangle_set.triangles_fractional_odd_spacing
dEQP-GL45.functional.tessellation.invariance.outer_triangle_set.triangles_fractional_even_spacing
dEQP-GL45.functional.tessellation.invariance.outer_triangle_set.quads_equal_spacing
dEQP-GL45.functional.tessellation.invariance.outer_triangle_set.quads_fractional_odd_spacing
dEQP-GL45.functional.tessellation.invariance.outer_triangle_set.quads_fractional_even_spacing
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_equal_spacing_ccw
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_equal_spacing_ccw_point_mode
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_equal_spacing_cw
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_equal_spacing_cw_point_mode
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_fractional_odd_spacing_ccw
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_fractional_odd_spacing_ccw_point_mode
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_fractional_odd_spacing_cw
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_fractional_odd_spacing_cw_point_mode
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_fractional_even_spacing_ccw
dEQP-GL45.functional.tessellation.invariance.tess_coord_component_range.triangles_fractional_even_spacing_ccw_point_mode

Fixes: e5d517f362 ("zink: rework query pool overflow")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22575>
(cherry picked from commit 3291050cc1)
This commit is contained in:
SoroushIMG 2023-04-19 22:10:15 +01:00 committed by Eric Engestrom
parent 089e14d4e9
commit 0bd99d6943
2 changed files with 3 additions and 5 deletions

View file

@ -274,7 +274,7 @@
"description": "zink: refcount the correct query pool",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "e5d517f36228c0788be58b00bdf23aa02f4dcf0c"
},

View file

@ -468,20 +468,18 @@ query_pool_get_range(struct zink_context *ctx, struct zink_query *q)
vkq->pool->refcount++;
} else {
struct zink_query_pool *pool = find_or_allocate_qp(ctx, q, pool_idx);
pool->refcount++;
pool->last_range++;
if (pool->last_range == NUM_QUERIES) {
list_del(&pool->list);
pool = find_or_allocate_qp(ctx, q, pool_idx);
}
vkq = CALLOC_STRUCT(zink_vk_query);
pool->refcount++;
vkq->refcount = 1;
vkq->needs_reset = true;
vkq->pool = pool;
vkq->started = false;
vkq->query_id = pool->last_range;
vkq->query_id = pool->last_range++;
}
unref_vk_query(ctx, start->vkq[i]);
start->vkq[i] = vkq;