[Refactor] Shared per-mesh vertex-stream binding helpers - #1130
Merged
untoldengine merged 2 commits intoAug 6, 2026
Conversation
Replace the nine open-coded per-mesh vertex buffer bind sites in the model-family and shadow-family passes with bindModelVertexStreams / bindShadowVertexStreams encoder helpers. Batched-geometry sites keep their raw batch-buffer binds. Also add a reader regression test covering unknown core-range chunk types so future format chunks cannot brick older runtimes. Groundwork for the deformation compute pass: the helpers are the single point where deformed position/normal buffers will replace the base streams.
untoldengine
reviewed
Aug 6, 2026
| // | ||
| // Shared per-mesh vertex-stream binding for the model-family and shadow-family | ||
| // render passes. | ||
| // |
Owner
There was a problem hiding this comment.
Nit picking here.
Can you add the proper license header:
//
// RenderVertexStreamBinding.swift
// UntoldEngine
//
// Copyright (C) Untold Engine Studios
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
bindModelVertexStreams/bindShadowVertexStreamsencoder helpers (Renderer/RenderVertexStreamBinding.swift) and replaces the nine open-coded per-mesh vertex-buffer bind sites across the model, shadow (CSM/spot/point), transparency, and wireframe passes plusRenderExtensionModelSurface. Batched-geometry sites keep their raw batch-buffer binds.testUnknownCoreChunkTypeIsIgnoredtoNativeFormatTests: a core-range chunk type unknown to the runtime must not prevent the rest of a.untoldasset from loading, locking in forward compatibility for future format chunks.Why
Every pass that draws meshes repeats the same six
setVertexBuffercalls plus thehasArmature/joint-matrix pair; the copies have already drifted stylistically and are easy to miss when the mesh streams evolve. Consolidating them into one helper makes future vertex-stream changes (e.g. GPU vertex deformation ahead of the shadow pass) a single-point edit. Zero behavior change intended.Notes for reviewers
metalKitMesh.vertexBuffersarray withmodelPass*enums while binding toshadowPass*slots — that was correct (the array is laid out in model-descriptor order); the helper now encodes the source-vs-destination distinction explicitly.hasArmatureusesgetEntityComponent(exists-guarded) instead of rawscene.get; equivalent on all current call paths.Verification
swift buildand the unit test target pass locally.developbaseline run: bit-identical.