16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 16:19:19 +02:00

make gtao quality variant actually selectable

This commit is contained in:
Wls50
2025-11-29 13:03:58 +01:00
committed by Hirek
parent 7316a35b00
commit 3f68c543bb
2 changed files with 24 additions and 17 deletions

View File

@@ -103,10 +103,11 @@ void NvSsao::Init() {
.setInitialState(ResourceStates::ShaderResource) .setInitialState(ResourceStates::ShaderResource)
.setKeepInitialState(true)); .setKeepInitialState(true));
SamplerHandle sampler_point = m_SamplerPoint = m_backend->GetDevice()->createSampler( SamplerHandle sampler_point = m_SamplerPoint =
nvrhi::SamplerDesc() m_backend->GetDevice()->createSampler(
.setAllAddressModes(SamplerAddressMode::Clamp) nvrhi::SamplerDesc()
.setAllFilters(false)); .setAllAddressModes(SamplerAddressMode::Clamp)
.setAllFilters(false));
{ {
BindingLayoutHandle blPrefilterDepths; BindingLayoutHandle blPrefilterDepths;
@@ -141,10 +142,14 @@ void NvSsao::Init() {
.addItem(BindingSetItem::Texture_UAV(2, m_debugImage)) .addItem(BindingSetItem::Texture_UAV(2, m_debugImage))
.addItem(BindingSetItem::Sampler(0, sampler_point)), .addItem(BindingSetItem::Sampler(0, sampler_point)),
blGTAO, m_BSGTAO); blGTAO, m_BSGTAO);
m_PSOGTAO = m_backend->GetDevice()->createComputePipeline( std::array<IShader*, 4> const shaders{m_CSGTAOLow, m_CSGTAOMedium,
ComputePipelineDesc() m_CSGTAOHigh, m_CSGTAOUltra};
.setComputeShader(m_CSGTAOHigh) for (int i = 0; i < 4; ++i) {
.addBindingLayout(blGTAO)); 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"); command_list->beginMarker("Main Pass");
nvrhi::ComputeState state; nvrhi::ComputeState state;
state.setPipeline(m_PSOGTAO); state.setPipeline(m_PSOGTAO[glm::clamp(settings.QualityLevel, 0, 3)]);
state.addBindingSet(m_BSGTAO); state.addBindingSet(m_BSGTAO);
command_list->setComputeState(state); command_list->setComputeState(state);
@@ -227,8 +232,7 @@ void NvSsao::Render(nvrhi::ICommandList* command_list,
.addItem( .addItem(
nvrhi::BindingSetItem::ConstantBuffer(0, m_constantBuffer)) nvrhi::BindingSetItem::ConstantBuffer(0, m_constantBuffer))
.addItem(nvrhi::BindingSetItem::Texture_SRV(0, ping)) .addItem(nvrhi::BindingSetItem::Texture_SRV(0, ping))
.addItem(nvrhi::BindingSetItem::Texture_SRV( .addItem(nvrhi::BindingSetItem::Texture_SRV(1, m_workingEdges))
1, m_workingEdges))
.addItem(nvrhi::BindingSetItem::Texture_UAV( .addItem(nvrhi::BindingSetItem::Texture_UAV(
0, last_pass ? m_outputAO.Get() : pong, 0, last_pass ? m_outputAO.Get() : pong,
nvrhi::Format::R32_UINT)) nvrhi::Format::R32_UINT))
@@ -258,17 +262,20 @@ void NvSsao::Render(nvrhi::ICommandList* command_list,
void NvSsao::OnGui(bool const open_now) { void NvSsao::OnGui(bool const open_now) {
static bool open = false; static bool open = false;
open |= open_now; 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("Quality level", &settings.QualityLevel);
ImGui::InputInt("Denoise passes", &settings.DenoisePasses); ImGui::InputInt("Denoise passes", &settings.DenoisePasses);
ImGui::InputFloat("Radius", &settings.Radius); ImGui::InputFloat("Radius", &settings.Radius);
if(ImGui::CollapsingHeader("Advanced")) { if (ImGui::CollapsingHeader("Advanced")) {
ImGui::InputFloat("Radius multiplier", &settings.RadiusMultiplier); ImGui::InputFloat("Radius multiplier", &settings.RadiusMultiplier);
ImGui::InputFloat("Falloff range", &settings.FalloffRange); ImGui::InputFloat("Falloff range", &settings.FalloffRange);
ImGui::InputFloat("Sample distribution power", &settings.SampleDistributionPower); ImGui::InputFloat("Sample distribution power",
ImGui::InputFloat("Thin occluder compensation", &settings.ThinOccluderCompensation); &settings.SampleDistributionPower);
ImGui::InputFloat("Thin occluder compensation",
&settings.ThinOccluderCompensation);
ImGui::InputFloat("Final value power", &settings.FinalValuePower); 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(); ImGui::End();
} }

View File

@@ -26,7 +26,7 @@ struct NvSsao {
nvrhi::ShaderHandle m_CSGTAOMedium; nvrhi::ShaderHandle m_CSGTAOMedium;
nvrhi::ShaderHandle m_CSGTAOHigh; nvrhi::ShaderHandle m_CSGTAOHigh;
nvrhi::ShaderHandle m_CSGTAOUltra; nvrhi::ShaderHandle m_CSGTAOUltra;
nvrhi::ComputePipelineHandle m_PSOGTAO; std::array<nvrhi::ComputePipelineHandle, 4> m_PSOGTAO;
nvrhi::BindingSetHandle m_BSGTAO; nvrhi::BindingSetHandle m_BSGTAO;
nvrhi::ShaderHandle m_CSDenoisePass; nvrhi::ShaderHandle m_CSDenoisePass;