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