Commit f0e45b059808
tarball3 files changed+10-2
@@ -269,6 +269,7 @@ pub(crate) fn import(
269269
format.code,270270
size.0,271271
size.1,272
+ usage,272273
true,273274
)274275
}@@ -25,6 +25,7 @@ pub(crate) struct ImageInner {
2525
pub format: vk::Format,2626
pub width: u32,2727
pub height: u32,28
+ pub usage: vk::ImageUsageFlags,2829
pub layout: Mutex<vk::ImageLayout>,2930
/// Shared with other devices or processes through a dmabuf. Every use3031
/// acquires the image from the foreign queue family and releases it after.@@ -117,7 +118,7 @@ impl ImageInner {
117118
Memory::Imported(m) => (*m, 0),118119
};119120
Self::finish(120
- shared, image, memory, mem, offset, fourcc, width, height, false,121
+ shared, image, memory, mem, offset, fourcc, width, height, usage, false,121122
)122123
}123124
@@ -133,6 +134,7 @@ impl ImageInner {
133134
fourcc: Fourcc,134135
width: u32,135136
height: u32,137
+ usage: vk::ImageUsageFlags,136138
external: bool,137139
) -> Result<Arc<Self>, Error> {138140
let fmt = vk_format(fourcc).ok_or(Error::UnsupportedFormat(fourcc))?;@@ -146,6 +148,7 @@ impl ImageInner {
146148
format: fmt.format,147149
width,148150
height,151
+ usage,149152
layout: Mutex::new(if external {150153
vk::ImageLayout::GENERAL151154
} else {@@ -1018,7 +1018,11 @@ impl ExportMem for VulkanRenderer {
10181018
}10191019
10201020
fn can_read_texture(&mut self, texture: &VulkanTexture) -> Result<bool, Error> {1021
- Ok(texture.0.external || texture.0.layout() != vk::ImageLayout::UNDEFINED)1021
+ let image = &texture.0;1022
+ let written = image.external1023
+ || image.layout() != vk::ImageLayout::UNDEFINED1024
+ || self.uploads.iter().any(|u| Arc::ptr_eq(&u.image, image));1025
+ Ok(written && image.usage.contains(vk::ImageUsageFlags::TRANSFER_SRC))10221026
}10231027
10241028
fn map_texture<'a>(&mut self, mapping: &'a VulkanMapping) -> Result<&'a [u8], Error> {