- rendering to texture requires a separate depth/stencil image as the image used by the main view may be using multisampling

This commit is contained in:
Magnus Norddahl 2019-05-05 01:58:36 +02:00
commit e1ae8bbc59
8 changed files with 50 additions and 10 deletions

View file

@ -210,6 +210,7 @@ void VkRenderState::ApplyRenderPass(int dt)
passKey.StencilPassOp = mStencilOp;
passKey.ColorMask = mColorMask;
passKey.CullMode = mCullMode;
passKey.DrawBufferFormat = mRenderTarget.Format;
passKey.Samples = mRenderTarget.Samples;
passKey.DrawBuffers = mRenderTarget.DrawBuffers;
passKey.NumTextureLayers = mMaterial.mMaterial ? mMaterial.mMaterial->GetLayers() : 0;
@ -535,13 +536,14 @@ void VkRenderState::EnableDrawBuffers(int count)
}
}
void VkRenderState::SetRenderTarget(VulkanImageView *view, int width, int height, VkSampleCountFlagBits samples)
void VkRenderState::SetRenderTarget(VulkanImageView *view, int width, int height, VkFormat format, VkSampleCountFlagBits samples)
{
EndRenderPass();
mRenderTarget.View = view;
mRenderTarget.Width = width;
mRenderTarget.Height = height;
mRenderTarget.Format = format;
mRenderTarget.Samples = samples;
}
@ -564,7 +566,7 @@ void VkRenderState::BeginRenderPass(const VkRenderPassKey &key, VulkanCommandBuf
if (key.DrawBuffers > 2)
builder.addAttachment(buffers->SceneNormalView.get());
if (key.UsesDepthStencil())
builder.addAttachment(buffers->SceneDepthStencilView.get());
builder.addAttachment(mRenderTarget.Format == VK_FORMAT_R8G8B8A8_UNORM ? buffers->CamtexDepthStencilView.get() : buffers->SceneDepthStencilView.get());
framebuffer = builder.create(GetVulkanFrameBuffer()->device);
framebuffer->SetDebugName("VkRenderPassSetup.Framebuffer");
}