From 00204104dd75ef9e82c2f44c712a69f130dd1919 Mon Sep 17 00:00:00 2001 From: Asuro Date: Sun, 14 Mar 2021 16:27:32 +0100 Subject: [PATCH] stuff --- src/vulkan/dds.rs | 8 ++++++++ src/vulkan/mod.rs | 7 ++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vulkan/dds.rs b/src/vulkan/dds.rs index c818571..696338f 100644 --- a/src/vulkan/dds.rs +++ b/src/vulkan/dds.rs @@ -37,4 +37,12 @@ pub fn upload_texture_from_file(path: &str, renderer: &mut VulkanRenderer) -> Re } Ok(()) +} + +pub fn get_block_size(format: Format) -> Option { + match format { + Format::BC1_RGBUnormBlock => Some(8), + Format::BC5UnormBlock => Some(16), + _ => None + } } \ No newline at end of file diff --git a/src/vulkan/mod.rs b/src/vulkan/mod.rs index 7af8ca4..3e2f87c 100644 --- a/src/vulkan/mod.rs +++ b/src/vulkan/mod.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use std::time::SystemTime; use cgmath::{Matrix4, SquareMatrix}; +use dds::get_block_size; use vulkano::{buffer::{BufferUsage, CpuAccessibleBuffer}, command_buffer::{CommandBuffer, SubpassContents}, image::{ImageLayout, ImageUsage, MipmapsCount, immutable::SubImage}}; use vulkano::command_buffer::{AutoCommandBuffer, AutoCommandBufferBuilder, DynamicState}; use vulkano::descriptor::DescriptorSet; @@ -467,11 +468,7 @@ impl VulkanRenderer { let mut offset = 0; - let block_bytes = match format { - Format::BC1_RGBUnormBlock => 8, - Format::BC5UnormBlock => 16, - f => panic!(format!("Unknown texture format {:?}!", f)) - }; + let block_bytes = get_block_size(format).expect(&format!("Unknown texture format {:?}!", format)); for i in 0..image_view.mipmap_levels() { let mip_size = dimensions.to_image_dimensions().mipmap_dimensions(i).unwrap().width_height_depth();