Skip to content
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

Import image from dma_buf following VK_EXT_external_memory_dma_buf #2145

Merged
merged 13 commits into from
Apr 1, 2023
Merged
6 changes: 5 additions & 1 deletion vulkano/src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ pub use self::{
attachment::AttachmentImage,
immutable::ImmutableImage,
layout::{ImageDescriptorLayouts, ImageLayout},
storage::{StorageImage, SubresourceData},
storage::StorageImage,
swapchain::SwapchainImage,
sys::ImageError,
traits::{ImageAccess, ImageInner},
usage::ImageUsage,
view::{ImageViewAbstract, ImageViewType},
};

#[cfg(target_os = "linux")]
pub use self::storage::SubresourceData;

use crate::{
format::Format,
macros::{vulkan_bitflags, vulkan_bitflags_enum, vulkan_enum},
Expand Down
25 changes: 19 additions & 6 deletions vulkano/src/image/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,35 @@ use super::{
use crate::{
device::{Device, DeviceOwned, Queue},
format::Format,
image::{sys::ImageCreateInfo, view::ImageView, ImageFormatInfo, ImageTiling},
image::{sys::ImageCreateInfo, view::ImageView, ImageFormatInfo},
memory::{
allocator::{
AllocationCreateInfo, AllocationType, MemoryAlloc, MemoryAllocatePreference,
AllocationCreateInfo, AllocationType, MemoryAllocatePreference,
MemoryAllocator, MemoryUsage,
},
DedicatedAllocation, DeviceMemory, DeviceMemoryError, ExternalMemoryHandleType,
ExternalMemoryHandleTypes, MemoryAllocateFlags, MemoryAllocateInfo,
DedicatedAllocation, DeviceMemoryError, ExternalMemoryHandleType,
ExternalMemoryHandleTypes,
},
sync::Sharing,
DeviceSize,
};
use ash::vk::{ImageDrmFormatModifierExplicitCreateInfoEXT, SubresourceLayout};
use smallvec::SmallVec;

#[cfg(target_os = "linux")]
use std::os::unix::prelude::{FromRawFd, IntoRawFd, RawFd};
#[cfg(target_os = "linux")]
use ash::vk::{ImageDrmFormatModifierExplicitCreateInfoEXT, SubresourceLayout};
#[cfg(target_os = "linux")]
use crate::{
image::ImageTiling,
memory::{
allocator::MemoryAlloc,
DeviceMemory,
MemoryAllocateFlags,
MemoryAllocateInfo
}
};

use std::{
fs::File,
hash::{Hash, Hasher},
Expand Down Expand Up @@ -351,7 +364,7 @@ impl StorageImage {
.bind_memory_unchecked([x])
.map_err(|(err, _, _)| err)?
});
Ok(Arc::new(StorageImage { inner }))
Ok(Arc::new(StorageImage { inner, layout_initialized: AtomicBool::new(false) }))
}
/// Allows the creation of a simple 2D general purpose image view from `StorageImage`.
#[inline]
Expand Down