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
380 changes: 379 additions & 1 deletion Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spir
ash = "0.38"
ash-window = "0.13"
wgpu = { version = "27.0.1", default-features = false, features = ["std", "parking_lot", "vulkan", "vulkan-portability", "spirv", "wgsl"] }
pollster = "0.4.0"

# rust-gpu
cargo-gpu = { git = "https://github.com/Rust-GPU/cargo-gpu", rev = "bf24eb6060e0c7b0013eceddd23b5d7cee68f4cc" }
Expand All @@ -31,5 +32,5 @@ glam = { version = "0.30.9", default-features = false }
bytemuck = { version = "1.24.0", features = ["derive"] }
raw-window-handle = "0.6.2"
winit = "0.30.0"
cfg-if = "1.0.0"
env_logger = "0.11.8"
anyhow = "1.0.98"
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ repository = ""
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[workspace.dependencies]
# API
ash = "0.38"
ash-window = "0.13"

# rust-gpu
cargo-gpu = { git = "https://github.com/Rust-GPU/cargo-gpu", rev = "bf24eb6060e0c7b0013eceddd23b5d7cee68f4cc" }
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6fb875068d0d35b1a81ae89b73cf7a464f8c60f7" }

# other
glam = { version = "0.30.9", default-features = false }
bytemuck = { version = "1.24.0", features = ["derive"] }
ash = "0.38"
ash-window = "0.13"
raw-window-handle = "0.6.2"
winit = "0.30.0"
cfg-if = "1.0.0"
env_logger = "0.11.8"
anyhow = "1.0.98"

Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ repository.workspace = true
workspace = true

[dependencies]
# shader crate
mygraphics-shaders = { path = "../mygraphics-shaders" }

# API
ash.workspace = true
ash-window.workspace = true

# other
raw-window-handle.workspace = true
winit.workspace = true
anyhow.workspace = true
bytemuck.workspace = true

[build-dependencies]
# rust-gpu
cargo-gpu.workspace = true

# other
anyhow.workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ repository = ""
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[workspace.dependencies]
# API
ash = "0.38"
ash-window = "0.13"

# rust-gpu
# The version of the dependencies `spirv-builder` and `spirv-std` must match exactly!
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6fb875068d0d35b1a81ae89b73cf7a464f8c60f7" }
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6fb875068d0d35b1a81ae89b73cf7a464f8c60f7" }

# other
glam = { version = "0.30.9", default-features = false }
bytemuck = { version = "1.24.0", features = ["derive"] }
ash = "0.38"
ash-window = "0.13"
raw-window-handle = "0.6.2"
winit = "0.30.0"
cfg-if = "1.0.0"
env_logger = "0.11.8"
anyhow = "1.0.98"

# Optimize build scripts, copied from rust-gpu's repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ default = ["use-compiled-tools"]
use-installed-tools = ["spirv-builder/use-installed-tools"]
use-compiled-tools = ["spirv-builder/use-compiled-tools"]
[dependencies]
# shader crate
mygraphics-shaders = { path = "../mygraphics-shaders" }

# API
ash.workspace = true
ash-window.workspace = true

# other
raw-window-handle.workspace = true
winit.workspace = true
anyhow.workspace = true
bytemuck.workspace = true

[build-dependencies]
# rust-gpu
spirv-builder.workspace = true

# other
anyhow.workspace = true
34 changes: 34 additions & 0 deletions generated/graphics/wgpu/cargo-gpu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[workspace]
members = [
"mygraphics",
"mygraphics-shaders"
]
resolver = "3"

[workspace.package]
version = "0.1.0"
authors = ["generated <generated>"]
edition = "2024"
license = "MIT"
repository = ""

[workspace.lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[workspace.dependencies]
# API
wgpu = { version = "27.0.1", default-features = false, features = ["std", "parking_lot", "vulkan", "vulkan-portability", "spirv", "wgsl"] }
pollster = "0.4.0"

# rust-gpu
cargo-gpu = { git = "https://github.com/Rust-GPU/cargo-gpu", rev = "bf24eb6060e0c7b0013eceddd23b5d7cee68f4cc" }
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6fb875068d0d35b1a81ae89b73cf7a464f8c60f7" }

# other
glam = { version = "0.30.9", default-features = false }
bytemuck = { version = "1.24.0", features = ["derive"] }
raw-window-handle = "0.6.2"
winit = "0.30.0"
env_logger = "0.11.8"
anyhow = "1.0.98"

15 changes: 15 additions & 0 deletions generated/graphics/wgpu/cargo-gpu/mygraphics-shaders/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "mygraphics-shaders"
version = "0.1.0"
edition = "2024"

[lints]
workspace = true

[lib]
crate-type = ["lib", "dylib"]

[dependencies]
spirv-std.workspace = true
glam.workspace = true
bytemuck.workspace = true
36 changes: 36 additions & 0 deletions generated/graphics/wgpu/cargo-gpu/mygraphics-shaders/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#![no_std]

use bytemuck::{Pod, Zeroable};
use core::f32::consts::PI;
use glam::{Vec3, Vec4, vec2, vec3};
#[cfg(target_arch = "spirv")]
use spirv_std::num_traits::Float;
use spirv_std::spirv;

#[derive(Copy, Clone, Pod, Zeroable)]
#[repr(C)]
pub struct ShaderConstants {
pub width: u32,
pub height: u32,
pub time: f32,
}

#[spirv(fragment)]
pub fn main_fs(vtx_color: Vec3, output: &mut Vec4) {
*output = Vec4::from((vtx_color, 1.));
}

#[spirv(vertex)]
pub fn main_vs(
#[spirv(vertex_index)] vert_id: i32,
#[spirv(push_constant)] constants: &ShaderConstants,
#[spirv(position)] vtx_pos: &mut Vec4,
vtx_color: &mut Vec3,
) {
let speed = 0.4;
let time = constants.time * speed + vert_id as f32 * (2. * PI * 120. / 360.);
let position = vec2(f32::sin(time), f32::cos(time));
*vtx_pos = Vec4::from((position, 0.0, 1.0));

*vtx_color = [vec3(1., 0., 0.), vec3(0., 1., 0.), vec3(0., 0., 1.)][vert_id as usize % 3];
}
33 changes: 33 additions & 0 deletions generated/graphics/wgpu/cargo-gpu/mygraphics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "mygraphics"
publish = false
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

[lints]
workspace = true

[dependencies]
# shader crate
mygraphics-shaders = { path = "../mygraphics-shaders" }

# API
wgpu.workspace = true
pollster.workspace = true
env_logger.workspace = true

# other
raw-window-handle.workspace = true
winit.workspace = true
anyhow.workspace = true
bytemuck.workspace = true

[build-dependencies]
# rust-gpu
cargo-gpu.workspace = true

# other
anyhow.workspace = true
24 changes: 24 additions & 0 deletions generated/graphics/wgpu/cargo-gpu/mygraphics/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use cargo_gpu::Install;
use cargo_gpu::spirv_builder::{MetadataPrintout, ShaderPanicStrategy};
use std::path::PathBuf;

pub fn main() -> anyhow::Result<()> {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let crate_path = [manifest_dir, "..", "mygraphics-shaders"]
.iter()
.copied()
.collect::<PathBuf>();

let install = Install::from_shader_crate(crate_path.clone()).run()?;
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
builder.print_metadata = MetadataPrintout::DependencyOnly;
builder.shader_panic_strategy = ShaderPanicStrategy::DebugPrintfThenExit {
print_inputs: true,
print_backtrace: true,
};

let compile_result = builder.build()?;
let spv_path = compile_result.module.unwrap_single();
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
Ok(())
}
74 changes: 74 additions & 0 deletions generated/graphics/wgpu/cargo-gpu/mygraphics/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// FIXME(eddyb) update/review these lints.
//
// BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
//#![deny(unsafe_code)] // impractical in this crate dealing with unsafe `ash`
#![warn(
clippy::all,
clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro,
clippy::debug_assert_with_mut_call,
clippy::doc_markdown,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools,
clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops,
clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value,
clippy::let_unit_value,
clippy::linkedlist,
clippy::lossy_float_literal,
clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore,
clippy::map_flatten,
clippy::map_unwrap_or,
clippy::match_same_arms,
clippy::match_wildcard_for_single_variants,
clippy::mem_forget,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow,
clippy::needless_continue,
clippy::option_option,
clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign,
clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string,
clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
clippy::unnested_or_patterns,
clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible,
nonstandard_style,
rust_2018_idioms
)]
// END - Embark standard lints v0.4
// crate-specific exceptions:
// #![allow()]

pub mod util;
pub mod wgpu_renderer;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub fn main() -> anyhow::Result<()> {
mygraphics::ash_renderer::main()
mygraphics::wgpu_renderer::main()
}
5 changes: 5 additions & 0 deletions generated/graphics/wgpu/cargo-gpu/mygraphics/src/util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub fn enable_debug_layer() -> bool {
std::env::var("DEBUG_LAYER")
.map(|e| !(e == "0" || e == "false"))
.unwrap_or(false)
}
Loading