Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_query.h
4570 views
/*1* Copyright (C) 2013 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_H_27#define FREEDRENO_QUERY_H_2829#include "pipe/p_context.h"3031#include "util/u_threaded_context.h"3233#include "freedreno_util.h"3435struct fd_context;36struct fd_query;3738struct fd_query_funcs {39void (*destroy_query)(struct fd_context *ctx, struct fd_query *q) dt;40void (*begin_query)(struct fd_context *ctx, struct fd_query *q) dt;41void (*end_query)(struct fd_context *ctx, struct fd_query *q) dt;42bool (*get_query_result)(struct fd_context *ctx, struct fd_query *q,43bool wait, union pipe_query_result *result);44};4546struct fd_query {47struct threaded_query base;4849const struct fd_query_funcs *funcs;50int type;51unsigned index;52};5354static inline struct fd_query *55fd_query(struct pipe_query *pq)56{57return (struct fd_query *)pq;58}5960#define FD_QUERY_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0)61#define FD_QUERY_BATCH_TOTAL \62(PIPE_QUERY_DRIVER_SPECIFIC + 1) /* total # of batches (submits) */63#define FD_QUERY_BATCH_SYSMEM \64(PIPE_QUERY_DRIVER_SPECIFIC + \652) /* batches using system memory (GMEM bypass) */66#define FD_QUERY_BATCH_GMEM \67(PIPE_QUERY_DRIVER_SPECIFIC + 3) /* batches using GMEM */68#define FD_QUERY_BATCH_NONDRAW \69(PIPE_QUERY_DRIVER_SPECIFIC + 4) /* compute/blit batches */70#define FD_QUERY_BATCH_RESTORE \71(PIPE_QUERY_DRIVER_SPECIFIC + 5) /* batches requiring GMEM restore */72#define FD_QUERY_STAGING_UPLOADS \73(PIPE_QUERY_DRIVER_SPECIFIC + \746) /* texture/buffer uploads using staging blit */75#define FD_QUERY_SHADOW_UPLOADS \76(PIPE_QUERY_DRIVER_SPECIFIC + \777) /* texture/buffer uploads that shadowed rsc */78#define FD_QUERY_VS_REGS \79(PIPE_QUERY_DRIVER_SPECIFIC + \808) /* avg # of VS registers (scaled up by 100x) */81#define FD_QUERY_FS_REGS \82(PIPE_QUERY_DRIVER_SPECIFIC + \839) /* avg # of VS registers (scaled up by 100x) */84/* insert any new non-perfcntr queries here, the first perfcntr index85* needs to come last!86*/87#define FD_QUERY_FIRST_PERFCNTR (PIPE_QUERY_DRIVER_SPECIFIC + 10)8889void fd_query_screen_init(struct pipe_screen *pscreen);90void fd_query_context_init(struct pipe_context *pctx);9192static inline bool93skip_begin_query(int type)94{95switch (type) {96case PIPE_QUERY_TIMESTAMP:97case PIPE_QUERY_GPU_FINISHED:98return true;99default:100return false;101}102}103104/* maps query_type to sample provider idx: */105static inline int106pidx(unsigned query_type)107{108switch (query_type) {109case PIPE_QUERY_OCCLUSION_COUNTER:110return 0;111case PIPE_QUERY_OCCLUSION_PREDICATE:112return 1;113case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:114return 2;115/* TODO currently queries only emitted in main pass (not in binning pass)..116* which is fine for occlusion query, but pretty much not anything else.117*/118case PIPE_QUERY_TIME_ELAPSED:119return 3;120case PIPE_QUERY_TIMESTAMP:121return 4;122123case PIPE_QUERY_PRIMITIVES_GENERATED:124return 5;125case PIPE_QUERY_PRIMITIVES_EMITTED:126return 6;127128default:129return -1;130}131}132133#endif /* FREEDRENO_QUERY_H_ */134135136