diff --git a/librashader-runtime-vk/src/draw_quad.rs b/librashader-runtime-vk/src/draw_quad.rs index 9f11959..5e67bbd 100644 --- a/librashader-runtime-vk/src/draw_quad.rs +++ b/librashader-runtime-vk/src/draw_quad.rs @@ -4,7 +4,7 @@ use array_concat::concat_arrays; use ash::vk; use gpu_allocator::vulkan::Allocator; use librashader_runtime::quad::{QuadType, VertexInput}; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::sync::Arc; const OFFSCREEN_VBO_DATA: [VertexInput; 4] = [ @@ -54,7 +54,7 @@ pub struct DrawQuad { impl DrawQuad { pub fn new( device: &Arc, - allocator: &Arc>, + allocator: &Arc>, ) -> error::Result { let mut buffer = VulkanBuffer::new( device, diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index c5ac6cd..d12ee50 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -26,7 +26,7 @@ use librashader_runtime::binding::BindingUtil; use librashader_runtime::image::{Image, ImageError, UVDirection, BGRA8}; use librashader_runtime::quad::QuadType; use librashader_runtime::uniforms::UniformStorage; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::collections::VecDeque; use std::convert::Infallible; use std::path::Path; @@ -43,7 +43,7 @@ use rayon::prelude::*; /// A Vulkan device and metadata that is required by the shader runtime. pub struct VulkanObjects { pub(crate) device: Arc, - pub(crate) alloc: Arc>, + pub(crate) alloc: Arc>, queue: vk::Queue, // pub(crate) memory_properties: vk::PhysicalDeviceMemoryProperties, } diff --git a/librashader-runtime-vk/src/memory.rs b/librashader-runtime-vk/src/memory.rs index d7c783f..07633aa 100644 --- a/librashader-runtime-vk/src/memory.rs +++ b/librashader-runtime-vk/src/memory.rs @@ -4,7 +4,7 @@ use ash::vk; use gpu_allocator::vulkan::{Allocation, AllocationCreateDesc, AllocationScheme, Allocator}; use gpu_allocator::MemoryLocation; use librashader_runtime::uniforms::UniformStorageAccess; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::ffi::c_void; use std::mem::ManuallyDrop; @@ -14,17 +14,17 @@ use std::sync::Arc; pub struct VulkanImageMemory { allocation: Option, - allocator: Arc>, + allocator: Arc>, } impl VulkanImageMemory { pub fn new( device: &Arc, - allocator: &Arc>, + allocator: &Arc>, requirements: vk::MemoryRequirements, image: &vk::Image, ) -> error::Result { - let allocation = allocator.write().allocate(&AllocationCreateDesc { + let allocation = allocator.lock().allocate(&AllocationCreateDesc { name: "imagemem", requirements, location: MemoryLocation::GpuOnly, @@ -46,7 +46,7 @@ impl Drop for VulkanImageMemory { fn drop(&mut self) { let allocation = self.allocation.take(); if let Some(allocation) = allocation { - if let Err(e) = self.allocator.write().free(allocation) { + if let Err(e) = self.allocator.lock().free(allocation) { println!("librashader-runtime-vk: [warn] failed to deallocate image buffer {e}") } } @@ -57,14 +57,14 @@ pub struct VulkanBuffer { pub handle: vk::Buffer, device: Arc, memory: Option, - allocator: Arc>, + allocator: Arc>, size: vk::DeviceSize, } impl VulkanBuffer { pub fn new( device: &Arc, - allocator: &Arc>, + allocator: &Arc>, usage: vk::BufferUsageFlags, size: usize, ) -> error::Result { @@ -77,7 +77,7 @@ impl VulkanBuffer { let memory_reqs = device.get_buffer_memory_requirements(buffer); - let alloc = allocator.write().allocate(&AllocationCreateDesc { + let alloc = allocator.lock().allocate(&AllocationCreateDesc { name: "buffer", requirements: memory_reqs, location: MemoryLocation::CpuToGpu, @@ -113,7 +113,7 @@ impl Drop for VulkanBuffer { fn drop(&mut self) { unsafe { if let Some(allocation) = self.memory.take() { - if let Err(e) = self.allocator.write().free(allocation) { + if let Err(e) = self.allocator.lock().free(allocation) { println!( "librashader-runtime-vk: [warn] failed to deallocate buffer memory {e}" ) @@ -141,7 +141,7 @@ pub struct RawVulkanBuffer { impl RawVulkanBuffer { pub fn new( device: &Arc, - allocator: &Arc>, + allocator: &Arc>, usage: vk::BufferUsageFlags, size: usize, ) -> error::Result { diff --git a/librashader-runtime-vk/src/texture.rs b/librashader-runtime-vk/src/texture.rs index 8bd892d..9b3b6f5 100644 --- a/librashader-runtime-vk/src/texture.rs +++ b/librashader-runtime-vk/src/texture.rs @@ -3,7 +3,7 @@ use crate::memory::VulkanImageMemory; use crate::{error, util}; use ash::vk; use gpu_allocator::vulkan::Allocator; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::sync::Arc; use crate::error::FilterChainError; @@ -13,7 +13,7 @@ use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize}; pub struct OwnedImage { pub device: Arc, - pub allocator: Arc>, + pub allocator: Arc>, pub image_view: vk::ImageView, pub image: VulkanImage, pub memory: VulkanImageMemory, @@ -33,7 +33,7 @@ pub struct OwnedImageLayout { impl OwnedImage { fn new_internal( device: Arc, - alloc: &Arc>, + alloc: &Arc>, size: Size, mut format: ImageFormat, max_miplevels: u32, diff --git a/librashader-runtime-vk/src/util.rs b/librashader-runtime-vk/src/util.rs index fa8832b..090bcd9 100644 --- a/librashader-runtime-vk/src/util.rs +++ b/librashader-runtime-vk/src/util.rs @@ -2,7 +2,7 @@ use ash::vk; use gpu_allocator::vulkan::{Allocator, AllocatorCreateDesc}; use gpu_allocator::AllocationSizes; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::sync::Arc; use crate::error; @@ -95,7 +95,7 @@ pub fn create_allocator( device: ash::Device, instance: ash::Instance, physical_device: vk::PhysicalDevice, -) -> error::Result>> { +) -> error::Result>> { let alloc = Allocator::new(&AllocatorCreateDesc { instance, device, @@ -104,5 +104,5 @@ pub fn create_allocator( buffer_device_address: false, allocation_sizes: AllocationSizes::default(), })?; - Ok(Arc::new(RwLock::new(alloc))) + Ok(Arc::new(Mutex::new(alloc))) } diff --git a/librashader-runtime-vk/tests/hello_triangle/memory.rs b/librashader-runtime-vk/tests/hello_triangle/memory.rs index 1783f88..928f05f 100644 --- a/librashader-runtime-vk/tests/hello_triangle/memory.rs +++ b/librashader-runtime-vk/tests/hello_triangle/memory.rs @@ -1,25 +1,25 @@ use ash::vk; use gpu_allocator::vulkan::{Allocation, AllocationCreateDesc, AllocationScheme, Allocator}; use gpu_allocator::MemoryLocation; -use parking_lot::RwLock; +use parking_lot::Mutex; use ash::prelude::VkResult; use std::sync::Arc; pub struct VulkanImageMemory { allocation: Option, - allocator: Arc>, + allocator: Arc>, } impl VulkanImageMemory { pub fn new( device: &Arc, - allocator: &Arc>, + allocator: &Arc>, requirements: vk::MemoryRequirements, image: &vk::Image, ) -> VkResult { let allocation = allocator - .write() + .lock() .allocate(&AllocationCreateDesc { name: "imagemem", requirements, @@ -43,7 +43,7 @@ impl Drop for VulkanImageMemory { fn drop(&mut self) { let allocation = self.allocation.take(); if let Some(allocation) = allocation { - if let Err(e) = self.allocator.write().free(allocation) { + if let Err(e) = self.allocator.lock().free(allocation) { println!("librashader-runtime-vk: [warn] failed to deallocate image buffer {e}") } } diff --git a/librashader-runtime-vk/tests/hello_triangle/mod.rs b/librashader-runtime-vk/tests/hello_triangle/mod.rs index 2a98114..598b8aa 100644 --- a/librashader-runtime-vk/tests/hello_triangle/mod.rs +++ b/librashader-runtime-vk/tests/hello_triangle/mod.rs @@ -26,8 +26,8 @@ use vulkan_base::VulkanBase; use librashader_common::Viewport; use librashader_runtime_vk::options::FrameOptionsVulkan; -use winit::event::{ElementState, Event, WindowEvent}; -use winit::event_loop::{ControlFlow, EventLoop, EventLoopBuilder}; +use winit::event::{Event, WindowEvent}; +use winit::event_loop::{EventLoop, EventLoopBuilder}; use winit::platform::windows::EventLoopBuilderExtWindows; // Constants diff --git a/librashader-runtime-vk/tests/hello_triangle/util.rs b/librashader-runtime-vk/tests/hello_triangle/util.rs index 9792033..3436360 100644 --- a/librashader-runtime-vk/tests/hello_triangle/util.rs +++ b/librashader-runtime-vk/tests/hello_triangle/util.rs @@ -2,7 +2,7 @@ use ash::vk; use gpu_allocator::vulkan::{Allocator, AllocatorCreateDesc}; use gpu_allocator::AllocationSizes; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::sync::Arc; #[inline(always)] @@ -50,7 +50,7 @@ pub fn create_allocator( device: ash::Device, instance: ash::Instance, physical_device: vk::PhysicalDevice, -) -> Arc> { +) -> Arc> { let alloc = Allocator::new(&AllocatorCreateDesc { instance, device, @@ -60,5 +60,5 @@ pub fn create_allocator( allocation_sizes: AllocationSizes::default(), }) .unwrap(); - Arc::new(RwLock::new(alloc)) + Arc::new(Mutex::new(alloc)) } diff --git a/librashader-runtime-vk/tests/hello_triangle/vulkan_base.rs b/librashader-runtime-vk/tests/hello_triangle/vulkan_base.rs index f1b86cb..49245e8 100644 --- a/librashader-runtime-vk/tests/hello_triangle/vulkan_base.rs +++ b/librashader-runtime-vk/tests/hello_triangle/vulkan_base.rs @@ -7,7 +7,7 @@ use ash::prelude::VkResult; use gpu_allocator::vulkan::Allocator; use librashader_runtime_vk::error::FilterChainError; use librashader_runtime_vk::VulkanObjects; -use parking_lot::RwLock; +use parking_lot::Mutex; use std::ffi::CStr; use std::sync::Arc; @@ -22,7 +22,7 @@ pub struct VulkanBase { // pub debug: VulkanDebug, pub physical_device: vk::PhysicalDevice, pub mem_props: vk::PhysicalDeviceMemoryProperties, - pub allocator: Arc>, + pub allocator: Arc>, } impl VulkanBase {