|
|
@ -456,6 +456,20 @@ VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescr
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkBufferCreateInfo symbol_buffer_info = {
|
|
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
|
|
|
|
|
|
|
.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
|
|
|
|
|
|
|
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
|
|
|
|
|
|
.size = sizeof(SymbolInfo)*font->info.num_symbols,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
VmaAllocationCreateInfo symbol_memory_info = {
|
|
|
|
|
|
|
|
.usage = VMA_MEMORY_USAGE_GPU_ONLY,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
result = vmaCreateBuffer(allocator, &symbol_buffer_info, &symbol_memory_info, &descriptor->symbols, &descriptor->symbol_memory, NULL);
|
|
|
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VkBufferCreateInfo uniform_buffer_info = {
|
|
|
|
VkBufferCreateInfo 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,
|
|
|
@ -497,7 +511,7 @@ VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescr
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
|
|
|
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
|
|
|
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
|
|
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
|
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
|
|
.size = sizeof(FontUniform) + image_size,
|
|
|
|
.size = sizeof(FontUniform) + image_size + sizeof(SymbolInfo)*font->info.num_symbols,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
VmaAllocationCreateInfo staging_memory_info = {
|
|
|
|
VmaAllocationCreateInfo staging_memory_info = {
|
|
|
@ -516,18 +530,31 @@ VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescr
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(mapped_staging + image_size + sizeof(FontUniform), symbols, sizeof(SymbolInfo)*font->info.num_symbols);
|
|
|
|
|
|
|
|
VkBufferDeviceAddressInfo address_info = {
|
|
|
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
|
|
|
|
|
|
|
|
.buffer = descriptor->symbols,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
font->info.symbol_list = vkGetBufferDeviceAddress(device, &address_info);
|
|
|
|
memcpy(mapped_staging + image_size, &font->info, sizeof(FontUniform));
|
|
|
|
memcpy(mapped_staging + image_size, &font->info, sizeof(FontUniform));
|
|
|
|
memcpy(mapped_staging, atlas, image_size);
|
|
|
|
memcpy(mapped_staging, atlas, image_size);
|
|
|
|
vmaUnmapMemory(allocator, staging_memory);
|
|
|
|
vmaUnmapMemory(allocator, staging_memory);
|
|
|
|
|
|
|
|
|
|
|
|
VkCommandBuffer command_buffer = command_begin_single(device, transfer_pool);
|
|
|
|
VkCommandBuffer command_buffer = command_begin_single(device, transfer_pool);
|
|
|
|
|
|
|
|
|
|
|
|
VkBufferCopy copy_info = {
|
|
|
|
VkBufferCopy uniform_copy_info = {
|
|
|
|
.size = sizeof(FontUniform),
|
|
|
|
.size = sizeof(FontUniform),
|
|
|
|
.srcOffset = image_size,
|
|
|
|
.srcOffset = image_size,
|
|
|
|
.dstOffset = 0,
|
|
|
|
.dstOffset = 0,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
vkCmdCopyBuffer(command_buffer, staging_buffer, descriptor->uniform, 1, ©_info);
|
|
|
|
vkCmdCopyBuffer(command_buffer, staging_buffer, descriptor->uniform, 1, &uniform_copy_info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkBufferCopy symbol_copy_info = {
|
|
|
|
|
|
|
|
.size = sizeof(SymbolInfo)*font->info.num_symbols,
|
|
|
|
|
|
|
|
.srcOffset = image_size + sizeof(FontUniform),
|
|
|
|
|
|
|
|
.dstOffset = 0,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
vkCmdCopyBuffer(command_buffer, staging_buffer, descriptor->symbols, 1, &symbol_copy_info);
|
|
|
|
|
|
|
|
|
|
|
|
VkImageMemoryBarrier first_barrier = {
|
|
|
|
VkImageMemoryBarrier first_barrier = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
|
|