-
Notifications
You must be signed in to change notification settings - Fork 0
Updates #82
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
base: main
Are you sure you want to change the base?
Updates #82
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,13 +50,16 @@ impl Instances { | |
| } | ||
|
|
||
| /// Inserts instance transforms for a key. | ||
| pub fn transform_insert(&mut self, key: TransformKey, transforms: &[Transform]) { | ||
| pub fn transform_insert(&mut self, key: TransformKey, transforms: &[Transform]) -> Result<()> { | ||
| self.cpu_transforms.insert(key, transforms.to_vec()); | ||
| let bytes = Self::transforms_to_bytes(transforms); | ||
| self.transform_buffer.update(key, &bytes); | ||
| self.transform_buffer.update(key, &bytes).map_err(|e| { | ||
| AwsmInstanceError::BufferCapacityOverflow(format!("instance transforms: {e}")) | ||
| })?; | ||
| self.transform_count.insert(key, transforms.len()); | ||
| self.transform_gpu_dirty = true; | ||
| self.transform_dirty.insert(key); | ||
| Ok(()) | ||
| } | ||
|
Comment on lines
+58
to
63
|
||
|
|
||
| /// Updates a single instance transform. | ||
|
|
@@ -121,7 +124,11 @@ impl Instances { | |
| .get(key) | ||
| .ok_or(AwsmInstanceError::TransformNotFound(key))?; | ||
| let full_bytes = Self::transforms_to_bytes(full_list); | ||
| self.transform_buffer.update(key, &full_bytes); | ||
| self.transform_buffer | ||
| .update(key, &full_bytes) | ||
| .map_err(|e| { | ||
| AwsmInstanceError::BufferCapacityOverflow(format!("instance transforms: {e}")) | ||
| })?; | ||
| } | ||
| self.transform_count.insert(key, len); | ||
| self.transform_gpu_dirty = true; | ||
|
|
@@ -281,7 +288,11 @@ impl Instances { | |
| }; | ||
|
|
||
| existing_bytes.resize(desired_bytes, 0); | ||
| self.transform_buffer.update(key, &existing_bytes); | ||
| self.transform_buffer | ||
| .update(key, &existing_bytes) | ||
| .map_err(|e| { | ||
| AwsmInstanceError::BufferCapacityOverflow(format!("instance transforms: {e}")) | ||
| })?; | ||
| self.transform_gpu_dirty = true; | ||
| self.transform_dirty.insert(key); | ||
|
|
||
|
|
@@ -314,4 +325,7 @@ pub enum AwsmInstanceError { | |
|
|
||
| #[error("[instance] transform does not exist {0:?}")] | ||
| TransformNotFound(TransformKey), | ||
|
|
||
| #[error("[instance] buffer capacity overflow: {0}")] | ||
| BufferCapacityOverflow(String), | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,10 +178,18 @@ impl Materials { | |
| } | ||
|
|
||
| match material.uniform_buffer_data(textures) { | ||
| Ok(data) => { | ||
| self.buffer.update(key, &data); | ||
| self.gpu_dirty = true; | ||
| } | ||
| Ok(data) => match self.buffer.update(key, &data) { | ||
| Ok(_) => { | ||
| self.gpu_dirty = true; | ||
| } | ||
| Err(e) => { | ||
| tracing::error!( | ||
| "Failed to update material buffer for key {:?}: {:?}", | ||
| key, | ||
| e | ||
| ); | ||
| } | ||
| }, | ||
|
Comment on lines
180
to
+192
|
||
| Err(e) => { | ||
| tracing::error!( | ||
| "Failed to get uniform buffer data for material key {:?}: {:?}", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,8 +160,12 @@ impl<Key: slotmap::Key, Info: MorphInfo> MorphData<Key, Info> { | |
|
|
||
| let key = self.infos.insert(morph_buffer_info.clone()); | ||
|
|
||
| self.weights.update(key, weights); | ||
| self.values.update(key, values); | ||
| self.weights | ||
| .update(key, weights) | ||
| .map_err(|e| AwsmMeshError::BufferCapacityOverflow(format!("morph weights: {e}")))?; | ||
| self.values | ||
| .update(key, values) | ||
| .map_err(|e| AwsmMeshError::BufferCapacityOverflow(format!("morph values: {e}")))?; | ||
|
Comment on lines
161
to
+168
|
||
|
|
||
| self.weights_dirty = true; | ||
| self.values_dirty = true; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transform_insertchanged from returning()toResult<()>and the method ispubon apubtype. IfInstancesis part of the crate’s public API, this is a breaking change for downstream users. Consider either bumping the crate version appropriately, or adding a new fallible method (e.g.,try_transform_insert) while keeping the old signature for compatibility.