vulkan oit: get rid of depth2 attachment
This commit is contained in:
parent
c10f075266
commit
25fb888d26
|
@ -353,7 +353,7 @@ bool OITDrawer::Draw(const Texture *fogTexture)
|
|||
|
||||
// Color subpass
|
||||
cmdBuffer.nextSubpass(vk::SubpassContents::eInline);
|
||||
GetCurrentDescSet().UpdatePass1Uniforms(stencilImageView, depthImageView);
|
||||
GetCurrentDescSet().UpdatePass1Uniforms(depthAttachment->GetStencilView(), depthAttachment->GetImageView());
|
||||
GetCurrentDescSet().BindPass1DescriptorSets(cmdBuffer);
|
||||
|
||||
// OP + PT
|
||||
|
@ -365,7 +365,7 @@ bool OITDrawer::Draw(const Texture *fogTexture)
|
|||
|
||||
// Final subpass
|
||||
cmdBuffer.nextSubpass(vk::SubpassContents::eInline);
|
||||
GetCurrentDescSet().UpdatePass2Uniforms(colorImageView);
|
||||
GetCurrentDescSet().UpdatePass2Uniforms(color1Attachment->GetImageView());
|
||||
GetCurrentDescSet().BindPass2DescriptorSets(cmdBuffer);
|
||||
|
||||
// Tr modifier volumes
|
||||
|
@ -421,31 +421,27 @@ void OITDrawer::MakeBuffers(int width, int height)
|
|||
|
||||
void OITDrawer::MakeAttachments(int width, int height)
|
||||
{
|
||||
colorAttachment = std::unique_ptr<FramebufferAttachment>(new FramebufferAttachment(GetContext()->GetPhysicalDevice(),
|
||||
color1Attachment = std::unique_ptr<FramebufferAttachment>(new FramebufferAttachment(GetContext()->GetPhysicalDevice(),
|
||||
GetContext()->GetDevice(), allocator));
|
||||
colorAttachment->Init(width, height, GetContext()->GetColorFormat(), vk::ImageUsageFlagBits::eInputAttachment);
|
||||
colorImageView = colorAttachment->GetImageView();
|
||||
color1Attachment->Init(width, height, GetContext()->GetColorFormat(), vk::ImageUsageFlagBits::eInputAttachment);
|
||||
|
||||
color2Attachment = std::unique_ptr<FramebufferAttachment>(new FramebufferAttachment(GetContext()->GetPhysicalDevice(),
|
||||
GetContext()->GetDevice(), allocator));
|
||||
color2Attachment->Init(width, height, GetContext()->GetColorFormat(), vk::ImageUsageFlagBits::eInputAttachment);
|
||||
|
||||
depthAttachment = std::unique_ptr<FramebufferAttachment>(new FramebufferAttachment(GetContext()->GetPhysicalDevice(),
|
||||
GetContext()->GetDevice(), allocator));
|
||||
depthAttachment->Init(width, height, GetContext()->GetDepthFormat(), vk::ImageUsageFlagBits::eInputAttachment);
|
||||
depthImageView = depthAttachment->GetImageView();
|
||||
stencilImageView = depthAttachment->GetStencilView();
|
||||
|
||||
depth2Attachment = std::unique_ptr<FramebufferAttachment>(new FramebufferAttachment(GetContext()->GetPhysicalDevice(),
|
||||
GetContext()->GetDevice(), allocator));
|
||||
depth2Attachment->Init(width, height, GetContext()->GetDepthFormat());
|
||||
printf("color attachment %p depth %p depth2 %p\n", (VkImage)colorAttachment->GetImage(), (VkImage)depthAttachment->GetImage(),
|
||||
(VkImage)depth2Attachment->GetImage());
|
||||
printf("color attachment %p depth %p\n", (VkImage)color1Attachment->GetImage(), (VkImage)depthAttachment->GetImage());
|
||||
}
|
||||
|
||||
void OITDrawer::MakeFramebuffers(int width, int height)
|
||||
{
|
||||
vk::ImageView attachments[] = {
|
||||
nullptr, // swap chain image view, set later
|
||||
colorImageView,
|
||||
depthImageView,
|
||||
depth2Attachment->GetImageView()
|
||||
color1Attachment->GetImageView(),
|
||||
depthAttachment->GetImageView(),
|
||||
};
|
||||
framebuffers.reserve(GetContext()->GetSwapChainSize());
|
||||
for (int i = 0; i < GetContext()->GetSwapChainSize(); i++)
|
||||
|
|
|
@ -106,13 +106,9 @@ private:
|
|||
|
||||
std::unique_ptr<QuadBuffer> quadBuffer;
|
||||
|
||||
vk::ImageView colorImageView;
|
||||
vk::ImageView depthImageView;
|
||||
vk::ImageView stencilImageView;
|
||||
|
||||
std::unique_ptr<FramebufferAttachment> colorAttachment;
|
||||
std::unique_ptr<FramebufferAttachment> color1Attachment;
|
||||
std::unique_ptr<FramebufferAttachment> color2Attachment;
|
||||
std::unique_ptr<FramebufferAttachment> depthAttachment;
|
||||
std::unique_ptr<FramebufferAttachment> depth2Attachment;
|
||||
|
||||
SamplerManager *samplerManager = nullptr;
|
||||
vk::Rect2D currentScissor;
|
||||
|
|
|
@ -35,28 +35,22 @@ void OITPipelineManager::MakeRenderPass()
|
|||
// OP+PT depth attachment
|
||||
vk::AttachmentDescription(vk::AttachmentDescriptionFlags(), GetContext()->GetDepthFormat(), vk::SampleCountFlagBits::e1,
|
||||
vk::AttachmentLoadOp::eClear, vk::AttachmentStoreOp::eStore, vk::AttachmentLoadOp::eClear, vk::AttachmentStoreOp::eStore,
|
||||
vk::ImageLayout::eUndefined, vk::ImageLayout::eShaderReadOnlyOptimal),
|
||||
// new depth attachment
|
||||
vk::AttachmentDescription(vk::AttachmentDescriptionFlags(), GetContext()->GetDepthFormat(), vk::SampleCountFlagBits::e1,
|
||||
vk::AttachmentLoadOp::eClear, vk::AttachmentStoreOp::eDontCare, vk::AttachmentLoadOp::eDontCare, vk::AttachmentStoreOp::eDontCare,
|
||||
vk::ImageLayout::eUndefined, vk::ImageLayout::eDepthStencilAttachmentOptimal),
|
||||
vk::ImageLayout::eUndefined, vk::ImageLayout::eDepthStencilReadOnlyOptimal),
|
||||
};
|
||||
vk::AttachmentReference swapChainReference(0, vk::ImageLayout::eColorAttachmentOptimal);
|
||||
vk::AttachmentReference colorReference(1, vk::ImageLayout::eColorAttachmentOptimal);
|
||||
vk::AttachmentReference depthReference(2, vk::ImageLayout::eDepthStencilAttachmentOptimal);
|
||||
vk::AttachmentReference depth2Reference(3, vk::ImageLayout::eDepthStencilAttachmentOptimal);
|
||||
|
||||
vk::AttachmentReference depthInput(2, vk::ImageLayout::eShaderReadOnlyOptimal); // eShaderReadOnlyOptimal really?
|
||||
vk::AttachmentReference depthReadOnlyRef(2, vk::ImageLayout::eDepthStencilReadOnlyOptimal);
|
||||
vk::AttachmentReference colorInput(1, vk::ImageLayout::eShaderReadOnlyOptimal);
|
||||
vk::AttachmentReference unused(VK_ATTACHMENT_UNUSED, vk::ImageLayout::eUndefined);
|
||||
|
||||
vk::SubpassDescription subpasses[] = {
|
||||
// Depth and modvol pass FIXME subpass 0 shouldn't reference the color attachment
|
||||
vk::SubpassDescription(vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, 0, nullptr, 1, &colorReference, nullptr, &depthReference),
|
||||
// Color pass
|
||||
vk::SubpassDescription(vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, 1, &depthInput, 1, &colorReference, nullptr, &depth2Reference),
|
||||
vk::SubpassDescription(vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, 1, &depthReadOnlyRef, 1, &colorReference, nullptr, &depthReadOnlyRef),
|
||||
// Final pass
|
||||
vk::SubpassDescription(vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, 1, &colorInput, 1, &swapChainReference, nullptr, &unused),
|
||||
vk::SubpassDescription(vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, 1, &colorInput, 1, &swapChainReference, nullptr, nullptr),
|
||||
};
|
||||
|
||||
vk::SubpassDependency dependencies[] = {
|
||||
|
@ -117,17 +111,19 @@ void OITPipelineManager::CreatePipeline(u32 listType, bool autosort, const PolyP
|
|||
|
||||
// Depth and stencil
|
||||
vk::CompareOp depthOp;
|
||||
if (listType == ListType_Punch_Through || autosort)
|
||||
if (pass == 1)
|
||||
depthOp = vk::CompareOp::eEqual;
|
||||
else if (listType == ListType_Punch_Through || autosort)
|
||||
depthOp = vk::CompareOp::eGreaterOrEqual;
|
||||
else
|
||||
depthOp = depthOps[pp.isp.DepthMode];
|
||||
bool depthWriteEnable;
|
||||
if (pass != 0)
|
||||
depthWriteEnable = false;
|
||||
// Z Write Disable seems to be ignored for punch-through.
|
||||
// Fixes Worms World Party, Bust-a-Move 4 and Re-Volt
|
||||
if (listType == ListType_Punch_Through)
|
||||
else if (listType == ListType_Punch_Through)
|
||||
depthWriteEnable = true;
|
||||
else if (listType == ListType_Translucent)
|
||||
depthWriteEnable = false;
|
||||
else
|
||||
depthWriteEnable = !pp.isp.ZWriteDis;
|
||||
|
||||
|
|
|
@ -130,9 +130,9 @@ public:
|
|||
vk::DescriptorSetAllocateInfo(GetContext()->GetDescriptorPool(), 1, &pass1Layout)).front());
|
||||
}
|
||||
std::vector<vk::WriteDescriptorSet> writeDescriptorSets;
|
||||
vk::DescriptorImageInfo stencilImageInfo(vk::Sampler(), stencilImageView, vk::ImageLayout::eShaderReadOnlyOptimal);
|
||||
vk::DescriptorImageInfo stencilImageInfo(vk::Sampler(), stencilImageView, vk::ImageLayout::eDepthStencilReadOnlyOptimal);
|
||||
writeDescriptorSets.push_back(vk::WriteDescriptorSet(*pass1DescSet, 0, 0, 1, vk::DescriptorType::eInputAttachment, &stencilImageInfo, nullptr, nullptr));
|
||||
vk::DescriptorImageInfo depthImageInfo(vk::Sampler(), depthImageView, vk::ImageLayout::eShaderReadOnlyOptimal);
|
||||
vk::DescriptorImageInfo depthImageInfo(vk::Sampler(), depthImageView, vk::ImageLayout::eDepthStencilReadOnlyOptimal);
|
||||
writeDescriptorSets.push_back(vk::WriteDescriptorSet(*pass1DescSet, 1, 0, 1, vk::DescriptorType::eInputAttachment, &depthImageInfo, nullptr, nullptr));
|
||||
|
||||
GetContext()->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr);
|
||||
|
|
Loading…
Reference in New Issue