mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-10-29 21:41:36 +00:00
Create gfx-memory allocator
This commit is contained in:
parent
680918a11d
commit
7c23f7f0a2
58
Cargo.lock
generated
58
Cargo.lock
generated
@ -218,11 +218,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "gfx-backend-dx12"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#122da131665d8a757bdda7323442b9beb9ac2088"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=a435a05#a435a052f604168154c645bb5033bb3f09d95e91"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spirv_cross 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -234,22 +234,22 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-empty"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#122da131665d8a757bdda7323442b9beb9ac2088"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=a435a05#a435a052f604168154c645bb5033bb3f09d95e91"
|
||||
dependencies = [
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gfx-backend-metal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#122da131665d8a757bdda7323442b9beb9ac2088"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=a435a05#a435a052f604168154c645bb5033bb3f09d95e91"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cocoa 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"metal 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"objc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -263,11 +263,11 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-vulkan"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#122da131665d8a757bdda7323442b9beb9ac2088"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=a435a05#a435a052f604168154c645bb5033bb3f09d95e91"
|
||||
dependencies = [
|
||||
"ash 0.24.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -280,18 +280,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-hal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#122da131665d8a757bdda7323442b9beb9ac2088"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gfx-hal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=6cb2a800b#6cb2a800b24affc34de1e6d0d93fd52a534e81a1"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=a435a05#a435a052f604168154c645bb5033bb3f09d95e91"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -302,10 +291,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-memory"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx-memory#4f6e4107806d19a54371325f3f5ae656300e3fea"
|
||||
source = "git+https://github.com/kvark/gfx-mem?branch=update#a82aa4221250a493c2fe6fcc22a2b6876742cef2"
|
||||
dependencies = [
|
||||
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=6cb2a800b)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"relevant 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -313,12 +302,12 @@ dependencies = [
|
||||
name = "gpu-native"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gfx-backend-dx12 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-backend-empty 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-backend-metal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-backend-vulkan 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||
"gfx-memory 0.1.0 (git+https://github.com/gfx-rs/gfx-memory)",
|
||||
"gfx-backend-dx12 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"gfx-backend-empty 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"gfx-backend-metal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"gfx-backend-vulkan 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
|
||||
"gfx-memory 0.1.0 (git+https://github.com/kvark/gfx-mem?branch=update)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -850,13 +839,12 @@ dependencies = [
|
||||
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
||||
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
||||
"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
|
||||
"checksum gfx-backend-dx12 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "<none>"
|
||||
"checksum gfx-backend-empty 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "<none>"
|
||||
"checksum gfx-backend-metal 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "<none>"
|
||||
"checksum gfx-backend-vulkan 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "<none>"
|
||||
"checksum gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "<none>"
|
||||
"checksum gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=6cb2a800b)" = "<none>"
|
||||
"checksum gfx-memory 0.1.0 (git+https://github.com/gfx-rs/gfx-memory)" = "<none>"
|
||||
"checksum gfx-backend-dx12 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)" = "<none>"
|
||||
"checksum gfx-backend-empty 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)" = "<none>"
|
||||
"checksum gfx-backend-metal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)" = "<none>"
|
||||
"checksum gfx-backend-vulkan 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)" = "<none>"
|
||||
"checksum gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)" = "<none>"
|
||||
"checksum gfx-memory 0.1.0 (git+https://github.com/kvark/gfx-mem?branch=update)" = "<none>"
|
||||
"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"
|
||||
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
|
||||
"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
|
||||
|
13
Cargo.toml
13
Cargo.toml
@ -7,9 +7,10 @@ authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
gfx-hal = { git = "https://github.com/gfx-rs/gfx" }
|
||||
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx" }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", optional = true }
|
||||
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", optional = true }
|
||||
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", optional = true }
|
||||
gfx-memory = { git = "https://github.com/gfx-rs/gfx-memory" }
|
||||
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05" } # required by gfx-memory
|
||||
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05" }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05", optional = true }
|
||||
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05", optional = true }
|
||||
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05", optional = true }
|
||||
#gfx-memory = { git = "https://github.com/gfx-rs/gfx-memory" }
|
||||
gfx-memory = { git = "https://github.com/kvark/gfx-mem", branch = "update" }
|
||||
|
@ -17,8 +17,17 @@ pub struct CommandBufferDescriptor {
|
||||
}
|
||||
|
||||
pub struct Device<B: hal::Backend> {
|
||||
pub gpu: hal::Gpu<B>,
|
||||
pub memory_properties: hal::MemoryProperties,
|
||||
gpu: hal::Gpu<B>,
|
||||
allocator: memory::SmartAllocator<B>,
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> Device<B> {
|
||||
pub(crate) fn new(gpu: hal::Gpu<B>, mem_props: hal::MemoryProperties) -> Self {
|
||||
Device {
|
||||
gpu,
|
||||
allocator: memory::SmartAllocator::new(mem_props, 1, 1, 1, 1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Buffer<B: hal::Backend> {
|
||||
@ -29,9 +38,10 @@ pub extern "C"
|
||||
fn device_create_buffer(
|
||||
device: DeviceHandle, desc: BufferDescriptor
|
||||
) -> BufferHandle {
|
||||
//let unbound = device.raw.create_buffer(desc.size, desc.usage).unwrap();
|
||||
//let reqs = device.raw.get_buffer_requirements(&unbound);
|
||||
unimplemented!()
|
||||
let buffer = device.gpu.device.create_buffer(desc.size, desc.usage).unwrap();
|
||||
BufferHandle::new(Buffer {
|
||||
raw: buffer,
|
||||
})
|
||||
}
|
||||
|
||||
pub extern "C"
|
||||
|
@ -1,4 +1,3 @@
|
||||
use back;
|
||||
use hal::{self, Instance as _Instance, PhysicalDevice as _PhysicalDevice};
|
||||
|
||||
use {AdapterHandle, Device, DeviceHandle, InstanceHandle};
|
||||
@ -28,8 +27,12 @@ pub struct DeviceDescriptor {
|
||||
|
||||
pub extern "C"
|
||||
fn create_instance() -> InstanceHandle {
|
||||
let inst = back::Instance::create("wgpu", 1);
|
||||
InstanceHandle::new(inst)
|
||||
#[cfg(any(feature = "gfx-backend-vulkan", feature = "gfx-backend-dx12", feature = "gfx-backend-metal"))]
|
||||
{
|
||||
let inst = ::back::Instance::create("wgpu", 1);
|
||||
InstanceHandle::new(inst)
|
||||
}
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub extern "C"
|
||||
@ -59,8 +62,6 @@ fn adapter_create_device(
|
||||
) -> DeviceHandle {
|
||||
let queue_family = &adapter.queue_families[0];
|
||||
let gpu = adapter.physical_device.open(&[(queue_family, &[1f32])]).unwrap();
|
||||
DeviceHandle::new(Device {
|
||||
gpu,
|
||||
memory_properties: adapter.physical_device.memory_properties(),
|
||||
})
|
||||
let mem_props = adapter.physical_device.memory_properties();
|
||||
DeviceHandle::new(Device::new(gpu, mem_props))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user