vulkan: enforce that dmabuf buffers are aligned to 4 bytes
This commit is contained in:
parent
3e52e4266f
commit
09a56edd47
2 changed files with 7 additions and 0 deletions
|
|
@ -223,6 +223,8 @@ pub enum VulkanError {
|
||||||
GetFl(#[source] OsError),
|
GetFl(#[source] OsError),
|
||||||
#[error("GBM implementation cannot be used with software renderer")]
|
#[error("GBM implementation cannot be used with software renderer")]
|
||||||
SoftwareRendererNotUsable,
|
SoftwareRendererNotUsable,
|
||||||
|
#[error("DMABUF buffer offsets must be aligned to 4 bytes")]
|
||||||
|
DmaBufBufferOffsetAlignment,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<VulkanError> for GfxError {
|
impl From<VulkanError> for GfxError {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ use {
|
||||||
uapi::OwnedFd,
|
uapi::OwnedFd,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub(super) const TRANSFER_QUEUE_BUFFER_ALIGNMENT: u64 = 4;
|
||||||
|
|
||||||
pub struct VulkanDmabufBuffer {
|
pub struct VulkanDmabufBuffer {
|
||||||
pub(super) device: Rc<VulkanDevice>,
|
pub(super) device: Rc<VulkanDevice>,
|
||||||
pub(super) size: u64,
|
pub(super) size: u64,
|
||||||
|
|
@ -31,6 +33,9 @@ impl VulkanDevice {
|
||||||
offset: u64,
|
offset: u64,
|
||||||
size: u64,
|
size: u64,
|
||||||
) -> Result<Rc<VulkanDmabufBuffer>, VulkanError> {
|
) -> Result<Rc<VulkanDmabufBuffer>, VulkanError> {
|
||||||
|
if offset % TRANSFER_QUEUE_BUFFER_ALIGNMENT != 0 {
|
||||||
|
return Err(VulkanError::DmaBufBufferOffsetAlignment);
|
||||||
|
}
|
||||||
let mut memory_fd_properties = MemoryFdPropertiesKHR::default();
|
let mut memory_fd_properties = MemoryFdPropertiesKHR::default();
|
||||||
unsafe {
|
unsafe {
|
||||||
self.external_memory_fd
|
self.external_memory_fd
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue