moved codes to VKDeviceRenderPassManage.cpp/.h
This commit is contained in:
parent
b5188a63ea
commit
f0ae8f5dae
@ -63,14 +63,9 @@ class GPUCmdBuffer;
|
||||
class RenderCmdBuffer;
|
||||
class TextureCmdBuffer;
|
||||
|
||||
enum class RenderPassTypeBy
|
||||
{
|
||||
Simple=0,
|
||||
Normal,
|
||||
Verbose
|
||||
};//
|
||||
|
||||
class RenderPass;
|
||||
class DeviceRenderPassManage;
|
||||
|
||||
class GPUFence;
|
||||
class GPUSemaphore;
|
||||
|
||||
|
@ -34,9 +34,16 @@ class GPUDevice
|
||||
GPUQueue *texture_queue;
|
||||
TextureCmdBuffer *texture_cmd_buf;
|
||||
|
||||
private:
|
||||
|
||||
DeviceRenderPassManage *render_pass_manage;
|
||||
RenderPass *device_render_pass;
|
||||
|
||||
Swapchain *swapchain;
|
||||
SwapchainRenderTarget *swapchainRT;
|
||||
|
||||
void InitRenderPassManage();
|
||||
|
||||
private:
|
||||
|
||||
VkCommandBuffer CreateCommandBuffer();
|
||||
@ -69,6 +76,7 @@ public:
|
||||
const VkFormat GetSurfaceFormat ()const {return attr->format;}
|
||||
VkQueue GetGraphicsQueue () {return attr->graphics_queue;}
|
||||
|
||||
RenderPass * GetRenderPass () {return device_render_pass;}
|
||||
Swapchain * GetSwapchain () {return swapchain;}
|
||||
|
||||
SwapchainRenderTarget * GetSwapchainRT () {return swapchainRT;}
|
||||
@ -211,17 +219,9 @@ public: //Command Buffer 相关
|
||||
RenderCmdBuffer * CreateRenderCommandBuffer();
|
||||
TextureCmdBuffer *CreateTextureCommandBuffer();
|
||||
|
||||
private:
|
||||
|
||||
RenderPass * CreateRenderPass( const List<VkAttachmentDescription> &desc_list,
|
||||
const List<VkSubpassDescription> &subpass,
|
||||
const List<VkSubpassDependency> &dependency,
|
||||
const RenderbufferInfo *,
|
||||
const RenderPassTypeBy &type_by=RenderPassTypeBy::Verbose);
|
||||
|
||||
public:
|
||||
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const RenderPassTypeBy &type_by=RenderPassTypeBy::Normal);
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *);
|
||||
|
||||
GPUFence * CreateFence(bool);
|
||||
GPUSemaphore * CreateGPUSemaphore();
|
||||
@ -252,25 +252,6 @@ public:
|
||||
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
|
||||
};//class GPUDevice
|
||||
|
||||
//void CreateSubpassDependency(VkSubpassDependency *);
|
||||
void CreateSubpassDependency(List<VkSubpassDependency> &dependency,const uint32_t count);
|
||||
|
||||
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint start,uint count,VkImageLayout layout);
|
||||
|
||||
inline void CreateColorAttachmentReference(VkAttachmentReference *ref_list, uint start,uint count) {CreateAttachmentReference(ref_list, start,count,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);}
|
||||
inline void CreateDepthAttachmentReference(VkAttachmentReference *depth_ref,uint index) {CreateAttachmentReference(depth_ref, index,1 ,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);}
|
||||
inline void CreateInputAttachmentReference(VkAttachmentReference *ref_list, uint start,uint count) {CreateAttachmentReference(ref_list, start,count,VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);}
|
||||
|
||||
|
||||
bool CreateColorAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const List<VkFormat> &color_format,const VkImageLayout color_final_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
bool CreateDepthAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const VkFormat &depth_format,const VkImageLayout depth_final_layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
|
||||
bool CreateAttachmentDescription( List<VkAttachmentDescription> &color_output_desc_list,
|
||||
const List<VkFormat> &color_format,
|
||||
const VkFormat depth_format,
|
||||
const VkImageLayout color_final_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
const VkImageLayout depth_final_layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
|
||||
GPUDevice *CreateRenderDevice(VulkanInstance *inst,Window *win,const GPUPhysicalDevice *physical_device=nullptr);
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
||||
|
36
inc/hgl/graph/VKDeviceRenderPassManage.h
Normal file
36
inc/hgl/graph/VKDeviceRenderPassManage.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef HGL_VULKAN_DEVICE_RENDERPASS_MANAGE_INCLUDE
|
||||
#define HGL_VULKAN_DEVICE_RENDERPASS_MANAGE_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/util/hash/Hash.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using RenderPassHASHCode=util::HashCodeSHA1LE;
|
||||
|
||||
class DeviceRenderPassManage
|
||||
{
|
||||
VkDevice device;
|
||||
|
||||
util::Hash *hash;
|
||||
|
||||
Map<RenderPassHASHCode,RenderPass *> RenderPassList;
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
DeviceRenderPassManage(VkDevice);
|
||||
~DeviceRenderPassManage();
|
||||
|
||||
private:
|
||||
|
||||
RenderPass * CreateRenderPass( const List<VkAttachmentDescription> &desc_list,
|
||||
const List<VkSubpassDescription> &subpass,
|
||||
const List<VkSubpassDependency> &dependency,
|
||||
const RenderbufferInfo *);
|
||||
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *);
|
||||
};//class DeviceRenderPassManage
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_VULKAN_DEVICE_RENDERPASS_MANAGE_INCLUDE
|
@ -18,7 +18,7 @@ class RenderPass
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
friend class DeviceRenderPassManage;
|
||||
|
||||
RenderPass(VkDevice d,VkRenderPass rp,const List<VkFormat> &cf,VkFormat df)
|
||||
{
|
||||
|
@ -123,6 +123,7 @@ SET(VK_DEVICE_SOURCE ${SG_INCLUDE_PATH}/VKDevice.h
|
||||
Vulkan/VKDeviceFramebuffer.cpp
|
||||
Vulkan/VKDeviceSwapchain.cpp
|
||||
Vulkan/VKDeviceRenderPass.cpp
|
||||
Vulkan/VKDeviceRenderPassManage.cpp
|
||||
Vulkan/VKDeviceRenderTarget.cpp)
|
||||
|
||||
SET(VK_PHYSICAL_DEVICE_SOURCE ${SG_INCLUDE_PATH}/VKPhysicalDevice.h
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
#include<hgl/graph/VKFramebuffer.h>
|
||||
#include<hgl/graph/VKDescriptorSets.h>
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
@ -18,6 +19,8 @@ GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
texture_queue=nullptr;
|
||||
texture_cmd_buf=nullptr;
|
||||
|
||||
InitRenderPassManage();
|
||||
|
||||
swapchain=nullptr;
|
||||
swapchainRT=nullptr;
|
||||
Resize(attr->surface_caps.currentExtent);
|
||||
@ -28,6 +31,8 @@ GPUDevice::~GPUDevice()
|
||||
SAFE_CLEAR(swapchainRT);
|
||||
SAFE_CLEAR(swapchain);
|
||||
|
||||
delete(render_pass_manage);
|
||||
|
||||
SAFE_CLEAR(texture_queue);
|
||||
SAFE_CLEAR(texture_cmd_buf);
|
||||
|
||||
|
@ -1,365 +1,30 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKDeviceAttribute.h>
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
#include<hgl/util/hash/Hash.h>
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
//void CreateSubpassDependency(VkSubpassDependency *dependency)
|
||||
//{
|
||||
// dependency->srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
// dependency->dstSubpass = 0;
|
||||
// dependency->srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
// dependency->srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
// dependency->dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
// dependency->dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
// dependency->dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
//}
|
||||
|
||||
void CreateSubpassDependency(List<VkSubpassDependency> &subpass_dependency_list,const uint32_t count)
|
||||
void GPUDevice::InitRenderPassManage()
|
||||
{
|
||||
if(count<=0)return;
|
||||
render_pass_manage=new DeviceRenderPassManage(attr->device);
|
||||
|
||||
subpass_dependency_list.SetCount(count);
|
||||
|
||||
VkSubpassDependency *dependency=subpass_dependency_list.GetData();
|
||||
|
||||
dependency->srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependency->dstSubpass = 0;
|
||||
dependency->srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
dependency->srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
dependency->dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
|
||||
if(count==1)
|
||||
{
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
SwapchainRenderbufferInfo rbi(attr->format,attr->physical_device->GetDepthFormat());
|
||||
|
||||
++dependency;
|
||||
|
||||
for(uint32_t i=1;i<count;i++)
|
||||
{
|
||||
dependency->srcSubpass = i-1;
|
||||
dependency->srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
|
||||
if(i==count-1)
|
||||
{
|
||||
dependency->dstSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
dependency->srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dependency->dstSubpass = i;
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||
dependency->srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
}
|
||||
|
||||
dependency->dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
|
||||
++dependency;
|
||||
}
|
||||
device_render_pass=render_pass_manage->AcquireRenderPass(&rbi);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint start,uint count,VkImageLayout layout)
|
||||
{
|
||||
VkAttachmentReference *ref=ref_list;
|
||||
|
||||
for(uint i=start;i<start+count;i++)
|
||||
{
|
||||
ref->attachment =i;
|
||||
ref->layout =layout;
|
||||
|
||||
++ref;
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateAttachmentDescription(List<VkAttachmentDescription> &desc_list,const RenderbufferInfo *rbi)
|
||||
{
|
||||
const uint color_count=rbi->GetColorCount();
|
||||
|
||||
const uint count=(rbi->HasDepthOrStencil())?color_count+1:color_count;
|
||||
|
||||
desc_list.SetCount(count);
|
||||
|
||||
VkAttachmentDescription *desc=desc_list.GetData();
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
desc->flags = 0;
|
||||
desc->samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
desc->loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; //LOAD_OP_CLEAR代表LOAD时清空内容
|
||||
desc->storeOp = VK_ATTACHMENT_STORE_OP_STORE; //STORE_OP_STROE代表SOTRE时储存内容
|
||||
desc->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; //DONT CARE表示不在意
|
||||
desc->stencilStoreOp= VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
desc->initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //代表不关心初始布局
|
||||
|
||||
++desc;
|
||||
}
|
||||
|
||||
desc=desc_list.GetData();
|
||||
const VkFormat *cf=rbi->GetColorFormat();
|
||||
for(uint i=0;i<color_count;i++)
|
||||
{
|
||||
desc->finalLayout = rbi->GetColorLayout();
|
||||
desc->format = *cf;
|
||||
|
||||
++desc;
|
||||
++cf;
|
||||
}
|
||||
|
||||
if(rbi->GetDepthFormat()!=PF_UNDEFINED)
|
||||
{
|
||||
desc->finalLayout = rbi->GetDepthLayout();
|
||||
desc->format = rbi->GetDepthFormat();
|
||||
desc->storeOp = rbi->IsSwapchain()?VK_ATTACHMENT_STORE_OP_DONT_CARE:VK_ATTACHMENT_STORE_OP_STORE;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool CreateColorAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const List<VkFormat> &color_format,const VkImageLayout color_final_layout)
|
||||
{
|
||||
//const VkFormat *cf=color_format_list.GetData();
|
||||
|
||||
//for(int i=0;i<color_format_list.GetCount();i++)
|
||||
//{
|
||||
// if(!attr->physical_device->IsColorAttachmentOptimal(*cf))
|
||||
// return(false);
|
||||
|
||||
// ++cf;
|
||||
//}
|
||||
|
||||
ref_list.SetCount(color_format.GetCount());
|
||||
VkAttachmentReference *ref=ref_list.GetData();
|
||||
|
||||
desc_list.SetCount(color_format.GetCount());
|
||||
VkAttachmentDescription *desc=desc_list.GetData();
|
||||
|
||||
for(int i=0;i<color_format.GetCount();i++)
|
||||
{
|
||||
desc->flags = 0;
|
||||
desc->samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
desc->loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; //LOAD_OP_CLEAR代表LOAD时清空内容
|
||||
desc->storeOp = VK_ATTACHMENT_STORE_OP_STORE; //STORE_OP_STROE代表SOTRE时储存内容
|
||||
desc->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; //DONT CARE表示不在意
|
||||
desc->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
desc->initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //代表不关心初始布局
|
||||
desc->finalLayout = color_final_layout;
|
||||
++desc;
|
||||
|
||||
ref->attachment = i;
|
||||
ref->layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
++ref;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool CreateDepthAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const VkFormat &depth_format,const VkImageLayout depth_final_layout)
|
||||
{
|
||||
//if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format))
|
||||
// return(false);
|
||||
|
||||
{
|
||||
ref_list.SetCount(1);
|
||||
VkAttachmentReference *ref=ref_list.GetData();
|
||||
|
||||
ref->attachment=0;
|
||||
ref->layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
|
||||
{
|
||||
desc_list.SetCount(1);
|
||||
VkAttachmentDescription *desc=desc_list.GetData();
|
||||
|
||||
desc->flags = 0;
|
||||
desc->samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
desc->loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; //LOAD_OP_CLEAR代表LOAD时清空内容
|
||||
desc->storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; //DONT CARE表示不在意
|
||||
desc->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
desc->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
desc->initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //代表不关心初始布局
|
||||
desc->finalLayout = depth_final_layout;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
using RenderPassHASHCode=util::HashCodeSHA1LE;
|
||||
|
||||
void HashRenderPass(RenderPassHASHCode *code,const VkRenderPassCreateInfo &rpci)
|
||||
{
|
||||
util::Hash *hash=util::CreateSHA1LEHash();
|
||||
|
||||
hash->Init();
|
||||
|
||||
// hash->Write(rpci.attachmentCount);
|
||||
hash->Write(rpci.pAttachments,rpci.attachmentCount);
|
||||
// hash->Write(rpci.subpassCount);
|
||||
{
|
||||
const VkSubpassDescription *sd=rpci.pSubpasses;
|
||||
|
||||
for(uint32_t i=0;i<rpci.subpassCount;i++)
|
||||
{
|
||||
hash->Write(sd->pipelineBindPoint);
|
||||
hash->Write(sd->pInputAttachments,sd->inputAttachmentCount);
|
||||
hash->Write(sd->pColorAttachments,sd->colorAttachmentCount);
|
||||
|
||||
if(sd->pResolveAttachments)
|
||||
hash->Write(*sd->pResolveAttachments);
|
||||
|
||||
if(sd->pDepthStencilAttachment)
|
||||
hash->Write(*sd->pDepthStencilAttachment);
|
||||
|
||||
hash->Write(sd->pPreserveAttachments,sd->preserveAttachmentCount);
|
||||
|
||||
++sd;
|
||||
}
|
||||
}
|
||||
|
||||
hash->Write(rpci.pDependencies,rpci.dependencyCount);
|
||||
|
||||
hash->Final(code);
|
||||
|
||||
delete hash;
|
||||
}
|
||||
|
||||
static Map<RenderPassHASHCode,RenderPass *> RenderPassListByVerbose;
|
||||
}
|
||||
|
||||
RenderPass *GPUDevice::CreateRenderPass(const List<VkAttachmentDescription> &desc_list,
|
||||
const List<VkSubpassDescription> &subpass,
|
||||
const List<VkSubpassDependency> &dependency,
|
||||
const RenderbufferInfo *rbi,
|
||||
const RenderPassTypeBy &type_by)
|
||||
{
|
||||
for(const VkFormat cf:rbi->GetColorFormatList())
|
||||
{
|
||||
if(!attr->physical_device->IsColorAttachmentOptimal(cf)
|
||||
&&!attr->physical_device->IsColorAttachmentLinear(cf))
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
const VkFormat depth_format=rbi->GetDepthFormat();
|
||||
|
||||
if(rbi->HasDepthOrStencil())
|
||||
{
|
||||
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format)
|
||||
&&!attr->physical_device->IsDepthAttachmentLinear(depth_format))
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
VkRenderPassCreateInfo rp_info;
|
||||
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
rp_info.pNext = nullptr;
|
||||
rp_info.flags = 0;
|
||||
rp_info.attachmentCount = desc_list.GetCount();
|
||||
rp_info.pAttachments = desc_list.GetData();
|
||||
rp_info.subpassCount = subpass.GetCount();
|
||||
rp_info.pSubpasses = subpass.GetData();
|
||||
rp_info.dependencyCount = dependency.GetCount();
|
||||
rp_info.pDependencies = dependency.GetData();
|
||||
|
||||
RenderPassHASHCode code;
|
||||
RenderPass *rp=nullptr;
|
||||
|
||||
if(type_by==RenderPassTypeBy::Verbose)
|
||||
{
|
||||
HashRenderPass(&code,rp_info);
|
||||
|
||||
if(RenderPassListByVerbose.Get(code,rp))
|
||||
return rp;
|
||||
}
|
||||
|
||||
VkRenderPass render_pass;
|
||||
|
||||
if(vkCreateRenderPass(attr->device,&rp_info,nullptr,&render_pass)!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
rp=new RenderPass(attr->device,render_pass,rbi->GetColorFormatList(),depth_format);
|
||||
|
||||
if(type_by==RenderPassTypeBy::Verbose)
|
||||
RenderPassListByVerbose.Add(code,rp);
|
||||
|
||||
return rp;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void HashRenderPass(RenderPassHASHCode *code,const RenderbufferInfo *rbi)
|
||||
{
|
||||
util::Hash *hash=util::CreateSHA1LEHash();
|
||||
|
||||
hash->Init();
|
||||
|
||||
for(const VkFormat &fmt:rbi->GetColorFormatList())
|
||||
hash->Write(fmt);
|
||||
|
||||
hash->Final(&code);
|
||||
delete hash;
|
||||
}
|
||||
|
||||
static Map<RenderPassHASHCode,RenderPass *> RenderPassListByNormal;
|
||||
}//namespace
|
||||
|
||||
RenderPass *GPUDevice::AcquireRenderPass(const RenderbufferInfo *rbi,const RenderPassTypeBy &type_by)
|
||||
RenderPass *GPUDevice::AcquireRenderPass(const RenderbufferInfo *rbi)
|
||||
{
|
||||
for(const VkFormat &fmt:rbi->GetColorFormatList())
|
||||
if(!attr->physical_device->IsColorAttachmentOptimal(fmt))
|
||||
return(nullptr);
|
||||
|
||||
RenderPassHASHCode code;
|
||||
RenderPass *rp=nullptr;
|
||||
|
||||
if(type_by==RenderPassTypeBy::Normal)
|
||||
{
|
||||
HashRenderPass(&code,rbi);
|
||||
|
||||
if(RenderPassListByNormal.Get(code,rp))
|
||||
return rp;
|
||||
}
|
||||
|
||||
List<VkAttachmentReference> color_ref_list;
|
||||
VkAttachmentReference depth_ref;
|
||||
List<VkAttachmentDescription> atta_desc_list;
|
||||
List<VkSubpassDescription> subpass_desc_list;
|
||||
List<VkSubpassDependency> subpass_dependency_list;
|
||||
|
||||
color_ref_list.SetCount(rbi->GetColorCount());
|
||||
CreateColorAttachmentReference(color_ref_list.GetData(),0,rbi->GetColorCount());
|
||||
|
||||
CreateAttachmentDescription(atta_desc_list,rbi);
|
||||
|
||||
if(rbi->HasDepthOrStencil())
|
||||
{
|
||||
if(!attr->physical_device->IsDepthAttachmentOptimal(rbi->GetDepthFormat()))
|
||||
if(!attr->physical_device->IsDepthAttachmentOptimal(rbi->GetDepthFormat()))
|
||||
return(nullptr);
|
||||
|
||||
CreateDepthAttachmentReference(&depth_ref,rbi->GetColorCount());
|
||||
subpass_desc_list.Add(SubpassDescription(color_ref_list.GetData(),color_ref_list.GetCount(),&depth_ref));
|
||||
}
|
||||
else
|
||||
{
|
||||
subpass_desc_list.Add(SubpassDescription(color_ref_list.GetData(),color_ref_list.GetCount()));
|
||||
}
|
||||
|
||||
CreateSubpassDependency(subpass_dependency_list,2);
|
||||
|
||||
rp=CreateRenderPass(atta_desc_list,subpass_desc_list,subpass_dependency_list,rbi,type_by);
|
||||
|
||||
if(type_by==RenderPassTypeBy::Normal)
|
||||
RenderPassListByNormal.Add(code,rp);
|
||||
|
||||
return rp;
|
||||
return render_pass_manage->AcquireRenderPass(rbi);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
343
src/SceneGraph/Vulkan/VKDeviceRenderPassManage.cpp
Normal file
343
src/SceneGraph/Vulkan/VKDeviceRenderPassManage.cpp
Normal file
@ -0,0 +1,343 @@
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
//void CreateSubpassDependency(VkSubpassDependency *);
|
||||
void CreateSubpassDependency(List<VkSubpassDependency> &dependency,const uint32_t count);
|
||||
|
||||
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint start,uint count,VkImageLayout layout);
|
||||
|
||||
inline void CreateColorAttachmentReference(VkAttachmentReference *ref_list, uint start,uint count) {CreateAttachmentReference(ref_list, start,count,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);}
|
||||
inline void CreateDepthAttachmentReference(VkAttachmentReference *depth_ref,uint index) {CreateAttachmentReference(depth_ref, index,1 ,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);}
|
||||
inline void CreateInputAttachmentReference(VkAttachmentReference *ref_list, uint start,uint count) {CreateAttachmentReference(ref_list, start,count,VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);}
|
||||
|
||||
bool CreateColorAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const List<VkFormat> &color_format,const VkImageLayout color_final_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
bool CreateDepthAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const VkFormat &depth_format,const VkImageLayout depth_final_layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
|
||||
bool CreateAttachmentDescription( List<VkAttachmentDescription> &color_output_desc_list,
|
||||
const List<VkFormat> &color_format,
|
||||
const VkFormat depth_format,
|
||||
const VkImageLayout color_final_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
const VkImageLayout depth_final_layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
|
||||
//void CreateSubpassDependency(VkSubpassDependency *dependency)
|
||||
//{
|
||||
// dependency->srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
// dependency->dstSubpass = 0;
|
||||
// dependency->srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
// dependency->srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
// dependency->dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
// dependency->dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
// dependency->dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
//}
|
||||
|
||||
void CreateSubpassDependency(List<VkSubpassDependency> &subpass_dependency_list,const uint32_t count)
|
||||
{
|
||||
if(count<=0)return;
|
||||
|
||||
subpass_dependency_list.SetCount(count);
|
||||
|
||||
VkSubpassDependency *dependency=subpass_dependency_list.GetData();
|
||||
|
||||
dependency->srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependency->dstSubpass = 0;
|
||||
dependency->srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
dependency->srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
dependency->dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
|
||||
if(count==1)
|
||||
{
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
|
||||
++dependency;
|
||||
|
||||
for(uint32_t i=1;i<count;i++)
|
||||
{
|
||||
dependency->srcSubpass = i-1;
|
||||
dependency->srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
|
||||
if(i==count-1)
|
||||
{
|
||||
dependency->dstSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
dependency->srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dependency->dstSubpass = i;
|
||||
dependency->dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||
dependency->srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
dependency->dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
}
|
||||
|
||||
dependency->dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
|
||||
++dependency;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint start,uint count,VkImageLayout layout)
|
||||
{
|
||||
VkAttachmentReference *ref=ref_list;
|
||||
|
||||
for(uint i=start;i<start+count;i++)
|
||||
{
|
||||
ref->attachment =i;
|
||||
ref->layout =layout;
|
||||
|
||||
++ref;
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateAttachmentDescription(List<VkAttachmentDescription> &desc_list,const RenderbufferInfo *rbi)
|
||||
{
|
||||
const uint color_count=rbi->GetColorCount();
|
||||
|
||||
const uint count=(rbi->HasDepthOrStencil())?color_count+1:color_count;
|
||||
|
||||
desc_list.SetCount(count);
|
||||
|
||||
VkAttachmentDescription *desc=desc_list.GetData();
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
desc->flags = 0;
|
||||
desc->samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
desc->loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; //LOAD_OP_CLEAR代表LOAD时清空内容
|
||||
desc->storeOp = VK_ATTACHMENT_STORE_OP_STORE; //STORE_OP_STROE代表SOTRE时储存内容
|
||||
desc->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; //DONT CARE表示不在意
|
||||
desc->stencilStoreOp= VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
desc->initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //代表不关心初始布局
|
||||
|
||||
++desc;
|
||||
}
|
||||
|
||||
desc=desc_list.GetData();
|
||||
const VkFormat *cf=rbi->GetColorFormat();
|
||||
for(uint i=0;i<color_count;i++)
|
||||
{
|
||||
desc->finalLayout = rbi->GetColorLayout();
|
||||
desc->format = *cf;
|
||||
|
||||
++desc;
|
||||
++cf;
|
||||
}
|
||||
|
||||
if(rbi->GetDepthFormat()!=PF_UNDEFINED)
|
||||
{
|
||||
desc->finalLayout = rbi->GetDepthLayout();
|
||||
desc->format = rbi->GetDepthFormat();
|
||||
desc->storeOp = rbi->IsSwapchain()?VK_ATTACHMENT_STORE_OP_DONT_CARE:VK_ATTACHMENT_STORE_OP_STORE;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool CreateColorAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const List<VkFormat> &color_format,const VkImageLayout color_final_layout)
|
||||
{
|
||||
//const VkFormat *cf=color_format_list.GetData();
|
||||
|
||||
//for(int i=0;i<color_format_list.GetCount();i++)
|
||||
//{
|
||||
// if(!attr->physical_device->IsColorAttachmentOptimal(*cf))
|
||||
// return(false);
|
||||
|
||||
// ++cf;
|
||||
//}
|
||||
|
||||
ref_list.SetCount(color_format.GetCount());
|
||||
VkAttachmentReference *ref=ref_list.GetData();
|
||||
|
||||
desc_list.SetCount(color_format.GetCount());
|
||||
VkAttachmentDescription *desc=desc_list.GetData();
|
||||
|
||||
for(int i=0;i<color_format.GetCount();i++)
|
||||
{
|
||||
desc->flags = 0;
|
||||
desc->samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
desc->loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; //LOAD_OP_CLEAR代表LOAD时清空内容
|
||||
desc->storeOp = VK_ATTACHMENT_STORE_OP_STORE; //STORE_OP_STROE代表SOTRE时储存内容
|
||||
desc->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; //DONT CARE表示不在意
|
||||
desc->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
desc->initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //代表不关心初始布局
|
||||
desc->finalLayout = color_final_layout;
|
||||
++desc;
|
||||
|
||||
ref->attachment = i;
|
||||
ref->layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
++ref;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool CreateDepthAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const VkFormat &depth_format,const VkImageLayout depth_final_layout)
|
||||
{
|
||||
//if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format))
|
||||
// return(false);
|
||||
|
||||
{
|
||||
ref_list.SetCount(1);
|
||||
VkAttachmentReference *ref=ref_list.GetData();
|
||||
|
||||
ref->attachment=0;
|
||||
ref->layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
|
||||
{
|
||||
desc_list.SetCount(1);
|
||||
VkAttachmentDescription *desc=desc_list.GetData();
|
||||
|
||||
desc->flags = 0;
|
||||
desc->samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
desc->loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; //LOAD_OP_CLEAR代表LOAD时清空内容
|
||||
desc->storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; //DONT CARE表示不在意
|
||||
desc->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
desc->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
desc->initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; //代表不关心初始布局
|
||||
desc->finalLayout = depth_final_layout;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
DeviceRenderPassManage::DeviceRenderPassManage(VkDevice dev)
|
||||
{
|
||||
device=dev;
|
||||
|
||||
hash=util::CreateSHA1LEHash();
|
||||
}
|
||||
|
||||
DeviceRenderPassManage::~DeviceRenderPassManage()
|
||||
{
|
||||
SAFE_CLEAR(hash);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// void HashRenderPass(RenderPassHASHCode *code,const VkRenderPassCreateInfo &rpci)
|
||||
// {
|
||||
// util::Hash *hash=util::CreateSHA1LEHash();
|
||||
//
|
||||
// hash->Init();
|
||||
//
|
||||
//// hash->Write(rpci.attachmentCount);
|
||||
// hash->Write(rpci.pAttachments,rpci.attachmentCount);
|
||||
//// hash->Write(rpci.subpassCount);
|
||||
// {
|
||||
// const VkSubpassDescription *sd=rpci.pSubpasses;
|
||||
//
|
||||
// for(uint32_t i=0;i<rpci.subpassCount;i++)
|
||||
// {
|
||||
// hash->Write(sd->pipelineBindPoint);
|
||||
// hash->Write(sd->pInputAttachments,sd->inputAttachmentCount);
|
||||
// hash->Write(sd->pColorAttachments,sd->colorAttachmentCount);
|
||||
//
|
||||
// if(sd->pResolveAttachments)
|
||||
// hash->Write(*sd->pResolveAttachments);
|
||||
//
|
||||
// if(sd->pDepthStencilAttachment)
|
||||
// hash->Write(*sd->pDepthStencilAttachment);
|
||||
//
|
||||
// hash->Write(sd->pPreserveAttachments,sd->preserveAttachmentCount);
|
||||
//
|
||||
// ++sd;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// hash->Write(rpci.pDependencies,rpci.dependencyCount);
|
||||
//
|
||||
// hash->Final(code);
|
||||
//
|
||||
// delete hash;
|
||||
// }
|
||||
|
||||
void HashRenderPass(RenderPassHASHCode *code,const RenderbufferInfo *rbi)
|
||||
{
|
||||
util::Hash *hash=util::CreateSHA1LEHash();
|
||||
|
||||
hash->Init();
|
||||
|
||||
for(const VkFormat &fmt:rbi->GetColorFormatList())
|
||||
hash->Write(fmt);
|
||||
|
||||
hash->Final(&code);
|
||||
delete hash;
|
||||
}
|
||||
}
|
||||
|
||||
RenderPass *DeviceRenderPassManage::CreateRenderPass( const List<VkAttachmentDescription> &desc_list,
|
||||
const List<VkSubpassDescription> &subpass,
|
||||
const List<VkSubpassDependency> &dependency,
|
||||
const RenderbufferInfo *rbi)
|
||||
{
|
||||
const VkFormat depth_format=rbi->GetDepthFormat();
|
||||
|
||||
VkRenderPassCreateInfo rp_info;
|
||||
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
rp_info.pNext = nullptr;
|
||||
rp_info.flags = 0;
|
||||
rp_info.attachmentCount = desc_list.GetCount();
|
||||
rp_info.pAttachments = desc_list.GetData();
|
||||
rp_info.subpassCount = subpass.GetCount();
|
||||
rp_info.pSubpasses = subpass.GetData();
|
||||
rp_info.dependencyCount = dependency.GetCount();
|
||||
rp_info.pDependencies = dependency.GetData();
|
||||
|
||||
VkRenderPass render_pass;
|
||||
|
||||
if(vkCreateRenderPass(device,&rp_info,nullptr,&render_pass)!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new RenderPass(device,render_pass,rbi->GetColorFormatList(),depth_format));
|
||||
}
|
||||
|
||||
RenderPass *DeviceRenderPassManage::AcquireRenderPass(const RenderbufferInfo *rbi)
|
||||
{
|
||||
RenderPassHASHCode code;
|
||||
RenderPass *rp=nullptr;
|
||||
|
||||
HashRenderPass(&code,rbi);
|
||||
|
||||
if(RenderPassList.Get(code,rp))
|
||||
return rp;
|
||||
|
||||
List<VkAttachmentReference> color_ref_list;
|
||||
VkAttachmentReference depth_ref;
|
||||
List<VkAttachmentDescription> atta_desc_list;
|
||||
List<VkSubpassDescription> subpass_desc_list;
|
||||
List<VkSubpassDependency> subpass_dependency_list;
|
||||
|
||||
color_ref_list.SetCount(rbi->GetColorCount());
|
||||
CreateColorAttachmentReference(color_ref_list.GetData(),0,rbi->GetColorCount());
|
||||
|
||||
CreateAttachmentDescription(atta_desc_list,rbi);
|
||||
|
||||
if(rbi->HasDepthOrStencil())
|
||||
{
|
||||
CreateDepthAttachmentReference(&depth_ref,rbi->GetColorCount());
|
||||
subpass_desc_list.Add(SubpassDescription(color_ref_list.GetData(),color_ref_list.GetCount(),&depth_ref));
|
||||
}
|
||||
else
|
||||
{
|
||||
subpass_desc_list.Add(SubpassDescription(color_ref_list.GetData(),color_ref_list.GetCount()));
|
||||
}
|
||||
|
||||
CreateSubpassDependency(subpass_dependency_list,2);
|
||||
|
||||
rp=CreateRenderPass(atta_desc_list,subpass_desc_list,subpass_dependency_list,rbi);
|
||||
|
||||
RenderPassList.Add(code,rp);
|
||||
|
||||
return rp;
|
||||
}
|
||||
VK_NAMESPACE_END
|
@ -21,10 +21,7 @@ RenderTarget *GPUDevice::CreateRenderTarget(const FramebufferInfo *fbi,RenderPas
|
||||
Texture2D *color_texture=CreateTexture2D(new ColorAttachmentTextureCreateInfo(fmt,extent));
|
||||
|
||||
if(!color_texture)
|
||||
{
|
||||
delete rp;
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
*tp++=color_texture;
|
||||
*iv++=color_texture->GetImageView();
|
||||
@ -50,7 +47,7 @@ RenderTarget *GPUDevice::CreateRenderTarget(const FramebufferInfo *fbi,const uin
|
||||
{
|
||||
if(!fbi)return(nullptr);
|
||||
|
||||
RenderPass *rp=AcquireRenderPass(fbi,RenderPassTypeBy::Normal);
|
||||
RenderPass *rp=AcquireRenderPass(fbi);
|
||||
|
||||
if(!rp)return(nullptr);
|
||||
|
||||
|
@ -3,25 +3,6 @@
|
||||
#include<hgl/graph/VKSemaphore.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
namespace
|
||||
{
|
||||
struct SwapchainFormatHash
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t color;
|
||||
uint32_t depth;
|
||||
};
|
||||
|
||||
uint64 hashcode;
|
||||
};
|
||||
};//
|
||||
|
||||
static Map<uint64,RenderPass *> RenderpassListBySimple;
|
||||
}//namespace
|
||||
|
||||
SwapchainRenderTarget::SwapchainRenderTarget(GPUDevice *dev,Swapchain *sc):RenderTarget(dev,nullptr,sc->GetImageCount())
|
||||
{
|
||||
swapchain=sc;
|
||||
@ -36,21 +17,7 @@ SwapchainRenderTarget::SwapchainRenderTarget(GPUDevice *dev,Swapchain *sc):Rende
|
||||
Texture2D **sc_color=swapchain->GetColorTextures();
|
||||
Texture2D *sc_depth=swapchain->GetDepthTexture();
|
||||
|
||||
{
|
||||
SwapchainFormatHash sfh;
|
||||
|
||||
sfh.color=(*sc_color)->GetFormat();
|
||||
sfh.depth=sc_depth->GetFormat();
|
||||
|
||||
if(!RenderpassListBySimple.Get(sfh.hashcode,this->render_pass))
|
||||
{
|
||||
SwapchainRenderbufferInfo rbi((*sc_color)->GetFormat(),sc_depth->GetFormat());
|
||||
|
||||
this->render_pass=device->AcquireRenderPass(&rbi,RenderPassTypeBy::Simple);
|
||||
|
||||
RenderpassListBySimple.Add(sfh.hashcode,this->render_pass);
|
||||
}
|
||||
}
|
||||
render_pass=dev->GetRenderPass();
|
||||
|
||||
swap_chain_count=swapchain->GetImageCount();
|
||||
|
||||
@ -60,7 +27,7 @@ SwapchainRenderTarget::SwapchainRenderTarget(GPUDevice *dev,Swapchain *sc):Rende
|
||||
|
||||
for(uint i=0;i<swap_chain_count;i++)
|
||||
{
|
||||
render_frame[i]=device->CreateFramebuffer(this->render_pass,(*sc_color)->GetImageView(),sc_depth->GetImageView());
|
||||
render_frame[i]=device->CreateFramebuffer(render_pass,(*sc_color)->GetImageView(),sc_depth->GetImageView());
|
||||
++sc_color;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user