1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2019 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included 12bf215546Sopenharmony_ci * in all copies or substantial portions of the Software. 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 21bf215546Sopenharmony_ci */ 22bf215546Sopenharmony_ci 23bf215546Sopenharmony_ci#include "iris_perf.h" 24bf215546Sopenharmony_ci#include "iris_context.h" 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_cistatic void * 27bf215546Sopenharmony_ciiris_oa_bo_alloc(void *bufmgr, const char *name, uint64_t size) 28bf215546Sopenharmony_ci{ 29bf215546Sopenharmony_ci return iris_bo_alloc(bufmgr, name, size, 64, IRIS_MEMZONE_OTHER, BO_ALLOC_SMEM); 30bf215546Sopenharmony_ci} 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_cistatic void 33bf215546Sopenharmony_ciiris_perf_emit_stall_at_pixel_scoreboard(struct iris_context *ice) 34bf215546Sopenharmony_ci{ 35bf215546Sopenharmony_ci iris_emit_end_of_pipe_sync(&ice->batches[IRIS_BATCH_RENDER], 36bf215546Sopenharmony_ci "OA metrics", 37bf215546Sopenharmony_ci PIPE_CONTROL_STALL_AT_SCOREBOARD); 38bf215546Sopenharmony_ci} 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cistatic void 41bf215546Sopenharmony_ciiris_perf_emit_mi_report_perf_count(void *c, 42bf215546Sopenharmony_ci void *bo, 43bf215546Sopenharmony_ci uint32_t offset_in_bytes, 44bf215546Sopenharmony_ci uint32_t report_id) 45bf215546Sopenharmony_ci{ 46bf215546Sopenharmony_ci struct iris_context *ice = c; 47bf215546Sopenharmony_ci struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER]; 48bf215546Sopenharmony_ci batch->screen->vtbl.emit_mi_report_perf_count(batch, bo, offset_in_bytes, report_id); 49bf215546Sopenharmony_ci} 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_cistatic void 52bf215546Sopenharmony_ciiris_perf_batchbuffer_flush(void *c, const char *file, int line) 53bf215546Sopenharmony_ci{ 54bf215546Sopenharmony_ci struct iris_context *ice = c; 55bf215546Sopenharmony_ci _iris_batch_flush(&ice->batches[IRIS_BATCH_RENDER], __FILE__, __LINE__); 56bf215546Sopenharmony_ci} 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cistatic void 59bf215546Sopenharmony_ciiris_perf_store_register_mem(void *ctx, void *bo, 60bf215546Sopenharmony_ci uint32_t reg, uint32_t reg_size, 61bf215546Sopenharmony_ci uint32_t offset) 62bf215546Sopenharmony_ci{ 63bf215546Sopenharmony_ci struct iris_context *ice = ctx; 64bf215546Sopenharmony_ci struct iris_batch *batch = &ice->batches[IRIS_BATCH_RENDER]; 65bf215546Sopenharmony_ci if (reg_size == 8) { 66bf215546Sopenharmony_ci batch->screen->vtbl.store_register_mem64(batch, reg, bo, offset, false); 67bf215546Sopenharmony_ci } else { 68bf215546Sopenharmony_ci assert(reg_size == 4); 69bf215546Sopenharmony_ci batch->screen->vtbl.store_register_mem32(batch, reg, bo, offset, false); 70bf215546Sopenharmony_ci } 71bf215546Sopenharmony_ci} 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_citypedef void (*bo_unreference_t)(void *); 74bf215546Sopenharmony_citypedef void *(*bo_map_t)(void *, void *, unsigned flags); 75bf215546Sopenharmony_citypedef void (*bo_unmap_t)(void *); 76bf215546Sopenharmony_citypedef void (*emit_mi_report_t)(void *, void *, uint32_t, uint32_t); 77bf215546Sopenharmony_citypedef void (*emit_mi_flush_t)(void *); 78bf215546Sopenharmony_citypedef void (*store_register_mem_t)(void *ctx, void *bo, 79bf215546Sopenharmony_ci uint32_t reg, uint32_t reg_size, 80bf215546Sopenharmony_ci uint32_t offset); 81bf215546Sopenharmony_citypedef bool (*batch_references_t)(void *batch, void *bo); 82bf215546Sopenharmony_citypedef void (*bo_wait_rendering_t)(void *bo); 83bf215546Sopenharmony_citypedef int (*bo_busy_t)(void *bo); 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_civoid 86bf215546Sopenharmony_ciiris_perf_init_vtbl(struct intel_perf_config *perf_cfg) 87bf215546Sopenharmony_ci{ 88bf215546Sopenharmony_ci perf_cfg->vtbl.bo_alloc = iris_oa_bo_alloc; 89bf215546Sopenharmony_ci perf_cfg->vtbl.bo_unreference = (bo_unreference_t)iris_bo_unreference; 90bf215546Sopenharmony_ci perf_cfg->vtbl.bo_map = (bo_map_t)iris_bo_map; 91bf215546Sopenharmony_ci perf_cfg->vtbl.bo_unmap = (bo_unmap_t)iris_bo_unmap; 92bf215546Sopenharmony_ci perf_cfg->vtbl.emit_stall_at_pixel_scoreboard = 93bf215546Sopenharmony_ci (emit_mi_flush_t)iris_perf_emit_stall_at_pixel_scoreboard; 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci perf_cfg->vtbl.emit_mi_report_perf_count = 96bf215546Sopenharmony_ci (emit_mi_report_t)iris_perf_emit_mi_report_perf_count; 97bf215546Sopenharmony_ci perf_cfg->vtbl.batchbuffer_flush = iris_perf_batchbuffer_flush; 98bf215546Sopenharmony_ci perf_cfg->vtbl.store_register_mem = 99bf215546Sopenharmony_ci (store_register_mem_t) iris_perf_store_register_mem; 100bf215546Sopenharmony_ci perf_cfg->vtbl.batch_references = (batch_references_t)iris_batch_references; 101bf215546Sopenharmony_ci perf_cfg->vtbl.bo_wait_rendering = 102bf215546Sopenharmony_ci (bo_wait_rendering_t)iris_bo_wait_rendering; 103bf215546Sopenharmony_ci perf_cfg->vtbl.bo_busy = (bo_busy_t)iris_bo_busy; 104bf215546Sopenharmony_ci} 105