|
|
|
@ -285,7 +285,7 @@ VkPipelineVertexInputStateCreateInfo input_info = {
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDescriptorSetLayout ui_descriptor_layout, VkDescriptorSetLayout text_layout, GraphicsPipeline* pipeline) {
|
|
|
|
|
VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDescriptorSetLayout ui_descriptor_layout, VkDescriptorSetLayout font_layout, GraphicsPipeline* pipeline, ComputePipeline* compute) {
|
|
|
|
|
VkShaderModule vert_shader = load_shader_file("shader_src/ui_text.vert.spv", device);
|
|
|
|
|
if(vert_shader == VK_NULL_HANDLE) {
|
|
|
|
|
return VK_ERROR_UNKNOWN;
|
|
|
|
@ -366,7 +366,7 @@ VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
|
|
|
|
|
.vertexAttributeDescriptionCount = sizeof(attributes)/sizeof(VkVertexInputAttributeDescription),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkDescriptorSetLayout all_layouts[] = {ui_descriptor_layout, text_layout};
|
|
|
|
|
VkDescriptorSetLayout all_layouts[] = {ui_descriptor_layout, font_layout};
|
|
|
|
|
VkPipelineLayoutCreateInfo layout_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
|
|
|
|
.setLayoutCount = sizeof(all_layouts)/sizeof(VkDescriptorSetLayout),
|
|
|
|
@ -387,9 +387,9 @@ VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkResult create_text_descriptor_pool(VkDevice device, uint32_t max_sets, VkDescriptorPool* pool, VkDescriptorSetLayout* text_descriptor_layout) {
|
|
|
|
|
VkResult create_text_descriptor_pools(VkDevice device, uint32_t max_sets, VkDescriptorPool* font_pool, VkDescriptorSetLayout* font_layout) {
|
|
|
|
|
VkResult result;
|
|
|
|
|
VkDescriptorPoolSize pool_sizes[] = {
|
|
|
|
|
VkDescriptorPoolSize font_pool_sizes[] = {
|
|
|
|
|
{
|
|
|
|
|
.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
|
|
|
|
.descriptorCount = 1,
|
|
|
|
@ -397,22 +397,22 @@ VkResult create_text_descriptor_pool(VkDevice device, uint32_t max_sets, VkDescr
|
|
|
|
|
{
|
|
|
|
|
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
|
|
|
|
.descriptorCount = 1,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkDescriptorPoolCreateInfo pool_info = {
|
|
|
|
|
VkDescriptorPoolCreateInfo font_pool_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
|
|
|
|
.pPoolSizes = pool_sizes,
|
|
|
|
|
.poolSizeCount = sizeof(pool_sizes)/sizeof(VkDescriptorPoolSize),
|
|
|
|
|
.pPoolSizes = font_pool_sizes,
|
|
|
|
|
.poolSizeCount = sizeof(font_pool_sizes)/sizeof(VkDescriptorPoolSize),
|
|
|
|
|
.maxSets = max_sets,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result = vkCreateDescriptorPool(device, &pool_info, NULL, pool);
|
|
|
|
|
result = vkCreateDescriptorPool(device, &font_pool_info, NULL, font_pool);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkDescriptorSetLayoutBinding text_descriptor_bindings[] = {
|
|
|
|
|
VkDescriptorSetLayoutBinding font_descriptor_bindings[] = {
|
|
|
|
|
{
|
|
|
|
|
.binding = 0,
|
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
|
|
|
@ -424,21 +424,20 @@ VkResult create_text_descriptor_pool(VkDevice device, uint32_t max_sets, VkDescr
|
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
|
|
|
|
.descriptorCount = 1,
|
|
|
|
|
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkDescriptorSetLayoutCreateInfo text_descriptor_info = {
|
|
|
|
|
VkDescriptorSetLayoutCreateInfo font_descriptor_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
|
|
|
|
.pBindings = text_descriptor_bindings,
|
|
|
|
|
.bindingCount = sizeof(text_descriptor_bindings)/sizeof(VkDescriptorSetLayoutBinding),
|
|
|
|
|
.pBindings = font_descriptor_bindings,
|
|
|
|
|
.bindingCount = sizeof(font_descriptor_bindings)/sizeof(VkDescriptorSetLayoutBinding),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result = vkCreateDescriptorSetLayout(device, &text_descriptor_info, NULL, text_descriptor_layout);
|
|
|
|
|
result = vkCreateDescriptorSetLayout(device, &font_descriptor_info, NULL, font_layout);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -472,7 +471,7 @@ VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescr
|
|
|
|
|
|
|
|
|
|
VkBufferCreateInfo uniform_buffer_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
|
|
|
|
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
|
|
|
|
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
|
|
|
|
.size = sizeof(FontUniform),
|
|
|
|
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
|
|
|
};
|
|
|
|
@ -495,6 +494,7 @@ VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescr
|
|
|
|
|
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
|
|
|
|
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
|
|
|
|
.samples = VK_SAMPLE_COUNT_1_BIT,
|
|
|
|
|
.imageType = VK_IMAGE_TYPE_2D,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VmaAllocationCreateInfo image_memory_info = {
|
|
|
|
@ -605,6 +605,7 @@ VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescr
|
|
|
|
|
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
|
|
|
|
.format = VK_FORMAT_R8G8B8A8_SRGB,
|
|
|
|
|
.subresourceRange = {
|
|
|
|
|
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
|
|
|
|
.layerCount = 1,
|
|
|
|
|
.baseMipLevel = 0,
|
|
|
|
|
.levelCount = 1,
|
|
|
|
@ -890,12 +891,12 @@ VkResult init_pipelines(VkDevice device, VmaAllocator allocator, VkExtent2D swap
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = create_text_descriptor_pool(device, 10, &context->font_pool, &context->font_layout);
|
|
|
|
|
result = create_text_descriptor_pools(device, 10, &context->font_pool, &context->font_layout);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = create_ui_text_pipeline(device, render_pass, context->ui_descriptor_layout, context->font_layout, &context->ui_pipeline_text);
|
|
|
|
|
result = create_ui_text_pipeline(device, render_pass, context->ui_descriptor_layout, context->font_layout, &context->ui_pipeline_text, &context->ui_compute_text);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|