From ccf9552e923d87a32b07587d1250c00d3ca6aac9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 29 Jul 2021 19:24:48 -0700 Subject: [PATCH] vkr: split out vkr_query_pool.c No functional change. Signed-off-by: Chia-I Wu Reviewed-by: Yiwei Zhang Reviewed-by: Ryan Neph --- src/meson.build | 1 + src/venus/vkr_query_pool.c | 69 ++++++++++++++++++++++++++++++++++++++ src/venus/vkr_query_pool.h | 3 ++ src/venus/vkr_renderer.c | 52 +--------------------------- 4 files changed, 74 insertions(+), 51 deletions(-) create mode 100644 src/venus/vkr_query_pool.c diff --git a/src/meson.build b/src/meson.build index 5bc835c..4a0bcf1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -91,6 +91,7 @@ venus_sources = [ 'venus/vkr_image.h', 'venus/vkr_pipeline.c', 'venus/vkr_pipeline.h', + 'venus/vkr_query_pool.c', 'venus/vkr_query_pool.h', 'venus/vkr_queue.h', 'venus/vkr_render_pass.h', diff --git a/src/venus/vkr_query_pool.c b/src/venus/vkr_query_pool.c new file mode 100644 index 0000000..a91d99f --- /dev/null +++ b/src/venus/vkr_query_pool.c @@ -0,0 +1,69 @@ +/* + * Copyright 2020 Google LLC + * SPDX-License-Identifier: MIT + */ + +#include "vkr_query_pool.h" + +#include "venus-protocol/vn_protocol_renderer_query_pool.h" + +#include "vkr_context.h" +#include "vkr_device.h" + +static void +vkr_dispatch_vkCreateQueryPool(struct vn_dispatch_context *dispatch, + struct vn_command_vkCreateQueryPool *args) +{ + struct vkr_context *ctx = dispatch->data; + + CREATE_OBJECT(pool, query_pool, QUERY_POOL, vkCreateQueryPool, pQueryPool); + + util_hash_table_set_u64(ctx->object_table, pool->base.id, pool); +} + +static void +vkr_dispatch_vkDestroyQueryPool(struct vn_dispatch_context *dispatch, + struct vn_command_vkDestroyQueryPool *args) +{ + struct vkr_context *ctx = dispatch->data; + + DESTROY_OBJECT(pool, query_pool, QUERY_POOL, vkDestroyQueryPool, queryPool); + + util_hash_table_remove_u64(ctx->object_table, pool->base.id); +} + +static void +vkr_dispatch_vkGetQueryPoolResults(UNUSED struct vn_dispatch_context *dispatch, + struct vn_command_vkGetQueryPoolResults *args) +{ + vn_replace_vkGetQueryPoolResults_args_handle(args); + args->ret = vkGetQueryPoolResults(args->device, args->queryPool, args->firstQuery, + args->queryCount, args->dataSize, args->pData, + args->stride, args->flags); +} + +static void +vkr_dispatch_vkResetQueryPool(struct vn_dispatch_context *dispatch, + struct vn_command_vkResetQueryPool *args) +{ + struct vkr_context *ctx = dispatch->data; + struct vkr_device *dev = (struct vkr_device *)args->device; + if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) { + vkr_cs_decoder_set_fatal(&ctx->decoder); + return; + } + + vn_replace_vkResetQueryPool_args_handle(args); + dev->ResetQueryPool(args->device, args->queryPool, args->firstQuery, args->queryCount); +} + +void +vkr_context_init_query_pool_dispatch(struct vkr_context *ctx) +{ + struct vn_dispatch_context *dispatch = &ctx->dispatch; + + dispatch->dispatch_vkCreateQueryPool = vkr_dispatch_vkCreateQueryPool; + dispatch->dispatch_vkDestroyQueryPool = vkr_dispatch_vkDestroyQueryPool; + dispatch->dispatch_vkGetQueryPoolResults = vkr_dispatch_vkGetQueryPoolResults; + dispatch->dispatch_vkResetQueryPool = vkr_dispatch_vkResetQueryPool; +} diff --git a/src/venus/vkr_query_pool.h b/src/venus/vkr_query_pool.h index 1050c5a..ad063c2 100644 --- a/src/venus/vkr_query_pool.h +++ b/src/venus/vkr_query_pool.h @@ -12,4 +12,7 @@ struct vkr_query_pool { struct vkr_object base; }; +void +vkr_context_init_query_pool_dispatch(struct vkr_context *ctx); + #endif /* VKR_QUERY_POOL_H */ diff --git a/src/venus/vkr_renderer.c b/src/venus/vkr_renderer.c index 5b6e8e4..16dd6de 100644 --- a/src/venus/vkr_renderer.c +++ b/src/venus/vkr_renderer.c @@ -2728,53 +2728,6 @@ vkr_dispatch_vkResetEvent(UNUSED struct vn_dispatch_context *dispatch, args->ret = vkResetEvent(args->device, args->event); } -static void -vkr_dispatch_vkCreateQueryPool(struct vn_dispatch_context *dispatch, - struct vn_command_vkCreateQueryPool *args) -{ - struct vkr_context *ctx = dispatch->data; - - CREATE_OBJECT(pool, query_pool, QUERY_POOL, vkCreateQueryPool, pQueryPool); - - util_hash_table_set_u64(ctx->object_table, pool->base.id, pool); -} - -static void -vkr_dispatch_vkDestroyQueryPool(struct vn_dispatch_context *dispatch, - struct vn_command_vkDestroyQueryPool *args) -{ - struct vkr_context *ctx = dispatch->data; - - DESTROY_OBJECT(pool, query_pool, QUERY_POOL, vkDestroyQueryPool, queryPool); - - util_hash_table_remove_u64(ctx->object_table, pool->base.id); -} - -static void -vkr_dispatch_vkGetQueryPoolResults(UNUSED struct vn_dispatch_context *dispatch, - struct vn_command_vkGetQueryPoolResults *args) -{ - vn_replace_vkGetQueryPoolResults_args_handle(args); - args->ret = vkGetQueryPoolResults(args->device, args->queryPool, args->firstQuery, - args->queryCount, args->dataSize, args->pData, - args->stride, args->flags); -} - -static void -vkr_dispatch_vkResetQueryPool(struct vn_dispatch_context *dispatch, - struct vn_command_vkResetQueryPool *args) -{ - struct vkr_context *ctx = dispatch->data; - struct vkr_device *dev = (struct vkr_device *)args->device; - if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) { - vkr_cs_decoder_set_fatal(&ctx->decoder); - return; - } - - vn_replace_vkResetQueryPool_args_handle(args); - dev->ResetQueryPool(args->device, args->queryPool, args->firstQuery, args->queryCount); -} - static void vkr_dispatch_vkGetImageDrmFormatModifierPropertiesEXT( struct vn_dispatch_context *dispatch, @@ -3069,10 +3022,7 @@ vkr_context_init_dispatch(struct vkr_context *ctx) dispatch->dispatch_vkSetEvent = vkr_dispatch_vkSetEvent; dispatch->dispatch_vkResetEvent = vkr_dispatch_vkResetEvent; - dispatch->dispatch_vkCreateQueryPool = vkr_dispatch_vkCreateQueryPool; - dispatch->dispatch_vkDestroyQueryPool = vkr_dispatch_vkDestroyQueryPool; - dispatch->dispatch_vkGetQueryPoolResults = vkr_dispatch_vkGetQueryPoolResults; - dispatch->dispatch_vkResetQueryPool = vkr_dispatch_vkResetQueryPool; + vkr_context_init_query_pool_dispatch(ctx); vkr_context_init_shader_module_dispatch(ctx); vkr_context_init_pipeline_layout_dispatch(ctx);