|
|
@ -15,7 +15,6 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render) {
|
|
|
|
|
|
|
|
|
|
|
|
UIContextStorage ui;
|
|
|
|
UIContextStorage ui;
|
|
|
|
UIContainerStorage container;
|
|
|
|
UIContainerStorage container;
|
|
|
|
UILayerStorage layers[2];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FontStorage font;
|
|
|
|
FontStorage font;
|
|
|
|
uint32_t font_index;
|
|
|
|
uint32_t font_index;
|
|
|
@ -42,35 +41,39 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render) {
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(load_texture("test.png", render, &ui, &texture_index, &texture));
|
|
|
|
VK_RESULT(load_texture("test.png", render, &ui, &texture_index, &texture));
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_container(0, 0, 200, 200, render, &container));
|
|
|
|
UILayerInput layers[] = {
|
|
|
|
|
|
|
|
{
|
|
|
|
VK_RESULT(create_layer(10, 100, 10, font_index, render, &container, &layers[0]));
|
|
|
|
.strings = 0,
|
|
|
|
VK_RESULT(create_layer(10, 100, 10, font_index, render, &container, &layers[1]));
|
|
|
|
.codes = 0,
|
|
|
|
|
|
|
|
.drawables = 1,
|
|
|
|
VK_RESULT(create_transfer_buffer(render->allocator, 2*sizeof(uint32_t) + 2*sizeof(UIDrawable) + sizeof(UIString) + 100*sizeof(uint32_t), &transfer, &transfer_memory, &mapped));
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
uint32_t* mapped_count = (uint32_t*)(mapped);
|
|
|
|
.strings = 1,
|
|
|
|
mapped_count[0] = 1;
|
|
|
|
.codes = 100,
|
|
|
|
mapped_count[1] = 1;
|
|
|
|
.drawables = 1,
|
|
|
|
UIDrawable* mapped_drawable = (UIDrawable*)(mapped + 2*sizeof(uint32_t));
|
|
|
|
.font = font_index,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_container(0xDEADBEEF, 0.0, 0.0, 200.0, 200.0, sizeof(layers)/sizeof(UILayerInput), layers, render, &container));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_transfer_buffer(render->allocator, 2*sizeof(UIDrawable) + sizeof(UIString) + 100*sizeof(uint32_t), &transfer, &transfer_memory, &mapped));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIDrawable* mapped_drawable = (UIDrawable*)(mapped + 0);
|
|
|
|
set_ui_image(0.0, 0.0, 100.0, 200.0, 1.0, 1.0, 1.0, 1.0, texture_index, &mapped_drawable[0]);
|
|
|
|
set_ui_image(0.0, 0.0, 100.0, 200.0, 1.0, 1.0, 1.0, 1.0, texture_index, &mapped_drawable[0]);
|
|
|
|
set_ui_rect(100.0, 0.0, 100.0, 200.0, 0.0, 1.0, 0.0, 1.0, &mapped_drawable[1]);
|
|
|
|
set_ui_rect(100.0, 0.0, 100.0, 200.0, 0.0, 1.0, 0.0, 1.0, &mapped_drawable[1]);
|
|
|
|
|
|
|
|
|
|
|
|
UIString* mapped_string = (UIString*)(mapped + 2*sizeof(uint32_t) + 2*sizeof(UIDrawable));
|
|
|
|
UIString* mapped_string = (UIString*)(mapped + 2*sizeof(UIDrawable));
|
|
|
|
set_ui_string(0.0, 100.0, 32.0, 1.0, 1.0, 1.0, 1.0, 13, 0, &mapped_string[0]);
|
|
|
|
set_ui_string(0.0, 100.0, 32.0, 1.0, 1.0, 1.0, 1.0, 13, 0, &mapped_string[0]);
|
|
|
|
uint32_t* mapped_codes = (uint32_t*)(mapped + 2*sizeof(uint32_t) + 2*sizeof(UIDrawable) + sizeof(UIString));
|
|
|
|
uint32_t* mapped_codes = (uint32_t*)(mapped + 2*sizeof(UIDrawable) + sizeof(UIString));
|
|
|
|
VK_RESULT(set_ui_codes("Hello, World!", mapped_codes, 0, font.charmap, font.num_symbols));
|
|
|
|
VK_RESULT(set_ui_codes("Hello, World!", mapped_codes, 0, font.charmap, font.num_symbols));
|
|
|
|
|
|
|
|
|
|
|
|
VkCommandBuffer command_buffer = command_begin_single(render->device, render->transfer_pool);
|
|
|
|
VkCommandBuffer command_buffer = command_begin_single(render->device, render->transfer_pool);
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[0].layer, 0, offsetof(UILayer, num_drawables), sizeof(uint32_t));
|
|
|
|
command_copy_buffer(command_buffer, transfer, container.layers[0].drawables, 0, 0, sizeof(UIDrawable));
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[1].layer, 0, offsetof(UILayer, num_drawables), sizeof(uint32_t));
|
|
|
|
command_copy_buffer(command_buffer, transfer, container.layers[1].drawables, sizeof(UIDrawable), 0, sizeof(UIDrawable));
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[1].layer, sizeof(uint32_t), offsetof(UILayer, dispatch_strings) + offsetof(DispatchCommand, x), sizeof(uint32_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[0].drawables, 2*sizeof(uint32_t), 0, sizeof(UIDrawable));
|
|
|
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[1].drawables, 2*sizeof(uint32_t) + sizeof(UIDrawable), 0, sizeof(UIDrawable));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[1].strings, 2*sizeof(uint32_t) + 2*sizeof(UIDrawable), 0, sizeof(UIString));
|
|
|
|
command_copy_buffer(command_buffer, transfer, container.layers[1].strings, 2*sizeof(UIDrawable), 0, sizeof(UIString));
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[1].codes, 2*sizeof(uint32_t) + 2*sizeof(UIDrawable) + sizeof(UIString), 0, 100*sizeof(uint32_t));
|
|
|
|
command_copy_buffer(command_buffer, transfer, container.layers[1].codes, 2*sizeof(UIDrawable) + sizeof(UIString), 0, 100*sizeof(uint32_t));
|
|
|
|
VK_RESULT(command_end_single(render->device, command_buffer, render->transfer_pool, render->transfer_queue));
|
|
|
|
VK_RESULT(command_end_single(render->device, command_buffer, render->transfer_pool, render->transfer_queue));
|
|
|
|
vkQueueWaitIdle(render->transfer_queue.handle);
|
|
|
|
vkQueueWaitIdle(render->transfer_queue.handle);
|
|
|
|
destroy_transfer_buffer(render->allocator, transfer, transfer_memory);
|
|
|
|
destroy_transfer_buffer(render->allocator, transfer, transfer_memory);
|
|
|
@ -78,7 +81,7 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render) {
|
|
|
|
while(glfwWindowShouldClose(window) == 0) {
|
|
|
|
while(glfwWindowShouldClose(window) == 0) {
|
|
|
|
glfwPollEvents();
|
|
|
|
glfwPollEvents();
|
|
|
|
|
|
|
|
|
|
|
|
result = draw_frame(render, &ui, layers, sizeof(layers)/sizeof(UILayerStorage));
|
|
|
|
result = draw_frame(render, &ui, container.layers, container.layer_count);
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
fprintf(stderr, "draw_frame error: %s\n", string_VkResult(result));
|
|
|
|
fprintf(stderr, "draw_frame error: %s\n", string_VkResult(result));
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|