From 1e30c09175047d260cd75c2fe7288e0bad462abc Mon Sep 17 00:00:00 2001 From: polymonster Date: Tue, 4 Jun 2024 11:34:00 +0200 Subject: [PATCH] - rename module to mtl to avoid collision with metal-rs metal, invoke device creation + device sample working --- examples/gfx_device/main.rs | 7 ++++--- src/gfx.rs | 2 +- src/gfx/{metal.rs => mtl.rs} | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) rename src/gfx/{metal.rs => mtl.rs} (98%) diff --git a/examples/gfx_device/main.rs b/examples/gfx_device/main.rs index 2b03627..82b6e73 100644 --- a/examples/gfx_device/main.rs +++ b/examples/gfx_device/main.rs @@ -15,13 +15,13 @@ use gfx::d3d12 as gfx_platform; use os::macos as os_platform; #[cfg(target_os = "macos")] -use gfx::metal as gfx_platform; +use gfx::mtl as gfx_platform; fn main() -> Result<(), hotline_rs::Error> { // create an app println!("create app!"); let mut app = os_platform::App::create(os::AppInfo { - name: String::from("window"), + name: String::from("gfx_device"), window: false, num_buffers: 0, dpi_aware: true, @@ -30,11 +30,12 @@ fn main() -> Result<(), hotline_rs::Error> { // create a window println!("create window!"); let mut window = app.create_window(os::WindowInfo { - title: String::from("window!"), + title: String::from("gfx_device!"), ..Default::default() }); // create a device + println!("create device!"); let num_buffers = 2; let mut device = gfx_platform::Device::create(&gfx::DeviceInfo { render_target_heap_size: num_buffers as usize, diff --git a/src/gfx.rs b/src/gfx.rs index b1695c3..ca9cd07 100644 --- a/src/gfx.rs +++ b/src/gfx.rs @@ -10,7 +10,7 @@ pub mod d3d12; /// Implemets this interface with a Metal backend. #[cfg(target_os = "macos")] -pub mod metal; +pub mod mtl; type Error = super::Error; diff --git a/src/gfx/metal.rs b/src/gfx/mtl.rs similarity index 98% rename from src/gfx/metal.rs rename to src/gfx/mtl.rs index 39e7acc..33a2d21 100644 --- a/src/gfx/metal.rs +++ b/src/gfx/mtl.rs @@ -12,6 +12,7 @@ use std::result; #[derive(Clone)] pub struct Device { + metal_device: metal::Device, shader_heap: Heap, adapter_info: AdapterInfo } @@ -393,6 +394,7 @@ impl super::Device for Device { fn create(info: &super::DeviceInfo) -> Device { Device { + metal_device: metal::Device::system_default().expect("hotline_rs::gfx::mtl: failed to create metal device"), shader_heap: Heap { },