Skip to content

Commit 7f28a4c

Browse files
committed
fix: Move DropGuards to the end of their parent structs.
This makes them be dropped after all other fields, which may be necessary, since the drop guard keeps the underlying resources alive.
1 parent f935660 commit 7f28a4c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ SamplerDescriptor {
9090

9191
- Align copies b/w textures and buffers via a single intermediate buffer per copy when `D3D12_FEATURE_DATA_D3D12_OPTIONS13.UnrestrictedBufferTextureCopyPitchSupported` is `false`. By @ErichDonGubler in [#7721](https://github.com/gfx-rs/wgpu/pull/7721).
9292

93+
#### hal
94+
95+
- `DropCallback`s are now called after dropping all other fields of their parent structs. By @jerzywilczek in [#99999](https://github.com/gfx-rs/wgpu/pull/99999)
96+
9397
## v27.0.2 (2025-10-03)
9498

9599
### Bug Fixes

wgpu-hal/src/gles/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,13 @@ impl TextureInner {
408408
#[derive(Debug)]
409409
pub struct Texture {
410410
pub inner: TextureInner,
411-
pub drop_guard: Option<crate::DropGuard>,
412411
pub mip_level_count: u32,
413412
pub array_layer_count: u32,
414413
pub format: wgt::TextureFormat,
415414
#[allow(unused)]
416415
pub format_desc: TextureFormatDesc,
417416
pub copy_size: CopyExtent,
417+
pub drop_guard: Option<crate::DropGuard>,
418418
}
419419

420420
impl crate::DynTexture for Texture {}

wgpu-hal/src/vulkan/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ pub struct DebugUtilsMessengerUserData {
156156
pub struct InstanceShared {
157157
raw: ash::Instance,
158158
extensions: Vec<&'static CStr>,
159-
drop_guard: Option<crate::DropGuard>,
160159
flags: wgt::InstanceFlags,
161160
memory_budget_thresholds: wgt::MemoryBudgetThresholds,
162161
debug_utils: Option<DebugUtils>,
@@ -171,6 +170,7 @@ pub struct InstanceShared {
171170
/// It is associated with a `VkInstance` and its children,
172171
/// except for a `VkPhysicalDevice` and its children.
173172
instance_api_version: u32,
173+
drop_guard: Option<crate::DropGuard>,
174174
}
175175

176176
pub struct Instance {
@@ -715,7 +715,6 @@ struct DeviceShared {
715715
family_index: u32,
716716
queue_index: u32,
717717
raw_queue: vk::Queue,
718-
drop_guard: Option<crate::DropGuard>,
719718
instance: Arc<InstanceShared>,
720719
physical_device: vk::PhysicalDevice,
721720
enabled_extensions: Vec<&'static CStr>,
@@ -737,6 +736,7 @@ struct DeviceShared {
737736
texture_identity_factory: ResourceIdentityFactory<vk::Image>,
738737
/// As above, for texture views.
739738
texture_view_identity_factory: ResourceIdentityFactory<vk::ImageView>,
739+
drop_guard: Option<crate::DropGuard>,
740740
}
741741

742742
impl Drop for DeviceShared {
@@ -945,12 +945,12 @@ impl crate::DynAccelerationStructure for AccelerationStructure {}
945945
#[derive(Debug)]
946946
pub struct Texture {
947947
raw: vk::Image,
948-
drop_guard: Option<crate::DropGuard>,
949948
external_memory: Option<vk::DeviceMemory>,
950949
block: Option<gpu_alloc::MemoryBlock<vk::DeviceMemory>>,
951950
format: wgt::TextureFormat,
952951
copy_size: crate::CopyExtent,
953952
identity: ResourceIdentity<vk::Image>,
953+
drop_guard: Option<crate::DropGuard>,
954954
}
955955

956956
impl crate::DynTexture for Texture {}

0 commit comments

Comments
 (0)