]> git.nega.tv - josh/narcissus/commitdiff
narcissus-gpu: Add Default bound to Tlsf super blocks
authorJoshua Simmons <josh@nega.tv>
Tue, 25 Jul 2023 07:43:18 +0000 (09:43 +0200)
committerJoshua Simmons <josh@nega.tv>
Tue, 25 Jul 2023 07:43:18 +0000 (09:43 +0200)
libs/narcissus-gpu/src/backend/vulkan/allocator.rs
libs/narcissus-gpu/src/tlsf.rs

index 565fa19c6cc8e15448fd27cd4705d9e418186f02..59f18b8c20faeeeb54fa15a41f285635b6a566d3 100644 (file)
@@ -90,6 +90,17 @@ pub struct VulkanSuperBlockInfo {
     memory_type_index: u32,
 }
 
+impl Default for VulkanSuperBlockInfo {
+    fn default() -> Self {
+        Self {
+            memory: vk::DeviceMemory::null(),
+            mapped_ptr: std::ptr::null_mut(),
+            non_linear: false,
+            memory_type_index: !0,
+        }
+    }
+}
+
 #[derive(Clone)]
 pub struct VulkanMemoryDedicated {
     memory: vk::DeviceMemory,
index 5e812a730892497abc432f8929fcf00296806ec9..2d99c4da2cb08b08bf155bc59e400e7901d82bab 100644 (file)
@@ -115,7 +115,7 @@ struct SuperBlockIndex(u32);
 
 pub struct SuperBlock<T>
 where
-    T: Copy,
+    T: Copy + Default,
 {
     _first_block_index: BlockIndex,
     pub user_data: T,
@@ -234,7 +234,7 @@ impl IndexMut<BlockIndex> for Vec<Block> {
 
 impl<T> Index<SuperBlockIndex> for Vec<SuperBlock<T>>
 where
-    T: Copy,
+    T: Copy + Default,
 {
     type Output = SuperBlock<T>;
 
@@ -246,7 +246,7 @@ where
 
 impl<T> IndexMut<SuperBlockIndex> for Vec<SuperBlock<T>>
 where
-    T: Copy,
+    T: Copy + Default,
 {
     #[inline(always)]
     fn index_mut(&mut self, index: SuperBlockIndex) -> &mut Self::Output {
@@ -275,7 +275,7 @@ impl<T> Allocation<T> {
 
 pub struct Tlsf<T>
 where
-    T: Copy,
+    T: Copy + Default,
 {
     bitmap_0: u32,
     bitmap_1: [u32; BIN_COUNT],
@@ -289,7 +289,7 @@ where
 
 impl<T> Default for Tlsf<T>
 where
-    T: Copy,
+    T: Copy + Default,
 {
     fn default() -> Self {
         Self::new()
@@ -298,7 +298,7 @@ where
 
 impl<T> Tlsf<T>
 where
-    T: Copy,
+    T: Copy + Default,
 {
     pub fn new() -> Self {
         Self {