From 2f988d5b1df4ccdafd05461655b1bac4f387884a Mon Sep 17 00:00:00 2001 From: chyyran Date: Sun, 15 Sep 2024 01:55:14 -0400 Subject: [PATCH] rt: add stable feature to build ShaderPassArtifacts via Box --- librashader-capi/Cargo.toml | 1 + librashader-reflect/src/lib.rs | 4 ++-- librashader-runtime-d3d11/Cargo.toml | 1 + librashader-runtime-d3d11/src/filter_chain.rs | 7 +++++++ librashader-runtime-d3d12/Cargo.toml | 3 +++ librashader-runtime-d3d12/src/filter_chain.rs | 13 +++++++++++++ librashader-runtime-d3d12/src/lib.rs | 2 +- librashader-runtime-d3d9/Cargo.toml | 3 +++ librashader-runtime-d3d9/src/filter_chain.rs | 7 +++++++ librashader-runtime-d3d9/src/lib.rs | 3 ++- librashader-runtime-gl/Cargo.toml | 3 +++ .../src/filter_chain/filter_impl.rs | 7 +++++++ librashader-runtime-gl/src/lib.rs | 2 +- librashader-runtime-mtl/Cargo.toml | 2 +- librashader-runtime-mtl/src/filter_chain.rs | 6 ++++++ librashader-runtime-mtl/src/lib.rs | 7 ++++++- librashader-runtime-vk/Cargo.toml | 3 +++ librashader-runtime-vk/src/filter_chain.rs | 7 +++++++ librashader-runtime-vk/src/lib.rs | 2 +- librashader-runtime-wgpu/Cargo.toml | 2 ++ librashader-runtime-wgpu/src/filter_chain.rs | 6 ++++++ librashader-runtime-wgpu/src/lib.rs | 2 +- librashader/Cargo.toml | 10 +++++++++- 23 files changed, 93 insertions(+), 10 deletions(-) diff --git a/librashader-capi/Cargo.toml b/librashader-capi/Cargo.toml index 884ab3b..336d4da 100644 --- a/librashader-capi/Cargo.toml +++ b/librashader-capi/Cargo.toml @@ -26,6 +26,7 @@ runtime-vulkan = ["ash", "librashader/runtime-vk"] runtime-metal = ["__cbindgen_internal_objc", "librashader/runtime-metal"] reflect-unstable = [] +stable = ["librashader/stable"] __cbindgen_internal = ["runtime-all"] diff --git a/librashader-reflect/src/lib.rs b/librashader-reflect/src/lib.rs index 5697fe6..68e1425 100644 --- a/librashader-reflect/src/lib.rs +++ b/librashader-reflect/src/lib.rs @@ -43,9 +43,9 @@ //! librashader-reflect is designed to be compiler-agnostic. [naga](https://docs.rs/naga/latest/naga/index.html), //! a pure-Rust shader compiler, as well as SPIRV-Cross via [SpirvCompilation](crate::front::SpirvCompilation) //! is supported. -#![cfg_attr(not(feature="stable"), feature(impl_trait_in_assoc_type))] +#![cfg_attr(not(feature = "stable"), feature(impl_trait_in_assoc_type))] #![allow(stable_features)] -#![cfg_attr(not(feature="stable"), feature(c_str_literals))] +#![cfg_attr(not(feature = "stable"), feature(c_str_literals))] /// Shader codegen backends. pub mod back; /// Error types. diff --git a/librashader-runtime-d3d11/Cargo.toml b/librashader-runtime-d3d11/Cargo.toml index d9376e2..6d2b6f9 100644 --- a/librashader-runtime-d3d11/Cargo.toml +++ b/librashader-runtime-d3d11/Cargo.toml @@ -26,6 +26,7 @@ array-concat = "0.5.2" [features] debug-shader = [] +stable = ["librashader-reflect/stable"] [target.'cfg(windows)'.dependencies.windows] workspace = true diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index 37a4894..dcd2cd9 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -73,9 +73,16 @@ pub(crate) struct FilterCommon { mod compile { use super::*; + + #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = ShaderPassArtifact + Send>; + #[cfg(feature = "stable")] + pub type ShaderPassMeta = ShaderPassArtifact< + Box + Send>, + >; + pub fn compile_passes( shaders: Vec, textures: &[TextureConfig], diff --git a/librashader-runtime-d3d12/Cargo.toml b/librashader-runtime-d3d12/Cargo.toml index d26532c..e7296d5 100644 --- a/librashader-runtime-d3d12/Cargo.toml +++ b/librashader-runtime-d3d12/Cargo.toml @@ -33,6 +33,9 @@ gpu-allocator = { version = "0.27.0", features = ["d3d12"], default-features = f parking_lot = "0.12.3" d3d12-descriptor-heap = "0.1.0" +[features] +stable = ["librashader-reflect/stable"] + [target.'cfg(windows)'.dependencies.windows] workspace = true features = [ diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index a570f86..b5924c6 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -169,9 +169,16 @@ impl Drop for FrameResiduals { mod compile { use super::*; + + #[cfg(not(feature = "stable"))] pub type DxilShaderPassMeta = ShaderPassArtifact + Send>; + #[cfg(feature = "stable")] + pub type DxilShaderPassMeta = ShaderPassArtifact< + Box + Send>, + >; + pub fn compile_passes_dxil( shaders: Vec, textures: &[TextureConfig], @@ -192,9 +199,15 @@ mod compile { Ok((passes, semantics)) } + #[cfg(not(feature = "stable"))] pub type HlslShaderPassMeta = ShaderPassArtifact + Send>; + #[cfg(feature = "stable")] + pub type HlslShaderPassMeta = ShaderPassArtifact< + Box + Send>, + >; + pub fn compile_passes_hlsl( shaders: Vec, textures: &[TextureConfig], diff --git a/librashader-runtime-d3d12/src/lib.rs b/librashader-runtime-d3d12/src/lib.rs index 9125765..e1473f4 100644 --- a/librashader-runtime-d3d12/src/lib.rs +++ b/librashader-runtime-d3d12/src/lib.rs @@ -1,6 +1,6 @@ #![cfg(target_os = "windows")] #![deny(unsafe_op_in_unsafe_fn)] -#![feature(type_alias_impl_trait)] +#![cfg_attr(not(feature = "stable"), feature(type_alias_impl_trait))] mod buffer; mod descriptor_heap; diff --git a/librashader-runtime-d3d9/Cargo.toml b/librashader-runtime-d3d9/Cargo.toml index 4526e10..92053ab 100644 --- a/librashader-runtime-d3d9/Cargo.toml +++ b/librashader-runtime-d3d9/Cargo.toml @@ -26,6 +26,9 @@ num-traits = "0.2.18" windows-core = "0.58.0" +[features] +stable = ["librashader-reflect/stable"] + [target.'cfg(windows)'.dependencies.windows] workspace = true features = [ diff --git a/librashader-runtime-d3d9/src/filter_chain.rs b/librashader-runtime-d3d9/src/filter_chain.rs index 2b8436b..b7d7895 100644 --- a/librashader-runtime-d3d9/src/filter_chain.rs +++ b/librashader-runtime-d3d9/src/filter_chain.rs @@ -60,9 +60,16 @@ pub struct FilterChainD3D9 { mod compile { use super::*; + + #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = ShaderPassArtifact + Send>; + #[cfg(feature = "stable")] + pub type ShaderPassMeta = ShaderPassArtifact< + Box + Send>, + >; + pub fn compile_passes( shaders: Vec, textures: &[TextureConfig], diff --git a/librashader-runtime-d3d9/src/lib.rs b/librashader-runtime-d3d9/src/lib.rs index fe16a26..1a6f502 100644 --- a/librashader-runtime-d3d9/src/lib.rs +++ b/librashader-runtime-d3d9/src/lib.rs @@ -1,5 +1,6 @@ #![cfg(target_os = "windows")] -#![feature(type_alias_impl_trait)] +#![cfg_attr(not(feature = "stable"), feature(type_alias_impl_trait))] + mod binding; mod d3dx; mod draw_quad; diff --git a/librashader-runtime-gl/Cargo.toml b/librashader-runtime-gl/Cargo.toml index 9e27874..7636cb2 100644 --- a/librashader-runtime-gl/Cargo.toml +++ b/librashader-runtime-gl/Cargo.toml @@ -27,6 +27,9 @@ rayon = "1.6.1" sptr = "0.3" +[features] +stable = ["librashader-reflect/stable"] + [dev-dependencies] glfw = "0.47.0" diff --git a/librashader-runtime-gl/src/filter_chain/filter_impl.rs b/librashader-runtime-gl/src/filter_chain/filter_impl.rs index 668c01e..b2f5faf 100644 --- a/librashader-runtime-gl/src/filter_chain/filter_impl.rs +++ b/librashader-runtime-gl/src/filter_chain/filter_impl.rs @@ -89,9 +89,16 @@ impl FilterChainImpl { mod compile { use super::*; + + #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = ShaderPassArtifact>; + #[cfg(feature = "stable")] + pub type ShaderPassMeta = ShaderPassArtifact< + Box + Send>, + >; + pub fn compile_passes( shaders: Vec, textures: &[TextureConfig], diff --git a/librashader-runtime-gl/src/lib.rs b/librashader-runtime-gl/src/lib.rs index 72313ce..fd3b0ab 100644 --- a/librashader-runtime-gl/src/lib.rs +++ b/librashader-runtime-gl/src/lib.rs @@ -3,7 +3,7 @@ //! This crate should not be used directly. //! See [`librashader::runtime::gl`](https://docs.rs/librashader/latest/librashader/runtime/gl/index.html) instead. #![deny(unsafe_op_in_unsafe_fn)] -#![feature(type_alias_impl_trait)] +#![cfg_attr(not(feature = "stable"), feature(type_alias_impl_trait))] mod binding; mod filter_chain; diff --git a/librashader-runtime-mtl/Cargo.toml b/librashader-runtime-mtl/Cargo.toml index cfd1e57..de15b3b 100644 --- a/librashader-runtime-mtl/Cargo.toml +++ b/librashader-runtime-mtl/Cargo.toml @@ -39,7 +39,7 @@ objc2-metal = { workspace = true, features = ["all"] } objc2 = { workspace = true, features = ["apple"] } [features] -# run_test = ["icrate/AppKit", "i "icrate/Foundation_all", "icrate/MetalKit", "icrate/MetalKit_all"] +stable = ["librashader-reflect/stable"] [target.'cfg(target_vendor="apple")'.dev-dependencies] objc2-metal-kit = { version = "0.2", features = ["all"]} diff --git a/librashader-runtime-mtl/src/filter_chain.rs b/librashader-runtime-mtl/src/filter_chain.rs index 3de50e7..fecb850 100644 --- a/librashader-runtime-mtl/src/filter_chain.rs +++ b/librashader-runtime-mtl/src/filter_chain.rs @@ -41,9 +41,15 @@ use std::path::Path; mod compile { use super::*; + + #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = ShaderPassArtifact + Send>; + #[cfg(feature = "stable")] + pub type ShaderPassMeta = + ShaderPassArtifact + Send>>; + pub fn compile_passes( shaders: Vec, textures: &[TextureConfig], diff --git a/librashader-runtime-mtl/src/lib.rs b/librashader-runtime-mtl/src/lib.rs index 6610697..21ab60c 100644 --- a/librashader-runtime-mtl/src/lib.rs +++ b/librashader-runtime-mtl/src/lib.rs @@ -1,5 +1,10 @@ +//! librashader Metal runtime +//! +//! This crate should not be used directly. +//! See [`librashader::runtime::mtl`](https://docs.rs/librashader/latest/aarch64-apple-darwin/librashader/runtime/mtl/index.html) instead. + #![cfg(target_vendor = "apple")] -#![feature(type_alias_impl_trait)] +#![cfg_attr(not(feature = "stable"), feature(type_alias_impl_trait))] mod buffer; mod draw_quad; diff --git a/librashader-runtime-vk/Cargo.toml b/librashader-runtime-vk/Cargo.toml index be6c84b..29a69bf 100644 --- a/librashader-runtime-vk/Cargo.toml +++ b/librashader-runtime-vk/Cargo.toml @@ -30,6 +30,9 @@ array-concat = "0.5.2" ash = { workspace = true, features = ["debug"] } +[features] +stable = ["librashader-reflect/stable"] + [dev-dependencies] num = "0.4.0" glfw = "0.49.0" diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index 296e63c..c21a7d9 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -206,9 +206,16 @@ impl Drop for FrameResiduals { mod compile { use super::*; + + #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = ShaderPassArtifact + Send>; + #[cfg(feature = "stable")] + pub type ShaderPassMeta = ShaderPassArtifact< + Box + Send>, + >; + pub fn compile_passes( shaders: Vec, textures: &[TextureConfig], diff --git a/librashader-runtime-vk/src/lib.rs b/librashader-runtime-vk/src/lib.rs index 8059e46..edcaf07 100644 --- a/librashader-runtime-vk/src/lib.rs +++ b/librashader-runtime-vk/src/lib.rs @@ -3,7 +3,7 @@ //! This crate should not be used directly. //! See [`librashader::runtime::vk`](https://docs.rs/librashader/latest/librashader/runtime/vk/index.html) instead. #![deny(unsafe_op_in_unsafe_fn)] -#![feature(type_alias_impl_trait)] +#![cfg_attr(not(feature = "stable"), feature(type_alias_impl_trait))] mod draw_quad; mod filter_chain; diff --git a/librashader-runtime-wgpu/Cargo.toml b/librashader-runtime-wgpu/Cargo.toml index 88b041d..247fd5c 100644 --- a/librashader-runtime-wgpu/Cargo.toml +++ b/librashader-runtime-wgpu/Cargo.toml @@ -33,6 +33,8 @@ wgpu_dx12 = ["wgpu/dx12"] wgpu_metal = ["wgpu/metal"] wgpu_webgpu = ["wgpu/webgpu"] +stable = ["librashader-reflect/stable"] + [target.'cfg(not(target_arch="wasm32"))'.dependencies] rayon = "1.8.1" diff --git a/librashader-runtime-wgpu/src/filter_chain.rs b/librashader-runtime-wgpu/src/filter_chain.rs index 01d998e..e39ad31 100644 --- a/librashader-runtime-wgpu/src/filter_chain.rs +++ b/librashader-runtime-wgpu/src/filter_chain.rs @@ -40,9 +40,15 @@ use crate::texture::{InputImage, OwnedImage}; mod compile { use super::*; + + #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = ShaderPassArtifact + Send>; + #[cfg(feature = "stable")] + pub type ShaderPassMeta = + ShaderPassArtifact + Send>>; + pub fn compile_passes( shaders: Vec, textures: &[TextureConfig], diff --git a/librashader-runtime-wgpu/src/lib.rs b/librashader-runtime-wgpu/src/lib.rs index 9efb1e8..99289fa 100644 --- a/librashader-runtime-wgpu/src/lib.rs +++ b/librashader-runtime-wgpu/src/lib.rs @@ -3,7 +3,7 @@ //! This crate should not be used directly. //! See [`librashader::runtime::wgpu`](https://docs.rs/librashader/latest/librashader/runtime/wgpu/index.html) instead. #![deny(unsafe_op_in_unsafe_fn)] -#![feature(type_alias_impl_trait)] +#![cfg_attr(not(feature = "stable"), feature(type_alias_impl_trait))] mod buffer; mod draw_quad; diff --git a/librashader/Cargo.toml b/librashader/Cargo.toml index 3abf640..f4bb39f 100644 --- a/librashader/Cargo.toml +++ b/librashader/Cargo.toml @@ -47,7 +47,15 @@ runtime = [] reflect = [] preprocess = [] presets = [] - +stable = [ "librashader-reflect/stable", + "librashader-runtime-d3d9?/stable", + "librashader-runtime-d3d11?/stable", + "librashader-runtime-d3d12?/stable", + "librashader-runtime-gl?/stable", + "librashader-runtime-vk?/stable", + "librashader-runtime-mtl?/stable", + "librashader-runtime-wgpu?/stable" +] # runtimes runtime-gl = [ "runtime", "reflect-cross", "librashader-common/opengl", "librashader-runtime-gl" ]