#include "framebuffer.h"
#include "device.h"
#include "renderpass.h"
#include "image.h"
#include "../pass/target.h"
namespace vulkanapi {
	FrameBuffer::FrameBuffer(Device& device, RenderTarget* target, RenderPass* pass, vector<VkImageView>& surfaces)
	: mSurfaces(surfaces)
    {
        uint32_t size = mSurfaces.size();
        VkFramebufferCreateInfo framebufferInfo{};
        framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
        // 指定可以兼容的render pass(这个frame buffer和指定的render pass的attachment的数量和类型需要一致)
        framebufferInfo.renderPass = pass->Ptr();
        framebufferInfo.attachmentCount = size;
        framebufferInfo.pAttachments = mSurfaces.data();
        framebufferInfo.width = target->width;
        framebufferInfo.height = target->height;
        framebufferInfo.layers = 1;
		vkCreateFramebuffer(device.Ptr(), &framebufferInfo, nullptr, &mPtr);
	}
}
