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: 0 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[build]
target-dir = "target"

[alias]
xtask = "run --package xtask --"
8 changes: 5 additions & 3 deletions generated/graphics/ash/cargo-gpu/mygraphics/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ pub fn main() -> anyhow::Result<()> {
.copied()
.collect::<PathBuf>();

let target = "spirv-unknown-vulkan1.3";
let install = Install::from_shader_crate(crate_path.clone())
.within_build_script()
.run()?;
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
let mut builder = install.to_spirv_builder(crate_path, target);
builder.build_script.defaults = true;
builder.shader_panic_strategy = ShaderPanicStrategy::SilentExit;
builder.spirv_metadata = SpirvMetadata::Full;

let compile_result = builder.build()?;
let spv_path = compile_result.module.unwrap_single();
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
let artifact = compile_result.module.unwrap_single();

println!("cargo::rustc-env=SHADER_SPV_PATH={}", artifact.display());
Ok(())
}
8 changes: 5 additions & 3 deletions generated/graphics/ash/spirv-builder/mygraphics/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ pub fn main() -> anyhow::Result<()> {
.copied()
.collect::<PathBuf>();

let mut builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.3");
let target = "spirv-unknown-vulkan1.3";
let mut builder = SpirvBuilder::new(crate_path, target);
builder.build_script.defaults = true;
builder.shader_panic_strategy = ShaderPanicStrategy::SilentExit;
builder.spirv_metadata = SpirvMetadata::Full;

let compile_result = builder.build()?;
let spv_path = compile_result.module.unwrap_single();
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
let artifact = compile_result.module.unwrap_single();

println!("cargo::rustc-env=SHADER_SPV_PATH={}", artifact.display());
Ok(())
}
8 changes: 5 additions & 3 deletions generated/graphics/wgpu/cargo-gpu/mygraphics/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ pub fn main() -> anyhow::Result<()> {
.copied()
.collect::<PathBuf>();

let target = "spirv-unknown-naga-wgsl";
let install = Install::from_shader_crate(crate_path.clone())
.within_build_script()
.run()?;
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
let mut builder = install.to_spirv_builder(crate_path, target);
builder.build_script.defaults = true;
builder.shader_panic_strategy = ShaderPanicStrategy::SilentExit;
builder.spirv_metadata = SpirvMetadata::Full;

let compile_result = builder.build()?;
let spv_path = compile_result.module.unwrap_single();
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
let artifact = compile_result.module.unwrap_single();

println!("cargo::rustc-env=SHADER_WGSL_PATH={}", artifact.display());
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use mygraphics_shaders::ShaderConstants;
use wgpu::{
ColorTargetState, ColorWrites, Device, FragmentState, FrontFace, MultisampleState,
PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, RenderPass,
RenderPipeline, RenderPipelineDescriptor, TextureFormat, VertexState, include_spirv,
RenderPipeline, RenderPipelineDescriptor, TextureFormat, VertexState, include_wgsl,
};

#[derive(Debug, Clone)]
Expand All @@ -17,7 +17,7 @@ impl MyRenderPipeline {
global_bind_group_layout: &GlobalBindGroupLayout,
out_format: TextureFormat,
) -> anyhow::Result<Self> {
let module = device.create_shader_module(include_spirv!(env!("SHADER_SPV_PATH")));
let module = device.create_shader_module(include_wgsl!(env!("SHADER_WGSL_PATH")));

let layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("MyRenderPipeline layout"),
Expand Down
8 changes: 5 additions & 3 deletions generated/graphics/wgpu/spirv-builder/mygraphics/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ pub fn main() -> anyhow::Result<()> {
.copied()
.collect::<PathBuf>();

let mut builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.3");
let target = "spirv-unknown-naga-wgsl";
let mut builder = SpirvBuilder::new(crate_path, target);
builder.build_script.defaults = true;
builder.shader_panic_strategy = ShaderPanicStrategy::SilentExit;
builder.spirv_metadata = SpirvMetadata::Full;

let compile_result = builder.build()?;
let spv_path = compile_result.module.unwrap_single();
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
let artifact = compile_result.module.unwrap_single();

println!("cargo::rustc-env=SHADER_WGSL_PATH={}", artifact.display());
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use mygraphics_shaders::ShaderConstants;
use wgpu::{
ColorTargetState, ColorWrites, Device, FragmentState, FrontFace, MultisampleState,
PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, RenderPass,
RenderPipeline, RenderPipelineDescriptor, TextureFormat, VertexState, include_spirv,
RenderPipeline, RenderPipelineDescriptor, TextureFormat, VertexState, include_wgsl,
};

#[derive(Debug, Clone)]
Expand All @@ -17,7 +17,7 @@ impl MyRenderPipeline {
global_bind_group_layout: &GlobalBindGroupLayout,
out_format: TextureFormat,
) -> anyhow::Result<Self> {
let module = device.create_shader_module(include_spirv!(env!("SHADER_SPV_PATH")));
let module = device.create_shader_module(include_wgsl!(env!("SHADER_WGSL_PATH")));

let layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("MyRenderPipeline layout"),
Expand Down
24 changes: 20 additions & 4 deletions graphics/mygraphics/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,29 @@ pub fn main() -> anyhow::Result<()> {
let install = Install::from_shader_crate(crate_path.clone())
.within_build_script()
.run()?;
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
let mut builder = install.to_spirv_builder(&crate_path, "");
builder.build_script.defaults = true;
builder.shader_panic_strategy = ShaderPanicStrategy::SilentExit;
builder.spirv_metadata = SpirvMetadata::Full;

let compile_result = builder.build()?;
let spv_path = compile_result.module.unwrap_single();
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
// SPIR-V
{
builder.target = Some("spirv-unknown-vulkan1.3".to_owned());
let compile_result = builder.build()?;
println!(
"cargo::rustc-env=SHADER_SPV_PATH={}",
compile_result.module.unwrap_single().display()
);
}

// wgsl
{
builder.target = Some("spirv-unknown-naga-wgsl".to_owned());
let compile_result = builder.build()?;
println!(
"cargo::rustc-env=SHADER_WGSL_PATH={}",
compile_result.module.unwrap_single().display()
);
}
Ok(())
}
21 changes: 17 additions & 4 deletions graphics/mygraphics/build.rs.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,34 @@ pub fn main() -> anyhow::Result<()> {
.copied()
.collect::<PathBuf>();

{% if api == "ash" -%}
let target = "spirv-unknown-vulkan1.3";
{% endif -%}
{% if api == "wgpu" -%}
let target = "spirv-unknown-naga-wgsl";
{% endif -%}

{% if integration == "spirv-builder" -%}
let mut builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.3");
let mut builder = SpirvBuilder::new(crate_path, target);
{% endif -%}
{% if integration == "cargo-gpu" -%}
let install = Install::from_shader_crate(crate_path.clone())
.within_build_script()
.run()?;
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
let mut builder = install.to_spirv_builder(crate_path, target);
{% endif -%}
builder.build_script.defaults = true;
builder.shader_panic_strategy = ShaderPanicStrategy::SilentExit;
builder.spirv_metadata = SpirvMetadata::Full;

let compile_result = builder.build()?;
let spv_path = compile_result.module.unwrap_single();
println!("cargo::rustc-env=SHADER_SPV_PATH={}", spv_path.display());
let artifact = compile_result.module.unwrap_single();

{% if api == "ash" -%}
println!("cargo::rustc-env=SHADER_SPV_PATH={}", artifact.display());
{% endif -%}
{% if api == "wgpu" -%}
println!("cargo::rustc-env=SHADER_WGSL_PATH={}", artifact.display());
{% endif -%}
Ok(())
}
4 changes: 2 additions & 2 deletions graphics/mygraphics/src/wgpu_renderer/render_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use mygraphics_shaders::ShaderConstants;
use wgpu::{
ColorTargetState, ColorWrites, Device, FragmentState, FrontFace, MultisampleState,
PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, RenderPass,
RenderPipeline, RenderPipelineDescriptor, TextureFormat, VertexState, include_spirv,
RenderPipeline, RenderPipelineDescriptor, TextureFormat, VertexState, include_wgsl,
};

#[derive(Debug, Clone)]
Expand All @@ -17,7 +17,7 @@ impl MyRenderPipeline {
global_bind_group_layout: &GlobalBindGroupLayout,
out_format: TextureFormat,
) -> anyhow::Result<Self> {
let module = device.create_shader_module(include_spirv!(env!("SHADER_SPV_PATH")));
let module = device.create_shader_module(include_wgsl!(env!("SHADER_WGSL_PATH")));

let layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: Some("MyRenderPipeline layout"),
Expand Down
Loading