diff --git a/example/Vulkan/RenderToColor.cpp b/example/Vulkan/RenderToColor.cpp new file mode 100644 index 00000000..e69de29b diff --git a/inc/hgl/graph/vulkan/VKRenderTarget.h b/inc/hgl/graph/vulkan/VKRenderTarget.h new file mode 100644 index 00000000..1fa3f216 --- /dev/null +++ b/inc/hgl/graph/vulkan/VKRenderTarget.h @@ -0,0 +1,49 @@ +#ifndef HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE +#define HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE + +#include +#include +#include +VK_NAMESPACE_BEGIN +class RenderTarget +{ + Device *device; + + RenderPass *rp; + Framebuffer *fb; + + VkExtent2D extent; + + List colors; + ImageView *depth; + +private: + + friend class Device; + + RenderTarget(Device *dev,RenderPass *_rp,Framebuffer *_fb) + { + device=dev; + rp=_rp; + fb=_fb; + } + +public: + + ~RenderTarget() + { + if(fb)delete fb; + } + + operator RenderPass * (){return rp;} + operator Framebuffer * (){return fb;} + operator VkRenderPass (){return rp?rp->operator VkRenderPass():nullptr;} + operator VkFramebuffer (){return fb?fb->operator VkFramebuffer():nullptr;} + + const VkExtent2D & GetExtent ()const{return extent;} ///<取得画面尺寸 + + const uint GetColorCount ()const{colors.GetCount();} ///<取得颜色成份数量 + const bool IsExistDepth ()const{return depth;} ///<是否存在深度成份 +};//class RenderTarget +VK_NAMESPACE_END +#endif//HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE diff --git a/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp b/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp index e056bd7f..2e10b1b6 100644 --- a/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceRenderPass.cpp @@ -27,7 +27,7 @@ RenderPass *Device::CreateRenderPass(List color_format,VkFormat depth_ attachments[i].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; } - VkFormat *cf=color_format.GetData(); + const VkFormat *cf=color_format.GetData(); for(int i=0;i + +VK_NAMESPACE_BEGIN +RenderTarget::~RenderTarget() +{ + if(fb) + delete fb; +} +VK_NAMESPACE_END