恢复默认同时使用COLOR+DEPTH缓冲区

This commit is contained in:
hyzboy 2019-04-20 20:07:41 +08:00
parent 0f389f907d
commit e87368eeaf
2 changed files with 12 additions and 14 deletions

View File

@ -76,8 +76,6 @@ Device::Device(DeviceAttribute *da)
} }
Device::~Device() Device::~Device()
{ {
const uint32_t sc_count=attr->sc_image_views.GetCount();
delete image_acquired_semaphore; delete image_acquired_semaphore;
delete draw_fence; delete draw_fence;
@ -149,15 +147,15 @@ RenderPass *Device::CreateRenderPass()
attachments[0].finalLayout=VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; attachments[0].finalLayout=VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
attachments[0].flags=0; attachments[0].flags=0;
//attachments[1].format=attr->depth.format; attachments[1].format=attr->depth.format;
//attachments[1].samples=VK_SAMPLE_COUNT_1_BIT; attachments[1].samples=VK_SAMPLE_COUNT_1_BIT;
//attachments[1].loadOp=VK_ATTACHMENT_LOAD_OP_CLEAR; attachments[1].loadOp=VK_ATTACHMENT_LOAD_OP_CLEAR;
//attachments[1].storeOp=VK_ATTACHMENT_STORE_OP_DONT_CARE; attachments[1].storeOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
//attachments[1].stencilLoadOp=VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachments[1].stencilLoadOp=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
//attachments[1].stencilStoreOp=VK_ATTACHMENT_STORE_OP_DONT_CARE; attachments[1].stencilStoreOp=VK_ATTACHMENT_STORE_OP_DONT_CARE;
//attachments[1].initialLayout=VK_IMAGE_LAYOUT_UNDEFINED; attachments[1].initialLayout=VK_IMAGE_LAYOUT_UNDEFINED;
//attachments[1].finalLayout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; attachments[1].finalLayout=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
//attachments[1].flags=0; attachments[1].flags=0;
VkAttachmentReference color_reference={0,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}; VkAttachmentReference color_reference={0,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL};
VkAttachmentReference depth_reference={1,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL}; VkAttachmentReference depth_reference={1,VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL};
@ -170,7 +168,7 @@ RenderPass *Device::CreateRenderPass()
subpass.colorAttachmentCount=1; subpass.colorAttachmentCount=1;
subpass.pColorAttachments=&color_reference; subpass.pColorAttachments=&color_reference;
subpass.pResolveAttachments=nullptr; subpass.pResolveAttachments=nullptr;
subpass.pDepthStencilAttachment=nullptr;//&depth_reference; subpass.pDepthStencilAttachment=&depth_reference;
subpass.preserveAttachmentCount=0; subpass.preserveAttachmentCount=0;
subpass.pPreserveAttachments=nullptr; subpass.pPreserveAttachments=nullptr;
@ -185,7 +183,7 @@ RenderPass *Device::CreateRenderPass()
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;
rp_info.pNext=nullptr; rp_info.pNext=nullptr;
rp_info.attachmentCount=1; rp_info.attachmentCount=2;
rp_info.pAttachments=attachments; rp_info.pAttachments=attachments;
rp_info.subpassCount=1; rp_info.subpassCount=1;
rp_info.pSubpasses=&subpass; rp_info.pSubpasses=&subpass;

View File

@ -201,7 +201,7 @@ int main(int,char **)
vulkan::Framebuffer **fb=new vulkan::Framebuffer *[image_count]; vulkan::Framebuffer **fb=new vulkan::Framebuffer *[image_count];
for(int i=0;i<image_count;i++) for(int i=0;i<image_count;i++)
fb[i]=vulkan::CreateFramebuffer(device,rp,device->GetColorImageView(i)); fb[i]=vulkan::CreateFramebuffer(device,rp,device->GetColorImageView(i),device->GetDepthImageView());
cmd_buf->Begin(rp,fb[0]); cmd_buf->Begin(rp,fb[0]);
cmd_buf->Bind(pipeline); cmd_buf->Bind(pipeline);