X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fapp.c;h=ae0a1f1cccbc162c6bea85c2fcf9714f52c23010;hb=51c70e21b25d107c4d86c6ae0c16eac7e0fff22a;hp=9a723095d97cb8ac2d0c78130fd4c6f3f28b1e19;hpb=6d36eee057f3d8504e337e6000c664683c2989ab;p=vktest3 diff --git a/src/app.c b/src/app.c index 9a72309..ae0a1f1 100644 --- a/src/app.c +++ b/src/app.c @@ -1,9 +1,14 @@ #include #include +#include #include "app.h" #include "vk.h" -static VkSemaphore sem_getimg; +int win_width, win_height; + +static int rpass, pipeln, fb; +static VkSemaphore sem_getimg, sem_draw; +static VkQueue queue; int app_init(void) { @@ -13,6 +18,19 @@ int app_init(void) return -1; } + if(!(queue = vk_getq(VKQ_GFX | VKQ_PRESENT, 0))) { + return -1; + } + + rpass = vk_create_rpass(); + + fb = vk_create_fb(); + vk_fb_size(fb, win_width, win_height); + vk_fb_rpass(fb, rpass); + + pipeln = vk_create_pipeln(); + vk_pipeln_ + sem_getimg = vk_create_sem(); sem_draw = vk_create_sem(); return 0; @@ -35,13 +53,33 @@ void app_display(void) imgid = vk_next_image(sem_getimg); cmdbuf = vk_get_cmdbuf(imgid); - /* TODO record */ + { + VkCommandBufferBeginInfo cmdbegin = {0}; + VkRenderPassBeginInfo rpbegin = {0}; + VkClearValue clear; + + cmdbegin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; + cmdbegin.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; + + if(vkBeginCommandBuffer(cmdbuf, &cmdbegin) != 0) { + fprintf(stderr, "failed to begin command buffer recording\n"); + abort(); + } + + clear.color.float32[0] = 0.5f; + clear.color.float32[1] = 0.1f; + clear.color.float32[2] = 0.2f; + clear.color.float32[3] = 1.0f; + + rpbegin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; + rpbegin.renderPass = + } /* submit the command buffer, wait for one semaphore, signal another */ - vk_submit(cmdbuf, sem_getimg, sem_draw); + vk_submit(queue, cmdbuf, sem_getimg, sem_draw); /* swap buffers after drawing is finished */ - vk_present(sem_draw); + vk_present(queue, imgid, sem_draw); } void app_reshape(int x, int y)