#include "detail/graphics.h"

namespace deerith {
	void graphics::create_vulkan_frame_buffer() {
		swap_chain_frame_buffers.resize(swap_chain_image_views.size());

		for (size_t i = 0; i < swap_chain_image_views.size(); i++) {
			VkImageView attachments[] = {swap_chain_image_views[i]};

			VkFramebufferCreateInfo framebufferInfo{};
			framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
			framebufferInfo.renderPass = render_pass;
			framebufferInfo.attachmentCount = 1;
			framebufferInfo.pAttachments = attachments;
			framebufferInfo.width = swap_chain_extent.width;
			framebufferInfo.height = swap_chain_extent.height;
			framebufferInfo.layers = 1;

			if (vkCreateFramebuffer(device, &framebufferInfo, nullptr, &swap_chain_frame_buffers[i]) != VK_SUCCESS) {
				deerith_graphics_error("failed to create framebuffer!");
			}
		}
	}
} // namespace deerith