Page MenuHomeWildfire Games

Optimise out of frustum rendering of textures overlays
Needs ReviewPublic

Authored by vladislavbelov on Apr 25 2019, 1:48 AM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

Currently all boundaries, overlays for rally points and so on are rendered even if they're not visible.

To out of frustum rendering enter Engine.GameView_SetLockCullCameraEnabled(true); and move a camera.

It looks like:

Test Plan
  1. Apply the patch and compile the game
  2. Check that all touched overlays are visible in usual frustum

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 7283
Build 11864: Vulcan BuildJenkins

Event Timeline

vladislavbelov created this revision.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/graphics/Overlay.cpp
|   1| /*·Copyright·(C)·2017·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2017"

source/simulation2/components/CCmpRangeOverlayRenderer.cpp
|   1| /*·Copyright·(C)·2018·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2018"

source/simulation2/components/CCmpSelectable.cpp
|   1| /*·Copyright·(C)·2018·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2018"

source/renderer/TexturedLineRData.h
|   1| /*·Copyright·(C)·2012·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2012"

source/renderer/TexturedLineRData.cpp
|   1| /*·Copyright·(C)·2017·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2017"

source/simulation2/components/CCmpTerritoryManager.cpp
|   1| /*·Copyright·(C)·2018·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2018"
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1274/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/differential/1275/display/redirect

Stan added a subscriber: Stan.Apr 25 2019, 7:57 AM

What's the perf gain like ?

source/graphics/Overlay.cpp
68

return !m_RenderData || m_RenderData->IsVisibleInFrustum(frustum) ?

In D1847#76051, @Stan wrote:

What's the perf gain like ?

The submit time shouldn't increase and the render time should decrease a bit. Probably it won't be really visible on powerful computers.

I think perf impact is negligible (it's definitely better, but probably not by much, and the main impact is likely a lower number of draw calls).
Probably a good idea to do it anyways though.

I notice UnitRenderer seems to call Frustrum methods directly rather than calling member of Unit, maybe that could be standardised?

I think perf impact is negligible (it's definitely better, but probably not by much, and the main impact is likely a lower number of draw calls).

Yeah, the same thoughts. It shouldn't increase and might decrease rendering time. So it's worth to not render invisible objects.

I notice UnitRenderer seems to call Frustrum methods directly rather than calling member of Unit, maybe that could be standardised?

Do you mean UnitOverlay?

Stan added a comment.Sat, May 18, 11:56 AM

Some more comments. The patch seems to work as announced. However, when pressing Tab, one can still still see lifebars, and possibly ranges if the building is close enough to the border. Maybe that should be fixed as well.

source/graphics/Overlay.cpp
68

Not done.

source/renderer/TexturedLineRData.cpp
307

Maybe that function should be called GetCBoundingBoxAligned().

source/renderer/TexturedLineRData.h
87

Not sure, but can't you forward declare some of them ?

source/simulation2/components/CCmpRangeOverlayRenderer.cpp
192

I think you need braces now according to the CC.

193

Could be

if (!rangeOverlay.second)
    continue;
source/simulation2/components/CCmpSelectable.cpp
524

Space between operators.

528

space between operators ++i maybe 4 could be extracted from somewhere.

source/simulation2/components/CCmpTerritoryManager.cpp
699

Range loop ?

I'm still seeing range overlays and status bars, I'm assuming that's because you haven't changed those? If so, commit this.

source/graphics/Overlay.cpp
68

I think it's worth keeping on two lines because the comment only refers to the first line, but your mileage might vary.