Skip to content

Commit

Permalink
Add the refl probes fallback path
Browse files Browse the repository at this point in the history
  • Loading branch information
godlikepanos committed Nov 17, 2024
1 parent f111dca commit 14cca43
Show file tree
Hide file tree
Showing 17 changed files with 421 additions and 561 deletions.
7 changes: 4 additions & 3 deletions AnKi/Renderer/IndirectDiffuseProbes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ void IndirectDiffuseProbes::populateRenderGraph(RenderingContext& rctx)
pass.newTextureDependency(shadowsRt, TextureUsageBit::kSrvPixel);
}

if(getRenderer().getSky().isEnabled())
if(getRenderer().getGeneratedSky().isEnabled())
{
pass.newTextureDependency(getRenderer().getSky().getSkyLutRt(), TextureUsageBit::kSrvPixel);
pass.newTextureDependency(getRenderer().getGeneratedSky().getSkyLutRt(), TextureUsageBit::kSrvPixel);
}

pass.setWork([this, visibleLightsBuffer = lightVis.m_visiblesBuffer, viewProjMat = frustum.getViewProjectionMatrix(), cellCenter,
Expand Down Expand Up @@ -415,7 +415,8 @@ void IndirectDiffuseProbes::populateRenderGraph(RenderingContext& rctx)
dsInfo.m_gbufferRenderTargetSubresource[2].m_face = faceIdx;
dsInfo.m_gbufferDepthRenderTarget = gbufferDepthRt;
dsInfo.m_directionalLightShadowmapRenderTarget = shadowsRt;
dsInfo.m_skyLutRenderTarget = (getRenderer().getSky().isEnabled()) ? getRenderer().getSky().getSkyLutRt() : RenderTargetHandle();
dsInfo.m_skyLutRenderTarget =
(getRenderer().getGeneratedSky().isEnabled()) ? getRenderer().getGeneratedSky().getSkyLutRt() : RenderTargetHandle();
dsInfo.m_globalRendererConsts = rctx.m_globalRenderingConstantsBuffer;
dsInfo.m_renderpassContext = &rgraphCtx;

Expand Down
30 changes: 5 additions & 25 deletions AnKi/Renderer/LightShading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <AnKi/Renderer/VrsSriGeneration.h>
#include <AnKi/Renderer/ClusterBinning.h>
#include <AnKi/Renderer/Ssao.h>
#include <AnKi/Renderer/Ssr.h>
#include <AnKi/Renderer/RtReflections.h>
#include <AnKi/Util/CVarSet.h>
#include <AnKi/Util/Tracer.h>
Expand Down Expand Up @@ -95,16 +94,7 @@ void LightShading::run(const RenderingContext& ctx, RenderPassWorkContext& rgrap
rgraphCtx.bindSrv(8, 0, getRenderer().getGBuffer().getDepthRt());
rgraphCtx.bindSrv(9, 0, getRenderer().getShadowmapsResolve().getRt());
rgraphCtx.bindSrv(10, 0, getRenderer().getSsao().getRt());

const Bool rtReflections = g_rtReflectionsCVar && GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled;
if(rtReflections)
{
rgraphCtx.bindSrv(11, 0, getRenderer().getRtReflections().getRt());
}
else
{
rgraphCtx.bindSrv(11, 0, getRenderer().getSsr().getRt());
}
rgraphCtx.bindSrv(11, 0, getRenderer().getRtReflections().getRt());
cmdb.bindSrv(12, 0, TextureView(&getRenderer().getProbeReflections().getIntegrationLut(), TextureSubresourceDesc::all()));

// Draw
Expand Down Expand Up @@ -162,7 +152,7 @@ void LightShading::run(const RenderingContext& ctx, RenderPassWorkContext& rgrap
cmdb.bindShaderProgram(m_skybox.m_grProgs[2].get());

cmdb.bindSampler(0, 0, getRenderer().getSamplers().m_trilinearClamp.get());
rgraphCtx.bindSrv(0, 0, getRenderer().getSky().getSkyLutRt());
rgraphCtx.bindSrv(0, 0, getRenderer().getGeneratedSky().getSkyLutRt());
cmdb.bindConstantBuffer(0, 0, ctx.m_globalRenderingConstantsBuffer);
}

Expand Down Expand Up @@ -264,8 +254,6 @@ void LightShading::populateRenderGraph(RenderingContext& ctx)
}

// Light shading
const Bool rtReflections = g_rtReflectionsCVar && GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled;

pass.newTextureDependency(m_runCtx.m_rt, TextureUsageBit::kRtvDsvWrite);
pass.newTextureDependency(getRenderer().getGBuffer().getColorRt(0), readUsage);
pass.newTextureDependency(getRenderer().getGBuffer().getColorRt(1), readUsage);
Expand All @@ -276,15 +264,7 @@ void LightShading::populateRenderGraph(RenderingContext& ctx)
pass.newBufferDependency(getRenderer().getClusterBinning().getPackedObjectsBufferHandle(GpuSceneNonRenderableObjectType::kLight),
BufferUsageBit::kSrvPixel);
pass.newTextureDependency(getRenderer().getSsao().getRt(), readUsage);

if(rtReflections)
{
pass.newTextureDependency(getRenderer().getRtReflections().getRt(), readUsage);
}
else
{
pass.newTextureDependency(getRenderer().getSsr().getRt(), readUsage);
}
pass.newTextureDependency(getRenderer().getRtReflections().getRt(), readUsage);

if(getRenderer().getProbeReflections().getHasCurrentlyRefreshedReflectionRt())
{
Expand All @@ -295,9 +275,9 @@ void LightShading::populateRenderGraph(RenderingContext& ctx)
pass.newTextureDependency(getRenderer().getVolumetricFog().getRt(), readUsage);

// Sky
if(getRenderer().getSky().isEnabled())
if(getRenderer().getGeneratedSky().isEnabled())
{
pass.newTextureDependency(getRenderer().getSky().getSkyLutRt(), readUsage);
pass.newTextureDependency(getRenderer().getGeneratedSky().getSkyLutRt(), readUsage);
}

// For forward shading
Expand Down
7 changes: 4 additions & 3 deletions AnKi/Renderer/ProbeReflections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ void ProbeReflections::populateRenderGraph(RenderingContext& rctx)
pass.newTextureDependency(shadowMapRt, TextureUsageBit::kSrvPixel);
}

if(getRenderer().getSky().isEnabled())
if(getRenderer().getGeneratedSky().isEnabled())
{
pass.newTextureDependency(getRenderer().getSky().getSkyLutRt(), TextureUsageBit::kSrvPixel);
pass.newTextureDependency(getRenderer().getGeneratedSky().getSkyLutRt(), TextureUsageBit::kSrvPixel);
}

pass.setWork([this, visResult = lightVis.m_visiblesBuffer, viewProjMat = frustum.getViewProjectionMatrix(),
Expand Down Expand Up @@ -396,7 +396,8 @@ void ProbeReflections::populateRenderGraph(RenderingContext& rctx)
{
dsInfo.m_directionalLightShadowmapRenderTarget = shadowMapRt;
}
dsInfo.m_skyLutRenderTarget = (getRenderer().getSky().isEnabled()) ? getRenderer().getSky().getSkyLutRt() : RenderTargetHandle();
dsInfo.m_skyLutRenderTarget =
(getRenderer().getGeneratedSky().isEnabled()) ? getRenderer().getGeneratedSky().getSkyLutRt() : RenderTargetHandle();
dsInfo.m_globalRendererConsts = rctx.m_globalRenderingConstantsBuffer;
dsInfo.m_renderpassContext = &rgraphCtx;

Expand Down
30 changes: 23 additions & 7 deletions AnKi/Renderer/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <AnKi/Core/GpuMemory/GpuSceneBuffer.h>
#include <AnKi/Scene/Components/CameraComponent.h>
#include <AnKi/Scene/Components/LightComponent.h>
#include <AnKi/Scene/Components/SkyboxComponent.h>
#include <AnKi/Core/StatsSet.h>
#include <AnKi/Core/App.h>

Expand Down Expand Up @@ -43,7 +44,6 @@
#include <AnKi/Renderer/PrimaryNonRenderableVisibility.h>
#include <AnKi/Renderer/ClusterBinning.h>
#include <AnKi/Renderer/Ssao.h>
#include <AnKi/Renderer/Ssr.h>
#include <AnKi/Renderer/Sky.h>
#include <AnKi/Renderer/MotionBlur.h>
#include <AnKi/Renderer/RtMaterialFetchDbg.h>
Expand Down Expand Up @@ -279,14 +279,13 @@ Error Renderer::populateRenderGraph(RenderingContext& ctx)
m_gbuffer->populateRenderGraph(ctx);
m_shadowMapping->populateRenderGraph(ctx);
m_clusterBinning2->populateRenderGraph(ctx);
m_sky->populateRenderGraph(ctx);
m_generatedSky->populateRenderGraph(ctx);
m_indirectDiffuseProbes->populateRenderGraph(ctx);
m_probeReflections->populateRenderGraph(ctx);
m_volumetricLightingAccumulation->populateRenderGraph(ctx);
m_motionVectors->populateRenderGraph(ctx);
m_gbufferPost->populateRenderGraph(ctx);
m_depthDownscale->populateRenderGraph(ctx);
m_ssr->populateRenderGraph(ctx);
if(m_rtShadows)
{
m_rtShadows->populateRenderGraph(ctx);
Expand All @@ -295,10 +294,8 @@ Error Renderer::populateRenderGraph(RenderingContext& ctx)
{
m_rtMaterialFetchDbg->populateRenderGraph(ctx);
}
if(m_rtReflections)
{
m_rtReflections->populateRenderGraph(ctx);
}

m_rtReflections->populateRenderGraph(ctx);
m_shadowmapsResolve->populateRenderGraph(ctx);
m_volumetricFog->populateRenderGraph(ctx);
m_lensFlare->populateRenderGraph(ctx);
Expand Down Expand Up @@ -379,6 +376,25 @@ void Renderer::writeGlobalRendererConstants(RenderingContext& ctx, GlobalRendere
{
consts.m_directionalLight.m_shadowCascadeCount_31bit_active_1bit = 0;
}

// Sky
const SkyboxComponent* sky = SceneGraph::getSingleton().getSkybox();

const Bool isSolidColor =
(!sky || sky->getSkyboxType() == SkyboxType::kSolidColor || (!dirLight && sky->getSkyboxType() == SkyboxType::kGenerated));
if(isSolidColor)
{
consts.m_sky.m_solidColor = (sky) ? sky->getSolidColor() : Vec3(0.0);
consts.m_sky.m_type = 0;
}
else if(sky->getSkyboxType() == SkyboxType::kImage2D)
{
consts.m_sky.m_type = 1;
}
else
{
consts.m_sky.m_type = 2;
}
}

TextureInitInfo Renderer::create2DRenderTargetInitInfo(U32 w, U32 h, Format format, TextureUsageBit usage, CString name)
Expand Down
5 changes: 2 additions & 3 deletions AnKi/Renderer/RendererObject.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ ANKI_RENDERER_OBJECT_DEF(VrsSriGeneration, vrsSriGeneration, 1)
ANKI_RENDERER_OBJECT_DEF(PrimaryNonRenderableVisibility, primaryNonRenderableVisibility, 1)
ANKI_RENDERER_OBJECT_DEF(ClusterBinning, clusterBinning2, 1)
ANKI_RENDERER_OBJECT_DEF(Ssao, ssao, 1)
ANKI_RENDERER_OBJECT_DEF(Ssr, ssr, 1)
ANKI_RENDERER_OBJECT_DEF(Sky, sky, 1)
ANKI_RENDERER_OBJECT_DEF(GeneratedSky, generatedSky, 1)
ANKI_RENDERER_OBJECT_DEF(MotionBlur, motionBlur, 1)
ANKI_RENDERER_OBJECT_DEF(RtMaterialFetchDbg, rtMaterialFetchDbg,
GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled&& g_rtMaterialFetchDbgCVar)
ANKI_RENDERER_OBJECT_DEF(RtReflections, rtReflections, GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled&& g_rtReflectionsCVar)
ANKI_RENDERER_OBJECT_DEF(RtReflections, rtReflections, 1)

// Util objects
ANKI_RENDERER_OBJECT_DEF(RenderableDrawer, drawer, 1)
Expand Down
Loading

0 comments on commit 14cca43

Please sign in to comment.