Allow extra flags to copy buffer creation
This commit is contained in:
parent
eae46a0d5e
commit
872c858f9e
1 changed files with 11 additions and 3 deletions
|
@ -793,7 +793,7 @@ impl Image {
|
|||
));
|
||||
}
|
||||
|
||||
let buffer = self.copy_image_to_buffer()?;
|
||||
let buffer = self.copy_image_to_buffer(None)?;
|
||||
let memory = buffer.map_complete()?;
|
||||
|
||||
let image = image::RgbaImage::from_raw(
|
||||
|
@ -811,9 +811,17 @@ impl Image {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn copy_image_to_buffer(self: &Arc<Image>) -> Result<Arc<Buffer<RawBuffer>>> {
|
||||
pub fn copy_image_to_buffer(
|
||||
self: &Arc<Image>,
|
||||
extra_buffer_flags: impl Into<Option<VkBufferUsageFlagBits>>,
|
||||
) -> Result<Arc<Buffer<RawBuffer>>> {
|
||||
let usage = match extra_buffer_flags.into() {
|
||||
Some(flags) => VK_BUFFER_USAGE_TRANSFER_DST_BIT | flags,
|
||||
None => VK_BUFFER_USAGE_TRANSFER_DST_BIT.into(),
|
||||
};
|
||||
|
||||
let buffer = Buffer::builder()
|
||||
.set_usage(VK_BUFFER_USAGE_TRANSFER_DST_BIT)
|
||||
.set_usage(usage)
|
||||
.set_memory_usage(MemoryUsage::GpuToCpu)
|
||||
.set_size((self.width * self.height * 4) as VkDeviceSize)
|
||||
.build(self.device.clone())?;
|
||||
|
|
Loading…
Reference in a new issue