Path: blob/21.2-virgl/src/gallium/drivers/iris/iris_perf.c
4565 views
/*1* Copyright © 2019 Intel Corporation2*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 shall be included11* in all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS14* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER19* DEALINGS IN THE SOFTWARE.20*/2122#include "iris_perf.h"23#include "iris_context.h"2425static void *26iris_oa_bo_alloc(void *bufmgr, const char *name, uint64_t size)27{28return iris_bo_alloc(bufmgr, name, size, 1, IRIS_MEMZONE_OTHER, BO_ALLOC_SMEM);29}3031static void32iris_perf_emit_stall_at_pixel_scoreboard(struct iris_context *ice)33{34iris_emit_end_of_pipe_sync(&ice->batches[IRIS_BATCH_RENDER],35"OA metrics",36PIPE_CONTROL_STALL_AT_SCOREBOARD);37}3839static void40iris_perf_emit_mi_report_perf_count(void *c,41void *bo,42uint32_t offset_in_bytes,43uint32_t report_id)44{45struct iris_context *ice = c;46struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER];47batch->screen->vtbl.emit_mi_report_perf_count(batch, bo, offset_in_bytes, report_id);48}4950static void51iris_perf_batchbuffer_flush(void *c, const char *file, int line)52{53struct iris_context *ice = c;54_iris_batch_flush(&ice->batches[IRIS_BATCH_RENDER], __FILE__, __LINE__);55}5657static void58iris_perf_store_register_mem(void *ctx, void *bo,59uint32_t reg, uint32_t reg_size,60uint32_t offset)61{62struct iris_context *ice = ctx;63struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER];64if (reg_size == 8) {65batch->screen->vtbl.store_register_mem64(batch, reg, bo, offset, false);66} else {67assert(reg_size == 4);68batch->screen->vtbl.store_register_mem32(batch, reg, bo, offset, false);69}70}7172typedef void (*bo_unreference_t)(void *);73typedef void *(*bo_map_t)(void *, void *, unsigned flags);74typedef void (*bo_unmap_t)(void *);75typedef void (*emit_mi_report_t)(void *, void *, uint32_t, uint32_t);76typedef void (*emit_mi_flush_t)(void *);77typedef void (*store_register_mem_t)(void *ctx, void *bo,78uint32_t reg, uint32_t reg_size,79uint32_t offset);80typedef bool (*batch_references_t)(void *batch, void *bo);81typedef void (*bo_wait_rendering_t)(void *bo);82typedef int (*bo_busy_t)(void *bo);8384void85iris_perf_init_vtbl(struct intel_perf_config *perf_cfg)86{87perf_cfg->vtbl.bo_alloc = iris_oa_bo_alloc;88perf_cfg->vtbl.bo_unreference = (bo_unreference_t)iris_bo_unreference;89perf_cfg->vtbl.bo_map = (bo_map_t)iris_bo_map;90perf_cfg->vtbl.bo_unmap = (bo_unmap_t)iris_bo_unmap;91perf_cfg->vtbl.emit_stall_at_pixel_scoreboard =92(emit_mi_flush_t)iris_perf_emit_stall_at_pixel_scoreboard;9394perf_cfg->vtbl.emit_mi_report_perf_count =95(emit_mi_report_t)iris_perf_emit_mi_report_perf_count;96perf_cfg->vtbl.batchbuffer_flush = iris_perf_batchbuffer_flush;97perf_cfg->vtbl.store_register_mem =98(store_register_mem_t) iris_perf_store_register_mem;99perf_cfg->vtbl.batch_references = (batch_references_t)iris_batch_references;100perf_cfg->vtbl.bo_wait_rendering =101(bo_wait_rendering_t)iris_bo_wait_rendering;102perf_cfg->vtbl.bo_busy = (bo_busy_t)iris_bo_busy;103}104105106