only lightmap updated tiles once they're visible

This commit is contained in:
Ricardo Luís Vaz Silva 2024-12-21 19:01:53 -03:00 committed by Magnus Norddahl
commit aa51ac7b6d
6 changed files with 26 additions and 7 deletions

View file

@ -140,6 +140,12 @@ LevelMeshTileStats LevelMesh::GatherTilePixelStats()
stats.tiles.dirty++;
stats.pixels.dirty += area;
}
if (tile.AlwaysUpdate)
{
stats.tiles.dirtyDynamic++;
stats.pixels.dirtyDynamic += area;
}
}
stats.tiles.total += Lightmap.Tiles.Size();
return stats;

View file

@ -250,7 +250,7 @@ struct LevelMeshTileStats
{
struct Stats
{
uint32_t total = 0, dirty = 0;
uint32_t total = 0, dirty = 0, dirtyDynamic = 0;
};
Stats tiles, pixels;

View file

@ -78,7 +78,11 @@ static void MarkTilesForUpdate(FLevelLocals * Level, const TArrayView<int> &tile
{
if(i >= 0)
{
Level->levelMesh->Lightmap.Tiles[i].NeedsUpdate = true;
auto &tile = Level->levelMesh->Lightmap.Tiles[i];
if(tile.AlwaysUpdate == 0 && !tile.NeedsUpdate)
{
tile.AlwaysUpdate = 3;
}
}
}
}

View file

@ -75,15 +75,15 @@ ADD_STAT(lightmap)
int indexBufferUsed = levelMesh->FreeLists.Index.GetUsedSize();
out.Format(
"Surfaces: %u (awaiting updates: %u)\n"
"Surface pixel area to update: %u\n"
"Surfaces: %u (awaiting updates: %u static, %u dynamic)\n"
"Surface pixel area to update: %u static, %u dynamic\n"
"Surface pixel area: %u\nAtlas pixel area: %u\n"
"Atlas efficiency: %.4f%%\n"
"Dynamic BLAS time: %2.3f ms\n"
"Level mesh process time: %2.3f ms\n"
"Level mesh index buffer: %d K used (%d%%)",
stats.tiles.total, stats.tiles.dirty,
stats.pixels.dirty,
stats.tiles.total, stats.tiles.dirty, stats.tiles.dirtyDynamic,
stats.pixels.dirty, stats.pixels.dirtyDynamic,
stats.pixels.total,
atlasPixelCount,
float(stats.pixels.total) / float(atlasPixelCount) * 100.0f,

View file

@ -139,6 +139,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
Coronas.Clear();
Fogballs.Clear();
VisibleTiles.Clear();
visibleDyn = 0;
vpIndex = 0;
// Fullbright information needs to be propagated from the main view.

View file

@ -158,6 +158,7 @@ struct HWDrawInfo
TArray<AActor*> Coronas;
TArray<Fogball> Fogballs;
TArray<LightmapTile*> VisibleTiles;
unsigned visibleDyn;
uint64_t LastFrameTime = 0;
TArray<MissingTextureInfo> MissingUpperTextures;
@ -243,8 +244,15 @@ public:
if (lm_always_update || tile->AlwaysUpdate == 2 || (tile->AlwaysUpdate == 1 && lm_dynamic))
{
tile->NeedsUpdate = true;
visibleDyn++;
}
else if (VisibleTiles.Size() >= unsigned(lm_max_updates))
else if(tile->AlwaysUpdate == 3 && lm_dynamic)
{
tile->AlwaysUpdate = 0;
tile->NeedsUpdate = true;
visibleDyn++;
}
else if ((VisibleTiles.Size() - visibleDyn) >= unsigned(lm_max_updates))
{
return;
}