Fix some Vulkan errors

Depth buffers were not tagged as output on passes writing on it
Handle holes in clear values
This commit is contained in:
SirLynix
2023-10-08 13:47:15 +02:00
parent 078542e44b
commit 98fe974fc8
6 changed files with 42 additions and 24 deletions

View File

@@ -301,8 +301,8 @@ namespace Nz
forwardPass.AddOutput(colorBufferIndex);
if (hasDepthPrepass)
forwardPass.SetDepthStencilInput(depthBufferIndex);
else
forwardPass.SetDepthStencilOutput(depthBufferIndex);
forwardPass.SetDepthStencilOutput(depthBufferIndex);
forwardPass.SetClearColor(0, m_viewer->GetClearColor());
forwardPass.SetDepthStencilClear(1.f, 0);

View File

@@ -85,19 +85,26 @@ namespace Nz
auto& bakedSubpass = bakedPass.subpasses.emplace_back();
bakedSubpass.commandCallback = framePass.GetCommandCallback();
for (const auto& output : framePass.GetOutputs())
const auto& colorOutputs = framePass.GetOutputs();
for (std::size_t i = 0; i < colorOutputs.size(); ++i)
{
const auto& output = colorOutputs[i];
bakedPass.outputTextureIndices.push_back(Retrieve(m_pending.attachmentToTextures, output.attachmentId));
auto& clearValues = bakedPass.outputClearValues.emplace_back();
if (output.clearColor)
clearValues.color = *output.clearColor;
{
bakedPass.outputClearValues.resize(i + 1);
bakedPass.outputClearValues[i].color = *output.clearColor;
}
}
// Add depth-stencil clear values
auto& dsClearValues = bakedPass.outputClearValues.emplace_back();
if (const auto& depthStencilClear = framePass.GetDepthStencilClear())
{
std::size_t depthClearIndex = colorOutputs.size();
bakedPass.outputClearValues.resize(depthClearIndex + 1);
auto& dsClearValues = bakedPass.outputClearValues[depthClearIndex];
dsClearValues.depth = depthStencilClear->depth;
dsClearValues.stencil = depthStencilClear->stencil;
}