# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
+version = 4
[[package]]
name = "blake3-smol"
[[package]]
name = "constant_time_eq"
-version = "0.3.0"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
+checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
[[package]]
name = "fast-float2"
[[package]]
name = "getrandom"
-version = "0.2.10"
+version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
+checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
dependencies = [
"cfg-if",
"libc",
[[package]]
name = "gmp-mpfr-sys"
-version = "1.6.2"
+version = "1.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "362a6cc3cbe9f41aebe49c03b91aee8fa8fc69d32fb90533f6ed965a882e08e3"
+checksum = "c66d61197a68f6323b9afa616cf83d55d69191e1bf364d4eb7d35ae18defe776"
dependencies = [
"libc",
"windows-sys",
[[package]]
name = "libc"
-version = "0.2.161"
+version = "0.2.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
+checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
name = "memchr"
-version = "2.5.0"
+version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "narcissus-app"
[[package]]
name = "ppv-lite86"
-version = "0.2.17"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
+dependencies = [
+ "zerocopy",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.94"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
+dependencies = [
+ "proc-macro2",
+]
[[package]]
name = "rand"
[[package]]
name = "sdl3-sys"
-version = "0.1.2+SDL3-preview-3.1.6"
+version = "0.4.7+SDL3-3.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "48501d90bf219bf3126b26155c04834af300088432f98c6985aa8ad3a2441baa"
+checksum = "f0d16a8a3623a4cb39a3661c81d9d4c5fd77ada27fc056e320b3651bf7bde1b1"
[[package]]
name = "shark"
name = "stb_truetype-sys"
version = "0.1.0"
+[[package]]
+name = "syn"
+version = "2.0.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+
[[package]]
name = "vulkan-sys"
version = "0.1.0"
[[package]]
name = "windows-sys"
-version = "0.52.0"
+version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
[[package]]
name = "windows_aarch64_gnullvm"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.52.5"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.52.5"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "zerocopy"
+version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
+checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.8.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
[package]
name = "narcissus-app"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
narcissus-core = { path = "../narcissus-core" }
-sdl3-sys = "0.1.2"
\ No newline at end of file
+sdl3-sys = "0.4.7"
\ No newline at end of file
[package]
name = "narcissus-core"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
impl std::error::Error for AllocError {}
#[inline(always)]
-unsafe fn layout_from_size_align(size: usize, align: usize) -> Layout {
+unsafe fn layout_from_size_align(size: usize, align: usize) -> Layout { unsafe {
if cfg!(debug_assertions) {
Layout::from_size_align(size, align).unwrap()
} else {
Layout::from_size_align_unchecked(size, align)
}
-}
+}}
/// Wrapper around a pointer to a page footer.
///
}
#[inline(always)]
- unsafe fn as_ref<'a>(&self) -> &'a PageFooter {
+ unsafe fn as_ref<'a>(&self) -> &'a PageFooter { unsafe {
&*self.as_ptr()
- }
+ }}
}
#[repr(C)]
/// This must only be called on pages which have no outstanding references to
/// allocations, as it allows subsequent operations to allocate the same
/// addresses.
- unsafe fn reset(&self) {
+ unsafe fn reset(&self) { unsafe {
self.bump.set(NonNull::new_unchecked(
self.base.as_ptr().add(self.size - PAGE_FOOTER_SIZE),
));
- }
+ }}
}
/// Special type for the empty page because static requires Sync.
///
/// `page` must refer to a valid page footer, or the empty page.
#[cold]
-unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option<PagePointer> {
+unsafe fn prepend_new_page(page: PagePointer, layout: Layout) -> Option<PagePointer> { unsafe {
let page_size = page.as_ref().size;
// Double each allocated page to amortize allocation cost.
let new_page_size = page_size * 2;
);
Some(PagePointer::new_heap(footer))
-}
+}}
/// Deallocate the given page if it was allocated with the global allocator, and
/// all the heap pages linked to it.
/// Must not be called on any pages that hold live allocations, or pages which
/// link to pages that hold live allocations.
#[cold]
-unsafe fn deallocate_page_list(mut page: PagePointer) {
+unsafe fn deallocate_page_list(mut page: PagePointer) { unsafe {
// Walk the linked list of pages and deallocate each one that originates from
// the heap. The last page is either the empty page, or the hybrid page, both of
// which are marked as stack page pointers.
let layout = layout_from_size_align(p.as_ref().size, std::mem::align_of::<PageFooter>());
std::alloc::dealloc(p.as_ref().base.as_ptr(), layout);
}
-}
+}}
/// An allocation arena.
///
/// the hybrid page.
#[inline(never)]
#[cold]
- unsafe fn setup_hybrid_page(&self) {
+ unsafe fn setup_hybrid_page(&self) { unsafe {
let base = self.data.as_ptr() as *mut u8;
let bump = base.add(STACK_CAP);
self.footer.set(PageFooter {
debug_assert_eq!(bump as usize, self.footer.as_ptr() as usize);
self.page_list_head
.set(PagePointer::new_stack(self.footer.as_ptr()));
- }
+ }}
#[inline(never)]
#[cold]
pub const SYS_epoll_pwait2: c_long = 441;
pub const SYS_mount_setattr: c_long = 442;
-extern "C" {
+unsafe extern "C" {
pub fn syscall(num: c_long, ...) -> c_long;
pub fn mmap(
pub fn release(mut self) -> Release<T> {
#[cold]
#[inline(never)]
- unsafe fn release_slow<T>(ptr: NonNull<Inner<T>>) -> T {
+ unsafe fn release_slow<T>(ptr: NonNull<Inner<T>>) -> T { unsafe {
// Ref-counting operations imply a full memory barrier on x86, but not in general. So
// insert an acquire barrier on the slow path to ensure all modifications to inner are
// visible before we call drop.
drop(inner);
value
- }
+ }}
// SAFETY: `release` consumes `self` so it's impossible to call twice on the same instance,
// release is also the only function able to invalidate the pointer. Hence the pointer is
/// dereferenced for the duration of the returned borrow. This is trivially the
/// case if no such pointers exist, for example immediately after [`Arc::new`].
#[inline]
- pub unsafe fn get_mut_unchecked(&mut self) -> &mut T {
+ pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { unsafe {
// We are careful to *not* create a reference covering the "count" fields, as
// this would alias with concurrent access to the reference counts.
&mut (*self.ptr.as_ptr()).value
- }
+ }}
#[inline]
fn from_inner(ptr: NonNull<Inner<T>>) -> Self {
/// Any other [`Rc`] or [`Arc`] pointers to the same allocation must not be dereferenced for the duration of the
/// returned borrow. This is trivially the case if no such pointers exist, for example immediately after
/// [`Arc::new`].
- pub unsafe fn get_mut_unchecked(&mut self) -> &mut T {
+ pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { unsafe {
// We are careful to *not* create a reference covering the "count" fields, as
// this would alias with concurrent access to the reference counts.
&mut (*self.ptr.as_ptr()).value
- }
+ }}
fn from_inner(ptr: NonNull<Inner<T>>) -> Self {
Self {
/// Panics if changing page permissions for the range fails.
#[cold]
#[inline(never)]
-pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) {
+pub unsafe fn virtual_commit(ptr: *mut std::ffi::c_void, size: usize) { unsafe {
let result = libc::mprotect(ptr, size, libc::PROT_READ | libc::PROT_WRITE);
assert!(result == 0);
-}
+}}
/// Release a reserved or comitted virtual memory range.
///
/// - `size` must be within range of that reservation.
#[cold]
#[inline(never)]
-pub unsafe fn virtual_free(ptr: *mut std::ffi::c_void, size: usize) -> Result<(), MapError> {
+pub unsafe fn virtual_free(ptr: *mut std::ffi::c_void, size: usize) -> Result<(), MapError> { unsafe {
let result = libc::munmap(ptr, size);
if result != 0 {
Err(MapError::MapFailed)
} else {
Ok(())
}
-}
+}}
/// Turn ptr into a slice
#[inline]
- unsafe fn buffer_as_slice(&self) -> &[T] {
+ unsafe fn buffer_as_slice(&self) -> &[T] { unsafe {
slice::from_raw_parts(self.ptr(), self.cap())
- }
+ }}
/// Turn ptr into a mut slice
#[inline]
- unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] {
+ unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] { unsafe {
slice::from_raw_parts_mut(self.ptr(), self.cap())
- }
+ }}
/// Moves an element out of the buffer
#[inline]
- unsafe fn buffer_read(&mut self, off: usize) -> T {
+ unsafe fn buffer_read(&mut self, off: usize) -> T { unsafe {
ptr::read(self.ptr().add(off))
- }
+ }}
/// Writes an element into the buffer, moving it.
#[inline]
- unsafe fn buffer_write(&mut self, off: usize, value: T) {
+ unsafe fn buffer_write(&mut self, off: usize, value: T) { unsafe {
ptr::write(self.ptr().add(off), value);
- }
+ }}
pub fn len(&self) -> usize {
count(self.tail, self.head, self.cap())
/// Copies a contiguous block of memory len long from src to dst
#[inline]
- unsafe fn copy(&self, dst: usize, src: usize, len: usize) {
+ unsafe fn copy(&self, dst: usize, src: usize, len: usize) { unsafe {
debug_assert!(
dst + len <= self.cap(),
"cpy dst={} src={} len={} cap={}",
self.cap()
);
ptr::copy(self.ptr().add(src), self.ptr().add(dst), len);
- }
+ }}
/// Copies a contiguous block of memory len long from src to dst
#[inline]
- unsafe fn copy_nonoverlapping(&self, dst: usize, src: usize, len: usize) {
+ unsafe fn copy_nonoverlapping(&self, dst: usize, src: usize, len: usize) { unsafe {
debug_assert!(
dst + len <= self.cap(),
"cno dst={} src={} len={} cap={}",
self.cap()
);
ptr::copy_nonoverlapping(self.ptr().add(src), self.ptr().add(dst), len);
- }
+ }}
/// Frobs the head and tail sections around to handle the fact that we
/// just reallocated. Unsafe because it trusts old_capacity.
#[inline]
- unsafe fn handle_capacity_increase(&mut self, old_capacity: usize) {
+ unsafe fn handle_capacity_increase(&mut self, old_capacity: usize) { unsafe {
let new_capacity = self.cap();
// Move the shortest contiguous section of the ring buffer
debug_assert!(self.head < self.cap());
debug_assert!(self.tail < self.cap());
debug_assert!(self.cap().count_ones() == 1);
- }
+ }}
pub fn reserve_exact(&mut self, additional: usize) {
self.reserve(additional);
}
#[inline]
- unsafe fn append_elements(&mut self, other: *const [T]) {
+ unsafe fn append_elements(&mut self, other: *const [T]) { unsafe {
let count = (*other).len();
self.reserve(count);
let len = self.len();
ptr::copy_nonoverlapping(other as *const T, self.as_mut_ptr().add(len), count);
self.len += count;
- }
+ }}
pub fn clear(&mut self) {
self.truncate(0)
[package]
name = "narcissus-font"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package]
name = "narcissus-gpu"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Some((memory, mapped_ptr))
}
- unsafe fn free_super_block(&self, user_data: &VulkanSuperBlockInfo) {
+ unsafe fn free_super_block(&self, user_data: &VulkanSuperBlockInfo) { unsafe {
self.device_fn
.free_memory(self.device, user_data.memory, None);
let size = self.allocator.tlsf_super_block_size[memory_heap_index.widen()];
self.allocator.stats.free(memory_heap_index, size);
- }
+ }}
pub fn allocate_memory(
&self,
pub const RTLD_NOW: c_int = 0x2;
pub const RTLD_LOCAL: c_int = 0;
-extern "C" {
+unsafe extern "C" {
pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
}
ptr: *const u8,
len: usize,
) {
- let len = u32::try_from(len).unwrap();
-
- let cmd_encoder = self.cmd_encoder_mut(cmd_encoder);
- let command_buffer = cmd_encoder.command_buffer;
-
- let VulkanBoundPipeline {
- pipeline_layout,
- pipeline_bind_point: _,
- } = cmd_encoder
- .bound_pipeline
- .as_ref()
- .expect("cannot push constants without a pipeline bound")
- .clone();
-
- let stage_flags = vulkan_shader_stage_flags(stage_flags);
- self.device_fn.cmd_push_constants(
- command_buffer,
- pipeline_layout,
- stage_flags,
- offset,
- len,
- ptr as *const std::ffi::c_void,
- )
+ unsafe {
+ let len = u32::try_from(len).unwrap();
+
+ let cmd_encoder = self.cmd_encoder_mut(cmd_encoder);
+ let command_buffer = cmd_encoder.command_buffer;
+
+ let VulkanBoundPipeline {
+ pipeline_layout,
+ pipeline_bind_point: _,
+ } = cmd_encoder
+ .bound_pipeline
+ .as_ref()
+ .expect("cannot push constants without a pipeline bound")
+ .clone();
+
+ let stage_flags = vulkan_shader_stage_flags(stage_flags);
+ self.device_fn.cmd_push_constants(
+ command_buffer,
+ pipeline_layout,
+ stage_flags,
+ offset,
+ len,
+ ptr as *const std::ffi::c_void,
+ )
+ }
}
fn cmd_copy_buffer_to_image(
/// This function will propagate undefined values from T, for example, padding
/// bytes, so it's vital that no Rust reference to the written memory exists
/// after writing a `T` which contains undefined values.
-unsafe fn copy_from_with_offset<T: ?Sized>(ptr: NonNull<u8>, len: usize, offset: usize, src: &T) {
+unsafe fn copy_from_with_offset<T: ?Sized>(ptr: NonNull<u8>, len: usize, offset: usize, src: &T) { unsafe {
let size = std::mem::size_of_val(src);
let Some(end) = offset.checked_add(size) else {
let src = src.add(offset);
let dst = ptr.as_ptr();
std::ptr::copy_nonoverlapping(src, dst, count)
-}
+}}
/// Persistent mapped buffer.
///
[package]
name = "narcissus-image"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package]
name = "narcissus-maths"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
mod mat2;
mod mat3;
mod mat4;
-mod next_after_f32;
mod perlin;
mod point2;
mod point3;
pub use mat2::Mat2;
pub use mat3::Mat3;
pub use mat4::Mat4;
-pub use next_after_f32::next_after_f32;
pub use perlin::{perlin_noise3, perlin_noise3_wrap, perlin_noise3_wrap_seed};
pub use point2::{point2, Point2};
pub use point3::{point3, Point3};
// SAFETY: Requires SSE2.
#[inline]
#[target_feature(enable = "sse2")]
- unsafe fn transpose_sse2(self) -> Mat4 {
+ unsafe fn transpose_sse2(self) -> Mat4 { unsafe {
use std::arch::x86_64::_MM_TRANSPOSE4_PS;
let [mut row0, mut row1, mut row2, mut row3] = self.as_m128_array();
_MM_TRANSPOSE4_PS(&mut row0, &mut row1, &mut row2, &mut row3);
Mat4::from_m128_array([row0, row1, row2, row3])
- }
+ }}
/// Returns the transpose of `self`.
#[must_use]
#[allow(dead_code)]
#[inline]
#[target_feature(enable = "sse4.1")]
- unsafe fn transform_vec4_sse41(&self, vec: Vec4) -> Vec4 {
+ unsafe fn transform_vec4_sse41(&self, vec: Vec4) -> Vec4 { unsafe {
use std::arch::x86_64::{_mm_hadd_ps, _mm_mul_ps};
let vec = vec.into();
);
values.into()
- }
+ }}
/// Transforms the given [`Vec4`] `vec` by `self`.
#[must_use]
#[allow(dead_code)]
#[inline]
#[target_feature(enable = "avx2")]
-unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 {
+unsafe fn mul_mat4_avx2(lhs: Mat4, rhs: Mat4) -> Mat4 { unsafe {
use std::arch::x86_64::{
__m128, __m256, _mm256_add_ps, _mm256_broadcast_ps, _mm256_loadu_ps, _mm256_mul_ps,
_mm256_shuffle_ps, _mm256_storeu_ps, _mm256_zeroupper,
};
#[inline(always)]
- unsafe fn two_linear_combine(a: __m256, m: &[__m128; 4]) -> __m256 {
+ unsafe fn two_linear_combine(a: __m256, m: &[__m128; 4]) -> __m256 { unsafe {
let m0 = _mm256_broadcast_ps(&m[0]);
let m1 = _mm256_broadcast_ps(&m[1]);
let m2 = _mm256_broadcast_ps(&m[2]);
let r = _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0x55), m1));
let r = _mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0xaa), m2));
_mm256_add_ps(r, _mm256_mul_ps(_mm256_shuffle_ps(a, a, 0xff), m3))
- }
+ }}
_mm256_zeroupper();
_mm256_storeu_ps(&mut result.0[0], x0);
_mm256_storeu_ps(&mut result.0[8], x1);
result
-}
+}}
impl std::ops::Mul for Mat4 {
type Output = Mat4;
+++ /dev/null
-/// Calculate the next representable floating-point value following x in the
-/// direction of y.
-///
-/// If y is less than x, these functions will return the largest representable
-/// number less than x.
-///
-/// # Returns
-///
-/// On success, the function returns the next representable floating-point value
-/// after x in the
-/// direction of y.
-///
-/// * If `x` equals `y`, then `y` is returned.
-/// * If `x` or `y` is a `NaN`, a `NaN` is returned.
-/// * If `x` is finite, and the result would overflow, a range error occurs, and
-/// the function returns `inf` with the correct mathematical sign.
-/// * If `x` is not equal to `y`, and the correct function result would be
-/// subnormal, zero, or underflow, a range error occurs, and either the
-/// correct value (if it can be represented), or `0.0`, is returned.
-/// * If x equals y, the function returns y.
-pub fn next_after_f32(x: f32, y: f32) -> f32 {
- if x.is_nan() || y.is_nan() {
- return x + y;
- }
-
- let ux = x.to_bits();
- let uy = y.to_bits();
-
- if ux == uy {
- return y;
- }
-
- let ax = ux & 0x7fff_ffff;
- let ay = uy & 0x7fff_ffff;
-
- let ux = if ax == 0 {
- if ay == 0 {
- return y;
- }
- (uy & 0x8000_0000) | 1
- } else if ax > ay || ((ux ^ uy) & 0x8000_0000) != 0 {
- ux - 1
- } else {
- ux + 1
- };
-
- let e = ux & 0x7f800000;
- // Overflow if ux is infinite, and x is finite.
- if e == 0x7f800000 {
- return x + x;
- }
- // Force underflow if ux is subnormal or zero.
- if e == 0 {
- let mut force_eval = 0.0;
- let val = f32::from_bits(ux);
- unsafe { std::ptr::write_volatile(&mut force_eval, x * x + val * val) };
- }
-
- f32::from_bits(ux)
-}
sync::atomic::{AtomicUsize, Ordering},
};
-use narcissus_maths::{exp_f32, next_after_f32, sin_cos_pi_f32, tan_pi_f32};
+use narcissus_maths::{exp_f32, sin_cos_pi_f32, tan_pi_f32};
use gmp_mpfr_sys::mpfr;
}
let err = our_value - ref_value;
- let ulp = next_after_f32(ref_value, our_value) - ref_value;
+ let ulp = if ref_value > our_value {
+ ref_value.next_down()
+ } else if ref_value < our_value {
+ ref_value.next_up()
+ } else {
+ ref_value
+ } - ref_value;
let err = (err / ulp).abs();
if err >= u32::MAX as f32 {
u32::MAX
+++ /dev/null
-use narcissus_maths::next_after_f32;
-
-mod libc {
- use std::os::raw::c_float;
-
- extern "C" {
- pub fn nextafterf(x: c_float, y: c_float) -> c_float;
- }
-}
-
-#[inline(always)]
-fn nextafterf(x: f32, y: f32) -> f32 {
- unsafe { libc::nextafterf(x, y) }
-}
-
-fn test_towards(y: f32) {
- for u in 0..=0xffff_ffff_u32 {
- let x = f32::from_bits(u);
- let ours = next_after_f32(x, y);
- let reference = nextafterf(x, y);
- assert!(
- ours == reference || (ours.is_nan() && reference.is_nan()),
- "x ({u:X}): ours ({ours}) != reference ({reference})"
- );
- }
-}
-
-#[test]
-#[ignore]
-fn next_after_f32_to_zero() {
- test_towards(0.0)
-}
-
-#[test]
-#[ignore]
-fn next_after_f32_to_inf() {
- test_towards(f32::INFINITY)
-}
-
-#[test]
-#[ignore]
-fn next_after_f32_to_neg_inf() {
- test_towards(f32::NEG_INFINITY)
-}
[package]
name = "narcissus-sqlite"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
static SQLITE_GLOBAL_INIT: OnceLock<()> = OnceLock::new();
#[cold]
-unsafe fn initialize() {
+unsafe fn initialize() { unsafe {
let ret = ffi::sqlite3_initialize();
if ret != sqlite_sys::SQLITE_OK {
panic!("error initializing sqlite: {:?}", Error::new(ret));
panic!("error installing sqlite logger: {:?}", Error::new(ret));
}
}
-}
+}}
fn check_initalized() {
SQLITE_GLOBAL_INIT.get_or_init(|| unsafe { initialize() });
[package]
name = "narcissus-world"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package]
name = "blake3-smol"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
#[allow(dead_code)]
-extern "C" {
+unsafe extern "C" {
pub fn blake3_compress_in_place_avx512(
cv: *mut u32,
block: *const u8,
[package]
name = "renderdoc-sys"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
pub const RTLD_NOW: c_int = 0x2;
pub const RTLD_NOLOAD: c_int = 0x4;
- extern "C" {
+ unsafe extern "C" {
pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
}
[package]
name = "sqlite-sys"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
pub const SQLITE_STATIC: Destructor = unsafe { std::mem::transmute(0usize) };
pub const SQLITE_TRANSIENT: Destructor = unsafe { std::mem::transmute(!0usize) };
-extern "C" {
+unsafe extern "C" {
pub fn sqlite3_libversion_number() -> c_int;
pub fn sqlite3_initialize() -> c_int;
[package]
name = "stb_image-sys"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
pub eof: extern "C" fn(user: *mut c_void) -> i32,
}
-extern "C" {
+unsafe extern "C" {
pub fn stbi_load_from_memory(
buffer: *const c_uchar,
len: c_int,
[package]
name = "stb_truetype-sys"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
}
}
-extern "C" {
+unsafe extern "C" {
pub fn stbrp_pack_rects(
context: *mut rectpack::Context,
rects: *mut rectpack::Rect,
[package]
name = "vulkan-sys"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
pub const RTLD_NOW: c_int = 0x2;
pub const RTLD_LOCAL: c_int = 0;
- extern "C" {
+ unsafe extern "C" {
pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
}
#[inline]
unsafe fn as_chunks_unchecked<T, const N: usize>(slice: &[T]) -> &[[T; N]] {
- debug_assert_ne!(N, 0);
- debug_assert_eq!(slice.len() % N, 0);
- let new_len = slice.len() / N;
- // SAFETY: We cast a slice of `new_len * N` elements into
- // a slice of `new_len` many `N` elements chunks.
- std::slice::from_raw_parts(slice.as_ptr().cast(), new_len)
+ unsafe {
+ debug_assert_ne!(N, 0);
+ debug_assert_eq!(slice.len() % N, 0);
+ let new_len = slice.len() / N;
+ // SAFETY: We cast a slice of `new_len * N` elements into
+ // a slice of `new_len` many `N` elements chunks.
+ std::slice::from_raw_parts(slice.as_ptr().cast(), new_len)
+ }
}
print!("\x1b[2J");
}
impl GlobalFunctions {
- pub unsafe fn new(get_proc_addr: *mut c_void) -> Self {
+ pub unsafe fn new(get_proc_addr: *mut c_void) -> Self { unsafe {
let get_instance_proc_addr = transmute::<_, FnGetInstanceProcAddr>(get_proc_addr);
Self {
get_instance_proc_addr,
.expect("failed to load vkCreateInstance"),
),
}
- }
+ }}
#[inline]
pub unsafe fn get_instance_proc_addr(
[package]
name = "shark-shaders"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package]
name = "shark"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
pub fn main() {
#[cfg(debug_assertions)]
if std::env::var("RUST_BACKTRACE").is_err() {
- std::env::set_var("RUST_BACKTRACE", "1")
+ // SAFETY: Called on the main thread before other threads are spawned.
+ unsafe { std::env::set_var("RUST_BACKTRACE", "1") }
}
let renderdoc = rdoc::RenderdocApi1_5_0::load();
// Hot new SDL 3 environment variables!
&& std::env::var("SDL_VIDEO_DRIVER").is_err()
{
- std::env::set_var("SDL_VIDEODRIVER", "wayland")
+ // SAFETY: Called on the main thread before other threads are spawned.
+ unsafe { std::env::set_var("SDL_VIDEODRIVER", "wayland") }
}
let ui_scale_override =