Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_query_acc.h
4570 views
/*1* Copyright (C) 2017 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FREEDRENO_QUERY_ACC_H_27#define FREEDRENO_QUERY_ACC_H_2829#include "util/list.h"3031#include "freedreno_context.h"32#include "freedreno_query.h"3334/*35* Accumulated HW Queries:36*37* Unlike the original HW Queries in earlier adreno generations (see38* freedreno_query_hw.[ch], later generations can accumulate the per-39* tile results of some (a4xx) or all (a5xx+?) queries in the cmdstream.40* But we still need to handle pausing/resuming the query across stage41* changes (in particular when switching between batches).42*43* fd_acc_sample_provider:44* - one per accumulated query type, registered/implemented by gpu45* generation specific code46* - knows how to emit cmdstream to pause/resume a query instance47*48* fd_acc_query:49* - one instance per query object50* - each query object has it's own result buffer, which may51* span multiple batches, etc.52*/5354struct fd_acc_query;5556struct fd_acc_sample_provider {57unsigned query_type;5859/* Set if the provider should still count while !ctx->active_queries */60bool always;6162unsigned size;6364void (*resume)(struct fd_acc_query *aq, struct fd_batch *batch) dt;65void (*pause)(struct fd_acc_query *aq, struct fd_batch *batch) dt;6667void (*result)(struct fd_acc_query *aq, void *buf,68union pipe_query_result *result);69};7071struct fd_acc_query {72struct fd_query base;7374const struct fd_acc_sample_provider *provider;7576struct pipe_resource *prsc;7778/* Pointer to the batch that our query has had resume() called on (if79* any).80*/81struct fd_batch *batch;8283/* usually the same as provider->size but for batch queries we84* need to calculate the size dynamically when the query is85* allocated:86*/87unsigned size;8889struct list_head node; /* list-node in ctx->active_acc_queries */9091void *query_data; /* query specific data */92};9394static inline struct fd_acc_query *95fd_acc_query(struct fd_query *q)96{97return (struct fd_acc_query *)q;98}99100struct fd_query *fd_acc_create_query(struct fd_context *ctx,101unsigned query_type, unsigned index);102struct fd_query *103fd_acc_create_query2(struct fd_context *ctx, unsigned query_type,104unsigned index,105const struct fd_acc_sample_provider *provider);106void fd_acc_query_update_batch(struct fd_batch *batch,107bool disable_all) assert_dt;108void109fd_acc_query_register_provider(struct pipe_context *pctx,110const struct fd_acc_sample_provider *provider);111112#endif /* FREEDRENO_QUERY_ACC_H_ */113114115