render: add support for more formats
This commit is contained in:
parent
9d78231cac
commit
551dafcce8
13 changed files with 348 additions and 491 deletions
|
|
@ -130,6 +130,9 @@ impl VulkanInstance {
|
|||
format: &Format,
|
||||
props: &FormatProperties2,
|
||||
) -> Result<Option<VulkanShmFormat>, VulkanError> {
|
||||
if format.shm_info.is_none() {
|
||||
return Ok(None);
|
||||
}
|
||||
if !props
|
||||
.format_properties
|
||||
.optimal_tiling_features
|
||||
|
|
|
|||
|
|
@ -120,13 +120,16 @@ impl VulkanRenderer {
|
|||
data: &[Cell<u8>],
|
||||
for_download: bool,
|
||||
) -> Result<Rc<VulkanImage>, VulkanError> {
|
||||
let Some(shm_info) = &format.shm_info else {
|
||||
return Err(VulkanError::UnsupportedShmFormat(format.name));
|
||||
};
|
||||
if width <= 0 || height <= 0 || stride <= 0 {
|
||||
return Err(VulkanError::NonPositiveImageSize);
|
||||
}
|
||||
let width = width as u32;
|
||||
let height = height as u32;
|
||||
let stride = stride as u32;
|
||||
if stride % format.bpp != 0 || stride / format.bpp < width {
|
||||
if stride % shm_info.bpp != 0 || stride / shm_info.bpp < width {
|
||||
return Err(VulkanError::InvalidStride);
|
||||
}
|
||||
let vk_format = self
|
||||
|
|
|
|||
|
|
@ -294,9 +294,12 @@ impl VulkanRenderer {
|
|||
fn copy_shm_to_image(&self, cmd: CommandBuffer) {
|
||||
let memory = self.memory.borrow_mut();
|
||||
for (img, staging) in &memory.flush_staging {
|
||||
let Some(shm_info) = &img.format.shm_info else {
|
||||
continue;
|
||||
};
|
||||
let cpy = BufferImageCopy2::builder()
|
||||
.buffer_image_height(img.height)
|
||||
.buffer_row_length(img.stride / img.format.bpp)
|
||||
.buffer_row_length(img.stride / shm_info.bpp)
|
||||
.image_extent(Extent3D {
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
|
|
@ -751,7 +754,10 @@ impl VulkanRenderer {
|
|||
stride: u32,
|
||||
dst: &[Cell<u8>],
|
||||
) -> Result<(), VulkanError> {
|
||||
if stride < tex.width * tex.format.bpp || stride % tex.format.bpp != 0 {
|
||||
let Some(shm_info) = &tex.format.shm_info else {
|
||||
return Err(VulkanError::UnsupportedShmFormat(tex.format.name));
|
||||
};
|
||||
if stride < tex.width * shm_info.bpp || stride % shm_info.bpp != 0 {
|
||||
return Err(VulkanError::InvalidStride);
|
||||
}
|
||||
let size = stride as u64 * tex.height as u64;
|
||||
|
|
@ -759,7 +765,7 @@ impl VulkanRenderer {
|
|||
return Err(VulkanError::InvalidBufferSize);
|
||||
}
|
||||
let region = BufferImageCopy::builder()
|
||||
.buffer_row_length(stride / tex.format.bpp)
|
||||
.buffer_row_length(stride / shm_info.bpp)
|
||||
.buffer_image_height(tex.height)
|
||||
.image_subresource(ImageSubresourceLayers {
|
||||
aspect_mask: ImageAspectFlags::COLOR,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue