new CreateRenderTarget functions.
This commit is contained in:
parent
bfec51d0a3
commit
924df77e1f
@ -288,6 +288,12 @@ public:
|
|||||||
const VkImageLayout color_final_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
const VkImageLayout color_final_layout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
const VkImageLayout depth_final_layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
const VkImageLayout depth_final_layout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
|
|
||||||
|
RenderTarget *CreateRenderTarget( const uint,const uint,
|
||||||
|
const List<VkFormat> &color_format_list,
|
||||||
|
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);
|
||||||
|
|
||||||
Pipeline *CreatePipeline(const InlinePipeline &,const Material *,const RenderTarget *);
|
Pipeline *CreatePipeline(const InlinePipeline &,const Material *,const RenderTarget *);
|
||||||
Pipeline *CreatePipeline( PipelineData *, const Material *,const RenderTarget *);
|
Pipeline *CreatePipeline( PipelineData *, const Material *,const RenderTarget *);
|
||||||
|
|
||||||
|
@ -201,9 +201,12 @@ RenderPass *Device::CreateRenderPass( const List<VkAttachmentDescription> &des
|
|||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format)
|
if(depth_format!=FMT_UNDEFINED)
|
||||||
&&!attr->physical_device->IsDepthAttachmentLinear(depth_format))
|
{
|
||||||
return(nullptr);
|
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format)
|
||||||
|
&&!attr->physical_device->IsDepthAttachmentLinear(depth_format))
|
||||||
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
VkRenderPassCreateInfo rp_info;
|
VkRenderPassCreateInfo rp_info;
|
||||||
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||||
@ -230,24 +233,29 @@ RenderPass *Device::CreateRenderPass(const List<VkFormat> &color_format_list,VkF
|
|||||||
if(!attr->physical_device->IsColorAttachmentOptimal(fmt))
|
if(!attr->physical_device->IsColorAttachmentOptimal(fmt))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format))
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
List<VkAttachmentReference> color_ref_list;
|
List<VkAttachmentReference> color_ref_list;
|
||||||
VkAttachmentReference depth_ref;
|
VkAttachmentReference depth_ref;
|
||||||
List<VkAttachmentDescription> atta_desc_list;
|
List<VkAttachmentDescription> atta_desc_list;
|
||||||
|
List<VkSubpassDescription> subpass_desc_list;
|
||||||
|
List<VkSubpassDependency> subpass_dependency_list;
|
||||||
|
|
||||||
color_ref_list.SetCount(color_format_list.GetCount());
|
color_ref_list.SetCount(color_format_list.GetCount());
|
||||||
CreateColorAttachmentReference(color_ref_list.GetData(),0,color_format_list.GetCount());
|
CreateColorAttachmentReference(color_ref_list.GetData(),0,color_format_list.GetCount());
|
||||||
CreateDepthAttachmentReference(&depth_ref,color_format_list.GetCount());
|
|
||||||
|
|
||||||
CreateAttachmentDescription(atta_desc_list,color_format_list,depth_format,color_final_layout,depth_final_layout);
|
CreateAttachmentDescription(atta_desc_list,color_format_list,depth_format,color_final_layout,depth_final_layout);
|
||||||
|
|
||||||
List<VkSubpassDescription> subpass_desc_list;
|
if(depth_format!=FMT_UNDEFINED)
|
||||||
|
{
|
||||||
subpass_desc_list.Add(SubpassDescription(color_ref_list.GetData(),color_ref_list.GetCount(),&depth_ref));
|
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format))
|
||||||
|
return(nullptr);
|
||||||
List<VkSubpassDependency> subpass_dependency_list;
|
|
||||||
|
CreateDepthAttachmentReference(&depth_ref,color_format_list.GetCount());
|
||||||
|
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);
|
CreateSubpassDependency(subpass_dependency_list,2);
|
||||||
|
|
||||||
|
@ -8,6 +8,47 @@ RenderTarget *Device::CreateRenderTarget(Framebuffer *fb)
|
|||||||
return(new RenderTarget(this,fb,cb));
|
return(new RenderTarget(this,fb,cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RenderTarget *Device::CreateRenderTarget( const uint w,const uint h,
|
||||||
|
const List<VkFormat> &color_format_list,
|
||||||
|
const VkFormat depth_format,
|
||||||
|
const VkImageLayout color_layout,
|
||||||
|
const VkImageLayout depth_layout)
|
||||||
|
{
|
||||||
|
if(w<=0||h<=0)return(nullptr);
|
||||||
|
|
||||||
|
RenderPass *rp=CreateRenderPass(color_format_list,depth_format,color_layout,depth_layout); //Renderpass内部会验证格式,所以不需要自己处理
|
||||||
|
|
||||||
|
ObjectList<Texture2D> color_texture_list;
|
||||||
|
List<ImageView *> color_texture_image_view_list;
|
||||||
|
|
||||||
|
for(const VkFormat &fmt:color_format_list)
|
||||||
|
{
|
||||||
|
Texture2D *color_texture=CreateAttachmentTextureColor(fmt,w,h);
|
||||||
|
|
||||||
|
if(!color_texture)
|
||||||
|
{
|
||||||
|
delete rp;
|
||||||
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
color_texture_list.Add(color_texture);
|
||||||
|
color_texture_image_view_list.Add(color_texture->GetImageView());
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D *depth_texture=(depth_format!=FMT_UNDEFINED)?CreateAttachmentTextureDepth(depth_format,w,h):nullptr;
|
||||||
|
|
||||||
|
Framebuffer *fb=CreateFramebuffer(rp,color_texture_image_view_list,depth_texture->GetImageView());
|
||||||
|
|
||||||
|
if(!fb)
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(depth_texture)
|
||||||
|
delete rp;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(CreateRenderTarget(fb));
|
||||||
|
}
|
||||||
|
|
||||||
RenderTarget *Device::CreateRenderTarget( const uint w,const uint h,
|
RenderTarget *Device::CreateRenderTarget( const uint w,const uint h,
|
||||||
const VkFormat color_format,
|
const VkFormat color_format,
|
||||||
const VkFormat depth_format,
|
const VkFormat depth_format,
|
||||||
@ -16,75 +57,10 @@ RenderTarget *Device::CreateRenderTarget( const uint w,const uint h,
|
|||||||
{
|
{
|
||||||
if(w<=0||h<=0)return(nullptr);
|
if(w<=0||h<=0)return(nullptr);
|
||||||
|
|
||||||
RenderPass *rp=CreateRenderPass(color_format,depth_format,color_layout,depth_layout); //Renderpass内部会验证格式,所以不需要自己处理
|
List<VkFormat> color_format_list;
|
||||||
|
|
||||||
if(!CheckTextureFormatSupport(color_format))return(nullptr);
|
color_format_list.Add(color_format);
|
||||||
if(!CheckTextureFormatSupport(depth_format))return(nullptr);
|
|
||||||
|
|
||||||
Texture2D *color_texture=CreateAttachmentTextureColor(color_format,w,h);
|
return CreateRenderTarget(w,h,color_format_list,depth_format,color_layout,depth_layout);
|
||||||
Texture2D *depth_texture=CreateAttachmentTextureDepth(depth_format,w,h);
|
|
||||||
|
|
||||||
Framebuffer *fb=CreateFramebuffer(rp,color_texture->GetImageView(),depth_texture->GetImageView());
|
|
||||||
|
|
||||||
return(CreateRenderTarget(fb));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//RenderTarget *Device::CreateRenderTarget(const uint w,const uint h,const List<VkFormat> &fmt_list)
|
|
||||||
//{
|
|
||||||
// if(w<=0||h<=0||fmt_list.GetCount()<=0)return(nullptr);
|
|
||||||
//
|
|
||||||
// uint color_count=0;
|
|
||||||
// uint depth_count=0; //只能有一个
|
|
||||||
// uint stencil_count=0;
|
|
||||||
//
|
|
||||||
// for(VkFormat fmt:fmt_list)
|
|
||||||
// {
|
|
||||||
// if(IsDepthFormat(fmt))++depth_count;
|
|
||||||
// else
|
|
||||||
// if(IsStencilFormat(fmt))++stencil_count;
|
|
||||||
// else
|
|
||||||
// ++color_count;
|
|
||||||
//
|
|
||||||
// if(CheckTextureFormatSupport(fmt))
|
|
||||||
// return(nullptr);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(depth_count>1)return(nullptr);
|
|
||||||
// if(stencil_count>1)return(nullptr);
|
|
||||||
//
|
|
||||||
// List<VkFormat> color_format_list;
|
|
||||||
// VkFormat depth_format;
|
|
||||||
// List<VkAttachmentDescription> desc_list;
|
|
||||||
// List<VkAttachmentReference> color_ref_list;
|
|
||||||
// VkAttachmentReference depth_ref;
|
|
||||||
// List<vulkan::ImageView *> image_view_list;
|
|
||||||
//
|
|
||||||
// for(VkFormat fmt:fmt_list)
|
|
||||||
// {
|
|
||||||
// Texture2D *tex=nullptr;
|
|
||||||
//
|
|
||||||
// if(IsDepthFormat(fmt))
|
|
||||||
// {
|
|
||||||
// tex=CreateAttachmentTextureDepth(fmt,w,h);
|
|
||||||
//
|
|
||||||
// depth_format=fmt;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// tex=CreateAttachmentTextureColor(fmt,w,h);
|
|
||||||
//
|
|
||||||
// image_view_list.Add(tex->GetImageView());
|
|
||||||
// color_format_list.Add(fmt);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(depth_count>0)CreateDepthAttachmentReference(&depth_ref,color_count);
|
|
||||||
// if(color_count>0)CreateColorAttachmentReference(color_ref_list,0,color_count);
|
|
||||||
//
|
|
||||||
// CreateAttachmentDescription(desc_list,color_format_list,depth_format,VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
|
||||||
//
|
|
||||||
// VkSubpassDescription sd;
|
|
||||||
//
|
|
||||||
// CreateSubpassDescription(sd,color_ref_list,&depth_ref);
|
|
||||||
//}
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user