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

Abstract away from just about everything #136

Draft
wants to merge 631 commits into
base: master
Choose a base branch
from

Conversation

DaMatrix
Copy link
Member

@DaMatrix DaMatrix commented Dec 23, 2021

This is a huge PR (which, in retrospect, probably should have been broken up into multiple smaller PRs). In combination with #117, it makes the vast majority of the codebase be able to operate entirely independently of the Minecraft version being used.

Additional major changes include:

  • The tile size for heightmap and voxel modes are now separate. The replacements for T_SHIFT and related constants are now to HeightmapConstants/VoxelConstants
  • The makefile-based system for compiling native code has been replaced with a Gradle plugin. This should make future changes substantially easier.
  • GUI code is completely rewritten.
  • All of the static event handler classes have been replaced with a universal FEventBus, which uses a familiar annotation-based event subscription system. It supports a few additional features not commonly found in other event buses, such as the ability to weakly reference a registered handler object, and generic parameter matching.
  • The @DebugOnly annotation is now gone. Debug statistics and related features are now available outside of debug mode.
  • Logging is now routed through a PorkLib Logger, as are messages which appear in the client-side chat menu.

With the exception of the :gl module and children (which are handled by #117), nearly everything is affected in some way.

Known shortcomings:

  • GPU frustum culling will currently crash on heightmap mode.

@DaMatrix DaMatrix self-assigned this Dec 23, 2021
@DaMatrix DaMatrix force-pushed the dev/abstract-everything branch from bf1527f to 22cc032 Compare February 16, 2022 20:26
@nickcat325
Copy link

I've tested this and it works well. You should mark this for review.

@DaMatrix
Copy link
Member Author

DaMatrix commented Nov 16, 2022

there is still some work required before i can merge this: most importantly, i need to make heightmap mode actually work with the abstracted API, which i'm currently doing on dev/abstract-heightmap-gen.

once that's done, i also still want to do a last round of refactoring in order to minimize the amount of duplicated code between versions, and move more stuff to the :api module to make it more useful.

this will avoid any future library conflicts
this avoids polluting the gradle classpath with a bunch of plugins which aren't required by all subprojects
…tters

this is just cleaner and ensures that there will be compilation errors if i add fields to an existing packet
this simplifies the ServerContext code a bit and separates the tiles queued for unloading from the packets queued for sending.
…tasks to the client thread

this ensures that the client thread executor isn't locked while executing a task which was scheduled to be executed on the client thread from the client thread (which happens during client context shutdown)
this is exceedingly stupid and barely works at all - it basically just has a hardcoded limit on the maximum data sent per tick and doesn't even change it. for all practical purposes we're limited to sending just a single tile per tick right now! more will come soon though :)
… the client

the client now informs us of the time since the last tile data packet was received when it sends ACKs, which allows us to infer the effective bandwidth and adjust our sending speed so that we don't hog the entire network while sending tile data.

also rearranged packets a bit so that we use a static create() method instead of a constructor, in order to disambiguate from the no-args constructor which is only used internally.

also added a sessionId field which can be used to determine if a tile Ack packet belongs to a previously closed session and ignore it
…if tile sending is backlogged by flow control
this saves us the effort of having to reference-count them, which has a non-trivial impact on code complexity and honestly doesn't add much value
the previous patch to limit the number of loaded tiles based on the context's send queue size worked, but the loop condition wasn't affected so the tracker thread could end up in a livelock scenario where it was spinning forever adding nothing to the waiting positions queue
this will force any dependency on a non-generated class to be explicitly registered, ensuring that the classes can be found regardless of what the actual classloader heirarchy is.
…ributes

also begin implementing struct layout assignment for the "shared" GLSL block format
Drivers may be faster with immutable buffers than mutable ones, this allows us to easily make use of that where possible while still being able to fall back transparently.
this can reduce GPU load by 10% or more with a high cutoff distance by reducing the amount of empty draw commands which need to be skipped over
this completely eliminates DebugStats
this is convenient for testing since it makes the database faster and avoids thrashing my SSD
also add some unsafe optimizations using unsafe
…d limit is exceeded

In practice, this can be forced to occur reliably, at least on KDE+NVIDIA with unlimited framerate+VSync: when the game window is minimized, flipBuffers seems to no longer cause the CPU to wait for VSync, while the process seems to be demoted to lower priority on the GPU, resulting in the CPU easily getting hundreds of frames ahead of the GPU.

Just for shits and giggles, I've added a thing to periodically log when this occurs. This will later be improved once I have a unified system for aggregating performance warnings and notifying the user.
this gets rid of a bunch of unnecessary lombok annotations and makes cloning more efficient
for some reason NVIDIA doesn't return atomic counters with the new introspection API, but all other implementations seem to do so.
this prevents shaders from taking up multiple gigabytes of RAM when compiled for the UNIFORM_ARRAY_DRAWID tile position strategy on Mesa radeonsi (and probably other drivers as well).
most importantly, binding textures to specific texture units
also begin trying to make buffer textures accurately detect when they're supported
this is convenient for call chaining, especially in constructors
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.

2 participants