Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
branches:
- main
pull_request:
branches:
- main
jobs:
win32:
runs-on: self-hosted
Expand Down
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ ddsfile = "0.5.1"
version = "0.9.0"
features = ["docking"]

[target.'cfg(target_os = "macos")'.dependencies]
metal = "0.28.0"
winit = "0.29.1"
objc = "0.2.4"
cocoa = "0.25.0"
core-graphics-types = "0.1.3"

[target.'cfg(windows)'.dependencies.windows]
version = "0.58.0"
features = [
Expand Down
6 changes: 3 additions & 3 deletions client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use hotline_rs::*;
use hotline_rs::client::*;


fn main() -> Result<(), hotline_rs::Error> {
fn main() -> Result<(), hotline_rs::Error> {

// create client
let ctx : Client<gfx_platform::Device, os_platform::App> = Client::create(HotlineInfo {
..Default::default()
})?;

// run
if let Err(e) = ctx.run() {
println!("error: {}", e.msg);
Expand Down
9 changes: 3 additions & 6 deletions examples/bindful/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// currently windows only because here we need a concrete gfx and os implementation
#![cfg(target_os = "windows")]

use hotline_rs::{*, prelude::*};
use hotline_rs::{*, prelude::{Pipeline, Texture}};

use os::{App, Window};
use gfx::{CmdBuf, Device, SwapChain, RenderPass};
Expand Down Expand Up @@ -113,7 +110,7 @@ fn main() -> Result<(), hotline_rs::Error> {
let mut pmfx : pmfx::Pmfx<gfx_platform::Device> = pmfx::Pmfx::create(&mut dev, 0);
pmfx.load(&hotline_rs::get_data_path("shaders/bindful"))?;
pmfx.create_render_pipeline(&dev, "bindful", swap_chain.get_backbuffer_pass())?;

let fmt = swap_chain.get_backbuffer_pass().get_format_hash();
let pso_pmfx = pmfx.get_render_pipeline_for_format("bindful", fmt)?;

Expand Down Expand Up @@ -199,7 +196,7 @@ fn main() -> Result<(), hotline_rs::Error> {
};
cmdbuffer.push_render_constants(c0.index, 2, 0, gfx::as_u8_slice(&pc));
}

cmdbuffer.set_index_buffer(&index_buffer);
cmdbuffer.set_vertex_buffer(&vertex_buffer, 0);
cmdbuffer.draw_indexed_instanced(6, 1, 0, 0, 0);
Expand Down
10 changes: 4 additions & 6 deletions examples/bindless/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// currently windows only because here we need a concrete gfx and os implementation
#![cfg(target_os = "windows")]

use hotline_rs::{*, prelude::*};
use hotline_rs::*;
use hotline_rs::prelude::*;

use os::{App, Window};
use gfx::{CmdBuf, Device, SwapChain, RenderPass};
Expand Down Expand Up @@ -116,7 +114,7 @@ fn main() -> Result<(), hotline_rs::Error> {
pmfx.load(&hotline_rs::get_data_path("shaders/bindless"))?;
pmfx.create_compute_pipeline(&dev, "compute_rw")?;
pmfx.create_render_pipeline(&dev, "bindless", swap_chain.get_backbuffer_pass())?;

let fmt = swap_chain.get_backbuffer_pass().get_format_hash();
let pso_pmfx = pmfx.get_render_pipeline_for_format("bindless", fmt)?;
let pso_compute = pmfx.get_compute_pipeline("compute_rw")?;
Expand Down Expand Up @@ -260,7 +258,7 @@ fn main() -> Result<(), hotline_rs::Error> {
cmdbuffer.set_scissor_rect(&scissor);

cmdbuffer.set_render_pipeline(pso_pmfx);

cmdbuffer.set_heap(pso_pmfx, dev.get_shader_heap());

cmdbuffer.set_index_buffer(&index_buffer);
Expand Down
7 changes: 2 additions & 5 deletions examples/imgui_demo/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// currently windows only because here we need a concrete gfx and os implementation
#![cfg(target_os = "windows")]

use hotline_rs::*;

use os::{App, Window};
use gfx::{CmdBuf, Device, SwapChain};


fn main() -> Result<(), hotline_rs::Error> {
// app
let mut app = os_platform::App::create(os::AppInfo {
Expand Down Expand Up @@ -67,6 +63,7 @@ fn main() -> Result<(), hotline_rs::Error> {
filepath: font_path,
glyph_ranges: None
}],
monitors: app.enumerate_display_monitors()
};
let mut imgui = imgui::ImGui::create(&mut imgui_info).unwrap();

Expand Down Expand Up @@ -118,6 +115,6 @@ fn main() -> Result<(), hotline_rs::Error> {

// resources now no longer in use they can be properly cleaned up
dev.cleanup_dropped_resources(&swap_chain);

Ok(())
}
7 changes: 3 additions & 4 deletions examples/play_video/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// currently windows only because here we need a concrete gfx and os implementation
#![cfg(target_os = "windows")]

use hotline_rs::prelude::*;
use hotline_rs::*;

fn main() -> Result<(), hotline_rs::Error> {
// app
Expand Down Expand Up @@ -53,7 +51,7 @@ fn main() -> Result<(), hotline_rs::Error> {
fonts: vec![
imgui::FontInfo{
filepath: hotline_rs::get_data_path("fonts/roboto_medium.ttf"),
glyph_ranges: None
glyph_ranges: None
},
imgui::FontInfo{
filepath: hotline_rs::get_data_path("fonts/font_awesome.ttf"),
Expand All @@ -62,6 +60,7 @@ fn main() -> Result<(), hotline_rs::Error> {
])
}
],
monitors: app.enumerate_display_monitors()
};

let mut imgui = imgui::ImGui::create(&mut imgui_info).unwrap();
Expand Down
20 changes: 8 additions & 12 deletions examples/raytraced_triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ use gfx::SwapChain;
use os::App;
use os::Window;

#[cfg(target_os = "windows")]
use os::win32 as os_platform;
use gfx::d3d12 as gfx_platform;

/// Create an rw texture output for raytracing to write into
fn create_raytracing_output(device: &mut gfx_platform::Device, window_rect: &os::Rect<i32>) -> gfx_platform::Texture {
let rw_info = gfx::TextureInfo {
Expand Down Expand Up @@ -96,7 +92,7 @@ fn main() -> Result<(), hotline_rs::Error> {
-0.25, 0.25, 1.0,
0.25, 0.25, 1.0
];

let vertex_buffer = device.create_buffer(&gfx::BufferInfo {
usage: BufferUsage::UPLOAD,
cpu_access: gfx::CpuAccessFlags::WRITE,
Expand Down Expand Up @@ -127,8 +123,8 @@ fn main() -> Result<(), hotline_rs::Error> {
let tlas = device.create_raytracing_tlas(&RaytracingTLASInfo {
instances: &vec![RaytracingInstanceInfo {
transform: [
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0
],
instance_id: 0,
Expand Down Expand Up @@ -163,7 +159,7 @@ fn main() -> Result<(), hotline_rs::Error> {

let raytracing_pipeline = pmfx.get_raytracing_pipeline("raytracing")?;
cmd.set_raytracing_pipeline(&raytracing_pipeline.pipeline);

// bind rw tex on u0
let uav0 = raytracing_output.get_uav_index().expect("expect raytracing_output to have a uav");
if let Some(u0) = raytracing_pipeline.pipeline.get_pipeline_slot(0, 0, gfx::DescriptorType::UnorderedAccess) {
Expand All @@ -175,14 +171,14 @@ fn main() -> Result<(), hotline_rs::Error> {
let aspect = window_rect.width as f32 / window_rect.height as f32;
cmd.push_compute_constants(0, 8, 0, gfx::as_u8_slice(&[
// viewport
-1.0 + border,
-1.0 + border,
-1.0 + border * aspect,
1.0 - border,
1.0 - border,
1.0 - border * aspect,
// scissor
-1.0 + border / aspect,
-1.0 + border / aspect,
-1.0 + border,
1.0 - border / aspect,
1.0 - border / aspect,
1.0 - border
]));

Expand Down
15 changes: 6 additions & 9 deletions examples/resource_tests/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// currently windows only because here we need a concrete gfx and os implementation
#![cfg(target_os = "windows")]

use hotline_rs::{*, prelude::{Pipeline, Texture}};

use os::{App, Window};
Expand Down Expand Up @@ -111,11 +108,11 @@ fn main() -> Result<(), hotline_rs::Error> {
// create resources that are defined in resource_tests.pmfx
pmfx.create_texture(&mut dev, "bear_frame")?;
pmfx.create_texture(&mut dev, "copy_dest")?;

pmfx.create_texture(&mut dev, "compressed_bc1")?;
pmfx.create_texture(&mut dev, "compressed_bc5")?;
pmfx.create_texture(&mut dev, "compressed_bc3")?;

let fmt = swap_chain.get_backbuffer_pass().get_format_hash();
let pso_pmfx = pmfx.get_render_pipeline_for_format("bindful", fmt)?;

Expand All @@ -141,7 +138,7 @@ fn main() -> Result<(), hotline_rs::Error> {
let viewport = gfx::Viewport::from(vp_rect);
let scissor = gfx::ScissorRect::from(vp_rect);

// copy texture region
// copy texture region
cmdbuffer.transition_barrier(&gfx::TransitionBarrier {
texture: Some(textures[1]),
buffer: None,
Expand All @@ -161,8 +158,8 @@ fn main() -> Result<(), hotline_rs::Error> {
0, 0, 0, 0,
textures[0],
Some(gfx::Region{
left: 380,
top: 380,
left: 380,
top: 380,
front: 0,
right: 380 + 512,
bottom: 380 + 512,
Expand Down Expand Up @@ -227,7 +224,7 @@ fn main() -> Result<(), hotline_rs::Error> {
if let Some(t3) = pso_pmfx.get_pipeline_slot(3, 0, gfx::DescriptorType::ShaderResource) {
cmdbuffer.set_binding(pso_pmfx, &pmfx.shader_heap, t3.index, srv3);
}

cmdbuffer.set_index_buffer(&index_buffer);
cmdbuffer.set_vertex_buffer(&vertex_buffer, 0);
cmdbuffer.draw_indexed_instanced(6, 1, 0, 0, 0);
Expand Down
12 changes: 0 additions & 12 deletions examples/swap_chain/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ use maths_rs::cos;

use gfx::Device;

#[cfg(target_os = "windows")]
use os::win32 as os_platform;

#[cfg(target_os = "windows")]
use gfx::d3d12 as gfx_platform;

#[cfg(target_os = "macos")]
use os::macos as os_platform;

#[cfg(target_os = "macos")]
use gfx::mtl as gfx_platform;

fn main() -> Result<(), hotline_rs::Error> {
// create an app
println!("create app!");
Expand Down
8 changes: 2 additions & 6 deletions examples/triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ use os::Window;

use std::fs;

#[cfg(target_os = "windows")]
use os::win32 as os_platform;
use gfx::d3d12 as gfx_platform;

#[repr(C)]
struct Vertex {
position: [f32; 3],
Expand Down Expand Up @@ -78,7 +74,7 @@ fn main() -> Result<(), hotline_rs::Error> {
initial_state: gfx::ResourceState::VertexConstantBuffer
};

let vertex_buffer = device.create_buffer(&info, Some(gfx::as_u8_slice(&vertices)))?;
let vertex_buffer = device.create_buffer(&info, Some(gfx::as_u8_slice(&vertices)))?;

let vsc_filepath = hotline_rs::get_data_path("shaders/triangle/vs_main.vsc");
let psc_filepath = hotline_rs::get_data_path("shaders/triangle/ps_main.psc");
Expand All @@ -91,7 +87,7 @@ fn main() -> Result<(), hotline_rs::Error> {
compile_info: None
};
let vs = device.create_shader(&vsc_info, &vsc_data)?;

let psc_info = gfx::ShaderInfo {
shader_type: gfx::ShaderType::Vertex,
compile_info: None
Expand Down
Loading