Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Improve BakedLightmap's lightprobes performance #80764

Merged
merged 1 commit into from Sep 20, 2023

Conversation

mrezai
Copy link
Contributor

@mrezai mrezai commented Aug 18, 2023

50-60% better performance for light probes in BakedLightmap by simplifying some computations.
Please test it using MRP from this comment: #71162 (comment)

These simplifications are possible because alpha array values are zero:

memset(alpha, 0, sizeof(float) * 2 * 8);

and I replace fmod(x,y) by x - int(x/y) * y because pos's values are positive here:
pos.x = CLAMP(p_pos.x, 0, clamp_v);

@Calinou
Copy link
Member

Calinou commented Aug 18, 2023

This may address #71162.

@Favkis Can you test this PR locally?

@mrezai mrezai force-pushed the improve-lightprobes-performance branch from f8308db to f6e2c37 Compare August 19, 2023 17:30
@mrezai
Copy link
Contributor Author

mrezai commented Sep 14, 2023

@akien-mga can someone review this to include in next beta?

Copy link
Member

@lawnjelly lawnjelly left a comment

Choose a reason for hiding this comment

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

I'm not super familiar with this code but it looks ok providing the suppositions are correct.

Note: I didn't test it, relying on author to test.

@akien-mga akien-mga merged commit 0640112 into godotengine:3.x Sep 20, 2023
13 checks passed
@akien-mga
Copy link
Member

Thanks!

@mrezai mrezai deleted the improve-lightprobes-performance branch September 21, 2023 03:42
@belzecue
Copy link

I'm seeing around 20% improvement in framerate using the MRP, but every frame saved is a win.

Tested today on my old potato Acer Chromebook with Intel graphics and MX Linux.

Before #80764:

--- 3.6.Beta3 ---

Movement OFF (~125 fps)
80764_3 6B3_off

Movement ON (~33 fps)
80764_3 6B3_on

--- 3.x built today ---

Movement OFF (~125 fps)
80764_3 x_off

Movement ON (~40 fps)
80764_3 x_on

@mrezai
Copy link
Contributor Author

mrezai commented Sep 26, 2023

@belzecue interesting, it seems difference is in CPU cache size. Can you test again by change "Cell Size" in Capture section of BakedLightmap from 0.5 to 1 and bake lightmap again? this reduce size of capture data from 9 to 2.2 MB.

@belzecue
Copy link

belzecue commented Sep 26, 2023

On v3.6.beta.custom_build [5271c97], with Cell Size bumped to 1.0 and rebaked, I'm seeing ~45 fps, so about 36% gain over baseline of 33 fps.

2023-09-26_15-22

@akien-mga akien-mga changed the title Improve BakedLightmap's lightprobes performance [3.x] Improve BakedLightmap's lightprobes performance Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants