Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_perfetto.h
4570 views
/*1* Copyright © 2021 Google, Inc.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*/2223#ifndef FREEDRENO_PERFETTO_H_24#define FREEDRENO_PERFETTO_H_2526#ifdef __cplusplus27extern "C" {28#endif2930#ifdef HAVE_PERFETTO3132/**33* Render-stage id's34*/35enum fd_stage_id {36SURFACE_STAGE_ID, /* Surface is a sort of meta-stage for render-target info */37BINNING_STAGE_ID,38GMEM_STAGE_ID,39BYPASS_STAGE_ID,40BLIT_STAGE_ID,41COMPUTE_STAGE_ID,42CLEAR_RESTORE_STAGE_ID,43RESOLVE_STAGE_ID,44// TODO add the rest4546NUM_STAGES47};4849static const struct {50const char *name;51const char *desc;52} stages[] = {53[SURFACE_STAGE_ID] = {"Surface"},54[BINNING_STAGE_ID] = {"Binning", "Perform Visibility pass and determine target bins"},55[GMEM_STAGE_ID] = {"Render", "Rendering to GMEM"},56[BYPASS_STAGE_ID] = {"Render", "Rendering to system memory"},57[BLIT_STAGE_ID] = {"Blit", "Performing a Blit operation"},58[COMPUTE_STAGE_ID] = {"Compute", "Compute job"},59[CLEAR_RESTORE_STAGE_ID] = {"Clear/Restore", "Clear (sysmem) or per-tile clear or restore (GMEM)"},60[RESOLVE_STAGE_ID] = {"Resolve", "Per tile resolve (GMEM to system memory"},61// TODO add the rest62};6364/**65* Queue-id's66*/67enum {68DEFAULT_HW_QUEUE_ID,69};7071static const struct {72const char *name;73const char *desc;74} queues[] = {75[DEFAULT_HW_QUEUE_ID] = {"GPU Queue 0", "Default Adreno Hardware Queue"},76};7778/**79* The u_trace tracepoints which are used to capture GPU timestamps and80* trigger perfetto events tend to come in begin/end pairs (ie. start81* and end of binning pass, etc), but perfetto wants one event for the82* whole pass. So we need to buffer up some state at the "begin" trae83* callback, and then emit the perfetto event at the "end" event based84* on previously recorded timestamp/data. This struct is where we can85* accumulate that state.86*/87struct fd_perfetto_state {88uint64_t start_ts[NUM_STAGES];8990/*91* Surface state for the renderpass:92*/93uint32_t submit_id;94enum pipe_format cbuf0_format : 16;95enum pipe_format zs_format : 16;96uint16_t width;97uint16_t height;98uint8_t mrts;99uint8_t samples;100uint16_t nbins;101uint16_t binw;102uint16_t binh;103// TODO # of draws and possibly estimated cost might be useful addition..104};105106void fd_perfetto_init(void);107108struct fd_context;109void fd_perfetto_submit(struct fd_context *ctx);110111#endif112113#ifdef __cplusplus114}115#endif116117#endif /* FREEDRENO_PERFETTO_H_ */118119120