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

Merge MappedDeviceMemory into DeviceMemory, make MemoryAlloc reuse the logic #2300

Merged
merged 16 commits into from
Aug 24, 2023
14 changes: 12 additions & 2 deletions vulkano/src/memory/device_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ impl DeviceMemory {
}

fn validate_unmap(&self, unmap_info: &MemoryUnmapInfo) -> Result<(), Box<ValidationError>> {
let &MemoryUnmapInfo { flags: _, _ne: _ } = unmap_info;

if self.mapping_state.is_none() {
return Err(Box::new(ValidationError {
problem: "this device memory is not currently host-mapped".into(),
Expand All @@ -538,6 +536,10 @@ impl DeviceMemory {
}));
}

unmap_info
.validate(self)
.map_err(|err| err.add_context("unmap_info"))?;

Ok(())
}

Expand Down Expand Up @@ -1507,6 +1509,14 @@ pub struct MemoryUnmapInfo {
pub _ne: crate::NonExhaustive,
}

impl MemoryUnmapInfo {
pub(crate) fn validate(&self, _memory: &DeviceMemory) -> Result<(), Box<ValidationError>> {
let &Self { flags: _, _ne: _ } = self;
marc0246 marked this conversation as resolved.
Show resolved Hide resolved

Ok(())
}
}

impl Default for MemoryUnmapInfo {
#[inline]
fn default() -> Self {
Expand Down