|
|
|
@ -48,7 +48,7 @@ VkShaderModule load_shader_file(const char* path, VkDevice device) {
|
|
|
|
|
return shader;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkResult create_ui_polygon_pipeline(VkDevice device, VkRenderPass render_pass, VkDescriptorSetLayout descriptor_layout, GraphicsPipeline* pipeline) {
|
|
|
|
|
VkResult create_ui_rect_pipeline(VkDevice device, VkRenderPass render_pass, VkDescriptorSetLayout descriptor_layout, GraphicsPipeline* pipeline) {
|
|
|
|
|
VkShaderModule vert_shader = load_shader_file("shader_src/ui_polygon.vert.spv", device);
|
|
|
|
|
VkShaderModule frag_shader = load_shader_file("shader_src/ui_polygon.frag.spv", device);
|
|
|
|
|
VkPipelineShaderStageCreateInfo shader_stages[] = {
|
|
|
|
@ -74,7 +74,7 @@ VkResult create_ui_polygon_pipeline(VkDevice device, VkRenderPass render_pass, V
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.binding = 1,
|
|
|
|
|
.stride = sizeof(struct UIElement),
|
|
|
|
|
.stride = sizeof(struct UIRect),
|
|
|
|
|
.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
@ -90,19 +90,19 @@ VkResult create_ui_polygon_pipeline(VkDevice device, VkRenderPass render_pass, V
|
|
|
|
|
.binding = 1,
|
|
|
|
|
.location = 1,
|
|
|
|
|
.format = VK_FORMAT_R32G32B32_SFLOAT,
|
|
|
|
|
.offset = offsetof(struct UIElement, pos),
|
|
|
|
|
.offset = offsetof(struct UIRect, pos),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.binding = 1,
|
|
|
|
|
.location = 2,
|
|
|
|
|
.format = VK_FORMAT_R32G32_SFLOAT,
|
|
|
|
|
.offset = offsetof(struct UIElement, size),
|
|
|
|
|
.offset = offsetof(struct UIRect, size),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.binding = 1,
|
|
|
|
|
.location = 3,
|
|
|
|
|
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
|
|
|
.offset = offsetof(struct UIElement, color),
|
|
|
|
|
.offset = offsetof(struct UIRect, color),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -360,13 +360,8 @@ VkResult create_ui_descriptor_set(VkDevice device, VmaAllocator allocator, VkExt
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkResult create_ui_polygon_buffer(VkDevice device, Queue transfer_queue, VkCommandPool transfer_pool, VmaAllocator allocator, struct UIPolygon* polygon, VmaAllocation* polygon_vertex_memory, VmaAllocation* polygon_index_memory) {
|
|
|
|
|
VkResult create_ui_rect_buffer(VkDevice device, Queue transfer_queue, VkCommandPool transfer_pool, VmaAllocator allocator, VkBuffer* vertex_buffer, VkBuffer* index_buffer, VmaAllocation* vertex_memory, VmaAllocation* index_memory) {
|
|
|
|
|
|
|
|
|
|
// Create and populate polygon buffers
|
|
|
|
|
polygon->indices = 6;
|
|
|
|
|
polygon->vertices = 4;
|
|
|
|
|
polygon->vertex_offset = 0;
|
|
|
|
|
polygon->index_offset = 0;
|
|
|
|
|
uint32_t vertex_buffer_size = 4 * sizeof(vec2);
|
|
|
|
|
uint32_t index_buffer_size = 6 * sizeof(uint32_t);
|
|
|
|
|
|
|
|
|
@ -403,7 +398,7 @@ VkResult create_ui_polygon_buffer(VkDevice device, Queue transfer_queue, VkComma
|
|
|
|
|
.size = vertex_buffer_size,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result = vmaCreateBuffer(allocator, &vertex_buffer_info, &allocation_info, &polygon->vertex_buffer, polygon_vertex_memory, NULL);
|
|
|
|
|
result = vmaCreateBuffer(allocator, &vertex_buffer_info, &allocation_info, vertex_buffer, vertex_memory, NULL);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
@ -415,7 +410,7 @@ VkResult create_ui_polygon_buffer(VkDevice device, Queue transfer_queue, VkComma
|
|
|
|
|
.size = index_buffer_size,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result = vmaCreateBuffer(allocator, &index_buffer_info, &allocation_info, &polygon->index_buffer, polygon_index_memory, NULL);
|
|
|
|
|
result = vmaCreateBuffer(allocator, &index_buffer_info, &allocation_info, index_buffer, index_memory, NULL);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
@ -452,14 +447,14 @@ VkResult create_ui_polygon_buffer(VkDevice device, Queue transfer_queue, VkComma
|
|
|
|
|
.dstOffset = 0,
|
|
|
|
|
.srcOffset = 0,
|
|
|
|
|
};
|
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, polygon->vertex_buffer, 1, &vertex_copy_region);
|
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, *vertex_buffer, 1, &vertex_copy_region);
|
|
|
|
|
|
|
|
|
|
VkBufferCopy index_copy_region = {
|
|
|
|
|
.size = index_buffer_size,
|
|
|
|
|
.dstOffset = 0,
|
|
|
|
|
.srcOffset = vertex_buffer_size,
|
|
|
|
|
};
|
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, polygon->index_buffer, 1, &index_copy_region);
|
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, *index_buffer, 1, &index_copy_region);
|
|
|
|
|
|
|
|
|
|
result = command_end_single(device, copy_buffer, transfer_pool, transfer_queue);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|