panfrost: add helper function for checking for active queries
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Add a convenience helper function, and use this for checking
whether queries are active. This fixes a bug where we were
basically always using a software fallback for indirect
rendering rather than the CSF hardware loop.

Cc: mesa-stable
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41141>
This commit is contained in:
Eric R. Smith 2026-04-23 15:22:13 -03:00 committed by Marge Bot
parent 2b10a6c37f
commit 80e6b468f4
4 changed files with 12 additions and 5 deletions

View file

@ -497,7 +497,7 @@ panfrost_prepare_fs_state(struct panfrost_context *ctx, uint64_t *blend_shaders,
for (unsigned c = 0; c < rt_count; ++c)
has_blend_shader |= (blend_shaders[c] != 0);
bool has_oq = ctx->occlusion_query && ctx->active_queries;
bool has_oq = panfrost_occlusion_query_active(ctx);
pan_pack(rsd, RENDERER_STATE, cfg) {
if (panfrost_fs_required(fs, so, &ctx->pipe_framebuffer, zsa)) {
@ -3567,7 +3567,8 @@ panfrost_draw_indirect(struct pipe_context *pipe,
{
struct panfrost_context *ctx = pan_context(pipe);
if (!PAN_GPU_SUPPORTS_DRAW_INDIRECT || ctx->active_queries ||
if (!PAN_GPU_SUPPORTS_DRAW_INDIRECT ||
panfrost_occlusion_query_active(ctx) ||
ctx->streamout.num_targets) {
util_draw_indirect(pipe, info, drawid_offset, indirect);
perf_debug(ctx, "Emulating indirect draw on the CPU");

View file

@ -545,6 +545,12 @@ panfrost_clean_state_3d(struct panfrost_context *ctx)
}
}
static inline bool
panfrost_occlusion_query_active(struct panfrost_context *ctx)
{
return ctx->occlusion_query && ctx->active_queries;
}
void panfrost_set_batch_masks_blend(struct panfrost_batch *batch);
void panfrost_set_batch_masks_zs(struct panfrost_batch *batch);

View file

@ -1177,7 +1177,7 @@ csf_emit_draw_state(struct panfrost_batch *batch,
fui(batch->maximum_z));
#endif
if (ctx->occlusion_query && ctx->active_queries) {
if (panfrost_occlusion_query_active(ctx)) {
struct panfrost_resource *rsrc = pan_resource(ctx->occlusion_query->rsrc);
cs_move64_to(b, cs_sr_reg64(b, IDVS, OQ), rsrc->plane.base);
panfrost_batch_write_rsrc(ctx->batch, rsrc, MESA_SHADER_FRAGMENT);

View file

@ -522,7 +522,7 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch,
cfg.front_face_ccw = rast->front_ccw;
#endif
if (ctx->occlusion_query && ctx->active_queries) {
if (panfrost_occlusion_query_active(ctx)) {
#if PAN_ARCH == 9
if (ctx->occlusion_query->type == PIPE_QUERY_OCCLUSION_COUNTER)
cfg.flags_0.occlusion_query = MALI_OCCLUSION_MODE_COUNTER;
@ -569,7 +569,7 @@ jm_emit_tiler_draw(struct mali_draw_packed *out, struct panfrost_batch *batch,
cfg.flags_0.multisample_enable = true;
if (fs_required) {
bool has_oq = ctx->occlusion_query && ctx->active_queries;
bool has_oq = panfrost_occlusion_query_active(ctx);
struct pan_earlyzs_state earlyzs = pan_earlyzs_get(
fs->earlyzs, ctx->depth_stencil->writes_zs || has_oq,