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

Port FRAPI to 1.21.4 and refactor #4247

Merged
merged 7 commits into from
Dec 2, 2024

Conversation

PepperCode1
Copy link
Member

@PepperCode1 PepperCode1 commented Nov 24, 2024

  • Port to 1.21.4
    • Change glint material property type from TriState to new GlintMode enum, due to addition of vanilla ItemRenderState.Glint enum
    • Remove ItemStack and ModelTransformationMode parameters from emitItemQuads to preserve contract of ItemRenderState
    • Implement FabricBakedModel methods on vanilla's WrapperBakedModel
  • Apply refactors and breaking changes
    • Move hasTransform, pushTransform, and popTransform from RenderContext to QuadEmitter to make the system more flexible and allow mesh builder emitters to also have transforms
    • Remove RenderContext and inline remaining parameters to emit* methods; allows outputting model to arbitrary emitter, invoking model from arbitrary location, and having better control over early culling
    • Convert MeshBuilder to MutableMesh, which has more functionality necessary for advanced use cases
    • Add Mesh#size
    • Remove RendererAccess and add static Renderer#get and #register instead
    • Disallow Renderer retrieval from returning a null value
    • Set default vertex color to 0xFFFFFFFF instead of 0
    • Remove QuadEmitter#hasTransform as it is no longer necessary for its original purpose
    • Remove disableColorIndex material property
    • Rename colorIndex methods to tintIndex in QuadView and MutableQuadView to match FabricMC/yarn@6d2cb31
    • Change QuadView#faceNormal to return a Vector3fc instead of a Vector3f
    • Remove ForwardingBakedModel as it is similar enough to vanilla's new WrapperBakedModel
    • Remove WrapperBakedModel as it was moved to Model Loading API v1 in Update Model Loading API to 1.21.4 #4243
    • Remove deprecated methods
  • Change MeshImpl to use a static cursor pool to save on memory and to allow nesting access to cursor on a thread
  • Disallow MutableQuadViewImpl#material from accepting a null material (in the API, the material parameter was already not nullable)
  • Precompute default quad data buffer instead of using zeroed buffer and setting defaults every time in MutableQuadViewImpl#clear
  • Optimize MutableQuadViewImpl#copyFrom by not precomputing geometry
  • Remove "compatibility mode" from Indigo

TODO

  • Allow QuadTransforms to say that they do not need to receive quads that will be culled in one way or another - "post-cull transforms". Utilizing this functionality in a custom model can significantly improve performance in some cases. [May require a breaking change]
    Resolution: Update documentation to make it clear that emitter.hasTransforms() does not need to be checked to perform early culling.
  • Add a MutableMesh/QuadBuffer which automatically grows and serves like a List<MutableQuadView>. This can make models that need to analyze submodels or perform 1:N transforms on submodels significantly more efficient, and make it easier to create such models. [May require a breaking change]
    Resolution: MeshBuilder was converted to MutableMesh with the necessary new methods.
  • Decide the fate of WrapperBakedModel and ForwaringBakedModel now that vanilla added its own WrapperBakedModel, which is very similar to ForwardingBakedModel. [May require a breaking change]
    Resolution: Remove ForwardingBakedModel and move WrapperBakedModel to Model Loading API with some changes.
  • Consider re-adding ModelTransformationMode parameter to emitItemQuads since it is an enum value and is passed to ItemRenderer#renderItem (where Indigo hooks into item rendering) anyway. [May require a breaking change]
    Resolution: Not re-added.
  • Consider removing QuadEmitter#hasTransform now that its initial purpose has been replaced by the cullTest parameter. [May require a breaking change]
    Resolution: Removed. Can be re-added later without a user-facing breaking change if necessary.
  • Consider exposing MutableQuadView#clear as public API.
    Resolution: Not exposed. Can be exposed later without a user-facing breaking change if necessary.
  • Finish porting FRAPI test mod and add new tests; Merging Update Model Loading API to 1.21.4 #4243 is a prerequisite.
  • Finish documentation.

- Port to 1.21.4
  - Change `glint` material property type from `TriState` to new `GlintMode` enum, due to addition of vanilla `ItemRenderState.Glint` enum
  - Remove `ItemStack` and `ModelTransformationMode` parameters from `emitItemQuads` to preserve contract of `ItemRenderState`
- Apply refactors and breaking changes
  - Move `hasTransform`, `pushTransform`, and `popTransform` from `RenderContext` to `QuadEmitter` to make the system more flexible and allowing mesh builder emitters to also have transforms
  - Remove `RenderContext` and inline remaining parameters to `emit*` methods; allows outputting model to arbitrary emitter and invoking model from arbitrary location
  - Remove `RendererAccess` and add static `Renderer#get` and `#register` instead
  - Disallow `Renderer` retrieval from returning a null value
  - Change `QuadView#faceNormal` to return a `Vector3fc` instead of a `Vector3f`
  - Remove deprecated methods
- Change `MeshImpl` to use a static cursor pool to save on memory and to allow nesting access to cursor on a thread
- Remove "compatibility mode" from Indigo
This allows a model to control which quads a submodel can cull early irrespective of transforms. Forwarding the test to the submodel will make it so pushed transforms may not receive quads that will be culled. The previous behavior of pushing a transform disabling early culling can now be achieved by passing `face -> false` to the submodel.
- Remove disableColorIndex material property
- Rename colorIndex methods to tintIndex in QuadView and MutableQuadView to match recent Yarn rename
- Remove ForwardingBakedModel and WrapperBakedModel
  - Vanilla's new WrapperBakedModel is similar enough to ForwardingBakedModel
  - WrapperBakedModel will be moved to Model Loading API v1 in a different PR
- Set default vertex color to 0xFFFFFFFF instead of 0
- Disallow MutableQuadView#material from accepting a null material
- Precompute default quad data buffer instead of using zeroed buffer and setting defaults every time
The error was caused by a classloading loop.
@PepperCode1 PepperCode1 added indigo Pull requests and issues related to Indigo's implementation of the rendering api port Porting existing code to a different version priority:high High priority PRs that need review and work now. Review these first. labels Nov 27, 2024
- Effectively split MeshBuilder#build into MutableMesh#immutableCopy and #clear
- Effectively add MutableMesh#forEachMutable
- Add Mesh#size
- Remove QuadEmitter#hasTransform
- Optimize MutableQuadViewImpl#copyFrom by not precomputing geometry
- Give UnwrappableBakedModel#unwrap a default implementation to prevent issues with interface injection
- Finish porting FRAPI and Model Loading API testmods
Copy link
Member

@modmuss50 modmuss50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

@modmuss50 modmuss50 merged commit 84404cd into FabricMC:1.21.4 Dec 2, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
indigo Pull requests and issues related to Indigo's implementation of the rendering api port Porting existing code to a different version priority:high High priority PRs that need review and work now. Review these first.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants