Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

DX12 with DXC: hanabi's utils shader named so DXC can read it; an export refuses a codec before rendering (#196)

shinyobjectzc3e7206581d9
diff --git a/apps/capcut/src/lib.rs b/apps/capcut/src/lib.rs
index 70a62138..d6d0217f 100644
--- a/apps/capcut/src/lib.rs
+++ b/apps/capcut/src/lib.rs
@@ -48,7 +48,7 @@ fn export(args: &[String]) -> R<String> {
let tsx = args.first().filter(|a| !a.starts_with('-')).ok_or(USAGE)?;
let tsx = dunce::canonicalize(&PathBuf::from(tsx)).map_err(|e| format!("{tsx}: {e}"))?;
let dir = tsx.parent().unwrap().to_path_buf();
- let codec = flag(args, "--alpha-codec").map_or(Ok(raea_io_alpha::Codec::default_here()), |c| raea_io_alpha::Codec::parse(&c))?;
+ let codec = raea_io_alpha::Codec::chosen(flag(args, "--alpha-codec").as_deref())?;
let (root, in_store) = match flag(args, "-o") {
Some(o) => (PathBuf::from(o), false),
None => {
diff --git a/apps/layers/src/lib.rs b/apps/layers/src/lib.rs
index 312702ed..17cf5109 100644
--- a/apps/layers/src/lib.rs
+++ b/apps/layers/src/lib.rs
@@ -145,7 +145,7 @@ pub fn export(args: &[String]) -> R<(Layers, String)> {
let tsx = args.first().filter(|a| !a.starts_with('-')).ok_or(USAGE)?;
let tsx = dunce::canonicalize(PathBuf::from(tsx)).map_err(|e| format!("{tsx}: {e}"))?;
let edit_dir = tsx.parent().unwrap().to_path_buf();
- let codec = flag(args, "--alpha-codec").map_or(Ok(raea_io_alpha::Codec::default_here()), |c| raea_io_alpha::Codec::parse(&c))?;
+ let codec = raea_io_alpha::Codec::chosen(flag(args, "--alpha-codec").as_deref())?;
let name = named(args, &tsx);
let dir = flag(args, "-o").map_or_else(|| edit_dir.join("out/layers").join(&name), PathBuf::from);
std::fs::create_dir_all(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
diff --git a/io/alpha/src/lib.rs b/io/alpha/src/lib.rs
index 2a16aee6..5ce43548 100644
--- a/io/alpha/src/lib.rs
+++ b/io/alpha/src/lib.rs
@@ -59,6 +59,18 @@ impl Codec {
pub fn here(self) -> bool {
cfg!(target_vendor = "apple") || matches!(self, Codec::Rle | Codec::Png)
}
+
+ /// It, or what to use instead where this build can't write it.
+ pub fn usable(self) -> R<Codec> {
+ if self.here() { Ok(self) } else { Err(format!("{} is written through VideoToolbox, on a Mac: --alpha-codec rle (QuickTime Animation) or png here", self.name())) }
+ }
+
+ /// The codec `--alpha-codec` names (this machine's own when it names none), refused when it can't be written here:
+ /// what an export asks for before it renders anything, so a Windows PC told prores hears so before the reference
+ /// render, not after it (#196).
+ pub fn chosen(flag: Option<&str>) -> R<Codec> {
+ flag.map_or(Ok(Codec::default_here()), Codec::parse)?.usable()
+ }
}
/// A transparent movie being written: frames in, `finish` makes the file.
@@ -79,9 +91,7 @@ enum Inner {
impl Writer {
/// A movie of `codec` at `out`; `quality` (0..1) is HEVC's, which the others don't take.
pub fn create(out: &Path, codec: Codec, width: u32, height: u32, fps: f64, quality: f32) -> R<Writer> {
- if !codec.here() {
- return Err(format!("{} is written through VideoToolbox, on a Mac: use --alpha-codec rle or png here", codec.name()));
- }
+ codec.usable()?;
if width == 0 || height == 0 || width > 0xFFFF || height > 0xFFFF {
return Err(format!("a {width}x{height} movie can't be written"));
}
diff --git a/io/alpha/src/movie.rs b/io/alpha/src/movie.rs
index 3223caeb..e76cbfc0 100644
--- a/io/alpha/src/movie.rs
+++ b/io/alpha/src/movie.rs
@@ -11,10 +11,7 @@ use crate::{Codec, R, encode_dir};
/// --manifest, HEVC's quality 0..1), from the frames `render` writes when given the same arguments with -o FOLDER/ and
/// --manifest in place of -o OUT.mov; what it said, APPLIED as the movie.
pub fn render_movie(args: &[String], out: &Path, codec: Option<&str>, manifest: Option<PathBuf>, quality: f32, render: impl Fn(&[String]) -> R<String>) -> R<String> {
- let codec = codec.map_or(Ok(Codec::default_here()), Codec::parse)?;
- if !codec.here() {
- return Err(format!("{} is written through VideoToolbox, on a Mac: --alpha-codec rle (QuickTime Animation) or png here", codec.name()));
- }
+ let codec = Codec::chosen(codec)?;
if let Some(d) = out.parent().filter(|d| !d.as_os_str().is_empty()) {
std::fs::create_dir_all(d).map_err(|e| format!("{}: {e}", d.display()))?;
}
diff --git a/vendor/bevy_hanabi/src/render/mod.rs b/vendor/bevy_hanabi/src/render/mod.rs
index a465ff2e..66dbf354 100644
--- a/vendor/bevy_hanabi/src/render/mod.rs
+++ b/vendor/bevy_hanabi/src/render/mod.rs
@@ -1710,8 +1710,10 @@ impl FromWorld for UtilsPipeline {
debug!("Create utils shader module:\n{}", shader_code);
#[allow(unsafe_code)]
let shader_module = unsafe {
+ // no colon in a shader module's label: DX12's DXC takes it as the source's file name, and on Windows
+ // "hanabi:shader:utils" names no file, so every Bevy app failed there wherever DXC loads (raea #196)
render_device.create_shader_module(ShaderModuleDescriptor {
- label: Some("hanabi:shader:utils"),
+ label: Some("hanabi_shader_utils"),
source: shader_source,
})
};
diff --git a/vendor/bevy_hanabi/src/render/shader_contract_tests.rs b/vendor/bevy_hanabi/src/render/shader_contract_tests.rs
index 266015b3..1acfd76f 100644
--- a/vendor/bevy_hanabi/src/render/shader_contract_tests.rs
+++ b/vendor/bevy_hanabi/src/render/shader_contract_tests.rs
@@ -191,7 +191,7 @@ fn create_sort_pipeline(
crate::test_utils::compile_wesl(VFX_SORT_WESL.as_ref(), &["HAS_DUAL_KEY", "TEST"], &[])
.unwrap();
let shader = wgpu_device.create_shader_module(wgpu::ShaderModuleDescriptor {
- label: Some("hanabi:test:vfx_sort"),
+ label: Some("hanabi_test_vfx_sort"),
source: wgpu::ShaderSource::Wgsl(source.into()),
});
let pipeline = wgpu_device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
@@ -724,7 +724,7 @@ fn location_mapping_contracts() {
let wgpu_device = device.wgpu_device();
let shader = wgpu_device.create_shader_module(wgpu::ShaderModuleDescriptor {
- label: Some("hanabi:test:location:shader"),
+ label: Some("hanabi_test_location_shader"),
source: wgpu::ShaderSource::Wgsl(
r#"
struct BatchInfo {
@@ -926,7 +926,7 @@ fn indirect_plus_update_routing_contracts() {
let wgpu_device = device.wgpu_device();
let indirect_shader = wgpu_device.create_shader_module(wgpu::ShaderModuleDescriptor {
- label: Some("hanabi:test:indirect-lite"),
+ label: Some("hanabi_test_indirect-lite"),
source: wgpu::ShaderSource::Wgsl(
r#"
struct Spawner {
@@ -964,7 +964,7 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
),
});
let update_route_shader = wgpu_device.create_shader_module(wgpu::ShaderModuleDescriptor {
- label: Some("hanabi:test:update-route"),
+ label: Some("hanabi_test_update-route"),
source: wgpu::ShaderSource::Wgsl(
r#"
struct BatchInfo {
diff --git a/vendor/vendor.toml b/vendor/vendor.toml
index 125941ca..7c6bdb67 100644
--- a/vendor/vendor.toml
+++ b/vendor/vendor.toml
@@ -169,7 +169,7 @@ exit = "a Rune release whose rune-taffy handles taffy's flexbox_balance"
path = "vendor/bevy_hanabi"
upstream = "git:github.com/djeedai/bevy_hanabi@77630ff1eed8b104f34e91d23e9440428dc5ab01:."
kind = "patch"
-reason = "frame-pure particles (raea #52): a new particle seeded by its spawn index, not the dead slot it recycles (vfx_init.wesl), and blended effects sorted by view depth from the main camera, far first as Bevy sorts its transparent phase, through the ribbons' sort pass (mod.rs, sort.rs, vfx_sort_fill.wesl); examples and GPU tests dropped"
+reason = "frame-pure particles (raea #52): a new particle seeded by its spawn index, not the dead slot it recycles (vfx_init.wesl), and blended effects sorted by view depth from the main camera, far first as Bevy sorts its transparent phase, through the ribbons' sort pass (mod.rs, sort.rs, vfx_sort_fill.wesl); examples and GPU tests dropped; and no colon in a shader module's label (mod.rs's utils, the contract tests'), which DX12's DXC takes as a file name that names no file on Windows (raea #196)"
exit = "a hanabi with a deterministic mode (both changes offered upstream); then back to the git dependency and drop the copy"
[usvg]