Skip to content

Commit 1f23bd4

Browse files
pipeline builder | sizeof for VMAImage formats
1 parent 0172a8a commit 1f23bd4

File tree

9 files changed

+394
-395
lines changed

9 files changed

+394
-395
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ env_logger = {version = "0.9.0", features = ["termcolor", "humantime"]}
2020
log = { version = "0.4.17"}
2121
thiserror = "1.0.40"
2222
shaderc = { version = "0.8.0", optional = true }
23+
itertools = "0.10.5"
2324

2425
[dev-dependencies]
2526
winit = "0.28.3"

src/create_info.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct VkInitCreateInfo {
3333
//Surface
3434
pub surface_format: Format,
3535
pub depth_format: Format,
36+
pub depth_format_sizeof: usize,
3637
pub request_img_count: u32,
3738
pub present_mode: PresentModeKHR,
3839
pub clear_color_value: ClearColorValue,
@@ -86,6 +87,7 @@ impl VkInitCreateInfo {
8687
Format::R8G8B8A8_UNORM
8788
},
8889
depth_format: Format::D32_SFLOAT,
90+
depth_format_sizeof: 4,
8991
request_img_count: 3,
9092
present_mode: PresentModeKHR::FIFO,
9193
clear_color_value: ClearColorValue {

src/imports.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pub(crate) use ash::extensions::{
22
ext::DebugUtils,
33
khr::{Surface, Swapchain},
44
};
5-
pub(crate) use ash::util::read_spv;
65
pub(crate) use ash::vk::*;
76
pub(crate) use ash::{Device, Entry, Instance};
87

@@ -12,9 +11,7 @@ pub(crate) use raw_window_handle::RawWindowHandle;
1211
pub(crate) use std::{
1312
borrow::Cow,
1413
ffi::{CStr, CString},
15-
io::Cursor,
1614
mem::size_of,
17-
path::Path,
1815
result::Result,
1916
};
2017
pub(crate) use vma::{

src/init.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub struct Head {
4545
pub clear_depth_stencil_value: ClearDepthStencilValue,
4646
pub surface_info: SurfaceInfo,
4747
pub depth_format: Format,
48+
pub depth_format_sizeof: usize,
4849
pub depth_image: VMAImage,
4950
}
5051

@@ -1170,13 +1171,15 @@ impl VkInit {
11701171
allocator: &Allocator,
11711172
window_size: [u32; 2],
11721173
format: Format,
1174+
sizeof: usize,
11731175
) -> Result<VMAImage, Error> {
11741176
let depth_extent = Extent3D {
11751177
width: window_size[0],
11761178
height: window_size[1],
11771179
depth: 1,
11781180
};
1179-
let depth_image = VMAImage::create_depth_image(device, allocator, depth_extent, format)?;
1181+
let depth_image =
1182+
VMAImage::create_depth_image(device, allocator, depth_extent, format, sizeof)?;
11801183

11811184
Ok(depth_image)
11821185
}
@@ -1205,8 +1208,13 @@ impl VkInit {
12051208
Self::create_swapchain(instance, device, &surface, &surface_info, window_size)?;
12061209
let (swapchain_images, swapchain_image_views) =
12071210
Self::create_swapchain_images(device, &swapchain_loader, &swapchain, &surface_info)?;
1208-
let depth_image =
1209-
Self::create_depth_image(device, allocator, window_size, create_info.depth_format)?;
1211+
let depth_image = Self::create_depth_image(
1212+
device,
1213+
allocator,
1214+
window_size,
1215+
create_info.depth_format,
1216+
create_info.depth_format_sizeof,
1217+
)?;
12101218

12111219
Ok(Head {
12121220
surface_loader,
@@ -1219,6 +1227,7 @@ impl VkInit {
12191227
clear_depth_stencil_value: create_info.clear_depth_stencil_value,
12201228
surface_info,
12211229
depth_format: create_info.depth_format,
1230+
depth_format_sizeof: create_info.depth_format_sizeof,
12221231
depth_image,
12231232
})
12241233
}

src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod error;
66
mod image_layout_transitions;
77
mod imports;
88
mod init;
9-
mod renderer;
9+
mod pipeline_builder;
1010
mod shader;
1111
mod swapchain;
1212
mod vma_buffer;
@@ -16,10 +16,9 @@ pub use ash;
1616
pub use compute_shader::ComputeShader;
1717
pub use create_info::VkInitCreateInfo;
1818
pub use error::Error;
19-
pub use init::{CmdType, PhysicalDeviceInfo, SurfaceInfo, VkInit};
20-
pub use renderer::{
21-
BaseRenderer, BlendMode, DepthTest, RendererCreateInfo, SampleMode, VertexConvert,
22-
};
19+
pub use init::*;
20+
pub use pipeline_builder::*;
21+
2322
#[cfg(feature = "shader")]
2423
pub use shader::{compile_all_shaders, shader_ad_hoc};
2524
pub use vma_buffer::VMABuffer;

0 commit comments

Comments
 (0)