X-Git-Url: https://eleni.mutantstargoat.com/git/?p=demo;a=blobdiff_plain;f=src%2Fvulkan%2Fvkutil.cc;fp=src%2Fvulkan%2Fvkutil.cc;h=1a33fa710afebac13b111b8dc99598a933413ad0;hp=c1ca1d56d856e6e2bef5ae63660a777683c9d3da;hb=dbce2a319517c09fcf1a9be60ae46a0ff20c423e;hpb=86c912d603be75ac8b2fdb2229f1696e9c0c01d9 diff --git a/src/vulkan/vkutil.cc b/src/vulkan/vkutil.cc index c1ca1d5..1a33fa7 100644 --- a/src/vulkan/vkutil.cc +++ b/src/vulkan/vkutil.cc @@ -19,6 +19,7 @@ int vk_qfamily; VkCommandPool vk_pool; VkSurfaceKHR vk_surface; VkSwapchainKHR vk_swapchain; +VkRenderPass vk_renderpass; VkDescriptorPool vk_dpool; /* static functions */ @@ -725,4 +726,88 @@ void vku_free_descriptor_sets(VkDescriptorSet *sets, int num) vkFreeDescriptorSets(vk_device, vk_dpool, num, sets); } +bool vku_update_descriptor_sets(VkDescriptorSet *sets, int num_sets) +{ +// std::vector + return true; +} +VkPipelineCache vku_create_pipeline_cache() +{ + VkPipelineCacheCreateInfo cinf; + memset(&cinf, 0, sizeof cinf); + cinf.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; + + VkPipelineCache cache; + if(vkCreatePipelineCache(vk_device, &cinf, 0, &cache) != VK_SUCCESS) { + fprintf(stderr, "Failed to create pipeline cache.\n"); + return 0; + } + return cache; +} + +void vku_destroy_pipeline_cache(VkPipelineCache cache) +{ + vkDestroyPipelineCache(vk_device, cache, 0); +} + +void vku_pl_init_shader_stage_state_info(VkPipelineShaderStageCreateInfo *ssinf, + VkShaderStageFlagBits stage, VkShaderModule sm) +{ + memset(ssinf, 0, sizeof *ssinf); + ssinf->sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + ssinf->stage = stage; + ssinf->module = sm; + ssinf->pName = "main"; +} + +void vku_pl_init_input_asm_state_info(VkPipelineInputAssemblyStateCreateInfo *iasinf) +{ + memset(iasinf, 0, sizeof *iasinf); + iasinf->sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; + iasinf->topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; +} + +void vku_pl_init_viewport_state_info(VkPipelineViewportStateCreateInfo *vsinf, + VkViewport *viewports, int num_viewports, VkRect2D *scissors, + int num_scissors) +{ + memset(vsinf, 0, sizeof *vsinf); + vsinf->sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; + vsinf->viewportCount = num_viewports; + vsinf->scissorCount = num_scissors; + vsinf->pViewports = viewports; + vsinf->pScissors = scissors; +} + +void vku_pl_init_rasterization_state_info(VkPipelineRasterizationStateCreateInfo *rsinf) +{ + memset(rsinf, 0, sizeof *rsinf); + rsinf->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; + rsinf->polygonMode = VK_POLYGON_MODE_FILL; + rsinf->cullMode = VK_CULL_MODE_FRONT_BIT; + rsinf->frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; +} + +void vku_pl_init_multisample_state_info(VkPipelineMultisampleStateCreateInfo *msinf) +{ + memset(msinf, 0, sizeof *msinf); + msinf->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; + msinf->rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; +} + +void vku_pl_init_depth_stencil_state_info(VkPipelineDepthStencilStateCreateInfo *dsinf, + bool enable) +{ + memset(dsinf, 0, sizeof *dsinf); + dsinf->sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; + dsinf->depthTestEnable = enable ? VK_TRUE : VK_FALSE; +} + +void vku_pl_init_color_blend_state_info(VkPipelineColorBlendStateCreateInfo *cbsinf, + bool enable) +{ + memset(cbsinf, 0, sizeof *cbsinf); + cbsinf->sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; + //TODO +}