Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1 @@
{"files":{"Cargo.toml":"ce92a2d32d4b2e50d617595e689b6bca736b7792280480c4057eaebef15bf325","README.md":"5a96b135d18e172f090bd6147830ab3a1b5cefac5f02be28f06cf88eea61b64f","src/device.rs":"8173609d5fb700f8b82d6335729c592ff62c306b12894a9bab9da45a47810e4a","src/lib.rs":"0f77c21a5770b54affa146e5f4c15abcb83599de551226d336ee48ec5185f866","src/types.rs":"aa861f891a63c232441c5a9fe5fed61cac2d62780108c01ebe6cb64a8547b4e2"},"package":"98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4"}

38
vendor/gpu-alloc-types/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,38 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "gpu-alloc-types"
version = "0.3.0"
authors = ["Zakarum <zakarumych@ya.ru>"]
description = "Core types of gpu-alloc crate"
homepage = "https://github.com/zakarumych/gpu-alloc"
documentation = "https://docs.rs/gpu-alloc-types"
readme = "README.md"
keywords = [
"gpu",
"vulkan",
"allocation",
"no-std",
]
categories = [
"graphics",
"memory-management",
"no-std",
"game-development",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/zakarumych/gpu-alloc"
[dependencies.bitflags]
version = "2.0"
default-features = false

51
vendor/gpu-alloc-types/README.md vendored Normal file
View File

@@ -0,0 +1,51 @@
# gpu-alloc
[![crates](https://img.shields.io/crates/v/gpu-alloc.svg?style=for-the-badge&label=gpu-alloc)](https://crates.io/crates/gpu-alloc)
[![docs](https://img.shields.io/badge/docs.rs-gpu--alloc-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white)](https://docs.rs/gpu-alloc)
[![actions](https://img.shields.io/github/workflow/status/zakarumych/gpu-alloc/Rust/main?style=for-the-badge)](https://github.com/zakarumych/gpu-alloc/actions?query=workflow%3ARust)
[![MIT/Apache](https://img.shields.io/badge/license-MIT%2FApache-blue.svg?style=for-the-badge)](COPYING)
![loc](https://img.shields.io/tokei/lines/github/zakarumych/gpu-alloc?style=for-the-badge)
Implementation agnostic memory allocator for Vulkan like APIs.
This crate is intended to be used as part of safe API implementations.\
Use with caution. There are unsafe functions all over the place.
## Usage
Start with fetching `DeviceProperties` from `gpu-alloc-<backend>` crate for the backend of choice.\
Then create `GpuAllocator` instance and use it for all device memory allocations.\
`GpuAllocator` will take care for all necessary bookkeeping like memory object count limit,
heap budget and memory mapping.
#### Backends implementations
Backend supporting crates should not depend on this crate.\
Instead they should depend on `gpu-alloc-types` which is much more stable,
allowing to upgrade `gpu-alloc` version without `gpu-alloc-<backend>` upgrade.
Supported Rust Versions
The minimum supported version is 1.40.
The current version is not guaranteed to build on Rust versions earlier than the minimum supported version.
`gpu-alloc-erupt` crate requires version 1.48 or higher due to dependency on `erupt` crate.
## License
Licensed under either of
* Apache License, Version 2.0, ([license/APACHE](license/APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([license/MIT](license/MIT) or http://opensource.org/licenses/MIT)
at your option.
## Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
## Donate
[![Become a patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/zakarum)

158
vendor/gpu-alloc-types/src/device.rs vendored Normal file
View File

@@ -0,0 +1,158 @@
use {
crate::types::{MemoryHeap, MemoryType},
alloc::borrow::Cow,
core::ptr::NonNull,
};
/// Memory exhausted error.
#[derive(Debug)]
pub enum OutOfMemory {
/// Device memory exhausted.
OutOfDeviceMemory,
/// Host memory exhausted.
OutOfHostMemory,
}
/// Memory mapped error.
#[derive(Debug)]
pub enum DeviceMapError {
/// Device memory exhausted.
OutOfDeviceMemory,
/// Host memory exhausted.
OutOfHostMemory,
/// Map failed due to implementation specific error.
MapFailed,
}
/// Specifies range of the mapped memory region.
#[derive(Debug)]
pub struct MappedMemoryRange<'a, M> {
/// Memory object reference.
pub memory: &'a M,
/// Offset in bytes from start of the memory object.
pub offset: u64,
/// Size in bytes of the memory range.
pub size: u64,
}
/// Properties of the device that will be used for allocating memory objects.
///
/// See `gpu-alloc-<backend>` crate to learn how to obtain one for backend of choice.
#[derive(Debug)]
pub struct DeviceProperties<'a> {
/// Array of memory types provided by the device.
pub memory_types: Cow<'a, [MemoryType]>,
/// Array of memory heaps provided by the device.
pub memory_heaps: Cow<'a, [MemoryHeap]>,
/// Maximum number of valid memory allocations that can exist simultaneously within the device.
pub max_memory_allocation_count: u32,
/// Maximum size for single allocation supported by the device.
pub max_memory_allocation_size: u64,
/// Atom size for host mappable non-coherent memory.
pub non_coherent_atom_size: u64,
/// Specifies if feature required to fetch device address is enabled.
pub buffer_device_address: bool,
}
bitflags::bitflags! {
/// Allocation flags
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct AllocationFlags : u8 {
/// Specifies that the memory can be used for buffers created
/// with flag that allows fetching device address.
const DEVICE_ADDRESS = 0x1;
}
}
/// Abstract device that can be used to allocate memory objects.
pub trait MemoryDevice<M> {
/// Allocates new memory object from device.
/// This function may be expensive and even limit maximum number of memory
/// objects allocated.
/// Which is the reason for sub-allocation this crate provides.
///
/// # Safety
///
/// `memory_type` must be valid index for memory type associated with this device.
/// Retrieving this information is implementation specific.
///
/// `flags` must be supported by the device.
unsafe fn allocate_memory(
&self,
size: u64,
memory_type: u32,
flags: AllocationFlags,
) -> Result<M, OutOfMemory>;
/// Deallocate memory object.
///
/// # Safety
///
/// Memory object must have been allocated from this device.\
/// All clones of specified memory handle must be dropped before calling this function.
unsafe fn deallocate_memory(&self, memory: M);
/// Map region of device memory to host memory space.
///
/// # Safety
///
/// * Memory object must have been allocated from this device.
/// * Memory object must not be already mapped.
/// * Memory must be allocated from type with `HOST_VISIBLE` property.
/// * `offset + size` must not overflow.
/// * `offset + size` must not be larger than memory object size specified when
/// memory object was allocated from this device.
unsafe fn map_memory(
&self,
memory: &mut M,
offset: u64,
size: u64,
) -> Result<NonNull<u8>, DeviceMapError>;
/// Unmap previously mapped memory region.
///
/// # Safety
///
/// * Memory object must have been allocated from this device.
/// * Memory object must be mapped
unsafe fn unmap_memory(&self, memory: &mut M);
/// Invalidates ranges of memory mapped regions.
///
/// # Safety
///
/// * Memory objects must have been allocated from this device.
/// * `offset` and `size` in each element of `ranges` must specify
/// subregion of currently mapped memory region
/// * if `memory` in some element of `ranges` does not contain `HOST_COHERENT` property
/// then `offset` and `size` of that element must be multiple of `non_coherent_atom_size`.
unsafe fn invalidate_memory_ranges(
&self,
ranges: &[MappedMemoryRange<'_, M>],
) -> Result<(), OutOfMemory>;
/// Flushes ranges of memory mapped regions.
///
/// # Safety
///
/// * Memory objects must have been allocated from this device.
/// * `offset` and `size` in each element of `ranges` must specify
/// subregion of currently mapped memory region
/// * if `memory` in some element of `ranges` does not contain `HOST_COHERENT` property
/// then `offset` and `size` of that element must be multiple of `non_coherent_atom_size`.
unsafe fn flush_memory_ranges(
&self,
ranges: &[MappedMemoryRange<'_, M>],
) -> Result<(), OutOfMemory>;
}

8
vendor/gpu-alloc-types/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,8 @@
#![no_std]
extern crate alloc;
mod device;
mod types;
pub use self::{device::*, types::*};

55
vendor/gpu-alloc-types/src/types.rs vendored Normal file
View File

@@ -0,0 +1,55 @@
bitflags::bitflags! {
/// Memory properties type.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct MemoryPropertyFlags: u8 {
/// This flag is set for device-local memory types.
/// Device-local memory is situated "close" to the GPU cores
/// and allows for fast access.
const DEVICE_LOCAL = 0x01;
/// This flag is set for host-visible memory types.
/// Host-visible memory can be mapped to the host memory range.
const HOST_VISIBLE = 0x02;
/// This flag is set for host-coherent memory types.
/// Host-coherent memory does not requires manual invalidation for
/// modifications on GPU to become visible on host;
/// nor flush for modification on host to become visible on GPU.
/// Access synchronization is still required.
const HOST_COHERENT = 0x04;
/// This flag is set for host-cached memory types.
/// Host-cached memory uses cache in host memory for faster reads from host.
const HOST_CACHED = 0x08;
/// This flag is set for lazily-allocated memory types.
/// Lazily-allocated memory must be used (and only) for transient image attachments.
const LAZILY_ALLOCATED = 0x10;
/// This flag is set for protected memory types.
/// Protected memory can be used for writing by protected operations
/// and can be read only by protected operations.
/// Protected memory cannot be host-visible.
/// Implementation must guarantee that there is no way for data to flow
/// from protected to unprotected memory.
const PROTECTED = 0x20;
}
}
/// Defines memory type.
#[derive(Clone, Copy, Debug)]
pub struct MemoryType {
/// Heap index of the memory type.
pub heap: u32,
/// Property flags of the memory type.
pub props: MemoryPropertyFlags,
}
/// Defines memory heap.
#[derive(Clone, Copy, Debug)]
pub struct MemoryHeap {
/// Size of memory heap in bytes.
pub size: u64,
}