View Issue Details

IDProjectCategoryView StatusLast Update
0005459The Dark ModCodingpublic25.12.2020 16:31
Reporterstgatilov Assigned To 
PrioritynormalSeveritynormalReproducibilityN/A
Status newResolutionopen 
Product VersionTDM 2.09 
Target VersionTDM 2.10 
Summary0005459: Optimize idRenderWorldLocal::CreateLightDefInteractions for ambient_world light
DescriptionThe function idRenderWorldLocal::CreateLightDefInteractions searches for interactions of light like this:
    foreach area having light:
      foreach entity in area:
        if light is noshadows and entity not visible:
          continue
        ... # complicated code here

Ambient world light is noshadows and covers the whole map.
So all entities in the map are traversed every frame, just to see that they are not in the view and should be discarded.

I tried to profile game on Painter's Wife FM.
6.7% of time is spent on this function, most of which wasted on entity visibility check.
If I add this hack:
    volatile bool skipAmbientWorld = true;
    void idRenderWorldLocal::CreateLightDefInteractions( idRenderLightLocal *ldef ) {
      if (skipAmbientWorld && idStr::Icmp(gameLocal.entities[ldef->parms.entityNum]->spawnArgs.GetString("classname"), "atdm:ambient_world") == 0) {
        skipAmbientWorld = !!skipAmbientWorld;
        return;
      }
Then only 1.4% is spent in this function. And all of it does into complicated logic of searching/adding interactions in the interaction table.

The idea of optimization is to extract light/entity processing into a separate function, then write second traversal.
The first traversal goes over all lights, then goes over their areas and entities.
The second traversal should go over visible entities, then go over lights in their areas.
The second approach should handle only specific class of lights, which are noshadows and large enough --- all the other lights should be handled with the first approach.
Additional InformationOriginally reported here, noticed during 100K entities experiment:
  https://forums.thedarkmod.com/index.php?/topic/16837-when-youre-getting-close-to-the-entity-limit-inlining/&do=findComment&comment=454663
TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
25.12.2020 16:31 stgatilov New Issue