freedreno/ir3: move per-generation compiler config
[mesa.git] / src / gallium / drivers / freedreno / freedreno_query_hw.c
index ef458ce5db28c32d579fb8fb9f5e62e8ad333886..86a46faa7308c58ea4c98f6095f3baa6bae3f947 100644 (file)
@@ -40,26 +40,6 @@ struct fd_hw_sample_period {
        struct list_head list;
 };
 
-/* maps query_type to sample provider idx: */
-static int pidx(unsigned query_type)
-{
-       switch (query_type) {
-       case PIPE_QUERY_OCCLUSION_COUNTER:
-               return 0;
-       case PIPE_QUERY_OCCLUSION_PREDICATE:
-               return 1;
-       /* TODO currently queries only emitted in main pass (not in binning pass)..
-        * which is fine for occlusion query, but pretty much not anything else.
-        */
-       case PIPE_QUERY_TIME_ELAPSED:
-               return 2;
-       case PIPE_QUERY_TIMESTAMP:
-               return 3;
-       default:
-               return -1;
-       }
-}
-
 static struct fd_hw_sample *
 get_sample(struct fd_batch *batch, struct fd_ringbuffer *ring,
                unsigned query_type)
@@ -72,7 +52,7 @@ get_sample(struct fd_batch *batch, struct fd_ringbuffer *ring,
 
        if (!batch->sample_cache[idx]) {
                struct fd_hw_sample *new_samp =
-                       ctx->sample_providers[idx]->get_sample(batch, ring);
+                       ctx->hw_sample_providers[idx]->get_sample(batch, ring);
                fd_hw_sample_reference(ctx, &batch->sample_cache[idx], new_samp);
                util_dynarray_append(&batch->samples, struct fd_hw_sample *, new_samp);
                batch->needs_flush = true;
@@ -170,7 +150,7 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q)
 
        /* add to active list: */
        assert(list_empty(&hq->list));
-       list_addtail(&hq->list, &ctx->active_queries);
+       list_addtail(&hq->list, &ctx->hw_active_queries);
 
        return true;
 }
@@ -231,14 +211,14 @@ fd_hw_get_query_result(struct fd_context *ctx, struct fd_query *q,
                         * spin forever:
                         */
                        if (hq->no_wait_cnt++ > 5)
-                               fd_batch_flush(rsc->write_batch, false);
+                               fd_batch_flush(rsc->write_batch, false, false);
                        return false;
                }
 
                if (!rsc->bo)
                        return false;
 
-               ret = fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe,
+               ret = fd_bo_cpu_prep(rsc->bo, ctx->pipe,
                                DRM_FREEDRENO_PREP_READ | DRM_FREEDRENO_PREP_NOSYNC);
                if (ret)
                        return false;
@@ -259,13 +239,13 @@ fd_hw_get_query_result(struct fd_context *ctx, struct fd_query *q,
                struct fd_resource *rsc = fd_resource(start->prsc);
 
                if (rsc->write_batch)
-                       fd_batch_flush(rsc->write_batch, true);
+                       fd_batch_flush(rsc->write_batch, true, false);
 
                /* some piglit tests at least do query with no draws, I guess: */
                if (!rsc->bo)
                        continue;
 
-               fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe, DRM_FREEDRENO_PREP_READ);
+               fd_bo_cpu_prep(rsc->bo, ctx->pipe, DRM_FREEDRENO_PREP_READ);
 
                void *ptr = fd_bo_map(rsc->bo);
 
@@ -294,7 +274,7 @@ fd_hw_create_query(struct fd_context *ctx, unsigned query_type)
        struct fd_query *q;
        int idx = pidx(query_type);
 
-       if ((idx < 0) || !ctx->sample_providers[idx])
+       if ((idx < 0) || !ctx->hw_sample_providers[idx])
                return NULL;
 
        hq = CALLOC_STRUCT(fd_hw_query);
@@ -303,7 +283,7 @@ fd_hw_create_query(struct fd_context *ctx, unsigned query_type)
 
        DBG("%p: query_type=%u", hq, query_type);
 
-       hq->provider = ctx->sample_providers[idx];
+       hq->provider = ctx->hw_sample_providers[idx];
 
        list_inithead(&hq->periods);
        list_inithead(&hq->list);
@@ -321,7 +301,7 @@ fd_hw_sample_init(struct fd_batch *batch, uint32_t size)
        struct fd_hw_sample *samp = slab_alloc_st(&batch->ctx->sample_pool);
        pipe_reference_init(&samp->reference, 1);
        samp->size = size;
-       debug_assert(util_is_power_of_two(size));
+       debug_assert(util_is_power_of_two_or_zero(size));
        batch->next_sample_offset = align(batch->next_sample_offset, size);
        samp->offset = batch->next_sample_offset;
        /* NOTE: slab_alloc_st() does not zero out the buffer: */
@@ -400,19 +380,18 @@ fd_hw_query_prepare_tile(struct fd_batch *batch, uint32_t n,
 }
 
 void
-fd_hw_query_set_stage(struct fd_batch *batch, struct fd_ringbuffer *ring,
-               enum fd_render_stage stage)
+fd_hw_query_set_stage(struct fd_batch *batch, enum fd_render_stage stage)
 {
        if (stage != batch->stage) {
                struct fd_hw_query *hq;
-               LIST_FOR_EACH_ENTRY(hq, &batch->ctx->active_queries, list) {
+               LIST_FOR_EACH_ENTRY(hq, &batch->ctx->hw_active_queries, list) {
                        bool was_active = is_active(hq, batch->stage);
                        bool now_active = is_active(hq, stage);
 
                        if (now_active && !was_active)
-                               resume_query(batch, hq, ring);
+                               resume_query(batch, hq, batch->draw);
                        else if (was_active && !now_active)
-                               pause_query(batch, hq, ring);
+                               pause_query(batch, hq, batch->draw);
                }
        }
        clear_sample_cache(batch);
@@ -428,9 +407,9 @@ fd_hw_query_enable(struct fd_batch *batch, struct fd_ringbuffer *ring)
        struct fd_context *ctx = batch->ctx;
        for (int idx = 0; idx < MAX_HW_SAMPLE_PROVIDERS; idx++) {
                if (batch->active_providers & (1 << idx)) {
-                       assert(ctx->sample_providers[idx]);
-                       if (ctx->sample_providers[idx]->enable)
-                               ctx->sample_providers[idx]->enable(ctx, ring);
+                       assert(ctx->hw_sample_providers[idx]);
+                       if (ctx->hw_sample_providers[idx]->enable)
+                               ctx->hw_sample_providers[idx]->enable(ctx, ring);
                }
        }
        batch->active_providers = 0;  /* clear it for next frame */
@@ -444,9 +423,9 @@ fd_hw_query_register_provider(struct pipe_context *pctx,
        int idx = pidx(provider->query_type);
 
        assert((0 <= idx) && (idx < MAX_HW_SAMPLE_PROVIDERS));
-       assert(!ctx->sample_providers[idx]);
+       assert(!ctx->hw_sample_providers[idx]);
 
-       ctx->sample_providers[idx] = provider;
+       ctx->hw_sample_providers[idx] = provider;
 }
 
 void
@@ -458,7 +437,6 @@ fd_hw_query_init(struct pipe_context *pctx)
                        16);
        slab_create(&ctx->sample_period_pool, sizeof(struct fd_hw_sample_period),
                        16);
-       list_inithead(&ctx->active_queries);
 }
 
 void