|
|
|
@ -13,7 +13,7 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render_context) {
|
|
|
|
|
FT_Library library;
|
|
|
|
|
|
|
|
|
|
UIContextStorage ui;
|
|
|
|
|
UILayerStorage layer;
|
|
|
|
|
UILayerStorage layers[2];
|
|
|
|
|
|
|
|
|
|
FontStorage font;
|
|
|
|
|
|
|
|
|
@ -40,36 +40,45 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render_context) {
|
|
|
|
|
|
|
|
|
|
VK_RESULT(load_font(render_context->device, render_context->allocator, ui.font_infos, ui.font_samplers, ui.font_textures, 0, render_context->transfer_pool, render_context->transfer_queue, library, "test.ttf", 16, VK_TRUE, &font));
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_layer(10, 100, 10, render_context->device, render_context->allocator, render_context->transfer_pool, render_context->transfer_queue, &layer));
|
|
|
|
|
VK_RESULT(create_layer(10, 100, 10, render_context->device, render_context->allocator, render_context->transfer_pool, render_context->transfer_queue, &layers[0]));
|
|
|
|
|
VK_RESULT(create_layer(10, 100, 10, render_context->device, render_context->allocator, render_context->transfer_pool, render_context->transfer_queue, &layers[1]));
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_transfer_buffer(render_context->allocator, sizeof(uint32_t) + sizeof(UIRect), &transfer, &transfer_memory, &mapped));
|
|
|
|
|
VK_RESULT(create_transfer_buffer(render_context->allocator, sizeof(uint32_t) + 2*sizeof(UIRect), &transfer, &transfer_memory, &mapped));
|
|
|
|
|
|
|
|
|
|
uint32_t* mapped_count = (uint32_t*)(mapped);
|
|
|
|
|
*mapped_count = 1;
|
|
|
|
|
mapped_count[0] = 1;
|
|
|
|
|
UIRect* mapped_rect = (UIRect*)(mapped + sizeof(uint32_t));
|
|
|
|
|
mapped_rect->pos[0] = 0.0;
|
|
|
|
|
mapped_rect->pos[1] = 0.0;
|
|
|
|
|
mapped_rect->size[0] = 200.0;
|
|
|
|
|
mapped_rect->size[1] = 200.0;
|
|
|
|
|
mapped_rect->color[0] = 1.0;
|
|
|
|
|
mapped_rect->color[1] = 0.0;
|
|
|
|
|
mapped_rect->color[2] = 0.0;
|
|
|
|
|
mapped_rect->color[3] = 1.0;
|
|
|
|
|
mapped_rect[0].pos[0] = 0.0;
|
|
|
|
|
mapped_rect[0].pos[1] = 0.0;
|
|
|
|
|
mapped_rect[0].size[0] = 200.0;
|
|
|
|
|
mapped_rect[0].size[1] = 200.0;
|
|
|
|
|
mapped_rect[0].color[0] = 1.0;
|
|
|
|
|
mapped_rect[0].color[1] = 0.0;
|
|
|
|
|
mapped_rect[0].color[2] = 0.0;
|
|
|
|
|
mapped_rect[0].color[3] = 1.0;
|
|
|
|
|
|
|
|
|
|
mapped_rect[1].pos[0] = 200.0;
|
|
|
|
|
mapped_rect[1].pos[1] = 0.0;
|
|
|
|
|
mapped_rect[1].size[0] = 200.0;
|
|
|
|
|
mapped_rect[1].size[1] = 200.0;
|
|
|
|
|
mapped_rect[1].color[0] = 0.0;
|
|
|
|
|
mapped_rect[1].color[1] = 1.0;
|
|
|
|
|
mapped_rect[1].color[2] = 0.0;
|
|
|
|
|
mapped_rect[1].color[3] = 1.0;
|
|
|
|
|
|
|
|
|
|
VkCommandBuffer command_buffer = command_begin_single(render_context->device, render_context->transfer_pool);
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layer.layer, 0, offsetof(UILayer, draw_rects) + offsetof(DrawCommand, instance_count), sizeof(uint32_t));
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layer.rects, sizeof(uint32_t), 0, sizeof(UIRect));
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[0].layer, 0, offsetof(UILayer, draw_rects) + offsetof(DrawCommand, instance_count), sizeof(uint32_t));
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[1].layer, 0, offsetof(UILayer, draw_rects) + offsetof(DrawCommand, instance_count), sizeof(uint32_t));
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[0].rects, sizeof(uint32_t), 0, sizeof(UIRect));
|
|
|
|
|
command_copy_buffer(command_buffer, transfer, layers[1].rects, sizeof(uint32_t) + sizeof(UIRect), 0, sizeof(UIRect));
|
|
|
|
|
VK_RESULT(command_end_single(render_context->device, command_buffer, render_context->transfer_pool, render_context->transfer_queue));
|
|
|
|
|
vkQueueWaitIdle(render_context->transfer_queue.handle);
|
|
|
|
|
destroy_transfer_buffer(render_context->allocator, transfer, transfer_memory);
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "%ld\n", sizeof(UILayer));
|
|
|
|
|
fprintf(stderr, "%ld\n", sizeof(UIRect));
|
|
|
|
|
|
|
|
|
|
while(glfwWindowShouldClose(window) == 0) {
|
|
|
|
|
glfwPollEvents();
|
|
|
|
|
|
|
|
|
|
result = draw_frame(render_context, &ui, &layer, 1);
|
|
|
|
|
result = draw_frame(render_context, &ui, layers, 2);
|
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
fprintf(stderr, "draw_frame error: %s\n", string_VkResult(result));
|
|
|
|
|
return result;
|
|
|
|
|