Joshua Simmons [Wed, 2 Nov 2022 21:16:50 +0000 (22:16 +0100)]
Add `Arena` and `HybridArena`
Add two variants on a simple bump allocator. Based loosly on the bumpalo
crate.
Provides two types, `Arena` which always allocates from the heap and
`HybridArena` which will first use a stack allocated page, then fall
back to allocating from the heap as well.
Joshua Simmons [Sat, 29 Oct 2022 14:12:39 +0000 (16:12 +0200)]
Rename `request_command_buffer` to `create_...`
The distinction between requesting and creating seems a bit tenuious and
probably just confusing. Might re-visit this later once the API is more
complete.
Joshua Simmons [Fri, 21 Oct 2022 21:05:21 +0000 (23:05 +0200)]
Be more defensive when doing range reduction
f32 as u32 saturates in rust, using to_int_unchecked wasn't currently
saturating on x86, but it's conceivable that it might. Go the long way
around by converting first to i32 and then to u32 in order to avoid the
possibility.
Joshua Simmons [Sat, 8 Oct 2022 11:03:44 +0000 (13:03 +0200)]
Improve pool implementation
Move virtual memory failures into the `virtual_reserve` and
`virtual_commit` signatures so we can give better assert messages on
failure.
Handle growth more accurately, allowing us to use the entire table
capacity before asserting.
Reserve a bit in the generation counter to keep track of whether a slot
is full by incrementing the counter on both allocation and deallocation.
This means exported handles can only ever have an odd generation
counter.
Assert when given a handle that has an invalid generation counter
(where the counter implies it would be pointing to an empty slot).
Both above changes together means it's no longer possible to create a
reference to an uninitialized slot, even when manually messing with the
handle or mixing handles between different pools.
Joshua Simmons [Thu, 6 Oct 2022 20:59:29 +0000 (22:59 +0200)]
Replace magic value in pool with random mixer
Instead of using a 4 bit magic number, and consequently restricting the
size of the pool, instead mix handles with a per-pool random integer
based on the pool's base memory address.
The associated tests will perhaps be a bit flaky, so disable them by
default.
Joshua Simmons [Sun, 2 Oct 2022 11:26:06 +0000 (13:26 +0200)]
Improve API of `ManualArc`
Consume the ManualArc when calling `release` to avoid needing to handle
double-free. Avoids unsafety in user code (was only protected by a debug
assert before)
Try to improve compile times by copy-pasting the handful of libc
definitions that we actually need. This is going to be a bit broken for
non-x86_64 platforms for now.
Improve `min`, `max` on ARM, and fix documentation
Use regular `f32::min` and `f32::max` for non-x86 platforms. Allows arm
to generate `fminnm`.
Improve documentation of platform specific behavior of `min` and `max`.
Add note about `sqrt` operation to `_sq` functions.
Split into multiple files.
Add `Affine2` and `Affine3` transformation types.
Add `Point2` and `Point3` types.
Use macro instead of repeating basic `Point` and `Vec` implementation.
Change `Mat4 * Point` to use homogeneous coordinates where `w=1`.
Change `Mat4 * Vec` to use homogeneous coordinates where `w=0`.