Skip to content

Commit

Permalink
Revert "Specify linear or non-linear allocation"
Browse files Browse the repository at this point in the history
I wasn't sure about this change, so I'm reverting it for now
  • Loading branch information
FlannyH committed Feb 22, 2024
1 parent fb16010 commit 5788bb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
12 changes: 2 additions & 10 deletions examples/metal-buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ fn main() {
&device,
"Test allocation (Gpu Only)",
512,
true,
gpu_allocator::MemoryLocation::GpuOnly,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
Expand All @@ -37,7 +36,6 @@ fn main() {
&device,
"Test allocation (Cpu to Gpu)",
512,
true,
gpu_allocator::MemoryLocation::CpuToGpu,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
Expand All @@ -52,7 +50,6 @@ fn main() {
&device,
"Test allocation (Gpu to Cpu)",
512,
true,
gpu_allocator::MemoryLocation::GpuToCpu,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
Expand All @@ -68,12 +65,8 @@ fn main() {
texture_desc.set_width(64);
texture_desc.set_height(64);
texture_desc.set_storage_mode(metal::MTLStorageMode::Private);
let allocation_desc = AllocationCreateDesc::texture(
&device,
"Test allocation (Texture)",
true,
&texture_desc,
);
let allocation_desc =
AllocationCreateDesc::texture(&device, "Test allocation (Texture)", &texture_desc);
let allocation = allocator.allocate(&allocation_desc).unwrap();
let _texture = allocation.make_texture(&texture_desc).unwrap();
allocator.free(&allocation).unwrap();
Expand All @@ -90,7 +83,6 @@ fn main() {
&device,
"Test allocation (Acceleration structure)",
sizes.acceleration_structure_size,
true,
gpu_allocator::MemoryLocation::GpuOnly,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
Expand Down
14 changes: 1 addition & 13 deletions src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ pub struct AllocationCreateDesc<'a> {
pub name: &'a str,
/// Location where the memory allocation should be stored
pub location: MemoryLocation,
/// If the resource is linear (buffer / linear texture) or a regular (tiled) texture.
pub linear: bool,
pub size: u64,
pub alignment: u64,
}
Expand All @@ -96,7 +94,6 @@ impl<'a> AllocationCreateDesc<'a> {
device: &metal::Device,
name: &'a str,
length: u64,
linear: bool,
location: MemoryLocation,
) -> AllocationCreateDesc<'a> {
let size_and_align =
Expand All @@ -106,14 +103,12 @@ impl<'a> AllocationCreateDesc<'a> {
location,
size: size_and_align.size,
alignment: size_and_align.align,
linear,
}
}

pub fn texture(
device: &metal::Device,
name: &'a str,
linear: bool,
desc: &metal::TextureDescriptor,
) -> AllocationCreateDesc<'a> {
let size_and_align = device.heap_texture_size_and_align(desc);
Expand All @@ -127,15 +122,13 @@ impl<'a> AllocationCreateDesc<'a> {
},
size: size_and_align.size,
alignment: size_and_align.align,
linear,
}
}

pub fn acceleration_structure_with_size(
device: &metal::Device,
name: &'a str,
size: u64,
linear: bool,
location: MemoryLocation,
) -> AllocationCreateDesc<'a> {
let size_and_align = device.heap_acceleration_structure_size_and_align_with_size(size);
Expand All @@ -144,7 +137,6 @@ impl<'a> AllocationCreateDesc<'a> {
location,
size: size_and_align.size,
alignment: size_and_align.align,
linear,
}
}
}
Expand Down Expand Up @@ -211,11 +203,7 @@ impl MemoryType {
backtrace: Arc<Backtrace>,
allocation_sizes: &AllocationSizes,
) -> Result<Allocation> {
let allocation_type = if desc.linear {
AllocationType::Linear
} else {
AllocationType::NonLinear
};
let allocation_type = AllocationType::Linear;

let memblock_size = if self.heap_properties.storage_mode() == MTLStorageMode::Private {
allocation_sizes.device_memblock_size
Expand Down

0 comments on commit 5788bb4

Please sign in to comment.