Commit Graph

2556 Commits

Author SHA1 Message Date
PepperCode1
115f57d341 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
8ea221e4f7 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
9afbc66b14 Missed renames 2023-11-18 11:53:01 -08:00
PepperCode1
66f11018fe 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
fcd70cccd0 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
257ee07e0e 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
961fafce0d 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
afb14bc1f6 Hol up
- Spin wait for .01ms in WorkerThreads before waiting
2023-05-27 12:01:47 -07:00
Jozufozu
176a839c16 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
d783617a73 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
e64976df5d 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
3da51885d1 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
37ecedb97a 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
96493e1571 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
06063cdb4b 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
7dcfc79a3e 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
d27929c307 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
d1e54d65da Actually do it somewhere else
- Move main thread checking to TaskExecutor
2023-05-13 12:01:12 -07:00
Jozufozu
639b2185ab 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
d44c973bcc 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
aa38ae4125 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
e2bcc5f325 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
19824e7a3c 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
b1a1120764 Enuf enums
- Remove GlVersioned abstraction in favor of explicit fallback
- Remove versioned.BufferStorage
2023-05-01 21:57:12 -07:00
Jozufozu
f1f289124d 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
ef7c259f43 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
Jozufozu
aef676517a Stick to the plan
- Plans are now generic about a context object
- Move default composition impls to SimplyComposedPlan
- Remove PlanUtil
- Make Synchronizer implement Runnable
- Add ContextAgnosticPlan to preserve old behavior
- Reduce creation of plan objects
- Make BatchingEngine, BatchingStage directly implement plan
- Introduce BatchContext for BatchingStage plans
- Introduce FrameContext, TickContext for VisualManager plans
- Cache separate "recreation plan" for when origin shifts occur
2023-04-23 12:42:07 -07:00
PepperCode1
f4cfb24c85 Organize and improve compiler code
- Ensure current backend is never null
- Fix StringUtil#countLines
- Use material index instead of file location when adapting material
shader function name
- Merge Includer and Compilation factory into ShaderCompiler and remove
builder
- Remove CompileUtil
- Remove Index
- Remove unnecessary code from ShaderSources
- Move source component classes to backend.compile.component
- Move core compilation classes to backend.compile.core
- Move pipeline classes to backend.compile
- Move GLSLVersion to glsl package
- Move SourceChecks to backend.compile
2023-04-20 12:22:51 -07:00
Jozufozu
296aa7ca08 Post-post-pre-refactor-refactor actual refactor
- Mark backends as unavailable if their shader compilation failed
- Update command output to notify when a fallback occurs
2023-04-18 21:28:28 -07:00
Jozufozu
4c8e174712 Pre-processing post-pre-refactor-refactor
- Separate pipeline compiler from compute compiler
- Remove Pipeline field from PipelineProgramKey
- Share one UniformComponent across compilers
- Use AbstractCompiler to deduplicate some shared code
- Separate indirect programs from instancing programs
- Move compilation tracking information to CompilerStats
- Improve compilation result/link result reporting
2023-04-18 20:27:25 -07:00
Jozufozu
b30d686785 And I oobe
- Raise exception when trying to slice outside DrawBuffer bounds
- Count vertices in BufferPlan#execute to account for instance creation
  during Visual updates
- Mark DrawBuffers active by default
2023-04-17 15:02:45 -07:00
PepperCode1
7afa2486ad Pre-processing Pre-refactor
- Move pipeline code to backend package
- Store compiled programs in FlwPrograms instead of FlwCompiler
- Rename PipelineContext to PipelineProgramKey and remove CullingContext
- Remove PipelineContextSet and CullingContextSet
- Improve quality of dumped sources
- Rename pipeline directory to internal
- Add underscores before more internal GLSL variables
- Remove unnecessary GLSL files
2023-04-16 22:09:28 -07:00
Jozufozu
5b84046c1d The manhattan batch
- Use atomics to determine buffer position for batches
- Pass resultant vertex count to DrawBuffer once all transform calls
  have run
- Refactor to use RunOnAllPlan within TransformCall
- Make all vertex transform logic to operate per-instance instead of
  per-chunk
- Cull instances based on bounding sphere transformations
- Make BufferedMesh#mesh public to expose bounding sphere
- Roll batching #plan() arguments into FrameContext record
2023-04-16 21:00:36 -07:00
Jozufozu
1bd4c4f6cb Non-uniform un-provider
- Delete UniformBuffer on renderer reload to fix crash when switching
  backend to off
- Use library method for getting boolean property (ty pepper!)
2023-04-16 17:20:32 -07:00
Jozufozu
51cbfbc75a Batch in action
- Rename TransformSet -> BatchingStage
- Inline BatchingTransformManager into BatchingEngine
- Reuse one Plan object for each DrawBuffer used by a stage.
- Separate DrawBuffer acquisition from marking as active.
- Remove some unused methods in BatchingDrawTracker
- Rename variables in AnimationTickHolder
- Make flw.loadRenderDoc=false behave as expected.
2023-04-16 15:23:14 -07:00
Jozufozu
e03590b270 Smaller batches
- Extract TransformSet to full class
- Move planning code into BatchingTransformManager
- Reduce exposure BatchingTransformManager of internals
- Comment out WaitGroup log :ioa:
- Move ceilingDiv to MoreMath
- Use dynamic chunk size for TransformCalls
2023-04-16 12:46:20 -07:00
Jozufozu
cb74fa4603 Merge branch '1.18/plan' into 1.18/next
# Conflicts:
#	src/main/java/com/jozufozu/flywheel/api/backend/Engine.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/batching/BatchingEngine.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/batching/TransformCall.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectEngine.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/instancing/InstancingEngine.java
#	src/main/java/com/jozufozu/flywheel/handler/EntityWorldHandler.java
#	src/main/java/com/jozufozu/flywheel/impl/instancing/InstancedRenderDispatcher.java
#	src/main/java/com/jozufozu/flywheel/impl/instancing/manager/InstanceManager.java
#	src/main/java/com/jozufozu/flywheel/impl/instancing/storage/AbstractStorage.java
#	src/main/java/com/jozufozu/flywheel/impl/visualization/VisualWorld.java
#	src/main/java/com/jozufozu/flywheel/mixin/instancemanage/InstanceRemoveMixin.java
#	src/main/java/com/jozufozu/flywheel/mixin/visualmanage/VisualAddMixin.java
#	src/main/java/com/jozufozu/flywheel/mixin/visualmanage/VisualUpdateMixin.java
2023-04-15 15:27:18 -07:00
Jozufozu
0861d8bfd2 Needs to wait
- Commit to non-blocking waitgroup impl
- Debug log when await takes suspiciously long
2023-04-14 17:14:12 -07:00
Jozufozu
f29dcbc486 Weaving threads
- Restore WaitGroup abstraction
- Simplify WaitGroup to make proper use of atomics
- Fix logic error in ParallelTaskExecutor causing task counter to go
  below zero when executing main thread tasks
- Use ConcurrentHashMap in models to allow parallel access
- Reduce chunk size in RunOnAllPlan
- Only queue in InstanceManager
- Defer syncPoint within renderStage
- AbstractStorage return immutable view for tickable/dynamic instances
- Process InstanceManager queues off-thread
2023-04-13 15:17:02 -07:00
PepperCode1
361cb5a1d9 Clean up mixins and fix changes from last commit
- Add FixNormalScalingMixin from Create
- Fix VisualizedRenderDispatcher#tryAddBlockEntity
- Fix flywheel.sodium.mixins.json using wrong plugin class name
2023-04-13 11:36:05 -07:00
PepperCode1
b4cef0b5c9 Add Rubidium compatibility
- Add proper Rubidium compatibility on our side
- Overwrite methods in Rubidium's FlywheelCompat class with stubs to
prevent crashes
2023-04-13 10:16:33 -07:00
PepperCode1
2847ad28ed Fix rendering far from world origin
- Make BatchingEngine use a shifting render origin
- Make frustum checks relative to the render origin
- Improve AbstractEntityVisual#isVisible to be closer to vanilla
- Move render origin implementation code to AbstractEngine
2023-04-10 14:30:08 -07:00
Jozufozu
76dcf3fed6 The botched batching plan
- Directly port over submitTasks to use Plan
- Could probably make better use of the plan primitives, but oh well
- Remove Engine#beginFrame
2023-04-09 14:37:12 -07:00
Jozufozu
1627874e33 Putting our plan to the test
- Implement plan simplification
- Add unit tests for plan execution and simplification
2023-04-09 14:15:29 -07:00
PepperCode1
05458d01d2 Flywheel's Visualized Rendering
- Rename Instance -> Visual (and all related elements)
- Rename InstancePart -> Instance (and all related elements)
- Move classes in package lib.format -> lib.vertex
- Rename Formats -> VertexTypes
- Remove SimpleLazyModel#setMaterial
- Remove unnecessary newlines in some files
2023-04-09 12:00:03 -07:00
Jozufozu
fb11f29010 Parallel planning primitives
- Engines/InstanceManagers now provide Plans for frames/ticks
- TODO: batching is broken
- TODO: plan caching
- Add Plan interface which can be used to compose complex systems
  of parallel execution
- Add Synchronizer to facilitate barriering
- Remove WorkGroup
- Summary of different primitives below, names need work :ioa:
  - BarrierPlan: executes one plan then another
  - NestedPlan: executes many plans at once
  - OnMainThreadPlan: waits for a syncPoint to execute
  - RunOnAllPlan: dispatches work over a Supplier<List>
  - SimplePlan: executes many Runnables at once
  - UnitPlan: does nothing
2023-04-08 18:08:53 -07:00
PepperCode1
72b5968305 More clean up 2023-04-07 16:01:03 -07:00
Jozufozu
945ed9a1e4 Simple storage staging
- Use one concurrent queue of transactions in InstanceManager
2023-04-07 00:14:39 -07:00
Jozufozu
ab8ab8dbd4 How to handle InstancePart abstraction
- Pull InstancePart into an interface
- Add Handle interface to opaquely notify an instancer something has
  changed or was deleted.
- Remove notify* methods from Instancer
- Remove stealInstance TODO: find a better way to accomplish that
- Track removals/changes through bitsets
- Deprecate InstancePart#copy
- Move InstanceManager#canCreateInstance to Storage#willAccept
2023-04-06 14:48:51 -07:00
PepperCode1
391adfef1a Instance Refactor II 2023-04-05 18:03:25 -07:00