Claude/mod vertex buffer mismatch ml8oiq - #90
Merged
Conversation
Authored by Claude (claude-opus-5) Previously only the UByte4N decl type got stub bytes when a texture coordinate element had a semantic index > 0; every other type was skipped with a warning and nothing was written. If such an element was the last one in the vertex, the vertex ended up short and writeVertex failed with "Wrote an insufficient number of bytes for the vertex", which aborted the whole fill and prevented the mod from loading. This was hit by a d3d11 layout with TEXCOORD1 as R32G32_Float (wrote 40 of 48 bytes). Now a stub of the correct size is written for all texture coordinate types that are supported at semantic index 0, using a mid-range UV (0.5,0.5) and zeros for any extra components. Unknown types are zero filled using the element size; if even that can't be determined, nothing is written (the old behavior). The existing UByte4N stub is unchanged. The warning is now emitted once per fill from setup rather than from the per-vertex loop, so the stub bytes can also be precomputed there instead of being rebuilt for every vertex. Also factors the format size table out of MeshUtil.getVertSizeFromEls into getSizeFromFormat/getSizeFromElType so the stub code can use it.
Authored by Claude (claude-opus-5) The stub-data warning was emitted from the vertex fill, which is skipped entirely on a VBData disk cache hit. So it only appeared the first time a mod was loaded, and after that the fact that part of the vertex data is fake -- and that rendering may therefore be somewhat off -- was invisible in the log. Move the stub construction (makeTexCoordStub, plus a new buildTexCoordStubs that warns and returns the per-semantic-index map) to module scope and run it in fillModDataInternalHelper before the cache check, so the warning is logged on every load regardless of which path fills the buffer. The warning now also names the mod and says that rendering may be incorrect.
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.
No description provided.