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

Optimize tracing by removing redundant BSP brush planes at load time? #1615

Open
slipher opened this issue Mar 22, 2025 · 1 comment
Open
Labels
T-Improvement Improvement for an existing feature T-Performance

Comments

@slipher
Copy link
Member

slipher commented Mar 22, 2025

I've noticed that BSP brushes always have the full set of 6 possible axis-aligned bounding planes, even if some of those planes don't form part of the resulting convex hull. This was apparently done so that simplified in/out tests for the plane can be performed by just comparing a single coordinate, rather than doing the whole dot product. Then dot products could be skipped if one of the axis-aligned ones allowed a collision to be ruled out. Presumably this was faster on machines of the day which had slow floating-point ops. But we found in #1142 that in the BoxOnPlaneSide function, it's faster to just always use SSE vectorized code, even for axis-aligned planes. (Although I'm not sure about something... did we ever test with the old code for axial planes but SSE for non-axial?) Anyway, for tracing, SSE vector instructions are not so relevant since compiler toolchain technology to build with vector instructions in the VM is lacking. But we have decently fast float instructions regardless. So we should try pruning planes that don't bound the convex hull at load time to see if that makes it faster.

So far I've only spoken of tracing, but it's possible this stuff could apply to the renderer too (for frustum culling etc.) since it has its own BSP loading code. The BoxOnPlaneSide function from #1142 is used in the renderer.

@slipher slipher added T-Improvement Improvement for an existing feature T-Performance labels Mar 22, 2025
@VReaperV
Copy link
Contributor

So far I've only spoken of tracing, but it's possible this stuff could apply to the renderer too (for frustum culling etc.) since it has its own BSP loading code. The BoxOnPlaneSide function from #1142 is used in the renderer.

Renderer uses it to cull against frustum planes, not surface planes. The mins/maxs of the box come from the surface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Improvement Improvement for an existing feature T-Performance
Projects
None yet
Development

No branches or pull requests

2 participants