Path: blob/21.2-virgl/src/gallium/drivers/etnaviv/etnaviv_query_acc.h
4570 views
/*1* Copyright (c) 2017 Etnaviv Project2* Copyright (C) 2017 Zodiac Inflight Innovations3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sub license,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the12* next paragraph) shall be included in all copies or substantial portions13* of the Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER21* DEALINGS IN THE SOFTWARE.22*23* Authors:24* Rob Clark <[email protected]>25* Christian Gmeiner <[email protected]>26*/2728#ifndef H_ETNAVIV_QUERY_HW29#define H_ETNAVIV_QUERY_HW3031#include "etnaviv_query.h"3233struct etna_acc_query;3435struct etna_acc_sample_provider {36bool (*supports)(unsigned query_type);37struct etna_acc_query * (*allocate)(struct etna_context *ctx, unsigned query_type);3839void (*resume)(struct etna_acc_query *aq, struct etna_context *ctx);40void (*suspend)(struct etna_acc_query *aq, struct etna_context *ctx);4142bool (*result)(struct etna_acc_query *aq, void *buf,43union pipe_query_result *result);44};4546struct etna_acc_query {47struct etna_query base;4849struct pipe_resource *prsc;50unsigned samples; /* number of samples stored in resource */51unsigned no_wait_cnt; /* see etna_hw_get_query_result() */52struct list_head node; /* list-node in ctx->active_hw_queries */5354const struct etna_acc_sample_provider *provider;55};5657static inline struct etna_acc_query *58etna_acc_query(struct etna_query *q)59{60return (struct etna_acc_query *)q;61}6263struct etna_query *64etna_acc_create_query(struct etna_context *ctx, unsigned query_type);6566static inline void67etna_acc_query_suspend(struct etna_acc_query *aq, struct etna_context *ctx)68{69const struct etna_acc_sample_provider *p = aq->provider;7071p->suspend(aq, ctx);72aq->samples++;73}7475static inline void76etna_acc_query_resume(struct etna_acc_query *aq, struct etna_context *ctx)77{78const struct etna_acc_sample_provider *p = aq->provider;7980p->resume(aq, ctx);81aq->samples++;82}8384#endif858687