xref: /aosp_15_r20/external/virglrenderer/src/venus/vkr_query_pool.c (revision bbecb9d118dfdb95f99bd754f8fa9be01f189df3)
1 /*
2  * Copyright 2020 Google LLC
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #include "vkr_query_pool.h"
7 
8 #include "vkr_query_pool_gen.h"
9 
10 static void
vkr_dispatch_vkCreateQueryPool(struct vn_dispatch_context * dispatch,struct vn_command_vkCreateQueryPool * args)11 vkr_dispatch_vkCreateQueryPool(struct vn_dispatch_context *dispatch,
12                                struct vn_command_vkCreateQueryPool *args)
13 {
14    vkr_query_pool_create_and_add(dispatch->data, args);
15 }
16 
17 static void
vkr_dispatch_vkDestroyQueryPool(struct vn_dispatch_context * dispatch,struct vn_command_vkDestroyQueryPool * args)18 vkr_dispatch_vkDestroyQueryPool(struct vn_dispatch_context *dispatch,
19                                 struct vn_command_vkDestroyQueryPool *args)
20 {
21    vkr_query_pool_destroy_and_remove(dispatch->data, args);
22 }
23 
24 static void
vkr_dispatch_vkGetQueryPoolResults(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetQueryPoolResults * args)25 vkr_dispatch_vkGetQueryPoolResults(UNUSED struct vn_dispatch_context *dispatch,
26                                    struct vn_command_vkGetQueryPoolResults *args)
27 {
28    struct vkr_device *dev = vkr_device_from_handle(args->device);
29    struct vn_device_proc_table *vk = &dev->proc_table;
30 
31    vn_replace_vkGetQueryPoolResults_args_handle(args);
32    args->ret = vk->GetQueryPoolResults(args->device, args->queryPool, args->firstQuery,
33                                        args->queryCount, args->dataSize, args->pData,
34                                        args->stride, args->flags);
35 }
36 
37 static void
vkr_dispatch_vkResetQueryPool(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkResetQueryPool * args)38 vkr_dispatch_vkResetQueryPool(UNUSED struct vn_dispatch_context *dispatch,
39                               struct vn_command_vkResetQueryPool *args)
40 {
41    struct vkr_device *dev = vkr_device_from_handle(args->device);
42    struct vn_device_proc_table *vk = &dev->proc_table;
43 
44    vn_replace_vkResetQueryPool_args_handle(args);
45    vk->ResetQueryPool(args->device, args->queryPool, args->firstQuery, args->queryCount);
46 }
47 
48 void
vkr_context_init_query_pool_dispatch(struct vkr_context * ctx)49 vkr_context_init_query_pool_dispatch(struct vkr_context *ctx)
50 {
51    struct vn_dispatch_context *dispatch = &ctx->dispatch;
52 
53    dispatch->dispatch_vkCreateQueryPool = vkr_dispatch_vkCreateQueryPool;
54    dispatch->dispatch_vkDestroyQueryPool = vkr_dispatch_vkDestroyQueryPool;
55    dispatch->dispatch_vkGetQueryPoolResults = vkr_dispatch_vkGetQueryPoolResults;
56    dispatch->dispatch_vkResetQueryPool = vkr_dispatch_vkResetQueryPool;
57 }
58