From ab8e78e1b14100e71d04dfcc6bbda8c3c0a1e81a Mon Sep 17 00:00:00 2001 From: zack Date: Sat, 28 Dec 2024 19:08:21 -0500 Subject: [PATCH] fix build --- .cargo/config.toml | 3 ++ Cargo.toml | 1 + crates/rt-helper/src/lib.rs | 99 ------------------------------------ crates/vk-rs/src/renderer.rs | 2 +- 4 files changed, 5 insertions(+), 100 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..633f3d2 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[target.x86_64-pc-windows-msvc] +linker = "rust-lld.exe" +rustflags = ["-Zshare-generics=n"] diff --git a/Cargo.toml b/Cargo.toml index 0eaea7c..79ea904 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,3 +46,4 @@ codegen-units = 256 # # rustflags = ["-Zshare-generics=off"] codegen-units = 1 +opt-level = 3 diff --git a/crates/rt-helper/src/lib.rs b/crates/rt-helper/src/lib.rs index 0b58202..139597f 100644 --- a/crates/rt-helper/src/lib.rs +++ b/crates/rt-helper/src/lib.rs @@ -1,101 +1,2 @@ -use std::{ - sync::{Arc, Mutex, MutexGuard}, - thread::Result, -}; -use ash::{vk, Device}; -use gpu_allocator::{ - vulkan::{Allocation, AllocationCreateDesc, Allocator}, - MemoryLocation, -}; -#[derive(Debug)] -pub enum RtError { - VulkanError(vk::Result), - AllocationError(gpu_allocator::AllocationError), -} - -pub struct AccelerationStructure { - accel: vk::AccelerationStructureKHR, - buffer: vk::Buffer, - allocation: Option, -} - -impl AccelerationStructure { - fn destroy(&mut self, device: &Device, allocator: &mut Allocator) { - unsafe { device.destroy_buffer(self.buffer, None) }; - if let Some(allocation) = self.allocation.take() { - allocator.free(allocation).unwrap(); - } - } -} - -pub struct Buffer { - buffer: vk::Buffer, - allocation: Option, - size: vk::DeviceSize, -} - -impl Buffer { - pub fn new( - device: &Device, - allocator: &mut Allocator, - size: vk::DeviceSize, - usage: vk::BufferUsageFlags, - location: MemoryLocation, - ) -> color_eyre::Result { - let buffer_info = vk::BufferCreateInfo::builder() - .size(size) - .usage(usage) - .sharing_mode(vk::SharingMode::EXCLUSIVE) - .build(); - - let buffer = unsafe { device.create_buffer(&buffer_info, None) }?; - - let requirements = unsafe { device.get_buffer_memory_requirements(buffer) }; - - let allocation = allocator.allocate(&AllocationCreateDesc { - name: "rt_buffer", - requirements, - location, - linear: true, - allocation_scheme: gpu_allocator::vulkan::AllocationScheme::GpuAllocatorManaged, - })?; - - unsafe { device.bind_buffer_memory(buffer, allocation.memory(), allocation.offset()) }?; - - Ok(Self { - buffer, - allocation: Some(allocation), - size, - }) - } - - pub fn destroy(&mut self, device: &Device, allocator: &mut Allocator) { - unsafe { device.destroy_buffer(self.buffer, None) }; - if let Some(allocation) = self.allocation.take() { - allocator.free(allocation).unwrap(); - } - } -} - -pub struct RaytracingBuilderKHR { - device: Arc, - queue_index: u32, - allocator: Arc>, - blas: Vec, - tlas: AccelerationStructure, - command_pool: vk::CommandPool, -} - -impl RaytracingBuilderKHR { - pub fn new() -> Self { - Self { - device: None, - queue_index: 0, - allocator: None, - blas: Vec::new(), - tlas: AccelerationStructure::de, - } - } -} diff --git a/crates/vk-rs/src/renderer.rs b/crates/vk-rs/src/renderer.rs index aba9869..d19ad03 100644 --- a/crates/vk-rs/src/renderer.rs +++ b/crates/vk-rs/src/renderer.rs @@ -607,7 +607,7 @@ impl RendererInner { let mut allocator = allocator.lock().unwrap(); let vertices = { let model_obj = tobj::load_obj( - "/home/zoey/dev/vk-rs/crates/vk-rs/assets/suzanne.obj", + "./crates/vk-rs/assets/suzanne.obj", &tobj::LoadOptions { single_index: true, triangulate: true,