From 243cacf2bba67456a4945c87735ab2899308749f 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_pipeline.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_pipeline.c | 170 +++++++++++++++++++++++++++++++++++++++ src/venus/vkr_pipeline.h | 12 +++ src/venus/vkr_renderer.c | 135 +------------------------------ 4 files changed, 187 insertions(+), 131 deletions(-) create mode 100644 src/venus/vkr_pipeline.c diff --git a/src/meson.build b/src/meson.build index f5bfd83..5bc835c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -89,6 +89,7 @@ venus_sources = [ 'venus/vkr_device.h', 'venus/vkr_device_memory.h', 'venus/vkr_image.h', + 'venus/vkr_pipeline.c', 'venus/vkr_pipeline.h', 'venus/vkr_query_pool.h', 'venus/vkr_queue.h', diff --git a/src/venus/vkr_pipeline.c b/src/venus/vkr_pipeline.c new file mode 100644 index 0000000..babf941 --- /dev/null +++ b/src/venus/vkr_pipeline.c @@ -0,0 +1,170 @@ +/* + * Copyright 2020 Google LLC + * SPDX-License-Identifier: MIT + */ + +#include "vkr_pipeline.h" + +#include "venus-protocol/vn_protocol_renderer_pipeline.h" +#include "venus-protocol/vn_protocol_renderer_pipeline_cache.h" +#include "venus-protocol/vn_protocol_renderer_pipeline_layout.h" +#include "venus-protocol/vn_protocol_renderer_shader_module.h" + +#include "vkr_context.h" +#include "vkr_device.h" + +static void +vkr_dispatch_vkCreateShaderModule(struct vn_dispatch_context *dispatch, + struct vn_command_vkCreateShaderModule *args) +{ + struct vkr_context *ctx = dispatch->data; + + CREATE_OBJECT(mod, shader_module, SHADER_MODULE, vkCreateShaderModule, pShaderModule); + + util_hash_table_set_u64(ctx->object_table, mod->base.id, mod); +} + +static void +vkr_dispatch_vkDestroyShaderModule(struct vn_dispatch_context *dispatch, + struct vn_command_vkDestroyShaderModule *args) +{ + struct vkr_context *ctx = dispatch->data; + + DESTROY_OBJECT(mod, shader_module, SHADER_MODULE, vkDestroyShaderModule, shaderModule); + + util_hash_table_remove_u64(ctx->object_table, mod->base.id); +} + +static void +vkr_dispatch_vkCreatePipelineLayout(struct vn_dispatch_context *dispatch, + struct vn_command_vkCreatePipelineLayout *args) +{ + struct vkr_context *ctx = dispatch->data; + + CREATE_OBJECT(layout, pipeline_layout, PIPELINE_LAYOUT, vkCreatePipelineLayout, + pPipelineLayout); + + util_hash_table_set_u64(ctx->object_table, layout->base.id, layout); +} + +static void +vkr_dispatch_vkDestroyPipelineLayout(struct vn_dispatch_context *dispatch, + struct vn_command_vkDestroyPipelineLayout *args) +{ + struct vkr_context *ctx = dispatch->data; + + DESTROY_OBJECT(layout, pipeline_layout, PIPELINE_LAYOUT, vkDestroyPipelineLayout, + pipelineLayout); + + util_hash_table_remove_u64(ctx->object_table, layout->base.id); +} + +static void +vkr_dispatch_vkCreatePipelineCache(struct vn_dispatch_context *dispatch, + struct vn_command_vkCreatePipelineCache *args) +{ + struct vkr_context *ctx = dispatch->data; + + CREATE_OBJECT(cache, pipeline_cache, PIPELINE_CACHE, vkCreatePipelineCache, + pPipelineCache); + + util_hash_table_set_u64(ctx->object_table, cache->base.id, cache); +} + +static void +vkr_dispatch_vkDestroyPipelineCache(struct vn_dispatch_context *dispatch, + struct vn_command_vkDestroyPipelineCache *args) +{ + struct vkr_context *ctx = dispatch->data; + + DESTROY_OBJECT(cache, pipeline_cache, PIPELINE_CACHE, vkDestroyPipelineCache, + pipelineCache); + + util_hash_table_remove_u64(ctx->object_table, cache->base.id); +} + +static void +vkr_dispatch_vkGetPipelineCacheData(UNUSED struct vn_dispatch_context *dispatch, + struct vn_command_vkGetPipelineCacheData *args) +{ + vn_replace_vkGetPipelineCacheData_args_handle(args); + args->ret = vkGetPipelineCacheData(args->device, args->pipelineCache, args->pDataSize, + args->pData); +} + +static void +vkr_dispatch_vkMergePipelineCaches(UNUSED struct vn_dispatch_context *dispatch, + struct vn_command_vkMergePipelineCaches *args) +{ + vn_replace_vkMergePipelineCaches_args_handle(args); + args->ret = vkMergePipelineCaches(args->device, args->dstCache, args->srcCacheCount, + args->pSrcCaches); +} + +static void +vkr_dispatch_vkCreateGraphicsPipelines(struct vn_dispatch_context *dispatch, + struct vn_command_vkCreateGraphicsPipelines *args) +{ + struct vkr_context *ctx = dispatch->data; + + CREATE_PIPELINE_ARRAY(vkCreateGraphicsPipelines); +} + +static void +vkr_dispatch_vkCreateComputePipelines(struct vn_dispatch_context *dispatch, + struct vn_command_vkCreateComputePipelines *args) +{ + struct vkr_context *ctx = dispatch->data; + + CREATE_PIPELINE_ARRAY(vkCreateComputePipelines); +} + +static void +vkr_dispatch_vkDestroyPipeline(struct vn_dispatch_context *dispatch, + struct vn_command_vkDestroyPipeline *args) +{ + struct vkr_context *ctx = dispatch->data; + + DESTROY_OBJECT(pipeline, pipeline, PIPELINE, vkDestroyPipeline, pipeline); + + util_hash_table_remove_u64(ctx->object_table, pipeline->base.id); +} + +void +vkr_context_init_shader_module_dispatch(struct vkr_context *ctx) +{ + struct vn_dispatch_context *dispatch = &ctx->dispatch; + + dispatch->dispatch_vkCreateShaderModule = vkr_dispatch_vkCreateShaderModule; + dispatch->dispatch_vkDestroyShaderModule = vkr_dispatch_vkDestroyShaderModule; +} + +void +vkr_context_init_pipeline_layout_dispatch(struct vkr_context *ctx) +{ + struct vn_dispatch_context *dispatch = &ctx->dispatch; + + dispatch->dispatch_vkCreatePipelineLayout = vkr_dispatch_vkCreatePipelineLayout; + dispatch->dispatch_vkDestroyPipelineLayout = vkr_dispatch_vkDestroyPipelineLayout; +} + +void +vkr_context_init_pipeline_cache_dispatch(struct vkr_context *ctx) +{ + struct vn_dispatch_context *dispatch = &ctx->dispatch; + + dispatch->dispatch_vkCreatePipelineCache = vkr_dispatch_vkCreatePipelineCache; + dispatch->dispatch_vkDestroyPipelineCache = vkr_dispatch_vkDestroyPipelineCache; + dispatch->dispatch_vkGetPipelineCacheData = vkr_dispatch_vkGetPipelineCacheData; + dispatch->dispatch_vkMergePipelineCaches = vkr_dispatch_vkMergePipelineCaches; +} + +void +vkr_context_init_pipeline_dispatch(struct vkr_context *ctx) +{ + struct vn_dispatch_context *dispatch = &ctx->dispatch; + + dispatch->dispatch_vkCreateGraphicsPipelines = vkr_dispatch_vkCreateGraphicsPipelines; + dispatch->dispatch_vkCreateComputePipelines = vkr_dispatch_vkCreateComputePipelines; + dispatch->dispatch_vkDestroyPipeline = vkr_dispatch_vkDestroyPipeline; +} diff --git a/src/venus/vkr_pipeline.h b/src/venus/vkr_pipeline.h index b52632e..d6de882 100644 --- a/src/venus/vkr_pipeline.h +++ b/src/venus/vkr_pipeline.h @@ -24,4 +24,16 @@ struct vkr_pipeline { struct vkr_object base; }; +void +vkr_context_init_shader_module_dispatch(struct vkr_context *ctx); + +void +vkr_context_init_pipeline_layout_dispatch(struct vkr_context *ctx); + +void +vkr_context_init_pipeline_cache_dispatch(struct vkr_context *ctx); + +void +vkr_context_init_pipeline_dispatch(struct vkr_context *ctx); + #endif /* VKR_PIPELINE_H */ diff --git a/src/venus/vkr_renderer.c b/src/venus/vkr_renderer.c index 75c81c2..5b6e8e4 100644 --- a/src/venus/vkr_renderer.c +++ b/src/venus/vkr_renderer.c @@ -2775,123 +2775,6 @@ vkr_dispatch_vkResetQueryPool(struct vn_dispatch_context *dispatch, dev->ResetQueryPool(args->device, args->queryPool, args->firstQuery, args->queryCount); } -static void -vkr_dispatch_vkCreateShaderModule(struct vn_dispatch_context *dispatch, - struct vn_command_vkCreateShaderModule *args) -{ - struct vkr_context *ctx = dispatch->data; - - CREATE_OBJECT(mod, shader_module, SHADER_MODULE, vkCreateShaderModule, pShaderModule); - - util_hash_table_set_u64(ctx->object_table, mod->base.id, mod); -} - -static void -vkr_dispatch_vkDestroyShaderModule(struct vn_dispatch_context *dispatch, - struct vn_command_vkDestroyShaderModule *args) -{ - struct vkr_context *ctx = dispatch->data; - - DESTROY_OBJECT(mod, shader_module, SHADER_MODULE, vkDestroyShaderModule, shaderModule); - - util_hash_table_remove_u64(ctx->object_table, mod->base.id); -} - -static void -vkr_dispatch_vkCreatePipelineLayout(struct vn_dispatch_context *dispatch, - struct vn_command_vkCreatePipelineLayout *args) -{ - struct vkr_context *ctx = dispatch->data; - - CREATE_OBJECT(layout, pipeline_layout, PIPELINE_LAYOUT, vkCreatePipelineLayout, - pPipelineLayout); - - util_hash_table_set_u64(ctx->object_table, layout->base.id, layout); -} - -static void -vkr_dispatch_vkDestroyPipelineLayout(struct vn_dispatch_context *dispatch, - struct vn_command_vkDestroyPipelineLayout *args) -{ - struct vkr_context *ctx = dispatch->data; - - DESTROY_OBJECT(layout, pipeline_layout, PIPELINE_LAYOUT, vkDestroyPipelineLayout, - pipelineLayout); - - util_hash_table_remove_u64(ctx->object_table, layout->base.id); -} - -static void -vkr_dispatch_vkCreatePipelineCache(struct vn_dispatch_context *dispatch, - struct vn_command_vkCreatePipelineCache *args) -{ - struct vkr_context *ctx = dispatch->data; - - CREATE_OBJECT(cache, pipeline_cache, PIPELINE_CACHE, vkCreatePipelineCache, - pPipelineCache); - - util_hash_table_set_u64(ctx->object_table, cache->base.id, cache); -} - -static void -vkr_dispatch_vkDestroyPipelineCache(struct vn_dispatch_context *dispatch, - struct vn_command_vkDestroyPipelineCache *args) -{ - struct vkr_context *ctx = dispatch->data; - - DESTROY_OBJECT(cache, pipeline_cache, PIPELINE_CACHE, vkDestroyPipelineCache, - pipelineCache); - - util_hash_table_remove_u64(ctx->object_table, cache->base.id); -} - -static void -vkr_dispatch_vkGetPipelineCacheData(UNUSED struct vn_dispatch_context *dispatch, - struct vn_command_vkGetPipelineCacheData *args) -{ - vn_replace_vkGetPipelineCacheData_args_handle(args); - args->ret = vkGetPipelineCacheData(args->device, args->pipelineCache, args->pDataSize, - args->pData); -} - -static void -vkr_dispatch_vkMergePipelineCaches(UNUSED struct vn_dispatch_context *dispatch, - struct vn_command_vkMergePipelineCaches *args) -{ - vn_replace_vkMergePipelineCaches_args_handle(args); - args->ret = vkMergePipelineCaches(args->device, args->dstCache, args->srcCacheCount, - args->pSrcCaches); -} - -static void -vkr_dispatch_vkCreateGraphicsPipelines(struct vn_dispatch_context *dispatch, - struct vn_command_vkCreateGraphicsPipelines *args) -{ - struct vkr_context *ctx = dispatch->data; - - CREATE_PIPELINE_ARRAY(vkCreateGraphicsPipelines); -} - -static void -vkr_dispatch_vkCreateComputePipelines(struct vn_dispatch_context *dispatch, - struct vn_command_vkCreateComputePipelines *args) -{ - struct vkr_context *ctx = dispatch->data; - - CREATE_PIPELINE_ARRAY(vkCreateComputePipelines); -} - -static void -vkr_dispatch_vkDestroyPipeline(struct vn_dispatch_context *dispatch, - struct vn_command_vkDestroyPipeline *args) -{ - struct vkr_context *ctx = dispatch->data; - - DESTROY_OBJECT(pipeline, pipeline, PIPELINE, vkDestroyPipeline, pipeline); - - util_hash_table_remove_u64(ctx->object_table, pipeline->base.id); -} - static void vkr_dispatch_vkGetImageDrmFormatModifierPropertiesEXT( struct vn_dispatch_context *dispatch, @@ -3191,20 +3074,10 @@ vkr_context_init_dispatch(struct vkr_context *ctx) dispatch->dispatch_vkGetQueryPoolResults = vkr_dispatch_vkGetQueryPoolResults; dispatch->dispatch_vkResetQueryPool = vkr_dispatch_vkResetQueryPool; - dispatch->dispatch_vkCreateShaderModule = vkr_dispatch_vkCreateShaderModule; - dispatch->dispatch_vkDestroyShaderModule = vkr_dispatch_vkDestroyShaderModule; - - dispatch->dispatch_vkCreatePipelineLayout = vkr_dispatch_vkCreatePipelineLayout; - dispatch->dispatch_vkDestroyPipelineLayout = vkr_dispatch_vkDestroyPipelineLayout; - - dispatch->dispatch_vkCreatePipelineCache = vkr_dispatch_vkCreatePipelineCache; - dispatch->dispatch_vkDestroyPipelineCache = vkr_dispatch_vkDestroyPipelineCache; - dispatch->dispatch_vkGetPipelineCacheData = vkr_dispatch_vkGetPipelineCacheData; - dispatch->dispatch_vkMergePipelineCaches = vkr_dispatch_vkMergePipelineCaches; - - dispatch->dispatch_vkCreateGraphicsPipelines = vkr_dispatch_vkCreateGraphicsPipelines; - dispatch->dispatch_vkCreateComputePipelines = vkr_dispatch_vkCreateComputePipelines; - dispatch->dispatch_vkDestroyPipeline = vkr_dispatch_vkDestroyPipeline; + vkr_context_init_shader_module_dispatch(ctx); + vkr_context_init_pipeline_layout_dispatch(ctx); + vkr_context_init_pipeline_cache_dispatch(ctx); + vkr_context_init_pipeline_dispatch(ctx); vkr_context_init_command_pool_dispatch(ctx); vkr_context_init_command_buffer_dispatch(ctx);