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

Implement full support for Fabric Rendering API #1851

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

Technici4n
Copy link
Contributor

@Technici4n Technici4n commented Jun 27, 2023

This PR implements full FRAPI support for Sodium. There are 3 pipelines: terrain, non-terrain, and item rendering. Terrain meshing was converted to always go through a FRAPI-aware pipeline. This is a heavily modified Indigo pipeline with new optimizations to use Sodium's chunk meshing caches to the largest possible extent. Non-terrain and item pipelines are only used for FRAPI models, and as such most code comes from Indigo.

To test this PR, compare the performance of the two meshing pipelines by enabling and disabling the Enable FRAPI terrain pipeline option under performance.

Explanation of the implementation

Bundled Indigo

Everything under me.jellysquid.mods.sodium.client.frapi is directly copy-pasted from Indigo. This handles all the QuadView, Mesh and RenderMaterial encoding for us.

QuadViewImpl was modified to also store the Sprite, as Sodium uses it for animated texture optimization.

An exception is the render subpackage which contains Indigo code, but heavily modified for use in Sodium.

The AO calculations of Indigo were left out as Sodium already contains what is needed.

BlockRenderer

BlockRenderer is the core class of this PR. It is completely rewritten to use a FRAPI-aware pipeline, with some optimizations for vanilla models however.

The way this works is that the quads end up in processQuad where they are processed and buffered one-by-one.

The key question is how much performance we lose from having to perform a bunch of chunks for light mode, material, etc... for each quad. From my testing, the new FRAPI pipeline has comparable performance to the original Sodium pipeline. There is 15-20% overhead from FRAPI, but this is compensated by not having to go though WeightedBakedModel#getQuads 7 times per face, so overall the performance should be comparable to current Sodium.

Non-terrain block pipeline

This was ported from Indigo, then modified heavily to use Sodium's light pipeline. This is only used for specific calls to the BlockModelRenderer, and only for FRAPI models. The core class is NonTerrainBlockRenderContext.

Item pipeline

This pipeline was ported from Indigo too, and is only used for FRAPI item models. The core class is ItemRenderContext.

@Technici4n Technici4n changed the title Proof-of-concept support for FRAPI in terrain meshing FRAPI support Jun 29, 2023
@Technici4n Technici4n changed the title FRAPI support Full FRAPI support Jun 29, 2023
@Technici4n Technici4n marked this pull request as ready for review June 29, 2023 20:48
@Technici4n Technici4n force-pushed the frapi-support branch 2 times, most recently from 930db85 to 1307344 Compare July 2, 2023 21:23
@mrjasonn
Copy link

mrjasonn commented Jul 12, 2023

This really deserves to be used. It would be a very good feature. However, if it doesn't support Sodium 0.5, which we don't know as it's not released at the time of writing this, then it would need updating. Same with Fabric API and possibly Minecraft changes as well. @jellysquid3 if you haven't noticed this, this is actually decent. But it has to be stable enough that things won't break though which requires checking.

@Technici4n
Copy link
Contributor Author

It was noticed and discussed a bit already. It will not be in the 0.5 release, however it is likely that it will be in a subsequent one.

@mrjasonn
Copy link

It was noticed and discussed a bit already. It will not be in the 0.5 release, however it is likely that it will be in a subsequent one.

Then do you have any idea of which release it will be in? Will we need to wait until after the whole major 0.5 release or it will be in a release like 0.5.1? @Technici4n

@Technici4n
Copy link
Contributor Author

Unclear yet. For now you can use Indium.

@Onahil

This comment was marked as spam.

@TheUserCreated

This comment was marked as off-topic.

@Onahil

This comment was marked as spam.

@Onahil

This comment was marked as spam.

@TheUserCreated

This comment was marked as off-topic.

@jellysquid3
Copy link
Member

User was banned from the issue tracker for spamming issues & being utterly helpless.

@jellysquid3 jellysquid3 added this to the Sodium 0.6 milestone Aug 20, 2023
@jellysquid3
Copy link
Member

That distraction aside, this is something we want to focus on & get implemented/merged for the next major version of Sodium. It's long over-due.

@jellysquid3 jellysquid3 changed the title Full FRAPI support Implement full support for Fabric Rendering API Aug 20, 2023
@jellysquid3 jellysquid3 self-assigned this Aug 20, 2023
@jellysquid3 jellysquid3 added the A-mods Area: Mod compatibility label Aug 20, 2023
@Technici4n Technici4n changed the base branch from 1.20/dev to dev August 26, 2023 16:54
Proof-of-concept support for FRAPI in terrain meshing

Further changes and optimizations

Animate sprites again

Optimize random handling a little bit

Fix typo

Fix cached sprite handling

Convert bundled Indium code to spaces

set cachedSprite in spriteBake

Optimize BasicBakedModel#getQuads away

Missing license

Add item and non-terrain block contexts. Refactor terrain renderer

Remove slower meshing

Make QuadViewImpl implement a subset of ModelQuadView

Cache default model builder

Remove old pipeline and pipeline switch

Remove NestedModelAccessor stuff

Make contexts more similar

Small cleanup

Consolidate code a bit

Honor per-quad normals in BakedModelEncoder

Remove misleading comment
@Lolothepro

This comment was marked as resolved.

@jellysquid3 jellysquid3 removed their assignment Sep 18, 2023
@Lolothepro

This comment was marked as resolved.

- Fix FRAPI mixin config
- Use more efficient ARGB to ABGR conversion in FluidRenderer
- Fix BlockModelRendererMixin using tabs for indentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mods Area: Mod compatibility P-high Priority: High
Development

Successfully merging this pull request may close these issues.

None yet

8 participants