Add check for usage flag when writing to file
This commit is contained in:
parent
b36a6ec96c
commit
b1f4243ccf
1 changed files with 10 additions and 3 deletions
|
@ -129,7 +129,7 @@ impl ImageBuilder {
|
||||||
layers: preinitialized_image.layers,
|
layers: preinitialized_image.layers,
|
||||||
levels: 1,
|
levels: 1,
|
||||||
sample_count: preinitialized_image.sample_count,
|
sample_count: preinitialized_image.sample_count,
|
||||||
_usage: preinitialized_image.usage,
|
usage: preinitialized_image.usage,
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: check necessity
|
// TODO: check necessity
|
||||||
|
@ -414,7 +414,7 @@ impl ImageBuilder {
|
||||||
layers: info.vk_image_create_info.arrayLayers,
|
layers: info.vk_image_create_info.arrayLayers,
|
||||||
levels: info.vk_image_create_info.mipLevels,
|
levels: info.vk_image_create_info.mipLevels,
|
||||||
sample_count: info.vk_image_create_info.samples,
|
sample_count: info.vk_image_create_info.samples,
|
||||||
_usage: info.vk_image_create_info.usage,
|
usage: info.vk_image_create_info.usage,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ pub struct Image {
|
||||||
layers: u32, // array layers
|
layers: u32, // array layers
|
||||||
levels: u32, // mip map levels
|
levels: u32, // mip map levels
|
||||||
sample_count: VkSampleCountFlagBits,
|
sample_count: VkSampleCountFlagBits,
|
||||||
_usage: VkImageUsageFlagBits,
|
usage: VkImageUsageFlagBits,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Image {
|
impl Image {
|
||||||
|
@ -779,6 +779,13 @@ impl Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_file(self: &Arc<Image>, path: impl AsRef<Path>) -> Result<()> {
|
pub fn to_file(self: &Arc<Image>, path: impl AsRef<Path>) -> Result<()> {
|
||||||
|
// check if image is created with correct usage flag that allows transfering data from it
|
||||||
|
if (self.usage | VK_IMAGE_USAGE_TRANSFER_SRC_BIT) == 0 {
|
||||||
|
return Err(anyhow::anyhow!(
|
||||||
|
"Image has not been create with VK_IMAGE_USAGE_TRANSFER_SRC_BIT flag!"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let buffer = self.copy_image_to_buffer()?;
|
let buffer = self.copy_image_to_buffer()?;
|
||||||
let memory = buffer.map_complete()?;
|
let memory = buffer.map_complete()?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue