Allow passing external_memory in vulkan-hal::Device::texture_from_raw() (#8512)

This commit is contained in:
s-ol 2025-11-11 17:01:02 +01:00 committed by GitHub
parent 81dfcaf664
commit d017d48b45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -123,6 +123,7 @@ By @SupaMaggie70Incorporated in [#8206](https://github.com/gfx-rs/wgpu/pull/8206
- Validation errors from `CommandEncoder::finish()` will report the label of the invalid encoder. By @kpreid in [#8449](https://github.com/gfx-rs/wgpu/pull/8449).
- Corrected documentation of the minimum alignment of the *end* of a mapped range of a buffer (it is 4, not 8). By @kpreid in [#8450](https://github.com/gfx-rs/wgpu/pull/8450).
- `util::StagingBelt` now takes a `Device` when it is created instead of when it is used. By @kpreid in [#8462](https://github.com/gfx-rs/wgpu/pull/8462).
- `wgpu_hal::vulkan::Device::texture_from_raw` now takes an `external_memory` argument. By @s-ol in [#8512](https://github.com/gfx-rs/wgpu/pull/8512)
### Bug Fixes

View File

@ -488,11 +488,14 @@ impl super::Device {
/// - If `drop_callback` is [`None`], wgpu-hal will take ownership of `vk_image`. If
/// `drop_callback` is [`Some`], `vk_image` must be valid until the callback is called.
/// - If the `ImageCreateFlags` does not contain `MUTABLE_FORMAT`, the `view_formats` of `desc` must be empty.
/// - If `external_memory` is [`Some`], wgpu-hal will take ownership of the memory (which is presumed to back
/// `vk_image`). If `external_memory` is [`None`], the memory must be valid until `drop_callback` is called.
pub unsafe fn texture_from_raw(
&self,
vk_image: vk::Image,
desc: &crate::TextureDescriptor,
drop_callback: Option<crate::DropCallback>,
external_memory: Option<vk::DeviceMemory>,
) -> super::Texture {
let mut raw_flags = vk::ImageCreateFlags::empty();
let mut view_formats = vec![];
@ -518,7 +521,7 @@ impl super::Device {
super::Texture {
raw: vk_image,
drop_guard,
external_memory: None,
external_memory,
block: None,
format: desc.format,
copy_size: desc.copy_extent(),