Skip to content

Optimize case 15 of marching squares - #8054

Merged
StephenCWills merged 1 commit into
diasurgical:masterfrom
StephenCWills:optimize-per-pixel-light
Jul 3, 2025
Merged

Optimize case 15 of marching squares#8054
StephenCWills merged 1 commit into
diasurgical:masterfrom
StephenCWills:optimize-per-pixel-light

Conversation

@StephenCWills

Copy link
Copy Markdown
Member

This PR optimizes the code for rendering a fully lit tile when using per-pixel lighting. Since we know that every pixel in the tile should be rendered, we can quickly draw the whole diamond using raw computations to determine how many pixels in each row should be drawn.

I'm targeting this case because the benchmark for light_render.cpp indicates that the vast majority of time is spent on case 15 of the marching squares algorithm. It makes sense because that case is used to fill the tiles in the center of every contour line so we should expect to encounter that case pretty often if there are any contour lines at all.

AJenbo
AJenbo previously approved these changes Jul 2, 2025
@StephenCWills
StephenCWills force-pushed the optimize-per-pixel-light branch from c599267 to 51c0965 Compare July 3, 2025 01:26
@StephenCWills
StephenCWills enabled auto-merge (rebase) July 3, 2025 01:56
@StephenCWills
StephenCWills merged commit aedd98e into diasurgical:master Jul 3, 2025
24 checks passed
@StephenCWills
StephenCWills deleted the optimize-per-pixel-light branch July 3, 2025 02:18
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.

3 participants