Skip to content

Commit

Permalink
Refactor surface handling logic in texture release.
Browse files Browse the repository at this point in the history
Simplify conditional branches by reducing nested matches and removing redundant code. This improves readability and maintains the intended functionality for surface texture management and resource cleanup.
  • Loading branch information
ygdrasil-io committed Jan 25, 2025
1 parent da90331 commit 452b21e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,15 @@ impl Drop for WGPUTextureImpl {
if thread::panicking() {
return;
}
match self.surface_id {
Some(surface_id) => {
if !self.has_surface_presented.load(atomic::Ordering::SeqCst) {
let context = &self.context;
match context.surface_texture_discard(surface_id) {
Ok(_) => (),
Err(cause) => handle_error_fatal(cause, "wgpuTextureRelease"),
}
if let Some(surface_id) = self.surface_id {
if !self.has_surface_presented.load(atomic::Ordering::SeqCst) {
match self.context.surface_texture_discard(surface_id) {
Ok(_) => (),
Err(cause) => handle_error_fatal(cause, "wgpuTextureRelease"),
}
}
None => {
let context = &self.context;
context.texture_drop(self.id);
}
}
self.context.texture_drop(self.id);
}
}

Expand Down

0 comments on commit 452b21e

Please sign in to comment.