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

[TS] Fix waterlogged glass panes and other TS-related follow-up work #2352

Merged
merged 17 commits into from
May 20, 2024

Conversation

douira
Copy link
Collaborator

@douira douira commented Feb 21, 2024

Cherry-picked edition of #2350

Fixes the sorting of waterlogged glass panes by changing the intersection detection that's run when it can't partition things. It now produces a list of "primary intersectors", quads that intersect with a large fraction of the quads in the current partition, and then puts those in a fixed-order partition tree node that always renders them after the other quads. This means that quads that intersect with lots of things will get rendered after everything else within that set of unpartitionable quads. It doesn't get into infinite recursion by not doing this if there's no non-primary intersector.

Before and after:
Screenshot 2024-02-20 at 01 09 09
Screenshot 2024-02-20 at 01 10 46

…ing distance sorting through

the detection of primary intersectors when geometry is intersecting and then sorting them in a fixed order
@jellysquid3 jellysquid3 added this to the Sodium 0.6 milestone Feb 22, 2024
…iately instead of keeping them to avoid memory usage

buffer caching would be a better solution but that's complicated and doesn't currently work correctly
@douira
Copy link
Collaborator Author

douira commented Mar 2, 2024

I've amended this by refactoring I did to buffer and sort result handling. This more cleanly separates the buffers and the translucent sorting data that generates those buffers. It might also solve previously undiscovered concurrency issues. It now always frees buffers when they've been uploaded without keeping them around for the next time. This previously caused high memory usage. Instead, the OS will now have to deal with re-supplying us with buffers efficiently.

A custom buffer caching and eviction system might be better at this because we can keep buffers around for a certain time before freeing them. (It's not guaranteed that it's actually better at this than the OS is) I have code for this at https://github.com/douira/sodium-fabric/tree/gfni-cache-eviction but it sometimes leaks buffers or crashes since there's unresolved bugs and unimplemented features that are necessary to maintain the caching structure.

@douira douira changed the title [TS] Fix waterlogged glass panes [TS] Fix waterlogged glass panes and other TS-related follow-up work Mar 4, 2024
@MeeniMc
Copy link
Contributor

MeeniMc commented Mar 12, 2024

just tried it (no other mods) and it works as intended

@douira
Copy link
Collaborator Author

douira commented Apr 1, 2024

I didn't anticipate needing to add another commit to this but we found a bug last week so it got added.

douira added 2 commits April 21, 2024 17:32
also removed the warning message about unpartitionable geometry as it seems to not be a relevant problem
@IMS212 IMS212 self-assigned this Apr 22, 2024
douira added 4 commits April 27, 2024 19:45
… not recalculated when the normal is quantized.

also fixed aligned quads not receiving the more accurate center based on the average of the unique vertexes.
@jellysquid3
Copy link
Member

Code looks fine to me, and no regressions were observed in testing.

@jellysquid3 jellysquid3 merged commit fa97f06 into CaffeineMC:dev May 20, 2024
1 check failed
IMS212 pushed a commit to IMS212/sodium-fabric that referenced this pull request Aug 6, 2024
…llow-up work (CaffeineMC#2352)

* rename some things for clarity

* fix waterlogged glass panes (once again, but more this time) by avoiding distance sorting through
the detection of primary intersectors when geometry is intersecting and then sorting them in a fixed order

* use Mth.clamp for clarity

* refactor buffer and sort result handling, buffers are now freed immediately instead of keeping them to avoid memory usage
buffer caching would be a better solution but that's complicated and doesn't currently work correctly

* reduce number of unique triggers by around 5 percent without impacting sorting or building performance

* importantly sort a little farther away, sort tasks are fast

* use defer zero frames for important sort tasks by default

* fix build

* clarify authorship of BitArray

* fix bug with radix sort for SNR heuristic in BSP partition generating wrong indexes

* skip heuristic if there's no quads

* refactor primary intersector detection to handle large cases better,
also removed the warning message about unpartitionable geometry as it seems to not be a relevant problem

* fix topo sorting in some situations where the dot product was wrongly not recalculated when the normal is quantized.
also fixed aligned quads not receiving the more accurate center based on the average of the unique vertexes.

* tune primary intersector detection to handle situations where only a small amount of geometry is intersecting
@douira douira deleted the ts-waterlogged-glass-panes branch September 14, 2024 19:30
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.

4 participants