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:
parent
078542e44b
commit
98fe974fc8
|
|
@ -835,6 +835,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
lightingPass.SetClearColor(lightingPass.AddOutput(lightOutput), Nz::Color::Black());
|
||||
lightingPass.SetDepthStencilInput(depthBuffer1);
|
||||
lightingPass.SetDepthStencilOutput(depthBuffer1);
|
||||
|
||||
Nz::FramePass& forwardPass = graph.AddPass("Forward pass");
|
||||
forwardPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||
|
|
@ -1517,7 +1518,12 @@ int main(int argc, char* argv[])
|
|||
|
||||
builder.TextureBarrier(Nz::PipelineStage::ColorOutput, Nz::PipelineStage::FragmentShader, Nz::MemoryAccess::ColorWrite, Nz::MemoryAccess::ShaderRead, Nz::TextureLayout::ColorOutput, Nz::TextureLayout::ColorInput, *bakedGraph.GetAttachmentTexture(toneMappingOutput));
|
||||
|
||||
builder.BeginRenderPass(windowRT->GetFramebuffer(frame.GetFramebufferIndex()), windowRT->GetRenderPass(), windowRenderRect);
|
||||
Nz::CommandBufferBuilder::ClearValues clearValues[2];
|
||||
clearValues[0].color = Nz::Color::Black();
|
||||
clearValues[1].depth = 1.f;
|
||||
clearValues[1].stencil = 0;
|
||||
|
||||
builder.BeginRenderPass(windowRT->GetFramebuffer(frame.GetFramebufferIndex()), windowRT->GetRenderPass(), windowRenderRect, { clearValues[0], clearValues[1] });
|
||||
{
|
||||
builder.BeginDebugRegion("Main window rendering", Nz::Color::Green());
|
||||
{
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ namespace Nz
|
|||
dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
break;
|
||||
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
|
||||
if (oldImageLayout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
|
||||
if (oldImageLayout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
|
||||
srcAccessMask |= VK_ACCESS_TRANSFER_READ_BIT;
|
||||
|
||||
dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ namespace Nz
|
|||
std::array enabledFeatures = {
|
||||
//VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,
|
||||
//VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,
|
||||
VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT,
|
||||
//VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT,
|
||||
VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,23 +36,28 @@ namespace Nz
|
|||
|
||||
std::size_t attachmentCount = vkRenderPass.GetAttachmentCount();
|
||||
|
||||
StackArray<VkClearValue> vkClearValues = NazaraStackArray(VkClearValue, attachmentCount);
|
||||
for (std::size_t i = 0; i < attachmentCount; ++i)
|
||||
{
|
||||
const auto& values = (i < clearValueCount) ? clearValues[i] : CommandBufferBuilder::ClearValues{};
|
||||
auto& vkValues = vkClearValues[i];
|
||||
StackArray<VkClearValue> vkClearValues;
|
||||
|
||||
if (PixelFormatInfo::GetContent(vkRenderPass.GetAttachment(i).format) == PixelFormatContent::ColorRGBA)
|
||||
if (clearValueCount > 0)
|
||||
{
|
||||
vkClearValues = NazaraStackArray(VkClearValue, attachmentCount);
|
||||
for (std::size_t i = 0; i < attachmentCount; ++i)
|
||||
{
|
||||
vkValues.color.float32[0] = values.color.r;
|
||||
vkValues.color.float32[1] = values.color.g;
|
||||
vkValues.color.float32[2] = values.color.b;
|
||||
vkValues.color.float32[3] = values.color.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
vkValues.depthStencil.depth = values.depth;
|
||||
vkValues.depthStencil.stencil = values.stencil;
|
||||
const auto& values = (i < clearValueCount) ? clearValues[i] : CommandBufferBuilder::ClearValues{};
|
||||
auto& vkValues = vkClearValues[i];
|
||||
|
||||
if (PixelFormatInfo::GetContent(vkRenderPass.GetAttachment(i).format) == PixelFormatContent::ColorRGBA)
|
||||
{
|
||||
vkValues.color.float32[0] = values.color.r;
|
||||
vkValues.color.float32[1] = values.color.g;
|
||||
vkValues.color.float32[2] = values.color.b;
|
||||
vkValues.color.float32[3] = values.color.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
vkValues.depthStencil.depth = values.depth;
|
||||
vkValues.depthStencil.stencil = values.stencil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue