fix attachment index error of Create renderpass

This commit is contained in:
hyzboy 2020-10-16 12:27:30 +08:00
parent 1e0676c6c7
commit b93925ce5a
2 changed files with 10 additions and 9 deletions

View File

@ -276,7 +276,8 @@ public:
const VkImageLayout color_final_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
const VkImageLayout depth_final_layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
Pipeline *CreatePipeline(PipelineData *,const Material *,const RenderTarget *);
Pipeline *CreatePipeline(const InlinePipeline &,const Material *,const RenderTarget *);
Pipeline *CreatePipeline( PipelineData *, const Material *,const RenderTarget *);
TileData *CreateTileData(const VkFormat video_format,const uint width,const uint height,const uint count); ///<创建一个Tile数据集
@ -286,11 +287,11 @@ public:
void CreateSubpassDependency(VkSubpassDependency *);
void CreateSubpassDependency(List<VkSubpassDependency> &dependency,const uint32_t count);
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint count,VkImageLayout layout);
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint start,uint count,VkImageLayout layout);
inline void CreateColorAttachmentReference(VkAttachmentReference *ref_list,uint count ){CreateAttachmentReference(ref_list, count,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);}
inline void CreateDepthAttachmentReference(VkAttachmentReference *depth_ref) {CreateAttachmentReference(depth_ref, 1 ,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);}
inline void CreateInputAttachmentReference(VkAttachmentReference *ref_list,uint count ){CreateAttachmentReference(ref_list, count,VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);}
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);

View File

@ -67,11 +67,11 @@ void CreateSubpassDependency(List<VkSubpassDependency> &subpass_dependency_list,
}
}
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint count,VkImageLayout layout)
void CreateAttachmentReference(VkAttachmentReference *ref_list,uint start,uint count,VkImageLayout layout)
{
VkAttachmentReference *ref=ref_list;
for(uint i=0;i<count;i++)
for(uint i=start;i<start+count;i++)
{
ref->attachment =i;
ref->layout =layout;
@ -240,8 +240,8 @@ RenderPass *Device::CreateRenderPass(VkFormat color_format,VkFormat depth_format
color_format_list.Add(color_format);
CreateColorAttachmentReference(&color_ref,1);
CreateDepthAttachmentReference(&depth_ref);
CreateColorAttachmentReference(&color_ref,0,1);
CreateDepthAttachmentReference(&depth_ref,1);
CreateAttachment(desc_list,color_format_list,depth_format,color_final_layout,depth_final_layout);