X-Git-Url: https://eleni.mutantstargoat.com/git/?p=vkrt;a=blobdiff_plain;f=src%2Fmain.c;h=6309b410529c74341b382fe717d1a32b3c98d7d9;hp=b0a5ec4223e0872e3a2801969a8a7fe28d9fb36c;hb=9d56322eb3c2c9967ab988faeb26e86be9661e34;hpb=9c5fa12eb2c6db6c8a3fbd280bab8951cf51f0a0 diff --git a/src/main.c b/src/main.c index b0a5ec4..6309b41 100644 --- a/src/main.c +++ b/src/main.c @@ -41,8 +41,10 @@ static VkSurfaceKHR vk_surf; static int vsz, fsz; static struct vk_renderer vk_rnd; static struct vk_swapchain vk_chain; - static struct vk_semaphores vk_sema; +static struct vk_image_attachment vk_color_att; +static struct vk_image_attachment vk_depth_att; +static struct vk_image_props vk_depth_att_props; /* empty for as long as we hardcode the vertices in the vertex shader */ static struct vk_vertex_info vk_vert_info; @@ -127,9 +129,27 @@ init() vsdr = sdr_load("data/main.vert.spv", &vsz); fsdr = sdr_load("data/main.frag.spv", &fsz); + /* create depth attachment (for the moment we are going to use this + * for all images */ + if (!vk_fill_image_props(&vk_core, + win_w, win_h, 1, + 1, 1, 1, + VK_FORMAT_D24_UNORM_S8_UINT, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, + false, &vk_depth_att_props)) { + fprintf(stderr, "Unsupported depth image properties\n"); + return false; + } + if (!vk_create_image(&vk_core, &vk_depth_att_props, &vk_depth_att.obj)) { + fprintf(stderr, "Failed to create depth attachment.\n"); + return false; + } + /* create renderer */ if (!vk_create_renderer(&vk_core, vsdr, vsz, fsdr, fsz, - false, false, 0, 0, + false, false, 0, &vk_depth_att, &vk_vert_info, &vk_rnd)) { fprintf(stderr, "Failed to create renderer.\n"); return false;