Commit Graph

170 Commits

Author SHA1 Message Date
Jozufozu
a6c5f93fb4 Spherical instances in a vacuum
- Write out instance bounding spheres in pass one
- Read them back in pass two so we don't have to read in the entire
  instance twice
- Cull pass 2 no longer needs to be parameterized by instance type, so
  less program binds are needed
- Fix page indexing logic
- Fix visibility sizing logic
2024-11-03 16:32:29 -08:00
Jozufozu
1823a9fa24 Merge branch '1.20/dev' into 1.20/last-frame-visibility
# Conflicts:
#	common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/late_cull.glsl
2024-11-03 12:52:35 -08:00
Jozufozu
4f0c1cc1ae Checking the source
- Remove source checks, it was very old and untouched
- Remove FIXMEs and TODOs that were already fixed/done
2024-11-03 12:15:04 -08:00
Jozufozu
540fe7a7fe Acetaminophen
- Generic pain relief
- Use new Instance[] rather than capturing the class object of the
  instance type
- Make InstancePage static, but manually track the instancer parent so
  we can check when stealing
- Simplify array creation helpers and make them static
- Mark InstanceHandleImpl#state as UnknownNullability
2024-11-02 16:56:49 -07:00
Jozufozu
a9f2018c0a The epitome of laziness
- Only upload changed page frame descriptors
- In the instancer, track changed contents separately from changed
  validity, so we can separately upload objects and descriptors
2024-11-02 14:12:45 -07:00
Jozufozu
fc3e475ec9 Gattai!
- Combine pages only when they're at most half full, and not empty
- This guarantees that we'll fully empty a page, allowing us to free the memory for use by other instancers
- Track mergeable pages via a separate bitset
2024-11-01 23:50:06 -07:00
Jozufozu
fac63168c1 Bookkeeping
- Mappings drop pages when they write zero validity bits
- Instancer only updates pages that changed
2024-11-01 12:47:15 -07:00
Jozufozu
20b3f78b9c A real page turner
- Try to shuffle over instances into pages with space
- Clear out now-unused logic from ObjectStorage
- Some cleanup and more comments in IndirectInstancer
2024-10-29 20:02:38 -07:00
Jozufozu
a7e7090866 Finding an old bookmark
- Make AbstractInstancer much more slim and move logic to BaseInstancer
- Extend paging concept to the indirect instancer
- Extend ObjectStorage to support more interesting layouts
- Instance creation on indirect is now entirely lock free and deletions
  no longer require re-uploading the entire instancer
2024-10-29 20:02:37 -07:00
Jozufozu
5862f3746c A clampy merge
- Remove dead code leftover from merge
- Add back clamping in late cull
2024-10-19 17:14:10 -07:00
Jozufozu
be7676eeb4 Merge branch '1.20/dev' into 1.20/last-frame-visibility 2024-10-19 16:59:09 -07:00
Jozufozu
3a949c717a Turn the cutout off crash off
- MaterialEncoder would trigger an indexing of CutoutShaders.OFF, though
  PipelineCompiler would explicitly not index OFF
- This caused a crash on instancing when MaterialEncoder would delete
  all pipeline shaders while instancing was trying to upload the packed
  ubershader uniform
2024-10-19 16:58:04 -07:00
IThundxr
3d2fdb7e83
Backport changes from 1.21.1 (#265)
* Backport changes from 1.21.1

* fix

* Fix building

* fix compile error

* fix

* fix build for real

* address reviews

* Fix sodium compat

* address requested changes

* mark rubidium as incompatible

* add missed call

* Should have worn steel toe boots

- Add "stub" sourceset to each subproject
- Directly pass vararg sourcesets to methods in PlatformExtension to
  avoid automatically shipping jars with the api stubs
- We may have to include stubs in setupLoomMod, but I don't think so
- A lot of this can be stripped back out if we don't need stub sources
  for the forge/fabric subprojects

* Guarded stubs

- Add Sodium 0.6 and Iris API stubs to stubs source set and remove Gradle dependencies on local Sodium jar, Iris, and Oculus
- Ensure usage of APIs that may not exist at runtime is in private classes and access is always guarded
- Change ShadersModHandler
  - Rename to ShadersModHelper
  - Convert methods to check for Iris' and Optifine's presence into static final fields
  - Move implementation to impl source set in form of IrisCompat and OptifineCompat classes
- Rename CompatMods to CompatMod and add public field to access mod ID
- Set BlockEntityType's Sodium predicate to null after it is removed
- Update repository links
- Remove local libs repository

---------

Co-authored-by: Jozufozu <jozsefaug@gmail.com>
Co-authored-by: PepperCode1 <44146161+PepperCode1@users.noreply.github.com>
2024-10-18 20:29:43 -07:00
PepperCode1
734506b010 Fix #266 2024-10-18 18:25:11 -07:00
Jozufozu
b90c43ba7e Directly visible
- Don't actually need a framebuffer attachment for visibility
- Instead, process everything in pass 2 and write out the visibility
  bitset directly
- Persist visibility bits between frames for use in pass 1
- No need for indirect dispatch!
- Also saves some ssbo bindings
- Do frustum culling in both passes
2024-10-18 13:45:37 -07:00
Jozufozu
afdab92010 Merge branch '1.20/last-frame-visibility' into 1.20/dev
# Conflicts:
#	common/src/backend/java/dev/engine_room/flywheel/backend/compile/IndirectPrograms.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/BufferBindings.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/DepthPyramid.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectBuffers.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDraw.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectInstancer.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/ObjectStorage.java
#	common/src/backend/java/dev/engine_room/flywheel/backend/engine/uniform/FrameUniforms.java
#	common/src/backend/resources/assets/flywheel/flywheel/internal/common.frag
#	common/src/backend/resources/assets/flywheel/flywheel/internal/common.vert
#	common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/buffer_bindings.glsl
#	common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/cull.glsl
#	common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/downsample.glsl
#	common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/downsample_first.glsl
#	common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/downsample_second.glsl
#	common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/main.vert
2024-10-18 12:09:05 -07:00
Jozufozu
3193e16498 Weak assumption
- Use a weak hash set for PipelineCompiler.ALL
2024-10-12 17:02:50 -07:00
Jozufozu
efb68dc776 All or nothing?
- Actually add PipelineCompilers into the ALL list so they get deleted
  when uber components need updating
2024-10-12 16:36:20 -07:00
Jozufozu
40577420d5 In the right direction
- Use vanilla light directions for diffuse lighting
- Copy mc's glsl code for it, but assume directions are normalized
- Add command/config to toggle use of light directions vs chunk accurate
  diffuse
- Always use shade in getItemMaterial
- Do not reload resource packs when updating light smoothness config,
  we don't need to anymore with lazy compilation
2024-09-29 11:52:35 -07:00
Jozufozu
22b5676e47 Quick thinking
- Decide not to render entities directly in the renderEntity method
- Prevents allocating large lists every frame to filter entities from
  the client level
2024-09-28 23:37:49 -07:00
Jozufozu
0a01b82647 Glimpse of glint
- Add pick glint material and system time uniform
- Move _FlwCullData to beginning of uniform block to ensure alignment
- Add helper to convert item rendertype into flywheel material
2024-09-28 23:27:28 -07:00
Jozufozu
bd0aadf9d9 Streamlined pipelines
- Make UberShaderComponent#build NotNull
- Move index update and key creation logic to PipelineCompiler
- Always update index when a resource location is requested to fix
  MaterialEncoder misses
- Indices trigger pipeline compiler deletion when updated
2024-09-28 22:05:38 -07:00
Jozufozu
ef05f7d3fd Errors galore
- Make everything in the compiler chain's results not null
- Throw errors immediately when encountered
- Log error messages when falling back
- Do not eagerly grab utility programs in IndirectDrawManager so we can
  actually catch errors and fall back
- Remove CompilerStats
2024-09-28 16:00:23 -07:00
Jozufozu
11ce4ac185 Dynamic ubering
- Remove fog shader registry
- Remove Registry and RegistryImpl
- Make shader indices mutable
- Track fog uber component in a static field in PipelineCompiler
- When a new fog source is added, delete the pipeline compilation
  harness and recreate the fog uber component
- Inline SourceLoader
2024-09-28 15:30:10 -07:00
Jozufozu
bce657804a Source of all pain
- Strip out almost all source registries
- Fog will be dealt with in a follow-up commit
- Remove most static #init methods
- Remove old ubershader indices from shaders
2024-09-28 14:48:22 -07:00
Jozufozu
48fdcdb751 DeDelleetete
- Process instancer deletions in parallel
- Give DrawManagers a frame plan
2024-09-28 14:26:15 -07:00
Jozufozu
7bd59f7b14 Not pointing
- Fix occasional npe in PlayerUniforms
- Mark accessor method as Nullable
2024-09-23 11:16:45 -07:00
Jozufozu
36b0ad4cf9 To bug or not to bug
- Disable the debug stuff in the frag shader with compile flags
- Also disable discard and conservative depth with CutoutShaders.OFF
2024-09-22 15:51:37 -07:00
Jozufozu
897c350f41 Uberstate ready
- Fix material state sorting/equality functions
2024-09-22 13:13:38 -07:00
Jozufozu
ff73e78e21 Visions of visibility
- Add visible/skipDraw getter/setter to InstanceTree
- Minecart finally gets to resolve its TODO!
2024-09-22 13:04:51 -07:00
Jozufozu
ee0f799f60 More statefuler
- Hidden state now tracks the Instance object to keep the handle small
- Make the recreate supplier an explicit record to allow comparisons
- Add setVisible method to Instance
2024-09-22 12:56:49 -07:00
Jozufozu
c5d9abab5f Tasteful stateful handles
- Use state machine interface in InstanceHandleImpl
- 3 states: deleted, visible, hidden
- Visible is directly implemented by AbstractInstancer
- Hidden stores the instancer supplier to recreate an instancer
2024-09-22 12:28:35 -07:00
Jozufozu
6a6d98c0a7 Fewber
- Do not uberize material or cutout shaders
- Add debug log for shader compilations/program links
2024-09-21 15:10:27 -07:00
Jozufozu
27e5b609af Reject eagerness return to lazy
- Eagerly load ALL shaders in ShaderSources, resolving imports there
- Compile and cache programs on-demand
- Move gl state try blocks to EngineImpl
- EngineImpl catches shader exceptions and triggers a fallback
2024-09-21 13:41:55 -07:00
Jozufozu
cb58f6075e Crumbling grumbling
- Fix crumbling on indirect
- Directly use the baseInstance as instance index without indirection
- #define base instance and draw id variables to simplify usage
- Fix null pointer looking up culling group
- Add method to map an instancer's local instance index to a global
  index in the page file
2024-09-21 12:00:09 -07:00
Jozufozu
b7b7cca992 Happy as a clamp
- Fix instances vanishing close to the edge of your screen
2024-09-20 20:07:38 -07:00
Jozufozu
40cfc08025 Mul-ing things over
- Add missing multiply functions to TransformedInstance
2024-09-20 19:28:27 -07:00
Jozufozu
90e088aedc Creation is change
- Indirect instancers mark pages as changed when instances are added
2024-09-20 19:14:50 -07:00
PepperCode1
5b6463b8f1 Regularly scheduled maintenance
- Remove ModelHolder and ModelCache
- Remove lib/util.FlwUtil
- Remove lib/util.Pair and replace usages with com.mojang.datafixers.util.Pair
- Remove lib/util.Unit and replace usages with net.minecraft.util.Unit
- Make ResourceReloadHolder and ResourceReloadCache final and move to util
- Clean up code in backend/glsl
- Move LightSmoothnessArgument to impl
2024-09-19 20:24:58 -07:00
PepperCode1
62a0954381 Home alone
- Remove LoweringVisitor
- Move functionality of four main static methods in LoweringVisitor to new ModelTrees class
  - Return ModelTree directly
  - Accept Material instead of TextureAtlasSprite for efficiency, so visuals don't need to look up the sprite to get the ModelTree
- Use ResourceReloadCache for MeshTree.CACHE
2024-09-19 11:40:41 -07:00
Jozufozu
5a75fe972f First try
- Implement instance hiding by deleting/stealing
- Work around instancer persistence by storing a recreation supplier in
  the instance handle
- Rework instancer ctors to just take an InstancerKey
- Parameterize InstanceHandle by I extends Instance so the steal method
  and the supplier can be safely assigned
2024-09-18 23:43:23 -07:00
Jozufozu
e1b594ac47 Ctrl + Alt + N
- IndirectInstancer#uploadInstances: 46% of render thread to 26%
- Inline #enqueueCopy to avoid allocating LongConsumers
- Do not even bother to track individual changed indices, instead rely
  on just the changedPage set
2024-09-15 21:29:00 -07:00
Jozufozu
c658b2bfe3 Pop! Goes the storage
- Trigger an upload when an allocation is deleted
2024-09-15 16:50:02 -07:00
Jozufozu
9f938e0673 A slap on the wrist
- Add restrict qualifier to images in downsample shaders
- Early out when there are no changed pages in
  IndirectInstancer#uploadInstances
2024-09-15 16:37:12 -07:00
Jozufozu
d342ae740c Get shulked
- Convert ShulkerBoxVisual to use InstanceTree
- Add "pruning" helper visitors
- Remove ModelPartConverter
- Remove TextureMapper and related code from VertexWriter
2024-09-15 15:29:09 -07:00
Jozufozu
31b3507d62 One big happy family
- Add ModelTree
- Add LoweringVisitor to traverse a MeshTree and emit ModelTree nodes
  and Models
- Provide some default visitor creation methods
- Abstract ModelCache -> ResourceReloadCache
- Abstract ModelHolder -> ResourceReloadHolder
- Add ModelTreeCache to hide lookup cost if it gets extreme
2024-09-15 14:49:33 -07:00
PepperCode1
904933e22e Treeify bells and minecarts
- Use InstanceTrees in BellVisual and MinecartVisual
- Use JOML Matrix4fStack instead of PoseStack
- Directly transform Matrix4f instead of using PoseStack to compute initial pose
2024-09-15 13:27:08 -07:00
Jozufozu
ed727e7a1b Things are changing
- Track if the transforms for an InstanceTree have changed
- Pass a boolean down the tree and || it with our changed flag to force
  updates
- Expose the force flag to visuals so they can hint to us if their root
  transforms never change
- Add 2 wrapper methods to make the distinction more clear
2024-09-15 00:28:10 -07:00
Jozufozu
5299571540 A little encapsulation goes a long way
- Encapsulate instancerProvider and renderOrigin in AbstractVisual
- Saves 8 bytes per visual
2024-09-14 22:46:06 -07:00
PepperCode1
b24e87262b Stackless
- Store a pose matrix in each InstanceTree, equivalent to its instance's pose matrix if the instance exists
- Directly transform the current InstanceTree's pose matrix instead of transforming a PoseStack and copying its matrix to the instance, eliminating the need to push and pop stack entries
- Remove InstanceTree.rotation
- Add more InstanceTree methods to allow full inspection of children
2024-09-14 22:37:48 -07:00