1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2014 Broadcom 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 (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include "v3d_query.h" 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ciint 27bf215546Sopenharmony_civ3d_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index, 28bf215546Sopenharmony_ci struct pipe_driver_query_group_info *info) 29bf215546Sopenharmony_ci{ 30bf215546Sopenharmony_ci struct v3d_screen *screen = v3d_screen(pscreen); 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci return v3d_get_driver_query_group_info_perfcnt(screen, index, info); 33bf215546Sopenharmony_ci} 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ciint 36bf215546Sopenharmony_civ3d_get_driver_query_info(struct pipe_screen *pscreen, unsigned index, 37bf215546Sopenharmony_ci struct pipe_driver_query_info *info) 38bf215546Sopenharmony_ci{ 39bf215546Sopenharmony_ci struct v3d_screen *screen = v3d_screen(pscreen); 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_ci return v3d_get_driver_query_info_perfcnt(screen, index, info); 42bf215546Sopenharmony_ci} 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_cistatic struct pipe_query * 45bf215546Sopenharmony_civ3d_create_query(struct pipe_context *pctx, unsigned query_type, unsigned index) 46bf215546Sopenharmony_ci{ 47bf215546Sopenharmony_ci struct v3d_context *v3d = v3d_context(pctx); 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci return v3d_create_query_pipe(v3d, query_type, index); 50bf215546Sopenharmony_ci} 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_cistatic struct pipe_query * 53bf215546Sopenharmony_civ3d_create_batch_query(struct pipe_context *pctx, unsigned num_queries, 54bf215546Sopenharmony_ci unsigned *query_types) 55bf215546Sopenharmony_ci{ 56bf215546Sopenharmony_ci return v3d_create_batch_query_perfcnt(v3d_context(pctx), 57bf215546Sopenharmony_ci num_queries, 58bf215546Sopenharmony_ci query_types); 59bf215546Sopenharmony_ci} 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_cistatic void 62bf215546Sopenharmony_civ3d_destroy_query(struct pipe_context *pctx, struct pipe_query *query) 63bf215546Sopenharmony_ci{ 64bf215546Sopenharmony_ci struct v3d_context *v3d = v3d_context(pctx); 65bf215546Sopenharmony_ci struct v3d_query *q = (struct v3d_query *)query; 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci q->funcs->destroy_query(v3d, q); 68bf215546Sopenharmony_ci} 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_cistatic bool 71bf215546Sopenharmony_civ3d_begin_query(struct pipe_context *pctx, struct pipe_query *query) 72bf215546Sopenharmony_ci{ 73bf215546Sopenharmony_ci struct v3d_context *v3d = v3d_context(pctx); 74bf215546Sopenharmony_ci struct v3d_query *q = (struct v3d_query *)query; 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci return q->funcs->begin_query(v3d, q); 77bf215546Sopenharmony_ci} 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_cistatic bool 80bf215546Sopenharmony_civ3d_end_query(struct pipe_context *pctx, struct pipe_query *query) 81bf215546Sopenharmony_ci{ 82bf215546Sopenharmony_ci struct v3d_context *v3d = v3d_context(pctx); 83bf215546Sopenharmony_ci struct v3d_query *q = (struct v3d_query *)query; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci return q->funcs->end_query(v3d, q); 86bf215546Sopenharmony_ci} 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_cistatic bool 89bf215546Sopenharmony_civ3d_get_query_result(struct pipe_context *pctx, struct pipe_query *query, 90bf215546Sopenharmony_ci bool wait, union pipe_query_result *vresult) 91bf215546Sopenharmony_ci{ 92bf215546Sopenharmony_ci struct v3d_context *v3d = v3d_context(pctx); 93bf215546Sopenharmony_ci struct v3d_query *q = (struct v3d_query *)query; 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci return q->funcs->get_query_result(v3d, q, wait, vresult); 96bf215546Sopenharmony_ci} 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_cistatic void 99bf215546Sopenharmony_civ3d_set_active_query_state(struct pipe_context *pctx, bool enable) 100bf215546Sopenharmony_ci{ 101bf215546Sopenharmony_ci struct v3d_context *v3d = v3d_context(pctx); 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci v3d->active_queries = enable; 104bf215546Sopenharmony_ci v3d->dirty |= V3D_DIRTY_OQ; 105bf215546Sopenharmony_ci v3d->dirty |= V3D_DIRTY_STREAMOUT; 106bf215546Sopenharmony_ci} 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_civoid 109bf215546Sopenharmony_civ3d_query_init(struct pipe_context *pctx) 110bf215546Sopenharmony_ci{ 111bf215546Sopenharmony_ci pctx->create_query = v3d_create_query; 112bf215546Sopenharmony_ci pctx->create_batch_query = v3d_create_batch_query; 113bf215546Sopenharmony_ci pctx->destroy_query = v3d_destroy_query; 114bf215546Sopenharmony_ci pctx->begin_query = v3d_begin_query; 115bf215546Sopenharmony_ci pctx->end_query = v3d_end_query; 116bf215546Sopenharmony_ci pctx->get_query_result = v3d_get_query_result; 117bf215546Sopenharmony_ci pctx->set_active_query_state = v3d_set_active_query_state; 118bf215546Sopenharmony_ci} 119