1
0
Fork 0
forked from wry/wry

vulkan: enforce that dmabuf buffers are aligned to 4 bytes

This commit is contained in:
Julian Orth 2025-10-01 19:25:56 +02:00
parent 3e52e4266f
commit 09a56edd47
2 changed files with 7 additions and 0 deletions

View file

@ -16,6 +16,8 @@ use {
uapi::OwnedFd,
};
pub(super) const TRANSFER_QUEUE_BUFFER_ALIGNMENT: u64 = 4;
pub struct VulkanDmabufBuffer {
pub(super) device: Rc<VulkanDevice>,
pub(super) size: u64,
@ -31,6 +33,9 @@ impl VulkanDevice {
offset: u64,
size: u64,
) -> Result<Rc<VulkanDmabufBuffer>, VulkanError> {
if offset % TRANSFER_QUEUE_BUFFER_ALIGNMENT != 0 {
return Err(VulkanError::DmaBufBufferOffsetAlignment);
}
let mut memory_fd_properties = MemoryFdPropertiesKHR::default();
unsafe {
self.external_memory_fd