Commit Graph

663 Commits

Author SHA1 Message Date
PepperCode1
5ff194cbc8 Re-reload
- Rename ReloadRenderersEvent to ReloadLevelRendererEvent
- Rename Engine#renderCrumblingInstances to #renderCrumbling
- Make all mixin classes package-private and abstract
- Make all event classes final and document which event bus they are
posted on
- Add EndClientResourceReloadEvent
  - Replace some usages of ReloadLevelRendererEvent with
EndClientResourceReloadEvent, including ModelHolder and ModelCache
- Always add all existing entities from world to
VisualizationManagerImpl on construction if level is instanceof Level
- Delete all VisualizationManagerImpls on resource reload
- Improve MemoryBlock utility
  - Add MemoryBlock#copyTo(MemoryBlock)
  - Remove MemoryBlock#reallocTracked and make #realloc create a tracked
block if and only if the existing block is tracked
  - Fix reallocating a debug memory block creating a regular memory
block
- Change BakedModelBufferer to only invoke the result consumer if the
data is not empty
- Improve BackendArgument
  - Fix classloading BackendArgument early causing it to return
incomplete suggestions
  - Always allow specifying namespace, allow matching only by path, and
always display suggested IDs with namespace
2023-11-29 20:03:26 -08:00
Jozufozu
8c86a66f18 Bit off a bigger batch than I could chew
- Implement crumbling for batching engine.
- It's ugly! (the code)
- Need to support translucency sorting in batching.
  - Plumb RenderType#sortOnUpload through to DrawBuffer.
  - Allocate room in DrawBuffer for BufferBuilder to write indices.
  - Set nextElementByte on injectForRender.
- Remove RenderStage from DrawBuffer, isn't really needed.
- Make some fields public, so they can be accessed by BatchedCrumbling.
- Track TransformCalls in BatchedInstancer.
-
2023-11-28 17:06:48 -08:00
Jozufozu
b668d10036 The boring way
- Just use vanilla's implementation for crumbling.
2023-11-27 12:42:41 -08:00
Jozufozu
7c934f2595 Good enough for government work
- Move crumbling tbn calculation back to the fragment shader.
- Pass the center of the crumbling block position as a uniform.
- Calculate how to flip the crumbling texture such that it tiles well at
  corners in model space.
- Move ugly crumbling code to utility class and improve bucketing.
- Cache uniform locations in GlProgram.
2023-11-26 23:18:09 -08:00
Jozufozu
745295f5ed Relativistic crumbling
- Apply crumbling texture based on model space coordinates, not world
  space.
- Discard based both on crumbling alpha and diffuse alpha.
2023-11-26 19:24:04 -08:00
Jozufozu
08d9f789dc Error in errors
- Parse error format produced by my intel laptop now.
- Fix some off-by-one errors in error reporting.
2023-11-26 16:16:33 -08:00
Jozufozu
c5f2361e6b Consistent batches
- Reintroduce BatchedDrawManager.
- BatchingEngine no longer implements plan itself, instead uses
  composition of other plans.
- Add DynamicNestedPlan, runs many plans provided at execution time.
- Add ContextFunction and ContextSupplier to match *Consumer and
  *Runnable.
- Add unit tests for DynamicNestedPlan and IfElsePlan.
2023-11-26 13:49:54 -08:00
Jozufozu
2039a964e2 Store bought engines
- Add InstancerStorage so engines can share common code.
- Instanced and Indirect DrawManagers extend InstancerStorage, while
  BatchingEngine keeps an anonymous class for it.
- AbstractEngine now has a InstancerStorage getter and does some
  delegation so the implementations don't have to.
- InstancedInstancer directly stores the list of DrawCalls it belongs
  to.
- InstancingEngine no longer accepts a context parameter.
- Make the /flywheel backend command default to the flywheel nampspace.
2023-11-26 12:07:05 -08:00
Jozufozu
8fa095cd16 Buckets of crumbs
- When crumbling, group DrawCalls by ShaderState.
- Pass all instances for a given crumbling progress at once.
- Use a map to associate initialized instancers with draw calls.
- Document most of the fields in InstancedDrawManager.
- Fix race condition in InstancedDrawManager#getInstancer.
- Will follow up for BatchingEngine and IndirectDrawManager.
2023-11-25 14:24:43 -08:00
PepperCode1
e68845ee3e Port fixes and other changes 2023-11-25 14:09:30 -08:00
Jozufozu
b400229ea4 Reduced to ashes
- renderCrumblingInstances accepts a list.
- Implement crumbling for InstancingEngine.
  - It's ugly.
  - Track what draw calls belong with what instancers.
  - DrawCalls lazily create a second VAO for one-off rendering.
  - Bind instance vbo with offset to scratch VAO to emulate a draw with
    baseInstance.
- Ignore discard predicate in crumbling context.
- SimpleContext takes a Consumer to set sampler bindings.
- Fix debugCrumbling command.
- Compile shaders against all contexts.

Side note: not sure if Context is the right place for crumbling. It
feels like it should be a material, but I don't know how that would
work.
2023-11-24 23:10:27 -08:00
Jozufozu
791c2ddf5c Undo invalidate back to delete
- Makes more sense given how the method is used.
2023-11-24 21:21:10 -08:00
Jozufozu
055ac161d8 Plans yet to crumble
- Rename Engine#delete -> #invalidate per pepper's TODO.
- Plans
  - Remove thenMap and andMap from Plan API.
  - Add builder for MapContextPlan for better composition.
  - Add IfElsePlan and Builder to "fork" on a condition.
  - VisualizationManagerImpl no longer rolls a special Plan class and
    instead uses a plan composition chain.
- Crumbling
  - Not implemented yet!! But the skeleton is taking shape.
  - Remove LevelRendererAccessor, and instead directly pass the map of
    destructionProgress to the VisualizationManagerImpl when it's time
    to render crumbling instances.
  - Give Instances a Handle getter.
  - Add way to get a block entity visual at a given position.
  - Add Engine#renderCrumblingInstance stub.
2023-11-24 20:40:14 -08:00
Jozufozu
e5cda8944e Shaking things out
- Use JOML better where we can.
  - Inline MatrixUtil#store and #toJoml
  - FlwShaderUniforms keeps a scratch matrix around for mutating the
    viewProjection.
  - Directly store a Quaternion4f in OrientedInstance to avoid creating
    new objects in the batching transformers.
- Move FrameContext creation to a functor.
- We do need to check the renderDebug flag still :ioa:
- Make VisualUpdatePlan's internal plan not null.
- Remove ClientMainMixin :sad:
  - Forge's new earlywindow stuff means there's no opportunity for
    Flywheel the mod to inject renderdoc before the window is
    initialized.
  - The workaround for now is to breakpoint in FML's
    DisplayWindow#initialize and evaluate
    `System.loadLibrary("renderdoc")` manually.
2023-11-24 14:29:03 -08:00
Jozufozu
5e42ecc1c6 Finally free
- Free from mojmath, have to flip many matrix field accesses.
- Free the memory allocated in model cache.
  - Shout out to pepper's DebugMemoryBlock telling me *exactly* where a
    leak was from.
- Instancing and batching seem to mostly work, indirect appears to be
  rendering instances in the wrong places, though they are culled from
  their real location.
2023-11-23 23:09:46 -08:00
Jozufozu
7b0b1883ed Loading visualization
- Fix up/comment out some touchy mixins.
- Get chests to render.
- There's something wrong with the projection matrix.
- Add comment to DebugMemoryBlockImpl's stack walker usage.
2023-11-23 22:48:29 -08:00
Jozufozu
8ff208d23e Instant backport
- Switch to 1.20.1
- It still compiles!
2023-11-23 22:45:39 -08:00
Jozufozu
1e9b0ee85c I'm partial to compiler errors
- Update PartialModel events
- Flywheel compiles!
2023-11-23 14:15:01 -08:00
Jozufozu
d9da952dc2 The bakery
- Port model baking infrastructure.
- VirtualEmptyModelData seems like it isn't needed anymore,
  but I left some stubs in.
2023-11-23 14:10:50 -08:00
Jozufozu
3f3f2b5791 Round 2
- Add Axes class to (temporarily?) replace old mojmath Vector3f.$axis.
- Add helper for getting a random float between 2 values.
- Implement diffuse light formula.
- Fix debug overlay event.
- Try and fix ChunkRebuildHooksMixin but the first parameter isn't
  visible. Hopefully stubbing in Object will compile later.
2023-11-23 11:42:11 -08:00
Jozufozu
df93b09f44 First blood
- Make a quick pass resolving conflicts
- Mostly joml related, or to do with the world -> level rename
- Basically left model builders and virtual levels alone
- There are also some forge events that seem to no longer exist
2023-11-22 21:30:58 -08:00
Jozufozu
57faab9291 Build system but no build
- Start with a cherry pick from 1.20/dev
- Copy over newer gradle wrapper related things from the forge 1.20 mdk
- Follow example from 1.20 mdk to update build.gradle and
  settings.gradle
- Update parchment version
2023-11-22 20:57:46 -08:00
Jozufozu
a8067d388d Discard discard
- Do not guard discard predicate on a compile definition because it
  doesn't matter for ubershaders.
2023-11-22 12:49:06 -08:00
Jozufozu
78975e8cad Improved vexillology
- Separate concept of Flags from TaskExecutor.
- Instead, allow TaskExecutor to sync until, or while a given condition
  is met.
- Flags directly store their state as an AtomicBoolean.
- Switch `executor.syncOn(flag)` to `executor.syncUntil(flag::isRaised)`
- Remove tests made redundant by improved interface.
2023-11-21 10:47:33 -08:00
PepperCode1
78e959d1a9 Less building, more converting
- Add ModelPartConverter and remove ModelPartBuilder
  - ModelPartConverter can convert ModelParts into Flywheel Meshes,
optionally using a transformation and TextureMapper. A
ModelLayerLocation and TextureAtlasSprite can be used instead to quickly
replicate entity models.
- Add ModelHolder and ModelCache to lazily initialize models and
automatically delete them on renderer reload
- Add SimpleModel and remove SimpleLazyModel
- Add flw.useSerialExecutor system property
- Rename ModelBufferingUtil to BakedModelBufferer
- Remove Instance.copy
- Remove Mesh.name
- Make FlwMemoryTracker thread-safe
- Fix potential thread-safety issues, texture issues, and memory leaks
related to previously memoized models
- Fix MinecartVisual only updating when not visible
- Fix ChestVisual locks not moving when opening the chest
2023-11-20 22:03:04 -08:00
Jozufozu
8126a63216 Full of red flags
- Add concept of flags to TaskExecutor.
- Can raise and lower flags from any thread.
- Add TaskExecutor#syncTo
  - Behaves much like #syncPoint, but exits early as soon as it detects
    that the requested flag has been raised.
- Document all methods in TaskExecutor.
- Do not discard tasks when destroying a VisualizationManagerImpl.
- Use flags in VisualizationManagerImpl to track frame plan and tick
  plan completion.
- Use flags in BatchingEngine to track stage buffering completion and
  flush completion.
  - Synchronization is now needed in BatchedDrawTracker#draw.
- Use flags in IndirectEngine and InstancingEngine to track flush
  completion.
- Add unit tests to validate flag behavior.
- Rename OnMainThreadPlan -> SyncedPlan.
2023-11-18 16:07:58 -08:00
PepperCode1
e7a6052a84 Missed renames 2023-11-18 11:53:01 -08:00
PepperCode1
6d86437514 Sweeping changes
- Add VisualizationManager and VisualManager API
- Simplify and fix memory leaks in model utilities
- Pass partialTick directly to visuals and remove AnimationTickHolder
- Fix LevelAttached and FlwTaskExecutor not being thread-safe
- Reorganize and rename many things
- Remove unnecessary things
2023-11-18 11:46:04 -08:00
Jozufozu
2b93462416 Barely better batches
- TransformCall now uses ForEachSlicePlan to reduce the number of
  objects created.
- WaitGroup#await can now timeout. This allows the main thread to
  contribute more work in a syncPoint.
- Don't normalize in transformNormal, things already are normalized.
2023-05-29 20:29:46 -07:00
Jozufozu
8c08079c4f Index sequences but they're unsafe
- Not totally happy with this but it's functional and better than
  directly supplying a GL object.
- Meshes provide an IndexSequence and the length of the sequence.
- IndexSequence can fill a buffer given a length.
- Special case QuadIndexSequence to optimize the most common case.
- All other sequences are treated as if they are unique
- Instancing uses EBOCache to manage ebos
- Indirect does it directly in the meshpool
2023-05-29 20:25:17 -07:00
PepperCode1
2a74ef19a6 Batched simplification
- Perform various cleanup in batching code
- Remove ClientLevel argument from InstanceVertexTransformer#transform
- Rename Plan#maybeSimplify to simplify
- Rename some classes
- Move TickContext from impl to impl.visualization
- Move VertexListProviderRegistryImpl from impl to impl.vertex
2023-05-28 09:54:51 -07:00
Jozufozu
3222c969e5 Hol up
- Spin wait for .01ms in WorkerThreads before waiting
2023-05-27 12:01:47 -07:00
Jozufozu
71e6dcc9ef Too many plans
- Add PlannedVisual
- Make ExampleEffect use PlannedVisual
- Remove One2ManyStorage
- Merge Storage, AbstractStorage, and One2OneStorage
- Storage directly provides update and tick plans
- Move work distribution logic to static methods in PlanUtil
- Rename RunOnAllPlan -> ForEachPlan
- Add ContextConsumer and ContextRunnable interfaces and remove
  ContextAgnosticPlan
2023-05-26 15:59:00 -07:00
Jozufozu
3b88b149ca Context for Tickable/Dynamic visuals
- Add VisualFrameContext for DynamicVisual#beginFrame
- Add VisualTickContext for TickableVisual#tick
- Move checks for update limiting to within the update calls themselves
- Provide update limiting/culling primitives within (B)E Visuals
- Remove methods from *Visual interfaces related to update limiting
- Add thenMap and andMap to Plan
- Add Plan primitive to transform context
  - Used in Visual update dispatch
2023-05-21 18:10:46 -07:00
Jozufozu
d6535dc9cd Gone, but not forgotten
- Track the last visible AABB within EntityVisuals to prevent entities
  from freezing when the go offscreen.
2023-05-21 16:07:46 -07:00
Jozufozu
ce6ce841d1 Housekeeping
- Update dependencies, forge version
- Bump LICENCE year
- Use fma in MatrixUtil and VertexTransformations
- Remove some dead variables from TransformCall
- Use onSpinWait in WaitGroup#await
- Do not allow adding negative numbers to a WaitGroup
- Thin abstraction for TaskNotifier
- Clean up WorkerThread task polling
2023-05-21 15:24:33 -07:00
Jozufozu
863958fb00 Building shade
- Use builder pattern for defining shader compiler flows
  - If only java had type inference extending to builders :whywheel:
- Support glsl 330 on instancing again
  - Set uniform block binding at link time
  - Remove associated glsl builder code
  - Use explicit uint literals in material adapter switch cases
  - No need to enable GL_ARB_explicit_attrib_location
2023-05-18 00:03:53 -07:00
Jozufozu
6e6779093a Instant legacy code 2: electric boogaloo
- Hardcode generation of unpacking structures/functions.
- Remove SourceLoader arg from InstanceAssemblerContext
- Remove types.glsl, move BoundingSphere to indirect_draw_command.glsl
- Remove extra methods from LayoutItem
- Tweak nested error lines
2023-05-17 20:45:30 -07:00
Jozufozu
2d923a91aa Missing lines
- Fix crash trying to generate pretty errors in generated source
- Generate short, unique file names for shaders
- Cleanup some legacy code
- Catch exceptions while compiling shaders for each backend
2023-05-15 16:55:18 -07:00
Jozufozu
98ebe9d95a Still loading
- Catch errors while loading complex source components
  - Allow compilers to progress when such an error occurs, but don't do
    any actual compilation.
- Tweak error messages.
- Make resource locations in shaders default to flywheel namespace
- Make PipelineCompiler somehow simpler yet more verbose
2023-05-14 16:41:37 -07:00
Jozufozu
b5fad9bd06 Shader sanity
- Switch #use to #include
- Stop ignoring errors from within shader compilers
- Track load errors in CompilerStats
- Move LoadError to separate sealed interface, LoadResult.Failure wraps
  a LoadError
- Move SourceFile member parsing methods to respective classes
- Add tests for SourceFile loading
- Start work on tests for error messages
2023-05-13 17:02:18 -07:00
Jozufozu
d3ca86e118 Actually do it somewhere else
- Move main thread checking to TaskExecutor
2023-05-13 12:01:12 -07:00
Jozufozu
1f484da50b A lot to unwrap
- Make ShaderSources return a LoadResult
- Refactor SourceFile loading to do all parsing outside the ctor
- Don't immediately swallow import errors, instead forward them
- Change Span to reference SourceLines instead of SourceFile
- Still WIP, but functional at this stage
2023-05-08 22:43:55 -07:00
Jozufozu
2520d4eb8c Just do it
- In OnMainThreadPlan#execute, don't queue anything if we're already on
  the render thread
2023-05-08 22:41:17 -07:00
Jozufozu
e53f011544 Separate separate attributes
- Add new GL43 vertex array impl
- GlNumericType cleaning
- Make GlBuffer growth more abstract
- Organize VertexArrayGL3, track bound ebo
2023-05-07 15:38:45 -07:00
Jozufozu
8e4ba54ea4 Should use separate attribute format correctly
- Switch to object oriented vertex array impl
- Expose vao api similar to separate attribute format
- For DSA, directly call methods
- For 33, defer state changes until bindForDraw is called
- Inline instanced mesh #drawInstances method in favor of more
  fine-grained control over binding order
- Move buffer binding to GlStateTracker
- Remove raw bindVAO(0) from indirect engine
- Make VertexAttribute a sealed interface.
- Fix ebo restore state by always updating it and never restoring it
- Remove restore state wrapping in DrawCall
- Also misc cleanup.
2023-05-06 17:04:58 -07:00
Jozufozu
cda7eca655 Apply directly to the buffer
- Add DSA abstraction to GlBuffer
- Move backing impls to their respective classes
- Remove versioned package, move impls to appropriate package
- Make fallback methods take no arguments
- Do VAO check/bind in GlStateTracker
- GlVertexArray actually checks the tracked info when binding attributes
- Add separate enable* and setup* methods in VertexArray
- Add support for DSA VAO with ARB instanced arrays incase there are
  some particularly cursed drivers out there
- Misc. cleanup
2023-05-01 23:43:01 -07:00
Jozufozu
12419fd50b Enuf enums
- Remove GlVersioned abstraction in favor of explicit fallback
- Remove versioned.BufferStorage
2023-05-01 21:57:12 -07:00
Jozufozu
9d1c4b3e92 Buffing the old works
- GlBuffer no longer has an explicit bind method or binding target
- Use READ/WRITE BUFFER for all data operations
- Make MappedBuffer simpler and more RAII
- Remove dead methods from GlBuffer
- Don't actually need to clear the tail of GPUInstancers on shrink
- Implement actual capability check for indirect
  (I think I check all the extensions)
2023-04-29 21:53:56 -07:00
Jozufozu
684d9c7913 InDSAanced vertex arrays
- Make GlCompat static
- Expand InstancedArrays compat to encompass all vertex array ops
- GlVertexArray calls into VertexArray compat layer
- VertexAttributes still use 2 separate interface methods
2023-04-24 21:54:59 -07:00