Skip to content

Better handling for excess proximity lights#10241

Merged
RogPodge merged 2 commits into
microsoft:prerelease/2.8.0from
jonathoncobb:proximity-light-queue
May 16, 2022
Merged

Better handling for excess proximity lights#10241
RogPodge merged 2 commits into
microsoft:prerelease/2.8.0from
jonathoncobb:proximity-light-queue

Conversation

@jonathoncobb

@jonathoncobb jonathoncobb commented Sep 29, 2021

Copy link
Copy Markdown
Member

Overview

Previously, if the shader's maximum proximity light limit was reached, a warning would be logged. I've changed this to keep all lights around on the CPU side and only send the first two valid ones to the shader. This helps with race conditions where multiple lights are added and removed in a single frame and eliminates a warning that was spamming to the log and degrading performance.

Comment thread Assets/MRTK/Core/Utilities/StandardShader/ProximityLight.cs Outdated

@RogPodge RogPodge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really seeing where in the original code that that additional light data was discarded, as the capacity parameter of a list does not actually prevent more items for being added to the list

https://www.geeksforgeeks.org/c-sharp-capacity-of-a-list/

Removing the debug statement or making it only fire once does seem useful. Maybe we can instead case on

if (activeProximityLights.Count == proximityLightCount)

instead of

if (activeProximityLights.Count >= proximityLightCount)

so the warning is only filed once we pass the threshold, instead of continously? Otherwise I'm not sure I see the performance improvements.


private static void AddProximityLight(ProximityLight light)
{
if (activeProximityLights.Count >= proximityLightCount)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any concerns with having the activeProximityLights list grow unboundedly? I guess we're currently allowing it to grow unboundedly, while only throwing a warning, but just want to double check

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendly ping on this @jonathoncobb

@jonathoncobb jonathoncobb Feb 16, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for letting this sit. I see the concern with this getting out of hand, though at a higher level, it's still bounded by the maximum number of pointers and thus light sources that will ever exist.

@polar-kev

Copy link
Copy Markdown
Contributor

Hey @Cameron-Micka, you've been working on proximity light improvements. Is this something you've considered?

@Cameron-Micka

Copy link
Copy Markdown
Member

Hey @Cameron-Micka, you've been working on proximity light improvements. Is this something you've considered?

I've not considered this but I like @jonathoncobb's idea! Makes sense to maintain the stack of lights so that the system can consider new lights in the order they were added when one of the first two slots frees up.

Previously, if the shader's maximum proximity light limit was reached, a warning would be logged and the lights discarded. I've changed this to keep all lights around on the CPU side and only send the first two valid ones to the shader. This helps with race conditions where multiple lights are added and removed in a single frame and eliminates a warning that was spamming to the log and degrading performance.
@jonathoncobb

Copy link
Copy Markdown
Member Author

Hey @RogPodge. Sorry, I misspoke in the PR description when I said the lights were discarded. The main problem we were trying to solve was a spike that we were seeing when hands were raised and lowered and this warning was logged several times.

If you're concerned about removing the logging entirely, perhaps it would be better if it were only in the editor since it's not particularly obvious when this warning is triggered on the device?

@david-c-kline

Copy link
Copy Markdown

@Cameron-Micka, can you ensure this gets ported to the v3 shaders?

@david-c-kline

Copy link
Copy Markdown

@RogPodge, can you also follow up with @jonathoncobb

@Cameron-Micka

Copy link
Copy Markdown
Member

@Cameron-Micka, can you ensure this gets ported to the v3 shaders?

Of course!

@RogPodge

Copy link
Copy Markdown
Contributor

Reminder to self, we should be able to get this in for 2.8 :)

@jonathoncobb jonathoncobb requested a review from julenka as a code owner May 13, 2022 20:24
@RogPodge RogPodge changed the base branch from main to prerelease/2.8.0 May 16, 2022 05:14
@RogPodge

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants