diff --git a/gpu.c b/gpu.c index 1af311c..33da806 100644 --- a/gpu.c +++ b/gpu.c @@ -768,6 +768,19 @@ void gpu_init(gpu_ctx_t *ctx, GLFWwindow *window, const char *name) assert(result == VK_SUCCESS); // Create framebuffers + const VkFramebufferCreateInfo shadow_framebuffer_config = { + .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + .renderPass = ctx->shadow_pass, + .attachmentCount = 1, + .pAttachments = &ctx->shadow_view, + .width = SHADOW_IMG_SIZE, + .height = SHADOW_IMG_SIZE, + .layers = 1, + }; + result = vkCreateFramebuffer( + ctx->dev, &shadow_framebuffer_config, nullptr, + &ctx->shadow_framebuf); + assert(result == VK_SUCCESS); for (unsigned i = 0; i < ctx->swapchain_img_count; ++i) { VkImageView attachments[] = { ctx->swapchain_img_views[i], @@ -885,6 +898,7 @@ void gpu_cleanup(const gpu_ctx_t *ctx) vkDestroyImage(ctx->dev, ctx->depth_img, nullptr); vkFreeMemory(ctx->dev, ctx->depth_mem, nullptr); + vkDestroyFramebuffer(ctx->dev, ctx->shadow_framebuf, nullptr); for (unsigned i = 0; i < ctx->swapchain_img_count; ++i) { vkDestroyFramebuffer(ctx->dev, ctx->framebuffers[i], nullptr); vkDestroyImageView(ctx->dev, ctx->swapchain_img_views[i], nullptr); diff --git a/gpu.h b/gpu.h index 29cb39c..a8f9ccd 100644 --- a/gpu.h +++ b/gpu.h @@ -25,6 +25,7 @@ typedef struct { VkImage depth_img; VkDeviceMemory depth_mem; VkImageView depth_view; + VkFramebuffer shadow_framebuf; VkFramebuffer framebuffers[MAX_FRAMES_IN_FLIGHT]; VkShaderModule floor_vert_shader; VkShaderModule model_vert_shader;