|
|
@ -371,11 +371,23 @@ VkResult load_texture(
|
|
|
|
VkDevice device,
|
|
|
|
VkDevice device,
|
|
|
|
VmaAllocator allocator,
|
|
|
|
VmaAllocator allocator,
|
|
|
|
UIContextStorage* context,
|
|
|
|
UIContextStorage* context,
|
|
|
|
uint32_t index,
|
|
|
|
|
|
|
|
VkCommandPool transfer_pool,
|
|
|
|
VkCommandPool transfer_pool,
|
|
|
|
Queue transfer_queue,
|
|
|
|
Queue transfer_queue,
|
|
|
|
const char* png_path,
|
|
|
|
const char* png_path,
|
|
|
|
|
|
|
|
uint32_t* index,
|
|
|
|
TextureStorage* memory) {
|
|
|
|
TextureStorage* memory) {
|
|
|
|
|
|
|
|
*index = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
for(uint32_t i = 0; i < context->max_textures; i++) {
|
|
|
|
|
|
|
|
if(context->texture_slots[i] == 0) {
|
|
|
|
|
|
|
|
context->texture_slots[i] = 1;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*index == 0xFFFFFFFF) {
|
|
|
|
|
|
|
|
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
spng_ctx* spng = spng_ctx_new(0);
|
|
|
|
spng_ctx* spng = spng_ctx_new(0);
|
|
|
|
if(spng == NULL) {
|
|
|
|
if(spng == NULL) {
|
|
|
|
return VK_ERROR_UNKNOWN;
|
|
|
|
return VK_ERROR_UNKNOWN;
|
|
|
@ -548,7 +560,7 @@ VkResult load_texture(
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.dstSet = context->textures,
|
|
|
|
.dstSet = context->textures,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstArrayElement = index,
|
|
|
|
.dstArrayElement = *index,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.pImageInfo = &desc_image_info,
|
|
|
|
.pImageInfo = &desc_image_info,
|
|
|
@ -557,7 +569,7 @@ VkResult load_texture(
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.dstSet = context->samplers,
|
|
|
|
.dstSet = context->samplers,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstArrayElement = index,
|
|
|
|
.dstArrayElement = *index,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.pImageInfo = &desc_sampler_info,
|
|
|
|
.pImageInfo = &desc_sampler_info,
|
|
|
@ -573,14 +585,26 @@ VkResult load_font(
|
|
|
|
VkDevice device,
|
|
|
|
VkDevice device,
|
|
|
|
VmaAllocator allocator,
|
|
|
|
VmaAllocator allocator,
|
|
|
|
UIContextStorage* context,
|
|
|
|
UIContextStorage* context,
|
|
|
|
uint32_t index,
|
|
|
|
|
|
|
|
VkCommandPool transfer_pool,
|
|
|
|
VkCommandPool transfer_pool,
|
|
|
|
Queue transfer_queue,
|
|
|
|
Queue transfer_queue,
|
|
|
|
FT_Library library,
|
|
|
|
FT_Library library,
|
|
|
|
const char* ttf_file,
|
|
|
|
const char* ttf_file,
|
|
|
|
uint32_t size,
|
|
|
|
uint32_t size,
|
|
|
|
VkBool32 antialias,
|
|
|
|
VkBool32 antialias,
|
|
|
|
|
|
|
|
uint32_t* index,
|
|
|
|
FontStorage* memory) {
|
|
|
|
FontStorage* memory) {
|
|
|
|
|
|
|
|
*index = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
for(uint32_t i = 0; i < context->max_fonts; i++) {
|
|
|
|
|
|
|
|
if(context->font_slots[i] == 0) {
|
|
|
|
|
|
|
|
context->font_slots[i] = 1;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*index == 0xFFFFFFFF) {
|
|
|
|
|
|
|
|
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_Face face;
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
|
|
|
|
int error;
|
|
|
|
int error;
|
|
|
@ -699,7 +723,7 @@ VkResult load_font(
|
|
|
|
free(symbols);
|
|
|
|
free(symbols);
|
|
|
|
|
|
|
|
|
|
|
|
VkCommandBuffer command_buffer = command_begin_single(device, transfer_pool);
|
|
|
|
VkCommandBuffer command_buffer = command_begin_single(device, transfer_pool);
|
|
|
|
command_copy_buffer(command_buffer, transfer, context->font_infos, image_size*info.num_symbols, index*sizeof(Font), sizeof(Font));
|
|
|
|
command_copy_buffer(command_buffer, transfer, context->font_infos, image_size*info.num_symbols, *index*sizeof(Font), sizeof(Font));
|
|
|
|
command_copy_buffer(command_buffer, transfer, memory->symbols, image_size*info.num_symbols + sizeof(Font), 0, sizeof(SymbolInfo)*info.num_symbols);
|
|
|
|
command_copy_buffer(command_buffer, transfer, memory->symbols, image_size*info.num_symbols + sizeof(Font), 0, sizeof(SymbolInfo)*info.num_symbols);
|
|
|
|
|
|
|
|
|
|
|
|
VkImageMemoryBarrier first_barrier = {
|
|
|
|
VkImageMemoryBarrier first_barrier = {
|
|
|
@ -791,7 +815,7 @@ VkResult load_font(
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.dstSet = context->font_textures,
|
|
|
|
.dstSet = context->font_textures,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstArrayElement = index,
|
|
|
|
.dstArrayElement = *index,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.pImageInfo = &desc_texture_info,
|
|
|
|
.pImageInfo = &desc_texture_info,
|
|
|
@ -800,7 +824,7 @@ VkResult load_font(
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
|
|
.dstSet = context->font_samplers,
|
|
|
|
.dstSet = context->font_samplers,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstBinding = 0,
|
|
|
|
.dstArrayElement = index,
|
|
|
|
.dstArrayElement = *index,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.descriptorCount = 1,
|
|
|
|
.pImageInfo = &desc_sampler_info,
|
|
|
|
.pImageInfo = &desc_sampler_info,
|
|
|
@ -1033,6 +1057,11 @@ VkResult create_ui_context(
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_ui_pipeline(device, render_pass, memory->samplers_layout, memory->textures_layout, &memory->pipeline, &memory->string_pipeline));
|
|
|
|
VK_RESULT(create_ui_pipeline(device, render_pass, memory->samplers_layout, memory->textures_layout, &memory->pipeline, &memory->string_pipeline));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memory->max_textures = max_textures;
|
|
|
|
|
|
|
|
memory->max_fonts = max_fonts;
|
|
|
|
|
|
|
|
memory->texture_slots = malloc(max_textures);
|
|
|
|
|
|
|
|
memory->font_slots = malloc(max_fonts);
|
|
|
|
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|