mesa/src/intel/perf/gen_perf_query.h
Marcin Ślusarz 2fbab5a1b3 intel/perf: fix performance counters availability after glFinish
Currently Linux kernel gathers performance counters at fixed
intervals (~5-10ms), so if application uses AMD_performance_monitor
extension and immediately after glFinish() asks GL driver for HW
performance counter values it might not get any data (values == 0).

Fix this by moving the "read counters from kernel" code from
"is query ready" to "get counter values" callback with a loop around
it. Unfortunately it means that the "read counters from kernel"
code can spin for up to 10ms.

Ideally kernel should gather performance counters whenever we ask
it for counter values, but for now we have deal with what we have.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5788>
2020-08-10 13:41:29 +00:00

89 lines
3.9 KiB
C

/*
* Copyright © 2019 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 GEN_PERF_QUERY_H
#define GEN_PERF_QUERY_H
#include <stdint.h>
struct gen_device_info;
struct gen_perf_config;
struct gen_perf_context;
struct gen_perf_query_object;
struct gen_perf_context *gen_perf_new_context(void *parent);
void gen_perf_init_context(struct gen_perf_context *perf_ctx,
struct gen_perf_config *perf_cfg,
void * ctx, /* driver context (eg, brw_context) */
void * bufmgr, /* eg brw_bufmgr */
const struct gen_device_info *devinfo,
uint32_t hw_ctx,
int drm_fd);
const struct gen_perf_query_info* gen_perf_query_info(const struct gen_perf_query_object *);
void gen_perf_init_context(struct gen_perf_context *perf_ctx,
struct gen_perf_config *perf_cfg,
void * ctx, /* driver context (eg, brw_context) */
void * bufmgr, /* eg brw_bufmgr */
const struct gen_device_info *devinfo,
uint32_t hw_ctx,
int drm_fd);
struct gen_perf_config *gen_perf_config(struct gen_perf_context *ctx);
int gen_perf_active_queries(struct gen_perf_context *perf_ctx,
const struct gen_perf_query_info *query);
struct gen_perf_query_object *
gen_perf_new_query(struct gen_perf_context *, unsigned query_index);
bool gen_perf_begin_query(struct gen_perf_context *perf_ctx,
struct gen_perf_query_object *query);
void gen_perf_end_query(struct gen_perf_context *perf_ctx,
struct gen_perf_query_object *query);
void gen_perf_wait_query(struct gen_perf_context *perf_ctx,
struct gen_perf_query_object *query,
void *current_batch);
bool gen_perf_is_query_ready(struct gen_perf_context *perf_ctx,
struct gen_perf_query_object *query,
void *current_batch);
void gen_perf_delete_query(struct gen_perf_context *perf_ctx,
struct gen_perf_query_object *query);
void gen_perf_get_query_data(struct gen_perf_context *perf_ctx,
struct gen_perf_query_object *query,
void *current_batch,
int data_size,
unsigned *data,
unsigned *bytes_written);
void gen_perf_dump_query_count(struct gen_perf_context *perf_ctx);
void gen_perf_dump_query(struct gen_perf_context *perf_ctx,
struct gen_perf_query_object *obj,
void *current_batch);
#endif /* GEN_PERF_QUERY_H */