diff --git a/betterRenderer/renderer/source/ssao.cpp b/betterRenderer/renderer/source/ssao.cpp index 2a1ccd67..7a098703 100644 --- a/betterRenderer/renderer/source/ssao.cpp +++ b/betterRenderer/renderer/source/ssao.cpp @@ -103,10 +103,11 @@ void NvSsao::Init() { .setInitialState(ResourceStates::ShaderResource) .setKeepInitialState(true)); - SamplerHandle sampler_point = m_SamplerPoint = m_backend->GetDevice()->createSampler( - nvrhi::SamplerDesc() - .setAllAddressModes(SamplerAddressMode::Clamp) - .setAllFilters(false)); + SamplerHandle sampler_point = m_SamplerPoint = + m_backend->GetDevice()->createSampler( + nvrhi::SamplerDesc() + .setAllAddressModes(SamplerAddressMode::Clamp) + .setAllFilters(false)); { BindingLayoutHandle blPrefilterDepths; @@ -141,10 +142,14 @@ void NvSsao::Init() { .addItem(BindingSetItem::Texture_UAV(2, m_debugImage)) .addItem(BindingSetItem::Sampler(0, sampler_point)), blGTAO, m_BSGTAO); - m_PSOGTAO = m_backend->GetDevice()->createComputePipeline( - ComputePipelineDesc() - .setComputeShader(m_CSGTAOHigh) - .addBindingLayout(blGTAO)); + std::array const shaders{m_CSGTAOLow, m_CSGTAOMedium, + m_CSGTAOHigh, m_CSGTAOUltra}; + for (int i = 0; i < 4; ++i) { + m_PSOGTAO[i] = m_backend->GetDevice()->createComputePipeline( + ComputePipelineDesc() + .setComputeShader(shaders[i]) + .addBindingLayout(blGTAO)); + } } { @@ -204,7 +209,7 @@ void NvSsao::Render(nvrhi::ICommandList* command_list, { command_list->beginMarker("Main Pass"); nvrhi::ComputeState state; - state.setPipeline(m_PSOGTAO); + state.setPipeline(m_PSOGTAO[glm::clamp(settings.QualityLevel, 0, 3)]); state.addBindingSet(m_BSGTAO); command_list->setComputeState(state); @@ -227,8 +232,7 @@ void NvSsao::Render(nvrhi::ICommandList* command_list, .addItem( nvrhi::BindingSetItem::ConstantBuffer(0, m_constantBuffer)) .addItem(nvrhi::BindingSetItem::Texture_SRV(0, ping)) - .addItem(nvrhi::BindingSetItem::Texture_SRV( - 1, m_workingEdges)) + .addItem(nvrhi::BindingSetItem::Texture_SRV(1, m_workingEdges)) .addItem(nvrhi::BindingSetItem::Texture_UAV( 0, last_pass ? m_outputAO.Get() : pong, nvrhi::Format::R32_UINT)) @@ -258,17 +262,20 @@ void NvSsao::Render(nvrhi::ICommandList* command_list, void NvSsao::OnGui(bool const open_now) { static bool open = false; open |= open_now; - if(open && ImGui::Begin("GTAO Settings", &open)) { + if (open && ImGui::Begin("GTAO Settings", &open)) { ImGui::InputInt("Quality level", &settings.QualityLevel); ImGui::InputInt("Denoise passes", &settings.DenoisePasses); ImGui::InputFloat("Radius", &settings.Radius); - if(ImGui::CollapsingHeader("Advanced")) { + if (ImGui::CollapsingHeader("Advanced")) { ImGui::InputFloat("Radius multiplier", &settings.RadiusMultiplier); ImGui::InputFloat("Falloff range", &settings.FalloffRange); - ImGui::InputFloat("Sample distribution power", &settings.SampleDistributionPower); - ImGui::InputFloat("Thin occluder compensation", &settings.ThinOccluderCompensation); + ImGui::InputFloat("Sample distribution power", + &settings.SampleDistributionPower); + ImGui::InputFloat("Thin occluder compensation", + &settings.ThinOccluderCompensation); ImGui::InputFloat("Final value power", &settings.FinalValuePower); - ImGui::InputFloat("Depth MIP sampling offset", &settings.DepthMIPSamplingOffset); + ImGui::InputFloat("Depth MIP sampling offset", + &settings.DepthMIPSamplingOffset); } ImGui::End(); } diff --git a/betterRenderer/renderer/source/ssao.h b/betterRenderer/renderer/source/ssao.h index e40460c9..62ee6dd1 100644 --- a/betterRenderer/renderer/source/ssao.h +++ b/betterRenderer/renderer/source/ssao.h @@ -26,7 +26,7 @@ struct NvSsao { nvrhi::ShaderHandle m_CSGTAOMedium; nvrhi::ShaderHandle m_CSGTAOHigh; nvrhi::ShaderHandle m_CSGTAOUltra; - nvrhi::ComputePipelineHandle m_PSOGTAO; + std::array m_PSOGTAO; nvrhi::BindingSetHandle m_BSGTAO; nvrhi::ShaderHandle m_CSDenoisePass;