only update the RTAS when required

This commit is contained in:
myT 2024-02-18 22:20:57 +01:00
parent 838c9a6485
commit 62f3a17e55
4 changed files with 12 additions and 4 deletions

View file

@ -128,3 +128,8 @@ void DynamicLights::Draw()
CmdDraw(3, 0);
}
}
bool DynamicLights::WantRTASUpdate(const trRefdef_t& scene)
{
return scene.num_dlights > 0;
}

View file

@ -323,6 +323,7 @@ struct DynamicLights
{
void Init();
void Draw();
bool WantRTASUpdate(const trRefdef_t& scene);
private:
HPipeline pipeline;
@ -333,7 +334,7 @@ struct Raytracing
{
void Init();
void ProcessWorld(world_t& world);
void BeginFrame();
void BeginFrame(bool wantUpdate);
HBuffer GetTLAS() { return tlasBuffer; }
HBuffer GetInstanceBuffer() { return tlasInstanceBuffer; }

View file

@ -560,7 +560,8 @@ void CRP::BeginFrame()
imgui.BeginFrame();
// must be run outside of the RHI::BeginFrame/RHI::EndFrame pair
raytracing.BeginFrame();
const bool rtasUpdate = dynamicLights.WantRTASUpdate(tr.rtRefdef);
raytracing.BeginFrame(rtasUpdate);
RHI::BeginFrame();
ui.BeginFrame();

View file

@ -246,14 +246,15 @@ void Raytracing::ProcessWorld(world_t& world)
}
}
void Raytracing::BeginFrame()
void Raytracing::BeginFrame(bool wantUpdate)
{
if(tr.world == NULL || tr.sceneCounterRT == 0)
{
return;
}
if(crp_updateRTAS->integer == 0 && !IsNullHandle(tlasBuffer))
if((crp_updateRTAS->integer == 0 || !wantUpdate) &&
!IsNullHandle(tlasBuffer))
{
return;
}