增加VKFramebuffer
This commit is contained in:
parent
da0fae8703
commit
08e353b07a
@ -23,6 +23,7 @@ SET(VULKAN_TEST_SOURCE_FILES main.cpp
|
|||||||
VKVertexInput.cpp
|
VKVertexInput.cpp
|
||||||
VKPipeline.cpp
|
VKPipeline.cpp
|
||||||
VKSemaphore.cpp
|
VKSemaphore.cpp
|
||||||
|
VKFramebuffer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(VULKAN_TEST_HEADER_FILES VK.h
|
SET(VULKAN_TEST_HEADER_FILES VK.h
|
||||||
@ -41,6 +42,7 @@ SET(VULKAN_TEST_HEADER_FILES VK.h
|
|||||||
VKVertexInput.h
|
VKVertexInput.h
|
||||||
VKSemaphore.h
|
VKSemaphore.h
|
||||||
VKPipeline.h
|
VKPipeline.h
|
||||||
|
VKFramebuffer.h
|
||||||
Window.h)
|
Window.h)
|
||||||
|
|
||||||
SET(SHADER_FILES shader_compile.bat
|
SET(SHADER_FILES shader_compile.bat
|
||||||
|
35
example/Vulkan/VKFramebuffer.cpp
Normal file
35
example/Vulkan/VKFramebuffer.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include"VKFramebuffer.h"
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
Framebuffer::~Framebuffer()
|
||||||
|
{
|
||||||
|
vkDestroyFramebuffer(device,frame_buffer,nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Framebuffer *CreateFramebuffer(Device *dev,RenderPass *rp,VkImageView color,VkImageView depth)
|
||||||
|
{
|
||||||
|
if(!dev||!rp||!color||!depth)return(nullptr);
|
||||||
|
|
||||||
|
const VkExtent2D extent=dev->GetExtent();
|
||||||
|
VkImageView attachments[2];
|
||||||
|
|
||||||
|
attachments[0]=color;
|
||||||
|
attachments[1]=depth;
|
||||||
|
|
||||||
|
VkFramebufferCreateInfo fb_info = {};
|
||||||
|
fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||||
|
fb_info.pNext = nullptr;
|
||||||
|
fb_info.renderPass = *rp;
|
||||||
|
fb_info.attachmentCount = 2;
|
||||||
|
fb_info.pAttachments = attachments;
|
||||||
|
fb_info.width = extent.width;
|
||||||
|
fb_info.height = extent.height;
|
||||||
|
fb_info.layers = 1;
|
||||||
|
|
||||||
|
VkFramebuffer fb;
|
||||||
|
|
||||||
|
if(vkCreateFramebuffer(dev->GetDevice(), &fb_info, nullptr, &fb)!=VK_SUCCESS)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
return(new Framebuffer(dev->GetDevice(),fb));
|
||||||
|
}
|
||||||
|
VK_NAMESPACE_END
|
30
example/Vulkan/VKFramebuffer.h
Normal file
30
example/Vulkan/VKFramebuffer.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||||
|
#define HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||||
|
|
||||||
|
#include"VK.h"
|
||||||
|
#include"VKDevice.h"
|
||||||
|
#include"VKRenderPass.h"
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
class Framebuffer
|
||||||
|
{
|
||||||
|
VkDevice device;
|
||||||
|
VkFramebuffer frame_buffer;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend Framebuffer *CreateFramebuffer(Device *,RenderPass *,VkImageView color,VkImageView depth);;
|
||||||
|
|
||||||
|
Framebuffer(VkDevice dev,VkFramebuffer fb)
|
||||||
|
{
|
||||||
|
device=dev;
|
||||||
|
frame_buffer=fb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
~Framebuffer();
|
||||||
|
};//class Framebuffer
|
||||||
|
|
||||||
|
Framebuffer *CreateFramebuffer(Device *,RenderPass *,VkImageView color,VkImageView depth);
|
||||||
|
VK_NAMESPACE_END
|
||||||
|
#endif//HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
Loading…
x
Reference in New Issue
Block a user