static VkImage *images;
static VkImageView *iviews;
static uint32_t num_images;
-//renderpass
-static VkRenderPass rpass;
static VkFramebuffer fbs[2];
//semaphores-drawing-presentation
static uint32_t curr_img; // current sc image
static VkSemaphore psema;
-
/* static variables */
-static VkDeviceMemory gpu_mem; // to be replaced when I fix the allocator
static Vec4 clear_color(1, 0.1, 0.1, 1.0);
/* static functions */
return false;
}
- if(!glfwGetPhysicalDevicePresentationSupport(vkinst, vk_physical, vkqfamily)) {
+ if(!glfwGetPhysicalDevicePresentationSupport(vk_instance, vk_physical, vk_qfamily)) {
fprintf(stderr, "Presentation support not found.\n");
return false;
}
return false;
}
- VkResult res = glfwCreateWindowSurface(vkinst, win, 0, &vk_surface);
+ VkResult res = glfwCreateWindowSurface(vk_instance, win, 0, &vk_surface);
if(res != VK_SUCCESS) {
fprintf(stderr, "Failed to create KHR surface: %s\n", vku_get_vulkan_error_str(res));
return false;
VkMemoryRequirements dmem_reqs;
vkGetImageMemoryRequirements(vk_device, dimg, &dmem_reqs);
- gpu_mem = vk_allocate(dmem_reqs.size);
-
- if(!gpu_mem)
+ DevMemBlock block;
+ if(!vku_allocate(dmem_reqs.size, &block)) {
+ fprintf(stderr, "Failed to allocate zbuffer image.\n");
return false;
+ }
- vkBindImageMemory(vk_device, dimg, gpu_mem, 0);
+ vkBindImageMemory(vk_device, dimg, block.dev_mem, 0);
if(!vk_image_set_layout(init_buf, dimg, VK_IMAGE_ASPECT_DEPTH_BIT,
VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
rinf.subpassCount = 1;
rinf.pSubpasses = &sd;
- if(vkCreateRenderPass(vk_device, &rinf, 0, &rpass) != VK_SUCCESS) {
- fprintf(stderr, "Failed to create rpass.\n");
+ if(vkCreateRenderPass(vk_device, &rinf, 0, &vk_renderpass) != VK_SUCCESS) {
+ fprintf(stderr, "Failed to create render pass.\n");
return false;
}
VkFramebufferCreateInfo fbinf;
memset(&fbinf, 0, sizeof fbinf);
fbinf.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
- fbinf.renderPass = rpass;
+ fbinf.renderPass = vk_renderpass;
fbinf.attachmentCount = 2;
fbinf.pAttachments = fb_att;
fbinf.width = win_w;
VkRenderPassBeginInfo rbinf;
memset(&rbinf, 0, sizeof rbinf);
rbinf.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- rbinf.renderPass = rpass;
+ rbinf.renderPass = vk_renderpass;
rbinf.framebuffer = fbs[i];
rbinf.renderArea.extent.width = win_w;
rbinf.renderArea.extent.height = win_h;
void cleanup_vulkan()
{
- //TODO!!!
free_rendering_command_buffers(rbufs, 2);
if(win) {
glfwDestroyWindow(win);
static void reshape(int width, int height)
{
-// VkSwapchainKHR sc;
-// if(!(sc = vku_create_swapchain(vk_surface, width, height, 2, VK_PRESENT_MODE_FIFO_KHR,
-// vk_swapchain))) {
-// fprintf(stderr, "Failed to create %dx%d double-buffered swapchain\n", width, height);
-// return;
-// }
-// vk_swapchain = sc;
-//
-// delete [] vkswapchain_images;
-// vkswapchain_images = vku_get_swapchain_images(sc, 0);
-// vk_curr_swapchain_image = vku_get_next_image(vk_swapchain);
}
static void clear(float r, float g, float b)