/* * Copyright © 2015 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef BRW_PERFORMANCE_QUERY_H #define BRW_PERFORMANCE_QUERY_H #include #include "brw_context.h" #include "perf/gen_perf.h" struct gen_perf_query_info; /* * When currently allocate only one page for pipeline statistics queries. Here * we derived the maximum number of counters for that amount. */ #define STATS_BO_SIZE 4096 #define STATS_BO_END_OFFSET_BYTES (STATS_BO_SIZE / 2) #define MAX_STAT_COUNTERS (STATS_BO_END_OFFSET_BYTES / 8) /** * i965 representation of a performance query object. * * NB: We want to keep this structure relatively lean considering that * applications may expect to allocate enough objects to be able to * query around all draw calls in a frame. */ struct brw_perf_query_object { struct gl_perf_query_object base; const struct gen_perf_query_info *query; /* See query->kind to know which state below is in use... */ union { struct { /** * BO containing OA counter snapshots at query Begin/End time. */ struct brw_bo *bo; /** * Address of mapped of @bo */ void *map; /** * The MI_REPORT_PERF_COUNT command lets us specify a unique * ID that will be reflected in the resulting OA report * that's written by the GPU. This is the ID we're expecting * in the begin report and the the end report should be * @begin_report_id + 1. */ int begin_report_id; /** * Reference the head of the brw->perfquery.sample_buffers * list at the time that the query started (so we only need * to look at nodes after this point when looking for samples * related to this query) * * (See struct brw_oa_sample_buf description for more details) */ struct exec_node *samples_head; /** * false while in the unaccumulated_elements list, and set to * true when the final, end MI_RPC snapshot has been * accumulated. */ bool results_accumulated; /** * Frequency of the GT at begin and end of the query. */ uint64_t gt_frequency[2]; /** * Accumulated OA results between begin and end of the query. */ struct gen_perf_query_result result; } oa; struct { /** * BO containing starting and ending snapshots for the * statistics counters. */ struct brw_bo *bo; } pipeline_stats; }; }; void brw_perf_query_register_mdapi_oa_query(struct brw_context *brw); void brw_perf_query_register_mdapi_statistic_query(struct brw_context *brw); #endif /* BRW_PERFORMANCE_QUERY_H */