Skip to content

Commit

Permalink
- rename module to mtl to avoid collision with metal-rs metal, invoke…
Browse files Browse the repository at this point in the history
… device creation + device sample working
  • Loading branch information
polymonster committed Jun 4, 2024
1 parent 84b3e5b commit 1e30c09
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions examples/gfx_device/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/gfx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/gfx/metal.rs → src/gfx/mtl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::result;

#[derive(Clone)]
pub struct Device {
metal_device: metal::Device,
shader_heap: Heap,
adapter_info: AdapterInfo
}
Expand Down Expand Up @@ -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 {

},
Expand Down

0 comments on commit 1e30c09

Please sign in to comment.