Commit Graph

615 Commits

Author SHA1 Message Date
Jozufozu
733ec60216 Instancing with Layouts
- InstancedArraysComponent now fully uses Layouts.
  - Trivial to get the glsl type name of a given Element.
  - Also quite easy to get the attribute count without actually
    creating the attribute list.
- IndirectComponent is WIP because unpacking is hard.
  - Reorganize so all the unpacking stuff is in one loop.
2024-01-04 23:44:35 -08:00
Jozufozu
bd00bdff97 A tribute from layouts
- Add utility to convert a Layout to a list of VertexAttributes.
2024-01-04 22:31:36 -08:00
Jozufozu
0b59067701 Untyped instance types
- Add SimpleInstanceType and builder.
- Remove OrientedType and TransformedType classes in favor of builder.
2024-01-04 15:21:02 -08:00
Jozufozu
7aa0e659d6 Add icon to .idea
- Scaled it down because the full-res icon had poor filtering when
  rendered in jetbrains toolbox.
2024-01-04 15:21:02 -08:00
PepperCode1
eda75078af Make layout map actually immutable
- Also implement hashCode and equals on *ElementTypeImpl, Layout, and
Layout.Element
2024-01-04 15:19:21 -08:00
PepperCode1
060bf624a0 Add missing underscores 2024-01-04 15:00:11 -08:00
PepperCode1
2cb68fea95 Rewrite the layout API 2024-01-04 14:57:21 -08:00
Jozufozu
c8590629a1 We do a little thieving
- Reimplement stealInstance.
2024-01-04 12:35:58 -08:00
Jozufozu
8221616eff Crumbling inheritance
- Instead of returning a list, collect crumbling instances via consumer.
- This is much friendlier to inheritance and generally better represents
  the behavior we want from Visuals.
2024-01-03 13:57:13 -08:00
Jozufozu
64df7ed981 Pain points
- Add Self parameter to TransformStack.
- Replace duck interface impl of TransformStack for PoseStack with
  lazily constructed wrapper object.
- Document Models.
- Replace PARTIAL_DIR with TRANSFORMED_PARTIAl and allow for arbitrary
  transformations with arbitrary keys.
  - Will be useful for transforming by different enums, or using
    alternative transforms by Direction.
- Add default impl of #delete to Instance.
- Store VisualizationContext in AbstractVisual.
- Reduce usage of @SuppressWarnings in Rotate and Transform.
2024-01-03 12:45:32 -08:00
Jozufozu
32668187c8 More artificer
- Add sources and javadoc to maven artifact
- Update artifact mc version
- Actually test publish locally :lwe:
2023-12-28 13:05:25 -08:00
Jozufozu
cb11ee030e Artifice
- Specify artifactId again in maven publication
2023-12-27 12:44:16 -08:00
Jozufozu
588bb4dda3 Buffer built
- Remove BufferBuilderExtension and mixin.
- Missed these in earlier commits.
2023-12-24 12:21:55 -08:00
Jozufozu
02321c52ef Consecutive normal draws
- Don't use MDI on intel, instead submit multiple draw indirect commands
2023-12-24 11:55:33 -08:00
Jozufozu
744199217c Drew buffer
- Remove DrawBuffer and related mixins.
2023-12-20 12:46:01 -08:00
Jozufozu
2dbdf83ec2 Gone, reduced to batches
- Remove BatchingEngine.
- Remove InstanceVertexTransformer and BoundingSphereTransformer.
- Remove fallback RenderType and MaterialVertexTransformer.
2023-12-20 12:46:00 -08:00
Jozufozu
b7a1eba59a To delete or not to delete
- Fix AtomicBitset#nextClearBit
- Add test for AtomicBitset
- Remove unnecessary gl state stuff from IndirectEngine#renderCrumbling.
- Fix instance removal on IndirectEngine.
  - Deleting an instance not at the end of the instancers list would
    cause an exception to be thrown during upload caused by
    out-of-bounds indexing.
  - Fixed by unsetting changed for the tail of the instancers list.
2023-12-20 11:21:18 -08:00
Jozufozu
7565685533 Spooky crumbling from a distance
- Add crumbling renderer for indirect backend.
- As usual, it's ugly.
- Submit one indirect draw per crumbling instance. Could do multidraw
  here, but we'd have to perform the material sort which seems
  unnecessary.
2023-12-15 13:24:09 -08:00
Jozufozu
594bbf411c Layout on me, dev
- Move gl-coupled BufferLayout and co. to lib.
- Add new Layout record to API.
  - List of Elements, a sealed interface of type safe records
    representing most possible vertex attributes.
- Deprecate InstanceType#getLayout.
- Add LayoutBuilder in lib for convenience.
- TODO: use new Layouts in backends.
2023-12-13 13:40:53 -08:00
Jozufozu
3618ba6ca3 TODONE
- Do not check moreThanTwoThirdsChanged in IndirectInstancer#upload
2023-12-10 15:55:04 -08:00
Jozufozu
4e782b8dcd Scattered to the winds
- A scatter command is 2 uints:
  - The first contains the size and source offset in the upper byte and
    lower 3 bytes respectively.
  - The destination offset.
  - All offsets and sizes are in uints, not bytes.
- Use ScatterList write scatter commands.
- Use TransferList to collect transfers.
- Rather than consolidating transfers in a separate pass, do so as they
  are collected.
- Reorganize StagingBuffer.
2023-12-10 15:45:16 -08:00
Jozufozu
1bfb6db6d1 Throw more compute at it
- Use a shader to perform copies.
- Needs optimization, but it works surprisingly well and avoids the
  driver hitch.
2023-12-09 15:32:21 -08:00
Jozufozu
ec6dbfbf49 Un unchanged
- Call setChanged in various visuals' #init.
- Not everything needs it because some just call their frame update
  methods right away.
- Improve lazy update logic for bells.
2023-12-08 18:38:40 -08:00
Jozufozu
1d318ecb02 Bit-ing the atom
- Use an atomic bitset in AbstractInstancer.
- Add method to iterate over each contiguous span of set bits.
2023-12-08 18:05:03 -08:00
Jozufozu
370a891aae DIY
- Visuals must manually call setChanged on Instances.
- Decreases the extent of resource contention and makes what's going on
  more explicit.
- Remove self type parameter from FlatLit, I don't think it was ever
  needed.
2023-12-08 18:05:02 -08:00
PepperCode1
a8b51aacbe Separation, for instance
- Separate instance vertex shaders and instance cull shaders into
different files with separate getters in InstanceType
- Remove all occurrences of Names and Files inner classes
2023-12-08 17:02:12 -08:00
PepperCode1
2c9a3edb97 Untyped vertices
- Remove VertexType
- Rename ReusableVertexList to VertexView and all associated classes,
methods, fields, and variables
- Add VertexView#stride
- Make vertex compiler automatically include layout shader
- Fix instancing and indirect not setting correct vertex count before
writing mesh
2023-12-07 16:49:12 -08:00
Jozufozu
abca3a2389 More smarter less upload
- Only write draw calls when they change.
- Update baseInstance in the apply shader.
- Simplify object upload logic.
2023-12-07 13:46:17 -08:00
Jozufozu
d4a9b51c8b Merge remote-tracking branch 'origin/1.20/next' into 1.20/next
# Conflicts:
#	src/main/java/com/jozufozu/flywheel/backend/compile/PipelineCompiler.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectBuffers.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectCullingGroup.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectDrawManager.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectEngine.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectInstancer.java
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectModel.java
#	src/main/resources/assets/flywheel/flywheel/internal/indirect/draw.vert
#	src/main/resources/assets/flywheel/flywheel/internal/instancing/main.vert
#	src/main/resources/assets/flywheel/flywheel/internal/layout.vert
2023-12-07 12:56:10 -08:00
Jozufozu
567491ca4d In an abstract sense, buffered
- Abstract indirect buffers to deduplicate code.
- Write buffer handles when updating sizes.
- StagingBuffer internally handles deferring to a memCopy, accepting a
  long consumer
2023-12-06 23:30:01 -08:00
PepperCode1
a4a2d6ba13 Sparse changes
- Add Model.boundingSphere()
- Fix MaterialRenderState not setting up polygon offset correctly
- Fix GlslSwitch using incorrect indentation for first and last line
- Tweak how instanced crumbling works
- Add CutoutShaders.ONE_TENTH
- Rename Contexts.WORLD to DEFAULT
- Rename Material.baseTexture() to texture
- Rename Transparency.LIGHTING to LIGHTNING
- Rename WriteMask.BOTH to COLOR_DEPTH
- Rename SimpleModel to SingleMeshModel and add new SimpleModel that
stores an arbitrary amount of meshes
- Remove flywheel:flywheel/api/* files and assume appropriate symbols
are automatically defined
- Rename many GLSL variables, functions, and constants
- Reorganize GLSL files
- Add NonExtendable annotation to some API classes
- Rename some Java classes, methods, fields, and variables
2023-12-06 22:00:31 -08:00
Jozufozu
d3e7789f13 OSHA Theatre
- Add staging buffer for indirect using unholy amounts of unsafe.
- Make GlFence RAII.
- Make all IndirectBuffers GPU only and use a shared staging buffer for
  transfers.
2023-12-05 14:25:21 -08:00
Jozufozu
1808d615d0 Internal overlay
- Add overlay to internal vertex format.
- Move interval vertex format related constants to helper class.
- Switch strides to long so java stops complaining about implicit casts
  in multiplication.
- Remove VertexTypes#init as it's not needed anymore.
2023-12-04 21:17:57 -08:00
Jozufozu
eace28cdd8 Merge remote-tracking branch 'origin/1.20/next' into 1.20/next
# Conflicts:
#	src/main/java/com/jozufozu/flywheel/backend/engine/indirect/IndirectDrawSet.java
#	src/main/resources/assets/flywheel/flywheel/internal/block.vert
#	src/main/resources/assets/flywheel/flywheel/layout/pos_tex_normal.vert
2023-12-04 00:29:32 -08:00
Jozufozu
e405c41ade More indirecter
- Indirect now supports multiple meshes per model.
- Cull entire models at once and then apply the accumulated instance
  count to each draw command in a separate compute pass.
- Add utility to calculate the bounding sphere for multiple meshes.
- Inline IndirectDrawSet into IndirectCullingGroup.
- Use MemoryBlocks for draw command and model descriptor storage.
- Fix leaked draw commands.
- Add IndirectModel to track bounding sphere and instancer stuffs.
- IndirectDrawCommand now references IndirectModel instead of Instancer.
2023-12-04 00:25:20 -08:00
PepperCode1
0608944743 Materials and You: Volume 3
- Add material properties
  - depthTest
  - useOverlay
- Rename some material properties
  - mip -> mipmap
  - backfaceCull -> backfaceCulling
  - lighting -> useLight
- Fix InstancingEngine and IndirectEngine not binding overlay texture
and setting unnecessary render state
- Fix indirect internal shaders applying light twice
- Fix internal shaders using removed ALPHA_CUTOFF define
- Rename some variables and functions in shader files
- Separate MaterialUtil into MaterialRenderState and MaterialEncoder
- Delete unused Textures class
2023-12-03 18:13:39 -08:00
Jozufozu
4f8e6af3d0 Laying out the API
- Remove BufferLayout from VertexType.
- Remove VertexType from mesh, and only allow writes to a VertexList.
- MeshPools directly refer to BufferLayout instead of going through
  VertexType.
2023-12-03 17:03:13 -08:00
Jozufozu
733d43e3b9 Blocks all the way down
- Instancing and indirect backends use the block format internally.
- Remove layout shaders.
- Do not compile against VertexType.
- Do not sort draw calls by VertexType.
- Remove VertexType#REGISTRY.
2023-12-03 16:27:18 -08:00
Jozufozu
d4426a5f6c Looks good to me
- Make SimpleMaterial.Builder implement Material itself.
- Add way to copy a material.
- Move fog/cutout shaders to their own utility classes.
- Fix crumbling on cutout materials by overriding properties.
- Add helper in glsl for unpacking 2 shorts from one uint.
- Remove Fog enum.
2023-12-02 13:08:53 -08:00
Jozufozu
8a4d319d8d Fog so thick you could cut it
- Add generic ResourceLocation Index in ShaderIndices.
- Add FogShader and CutoutShader API.
- Implement existing fog/cutout configurations as separate shaders.
- Simplify pipeline shaders to accommodate for new api.
- Separate fog and cutout ubershader components.
  - This was much easier than I anticipated, seems we finally have a
    usable compiler/shader stitcher.
- Pass fog and cutout IDs to ubershader via a 2x16 packed uint.
- Remove discardPredicate and fogFilter from default material shader.
2023-12-02 13:08:25 -08:00
Jozufozu
5ae01e4899 We have shards at home
- Break material setup into constituent parts.
- Sort materials by what they setup.
- Fix some shader issues.
2023-12-02 00:40:54 -08:00
Jozufozu
90ae50a5ca Cut it out!
- Down to just one material shader.
- May need some better examples?
2023-12-01 23:59:51 -08:00
Jozufozu
eb60e7d179 Usurper materials, do you have any last words?
- Pipeline shaders now implement all currently used material properties.
- Rename flw_initVertex/flw_initFragment to flw_begin*.
- Rename flw_contextVertex/flw_contextFragment to flw_end*.
- Bind the diffuse texture by hand instead of calling bindActive.
- Add cutout property to materials that need it.
2023-12-01 23:44:04 -08:00
Jozufozu
4cccc9214c Something is materializing
- Add flw_material struct to the shader api.
- Initialized by the pipeline.
2023-12-01 13:51:34 -08:00
Jozufozu
a1ff8dbc0f Make it even shadier
- Reorganize internal package based on backend.
- Add api redefinitions in separate files.
- When compiling, insert pipeline api impls at the top.
2023-12-01 13:18:05 -08:00
Jozufozu
d730ab02a9 A shady API
- Remove storage qualifiers and compile guards from api sources.
- Replace api sources with empty stubs by poisoning the ShaderSources
  cache.
- Pipelines redefine the shader api and are inserted at the top of a
  compilation.
- Declare shader api methods in api sources.
- Fix crash in ErrorBuilder#pointAtLine
2023-12-01 00:26:02 -08:00
Jozufozu
b947470089 Materials and You: Volume 2
- Make the state provided by materials explicit
- Add utility to pack material properties into an int for use in shaders
2023-11-30 23:16:23 -08:00
Jozufozu
b7cbc29764 Put a lid on it
- Apply lid transform in ChestVisual#init.
- Fixes a horrifying bug where all chest lids you haven't looked
  directly at yet appear coinciding at the origin.
2023-11-30 17:14:09 -08:00
Jozufozu
0b165df0e9 More direct buffers
- Merge object and batch ID buffer.
- ShaderCompiler accepts a Compilation callback.
- Use callback to enable the conservative depth extension only in
  fragment shaders.
- Query subgroup size if available and use callback to set a compile
  definition in compute shaders.
2023-11-30 15:45:11 -08:00
PepperCode1
ddd159bb6c Materials and You: Volume 1
- Add MaterialShaders
  - MaterialShaders must be registered
  - Materials are no longer registered
  - Material now returns a MaterialShaders instead of the locations of
each shader
- Rename MaterialIndices to MaterialShaderIndicies
- Improve MaterialShaderIndicies and move it to the backend package
- Use RegisterClientReloadListenersEvent instead of adding listeners
manually
2023-11-30 15:38:14 -08:00