From b744fb486bf3cd53cafb6bf1863d24eeb7cfb800 Mon Sep 17 00:00:00 2001 From: Benjamin Brienen Date: Tue, 10 Dec 2024 03:03:51 +0100 Subject: [PATCH] Document why `MAX_JOINTS` and `MAX_MORPH_WEIGHTS` are set (#16324) # Objective Fixes #15974 ## Solution Add the comment from @mockersf, adapted to fix in-context. --- crates/bevy_pbr/src/render/mesh_bindings.rs | 6 ++++++ crates/bevy_pbr/src/render/skin.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/crates/bevy_pbr/src/render/mesh_bindings.rs b/crates/bevy_pbr/src/render/mesh_bindings.rs index cda05314fb..b458b3f98e 100644 --- a/crates/bevy_pbr/src/render/mesh_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_bindings.rs @@ -8,6 +8,12 @@ use bevy_render::{ use crate::render::skin::MAX_JOINTS; const MORPH_WEIGHT_SIZE: usize = size_of::(); + +/// This is used to allocate buffers. +/// The correctness of the value depends on the GPU/platform. +/// The current value is chosen because it is guaranteed to work everywhere. +/// To allow for bigger values, a check must be made for the limits +/// of the GPU at runtime, which would mean not using consts anymore. pub const MORPH_BUFFER_SIZE: usize = MAX_MORPH_WEIGHTS * MORPH_WEIGHT_SIZE; const JOINT_SIZE: usize = size_of::(); diff --git a/crates/bevy_pbr/src/render/skin.rs b/crates/bevy_pbr/src/render/skin.rs index b6f35fc0bf..1f1ba39f8b 100644 --- a/crates/bevy_pbr/src/render/skin.rs +++ b/crates/bevy_pbr/src/render/skin.rs @@ -15,6 +15,12 @@ use bevy_render::{ use bevy_transform::prelude::GlobalTransform; /// Maximum number of joints supported for skinned meshes. +/// +/// It is used to allocate buffers. +/// The correctness of the value depends on the GPU/platform. +/// The current value is chosen because it is guaranteed to work everywhere. +/// To allow for bigger values, a check must be made for the limits +/// of the GPU at runtime, which would mean not using consts anymore. pub const MAX_JOINTS: usize = 256; #[derive(Component)]