Crates.io | vku |
lib.rs | vku |
version | 0.3.0 |
source | src |
created_at | 2023-04-08 17:09:04.544844 |
updated_at | 2023-11-05 16:06:08.950635 |
description | Utility crate for kickstarting vulkan development |
homepage | |
repository | https://github.com/ArrowMaxGithub/vku |
max_upload_size | |
id | 833704 |
size | 146,900 |
Work in progress utility crate for kickstarting vulkan development with shaderc, ash and the gpu-allocator.
Center module is Vkinit, created from RawHandles and VkInitCreateInfo.
This is mostly a personal utility crate and no guarentees are made in terms of stability until 1.0.0.
use winit::window::WindowBuilder;
use winit::event_loop::{EventLoop, EventLoopBuilder};
use winit::dpi::LogicalSize;
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use vku::{VkInitCreateInfo, VkInit};
fn main() -> Result<(), vku::Error>{
let event_loop: EventLoop<()> = EventLoopBuilder::default().build();
let size = [800_u32, 600_u32];
let window = WindowBuilder::new()
.with_inner_size(LogicalSize{width: size[0], height: size[1]})
.build(&event_loop)
.unwrap();
let create_info = VkInitCreateInfo::default();
let vk_init = VkInit::new(Some(&window), Some(size), create_info)?;
Ok(())
}
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
use vku::VkInit;
use winit::window::Window;
fn main() -> Result<(), vku::Error>{
let window: Window = todo!();
let mut vk_init: VkInit = todo!();
let new_size = [1200_u32, 900_u32];
vk_init.on_resize(&window, new_size)?;
Ok(())
}
use vku::{VkInit, CmdType};
use ash::vk::{Extent3D, Format, ImageAspectFlags, ImageLayout};
fn main() -> Result<(), vku::Error>{
let vk_init: VkInit = todo!();
let setup_cmd_buffer_pool =
vk_init.create_cmd_pool(CmdType::Any)?;
let setup_cmd_buffer =
vk_init.create_command_buffers(&setup_cmd_buffer_pool, 1)?[0];
let setup_fence = vk_init.create_fence()?;
vk_init.begin_cmd_buffer(&setup_cmd_buffer)?;
let extent = Extent3D{width: 100, height: 100, depth: 1};
let format = Format::R8G8B8A8_UNORM;
let format_bytes = 4;
let aspect_flags = ImageAspectFlags::COLOR;
let mut image = vk_init.create_empty_image(extent, format, format_bytes, aspect_flags)?;
let image_barrier = image.get_image_layout_transition_barrier2(
ImageLayout::TRANSFER_DST_OPTIMAL,
None, None)?; // No queue family ownership transfer
vk_init.cmd_pipeline_barrier2(
&setup_cmd_buffer,
&[image_barrier], &[]); // Only this image barrier, no BufferMemoryBarriers
vk_init.end_and_submit_cmd_buffer(
&setup_cmd_buffer,
CmdType::Any,
&setup_fence, &[], &[], &[])?; // Wait on setup fence, wait/signal no semaphores
Ok(())
}
fn main() -> Result<(), vku::Error>{
let src_dir_path = std::path::Path::new("./assets/shaders/src/");
let target_dir_path = std::path::Path::new("./assets/shaders/compiled_shaders/");
let debug_text_result = true;
vku::compile_all_shaders(&src_dir_path, &target_dir_path, debug_text_result)?;
Ok(())
}