1/* 2 * Copyright © 2014 Broadcom 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24#include "v3d_query.h" 25 26int 27v3d_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index, 28 struct pipe_driver_query_group_info *info) 29{ 30 struct v3d_screen *screen = v3d_screen(pscreen); 31 32 return v3d_get_driver_query_group_info_perfcnt(screen, index, info); 33} 34 35int 36v3d_get_driver_query_info(struct pipe_screen *pscreen, unsigned index, 37 struct pipe_driver_query_info *info) 38{ 39 struct v3d_screen *screen = v3d_screen(pscreen); 40 41 return v3d_get_driver_query_info_perfcnt(screen, index, info); 42} 43 44static struct pipe_query * 45v3d_create_query(struct pipe_context *pctx, unsigned query_type, unsigned index) 46{ 47 struct v3d_context *v3d = v3d_context(pctx); 48 49 return v3d_create_query_pipe(v3d, query_type, index); 50} 51 52static struct pipe_query * 53v3d_create_batch_query(struct pipe_context *pctx, unsigned num_queries, 54 unsigned *query_types) 55{ 56 return v3d_create_batch_query_perfcnt(v3d_context(pctx), 57 num_queries, 58 query_types); 59} 60 61static void 62v3d_destroy_query(struct pipe_context *pctx, struct pipe_query *query) 63{ 64 struct v3d_context *v3d = v3d_context(pctx); 65 struct v3d_query *q = (struct v3d_query *)query; 66 67 q->funcs->destroy_query(v3d, q); 68} 69 70static bool 71v3d_begin_query(struct pipe_context *pctx, struct pipe_query *query) 72{ 73 struct v3d_context *v3d = v3d_context(pctx); 74 struct v3d_query *q = (struct v3d_query *)query; 75 76 return q->funcs->begin_query(v3d, q); 77} 78 79static bool 80v3d_end_query(struct pipe_context *pctx, struct pipe_query *query) 81{ 82 struct v3d_context *v3d = v3d_context(pctx); 83 struct v3d_query *q = (struct v3d_query *)query; 84 85 return q->funcs->end_query(v3d, q); 86} 87 88static bool 89v3d_get_query_result(struct pipe_context *pctx, struct pipe_query *query, 90 bool wait, union pipe_query_result *vresult) 91{ 92 struct v3d_context *v3d = v3d_context(pctx); 93 struct v3d_query *q = (struct v3d_query *)query; 94 95 return q->funcs->get_query_result(v3d, q, wait, vresult); 96} 97 98static void 99v3d_set_active_query_state(struct pipe_context *pctx, bool enable) 100{ 101 struct v3d_context *v3d = v3d_context(pctx); 102 103 v3d->active_queries = enable; 104 v3d->dirty |= V3D_DIRTY_OQ; 105 v3d->dirty |= V3D_DIRTY_STREAMOUT; 106} 107 108void 109v3d_query_init(struct pipe_context *pctx) 110{ 111 pctx->create_query = v3d_create_query; 112 pctx->create_batch_query = v3d_create_batch_query; 113 pctx->destroy_query = v3d_destroy_query; 114 pctx->begin_query = v3d_begin_query; 115 pctx->end_query = v3d_end_query; 116 pctx->get_query_result = v3d_get_query_result; 117 pctx->set_active_query_state = v3d_set_active_query_state; 118} 119