|
|
@ -74,7 +74,7 @@ VkResult create_ui_rect_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.binding = 1,
|
|
|
|
.binding = 1,
|
|
|
|
.stride = sizeof(struct UIRect),
|
|
|
|
.stride = sizeof(ColoredRect),
|
|
|
|
.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE,
|
|
|
|
.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -90,19 +90,19 @@ VkResult create_ui_rect_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
|
|
|
|
.binding = 1,
|
|
|
|
.binding = 1,
|
|
|
|
.location = 1,
|
|
|
|
.location = 1,
|
|
|
|
.format = VK_FORMAT_R32G32B32_SFLOAT,
|
|
|
|
.format = VK_FORMAT_R32G32B32_SFLOAT,
|
|
|
|
.offset = offsetof(struct UIRect, pos),
|
|
|
|
.offset = offsetof(ColoredRect, pos),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.binding = 1,
|
|
|
|
.binding = 1,
|
|
|
|
.location = 2,
|
|
|
|
.location = 2,
|
|
|
|
.format = VK_FORMAT_R32G32_SFLOAT,
|
|
|
|
.format = VK_FORMAT_R32G32_SFLOAT,
|
|
|
|
.offset = offsetof(struct UIRect, size),
|
|
|
|
.offset = offsetof(ColoredRect, size),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.binding = 1,
|
|
|
|
.binding = 1,
|
|
|
|
.location = 3,
|
|
|
|
.location = 3,
|
|
|
|
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
|
|
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
|
|
.offset = offsetof(struct UIRect, color),
|
|
|
|
.offset = offsetof(ColoredRect, color),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -313,7 +313,7 @@ VkResult create_ui_descriptor_set(VkDevice device, VmaAllocator allocator, VkExt
|
|
|
|
VkBufferCreateInfo ui_uniform_buffer_info = {
|
|
|
|
VkBufferCreateInfo ui_uniform_buffer_info = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
|
|
|
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
|
|
|
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
|
|
|
.size = sizeof(struct UIUniform),
|
|
|
|
.size = sizeof(UIUniform),
|
|
|
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
|
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -331,7 +331,7 @@ VkResult create_ui_descriptor_set(VkDevice device, VmaAllocator allocator, VkExt
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
struct UIUniform ui_uniform;
|
|
|
|
UIUniform ui_uniform;
|
|
|
|
vec3 screen_offset = {-1.0, -1.0, 0.0};
|
|
|
|
vec3 screen_offset = {-1.0, -1.0, 0.0};
|
|
|
|
vec3 screen_scale = {1.0/(float)swapchain_extent.width, 1.0/(float)swapchain_extent.height, 1.0};
|
|
|
|
vec3 screen_scale = {1.0/(float)swapchain_extent.width, 1.0/(float)swapchain_extent.height, 1.0};
|
|
|
|
glm_mat4_identity(ui_uniform.screen);
|
|
|
|
glm_mat4_identity(ui_uniform.screen);
|
|
|
@ -360,7 +360,7 @@ VkResult create_ui_descriptor_set(VkDevice device, VmaAllocator allocator, VkExt
|
|
|
|
return VK_SUCCESS;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
VkResult create_ui_rect_buffer(VkDevice device, Queue transfer_queue, VkCommandPool transfer_pool, VmaAllocator allocator, struct RectBuffer* rect) {
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t vertex_buffer_size = 4 * sizeof(vec2);
|
|
|
|
uint32_t vertex_buffer_size = 4 * sizeof(vec2);
|
|
|
|
uint32_t index_buffer_size = 6 * sizeof(uint32_t);
|
|
|
|
uint32_t index_buffer_size = 6 * sizeof(uint32_t);
|
|
|
@ -398,7 +398,7 @@ VkResult create_ui_rect_buffer(VkDevice device, Queue transfer_queue, VkCommandP
|
|
|
|
.size = vertex_buffer_size,
|
|
|
|
.size = vertex_buffer_size,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
result = vmaCreateBuffer(allocator, &vertex_buffer_info, &allocation_info, vertex_buffer, vertex_memory, NULL);
|
|
|
|
result = vmaCreateBuffer(allocator, &vertex_buffer_info, &allocation_info, &rect->vertex, &rect->vertex_memory, NULL);
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -410,7 +410,7 @@ VkResult create_ui_rect_buffer(VkDevice device, Queue transfer_queue, VkCommandP
|
|
|
|
.size = index_buffer_size,
|
|
|
|
.size = index_buffer_size,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
result = vmaCreateBuffer(allocator, &index_buffer_info, &allocation_info, index_buffer, index_memory, NULL);
|
|
|
|
result = vmaCreateBuffer(allocator, &index_buffer_info, &allocation_info, &rect->index, &rect->index_memory, NULL);
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -447,14 +447,14 @@ VkResult create_ui_rect_buffer(VkDevice device, Queue transfer_queue, VkCommandP
|
|
|
|
.dstOffset = 0,
|
|
|
|
.dstOffset = 0,
|
|
|
|
.srcOffset = 0,
|
|
|
|
.srcOffset = 0,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, *vertex_buffer, 1, &vertex_copy_region);
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, rect->vertex, 1, &vertex_copy_region);
|
|
|
|
|
|
|
|
|
|
|
|
VkBufferCopy index_copy_region = {
|
|
|
|
VkBufferCopy index_copy_region = {
|
|
|
|
.size = index_buffer_size,
|
|
|
|
.size = index_buffer_size,
|
|
|
|
.dstOffset = 0,
|
|
|
|
.dstOffset = 0,
|
|
|
|
.srcOffset = vertex_buffer_size,
|
|
|
|
.srcOffset = vertex_buffer_size,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, *index_buffer, 1, &index_copy_region);
|
|
|
|
vkCmdCopyBuffer(copy_buffer, temp_buffer, rect->index, 1, &index_copy_region);
|
|
|
|
|
|
|
|
|
|
|
|
result = command_end_single(device, copy_buffer, transfer_pool, transfer_queue);
|
|
|
|
result = command_end_single(device, copy_buffer, transfer_pool, transfer_queue);
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|