void vku_destroy_buffer(struct vku_buffer *buf)
{
- if(buf) {
- //TODO change when the allocator changes
- vku_free(buf->mem_pool);
-
- vkDestroyBuffer(vk_device, buf->buf, 0);
- delete buf;
- }
}
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;
}
}
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;
// 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
-}