X-Git-Url: https://eleni.mutantstargoat.com/git/?p=demo;a=blobdiff_plain;f=src%2Fvulkan%2Fvkutil.cc;fp=src%2Fvulkan%2Fvkutil.cc;h=04a9fe560170b76da7f52865c85ab3c3a45f2bcc;hp=46228192754b29a68f307ae145cea953a134f0c6;hb=f6ceb163227d00d7f97df1fc2dfbdd419c56277e;hpb=75b8713addd14a845e2fa8ad9a9d3d4a6a323bec diff --git a/src/vulkan/vkutil.cc b/src/vulkan/vkutil.cc index 4622819..04a9fe5 100644 --- a/src/vulkan/vkutil.cc +++ b/src/vulkan/vkutil.cc @@ -427,15 +427,12 @@ struct vku_buffer *vku_create_buffer(int sz, unsigned int usage) void vku_destroy_buffer(struct vku_buffer *buf) { - if(buf) { - vkDestroyBuffer(vk_device, buf->buf, 0); - } } bool vku_update_buffer(vku_buffer *buf, int size, void *data) { uint8_t *pdata; - if(vkMapMemory(vk_device, buf->mem_pool, 0, size, 0, (void**)&pdata) != VK_SUCCESS) { + if(vkMapMemory(vk_device, buf->mem_pool, 0, size, 0, (void **)&pdata) != VK_SUCCESS) { fprintf(stderr, "Failed to map memory.\n"); return false; } @@ -620,8 +617,8 @@ static const char *get_mem_size_str(long sz) } vku_descriptor *vku_create_descriptor(VkDescriptorType type, - VkFlags stage, int binding_point, - int size, int num_desc) + VkFlags stage, int binding_point, + int size, int num_desc) { vku_descriptor *desc = new vku_descriptor; @@ -727,83 +724,3 @@ 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 -}