Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/core/src/mesh/SkinnedMeshRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import { Skin, SkinUpdateFlag } from "./Skin";
* SkinnedMeshRenderer.
*/
export class SkinnedMeshRenderer extends MeshRenderer {
// @TODO: different shader type should use different count, not always 48
/** @internal */
static _baseVertexUniformVectorCount = 48;

private static _jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
private static _jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
private static _jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
Expand Down Expand Up @@ -163,8 +167,11 @@ export class SkinnedMeshRenderer extends MeshRenderer {

if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
// directly use max joint count to avoid shader recompile
// @TODO: different shader type should use different count, not always 44
const remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (44 + bsUniformOccupiesCount)) / 4);
const remainUniformJointCount = Math.ceil(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using Math.ceil here can overestimate remainUniformJointCount when the available uniform-vector budget isn’t divisible by 4, which may make RENDERER_JOINTS_NUM exceed MAX_VERTEX_UNIFORM_VECTORS and cause shader compile failures on some devices. Consider rounding down instead of up so the computed joint limit always stays within the reported uniform budget.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

(this._maxVertexUniformVectors -
(SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) /
4
);

if (boneCount > remainUniformJointCount) {
const engine = this.engine;
Expand Down
Loading