From 7d8577cb90d73b1cc6d3010bafe97ae3d4c8ba6c Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 14 Sep 2018 09:06:44 -0400 Subject: [PATCH] Obtain memory properties --- src/command/compute.rs | 20 ++++++++++++++++++++ src/command/render.rs | 9 +++++++-- src/device.rs | 2 ++ src/instance.rs | 1 + src/lib.rs | 1 + 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/command/compute.rs b/src/command/compute.rs index 044880348..df2f0c01a 100644 --- a/src/command/compute.rs +++ b/src/command/compute.rs @@ -1,5 +1,25 @@ use hal; +use {CommandBuffer, CommandBufferHandle, ComputePassHandle}; + + pub struct ComputePass { raw: B::CommandBuffer, } + +pub extern "C" +fn compute_pass_dispatch( + pass: ComputePassHandle, groups_x: u32, groups_y: u32, groups_z: u32 +) { + unimplemented!() +} + +pub extern "C" +fn compute_pass_end(pass: ComputePassHandle) -> CommandBufferHandle { + match pass.unbox() { + Some(pass) => CommandBufferHandle::new(CommandBuffer { + raw: pass.raw, + }), + None => CommandBufferHandle::null(), + } +} diff --git a/src/command/render.rs b/src/command/render.rs index 701386a16..a6c1e19a5 100644 --- a/src/command/render.rs +++ b/src/command/render.rs @@ -1,6 +1,6 @@ use hal; -use {CommandBufferHandle, RenderPassHandle}; +use {CommandBuffer, CommandBufferHandle, RenderPassHandle}; pub struct RenderPass { @@ -23,5 +23,10 @@ fn render_pass_draw_indexed( pub extern "C" fn render_pass_end(pass: RenderPassHandle) -> CommandBufferHandle { - unimplemented!() + match pass.unbox() { + Some(pass) => CommandBufferHandle::new(CommandBuffer { + raw: pass.raw, + }), + None => CommandBufferHandle::null(), + } } diff --git a/src/device.rs b/src/device.rs index 90775deb2..646e6278a 100644 --- a/src/device.rs +++ b/src/device.rs @@ -1,4 +1,5 @@ use hal::{self, Device as _Device}; +use memory; use {BufferHandle, CommandBufferHandle, DeviceHandle}; @@ -17,6 +18,7 @@ pub struct CommandBufferDescriptor { pub struct Device { pub gpu: hal::Gpu, + pub memory_properties: hal::MemoryProperties, } pub struct Buffer { diff --git a/src/instance.rs b/src/instance.rs index 388d9f160..1616ef3ec 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -61,5 +61,6 @@ fn adapter_create_device( let gpu = adapter.physical_device.open(&[(queue_family, &[1f32])]).unwrap(); DeviceHandle::new(Device { gpu, + memory_properties: adapter.physical_device.memory_properties(), }) } diff --git a/src/lib.rs b/src/lib.rs index aed275dd4..48e943f16 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ extern crate gfx_backend_vulkan as back; extern crate gfx_backend_dx12 as back; #[cfg(feature = "gfx-backend-metal")] extern crate gfx_backend_metal as back; +extern crate gfx_memory as memory; mod command; mod device;