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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ jobs:
- name: xtask build
run: cd xtask && cargo build
- name: xtask generate
run: cargo xtask generate ${{ matrix.integration }}
# generate all variants, since `--clean` deletes `generated/`, not generating all of them will cause changes
run: cargo xtask generate --clean
- name: check generated files are up-to-date
run: |
git add .
Expand Down
9 changes: 0 additions & 9 deletions ash-graphics/cargo-generate.toml

This file was deleted.

2 changes: 1 addition & 1 deletion cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[template]
sub_templates = ["ash-graphics"]
sub_templates = ["graphics"]
4 changes: 2 additions & 2 deletions generated/cargo-gpu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = [
"ash-graphics",
"ash-graphics-shaders"
"ash",
"shaders"
]
resolver = "3"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ash-graphics"
name = "graphics-ash"
publish = false
version.workspace = true
authors.workspace = true
Expand All @@ -11,7 +11,7 @@ repository.workspace = true
workspace = true

[dependencies]
ash-graphics-shaders = { path = "../ash-graphics-shaders" }
graphics-shaders = { path = "../shaders" }

ash.workspace = true
ash-window.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;

pub fn main() -> anyhow::Result<()> {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let crate_path = [manifest_dir, "..", "ash-graphics-shaders"]
let crate_path = [manifest_dir, "..", "shaders"]
.iter()
.copied()
.collect::<PathBuf>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::single_command_buffer::SingleCommandBuffer;
use crate::swapchain::DrawFrame;
use anyhow::Context;
use ash::vk;
use ash_graphics_shaders::ShaderConstants;
use graphics_shaders::ShaderConstants;
use std::sync::Arc;

/// Manages the creation and recreation of [`MyRenderPipeline`], whenever new shader code ([`Self::set_shader_code`])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ use crate::device::MyDevice;
use crate::graphics::{MyRenderPipelineManager, MyRenderer};
use crate::swapchain::MySwapchainManager;
use ash::util::read_spv;
use ash_graphics_shaders::ShaderConstants;
use graphics_shaders::ShaderConstants;
use raw_window_handle::HasDisplayHandle as _;
use winit::event_loop::ActiveEventLoop;
use winit::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ash-graphics-shaders"
name = "graphics-shaders"
version = "0.1.0"
edition = "2024"

Expand Down
4 changes: 2 additions & 2 deletions generated/spirv-builder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = [
"ash-graphics",
"ash-graphics-shaders"
"ash",
"shaders"
]
resolver = "3"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ash-graphics"
name = "graphics-ash"
publish = false
version.workspace = true
authors.workspace = true
Expand All @@ -15,7 +15,7 @@ default = ["use-compiled-tools"]
use-installed-tools = ["spirv-builder/use-installed-tools"]
use-compiled-tools = ["spirv-builder/use-compiled-tools"]
[dependencies]
ash-graphics-shaders = { path = "../ash-graphics-shaders" }
graphics-shaders = { path = "../shaders" }

ash.workspace = true
ash-window.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;

pub fn main() -> anyhow::Result<()> {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let crate_path = [manifest_dir, "..", "ash-graphics-shaders"]
let crate_path = [manifest_dir, "..", "shaders"]
.iter()
.copied()
.collect::<PathBuf>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::single_command_buffer::SingleCommandBuffer;
use crate::swapchain::DrawFrame;
use anyhow::Context;
use ash::vk;
use ash_graphics_shaders::ShaderConstants;
use graphics_shaders::ShaderConstants;
use std::sync::Arc;

/// Manages the creation and recreation of [`MyRenderPipeline`], whenever new shader code ([`Self::set_shader_code`])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ use crate::device::MyDevice;
use crate::graphics::{MyRenderPipelineManager, MyRenderer};
use crate::swapchain::MySwapchainManager;
use ash::util::read_spv;
use ash_graphics_shaders::ShaderConstants;
use graphics_shaders::ShaderConstants;
use raw_window_handle::HasDisplayHandle as _;
use winit::event_loop::ActiveEventLoop;
use winit::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ash-graphics-shaders"
name = "graphics-shaders"
version = "0.1.0"
edition = "2024"

Expand Down
10 changes: 5 additions & 5 deletions ash-graphics/Cargo.toml.liquid → graphics/Cargo.toml.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = [
"ash-graphics",
"ash-graphics-shaders"
"ash",
"shaders"
]
resolver = "3"

Expand All @@ -16,11 +16,11 @@ repository = ""
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[workspace.dependencies]
{% if integration_type == "spirv-builder" -%}
{% if integration == "spirv-builder" -%}
# 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" }
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
{% if integration == "cargo-gpu" -%}
cargo-gpu = { git = "https://github.com/Rust-GPU/cargo-gpu", rev = "bf24eb6060e0c7b0013eceddd23b5d7cee68f4cc" }
{% endif -%}
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6fb875068d0d35b1a81ae89b73cf7a464f8c60f7" }
Expand All @@ -34,7 +34,7 @@ winit = "0.30.0"
cfg-if = "1.0.0"
anyhow = "1.0.98"

{% if integration_type == "spirv-builder" -%}
{% if integration == "spirv-builder" -%}
# Optimize build scripts, copied from rust-gpu's repo
# Enable incremental by default in release mode.
[profile.release]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ash-graphics"
name = "graphics-ash"
publish = false
version.workspace = true
authors.workspace = true
Expand All @@ -10,15 +10,15 @@ repository.workspace = true
[lints]
workspace = true

{% if integration_type == "spirv-builder" -%}
{% if integration == "spirv-builder" -%}
[features]
default = ["use-compiled-tools"]
use-installed-tools = ["spirv-builder/use-installed-tools"]
use-compiled-tools = ["spirv-builder/use-compiled-tools"]
{% endif -%}

[dependencies]
ash-graphics-shaders = { path = "../ash-graphics-shaders" }
graphics-shaders = { path = "../shaders" }

ash.workspace = true
ash-window.workspace = true
Expand All @@ -28,10 +28,10 @@ anyhow.workspace = true
bytemuck.workspace = true

[build-dependencies]
{% if integration_type == "spirv-builder" -%}
{% if integration == "spirv-builder" -%}
spirv-builder.workspace = true
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
{% if integration == "cargo-gpu" -%}
cargo-gpu.workspace = true
{% endif -%}
anyhow.workspace = true
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{% if integration_type == "spirv-builder" -%}
{% if integration == "spirv-builder" -%}
use spirv_builder::{MetadataPrintout, ShaderPanicStrategy, SpirvBuilder};
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
{% if integration == "cargo-gpu" -%}
use cargo_gpu::Install;
use cargo_gpu::spirv_builder::{MetadataPrintout, ShaderPanicStrategy};
{% endif -%}
use std::path::PathBuf;

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

{% if integration_type == "spirv-builder" -%}
{% if integration == "spirv-builder" -%}
let mut builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.3");
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
{% if integration == "cargo-gpu" -%}
let install = Install::from_shader_crate(crate_path.clone()).run()?;
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::single_command_buffer::SingleCommandBuffer;
use crate::swapchain::DrawFrame;
use anyhow::Context;
use ash::vk;
use ash_graphics_shaders::ShaderConstants;
use graphics_shaders::ShaderConstants;
use std::sync::Arc;

/// Manages the creation and recreation of [`MyRenderPipeline`], whenever new shader code ([`Self::set_shader_code`])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ use crate::device::MyDevice;
use crate::graphics::{MyRenderPipelineManager, MyRenderer};
use crate::swapchain::MySwapchainManager;
use ash::util::read_spv;
use ash_graphics_shaders::ShaderConstants;
use graphics_shaders::ShaderConstants;
use raw_window_handle::HasDisplayHandle as _;
use winit::event_loop::ActiveEventLoop;
use winit::{
Expand Down
9 changes: 9 additions & 0 deletions graphics/cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[template]
ignore = ["target"]
exclude = ["target"]

[placeholders]
integration = { prompt = "What integration type?", choices = ["cargo-gpu", "spirv-builder"], default = "cargo-gpu", type = "string" }

[conditional.'integration != "spirv-builder"']
ignore = [ "rust-toolchain.toml" ]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ash-graphics-shaders"
name = "graphics-shaders"
version = "0.1.0"
edition = "2024"

Expand Down
18 changes: 14 additions & 4 deletions xtask/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::fmt::{Debug, Display, Formatter};
use std::path::{Path, PathBuf};
use strum::{Display, EnumString, IntoStaticStr, VariantArray};

pub const TEMPLATE_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../graphics");

/// All possible placeholder *values*.
///
/// We assume there are no duplicate values for placeholders, so we don't need to type out the key / placeholder name,
Expand Down Expand Up @@ -40,7 +42,7 @@ impl clap::ValueEnum for Values {
impl Values {
pub fn key(&self) -> Placeholders {
match self {
Values::CargoGpu | Values::SpirvBuilder => Placeholders::IntegrationType,
Values::CargoGpu | Values::SpirvBuilder => Placeholders::Integration,
}
}

Expand All @@ -52,8 +54,8 @@ impl Values {
#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Display, EnumString, IntoStaticStr, VariantArray)]
pub enum Placeholders {
#[strum(to_string = "integration_type")]
IntegrationType,
#[strum(to_string = "integration")]
Integration,
}

impl Debug for Placeholders {
Expand All @@ -67,6 +69,10 @@ pub struct Generate {
/// Directory where to place the generated templates.
#[clap(long)]
out: Option<PathBuf>,
/// Clean generate, deletes the generated directory before generating templates. Use this when you moved or removed
/// files.
#[clap(long)]
clean: bool,
/// A command that should be executed on each generated template.
///
/// If a command fails, this process will fail as well, allowing you to test the template output.
Expand Down Expand Up @@ -124,6 +130,10 @@ impl Generate {
.out
.clone()
.unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../generated"));
debug!("out_base_dir: {}", out.display());
if self.clean {
std::fs::remove_dir_all(&out)?;
}
std::fs::create_dir_all(&out)?;
Ok(out)
}
Expand All @@ -148,7 +158,7 @@ impl Generate {

debug!("Generating `{variant:?}` at `{}`", out_dir.display());
let mut args = GenerateArgs::default();
args.template_path.path = Some(format!("{}/../ash-graphics", env!("CARGO_MANIFEST_DIR")));
args.template_path.path = Some(TEMPLATE_PATH.to_string());
args.init = true;
args.overwrite = true;
args.define = variant
Expand Down
Loading