fix: Move DropGuards to the end of their parent structs. (#8353)

This commit is contained in:
Jerzy Wilczek 2025-10-16 21:58:18 +02:00 committed by GitHub
parent 756dd3c089
commit a70b8336c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 4 deletions

View File

@ -93,6 +93,10 @@ SamplerDescriptor {
- 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).
#### hal
- `DropCallback`s are now called after dropping all other fields of their parent structs. By @jerzywilczek in [#8353](https://github.com/gfx-rs/wgpu/pull/8353)
## v27.0.2 (2025-10-03)
### Bug Fixes

View File

@ -408,13 +408,16 @@ impl TextureInner {
#[derive(Debug)]
pub struct Texture {
pub inner: TextureInner,
pub drop_guard: Option<crate::DropGuard>,
pub mip_level_count: u32,
pub array_layer_count: u32,
pub format: wgt::TextureFormat,
#[allow(unused)]
pub format_desc: TextureFormatDesc,
pub copy_size: CopyExtent,
// The `drop_guard` field must be the last field of this struct so it is dropped last.
// Do not add new fields after it.
pub drop_guard: Option<crate::DropGuard>,
}
impl crate::DynTexture for Texture {}

View File

@ -156,7 +156,6 @@ pub struct DebugUtilsMessengerUserData {
pub struct InstanceShared {
raw: ash::Instance,
extensions: Vec<&'static CStr>,
drop_guard: Option<crate::DropGuard>,
flags: wgt::InstanceFlags,
memory_budget_thresholds: wgt::MemoryBudgetThresholds,
debug_utils: Option<DebugUtils>,
@ -171,6 +170,10 @@ pub struct InstanceShared {
/// It is associated with a `VkInstance` and its children,
/// except for a `VkPhysicalDevice` and its children.
instance_api_version: u32,
// The `drop_guard` field must be the last field of this struct so it is dropped last.
// Do not add new fields after it.
drop_guard: Option<crate::DropGuard>,
}
pub struct Instance {
@ -715,7 +718,6 @@ struct DeviceShared {
family_index: u32,
queue_index: u32,
raw_queue: vk::Queue,
drop_guard: Option<crate::DropGuard>,
instance: Arc<InstanceShared>,
physical_device: vk::PhysicalDevice,
enabled_extensions: Vec<&'static CStr>,
@ -737,6 +739,10 @@ struct DeviceShared {
texture_identity_factory: ResourceIdentityFactory<vk::Image>,
/// As above, for texture views.
texture_view_identity_factory: ResourceIdentityFactory<vk::ImageView>,
// The `drop_guard` field must be the last field of this struct so it is dropped last.
// Do not add new fields after it.
drop_guard: Option<crate::DropGuard>,
}
impl Drop for DeviceShared {
@ -945,12 +951,15 @@ impl crate::DynAccelerationStructure for AccelerationStructure {}
#[derive(Debug)]
pub struct Texture {
raw: vk::Image,
drop_guard: Option<crate::DropGuard>,
external_memory: Option<vk::DeviceMemory>,
block: Option<gpu_alloc::MemoryBlock<vk::DeviceMemory>>,
format: wgt::TextureFormat,
copy_size: crate::CopyExtent,
identity: ResourceIdentity<vk::Image>,
// The `drop_guard` field must be the last field of this struct so it is dropped last.
// Do not add new fields after it.
drop_guard: Option<crate::DropGuard>,
}
impl crate::DynTexture for Texture {}