diff --git a/librashader-cache/Cargo.toml b/librashader-cache/Cargo.toml index ee41311..aa13d92 100644 --- a/librashader-cache/Cargo.toml +++ b/librashader-cache/Cargo.toml @@ -18,7 +18,7 @@ platform-dirs = "0.3.0" blake3 = { version = "1.3.3" } thiserror = "1.0.38" bincode = { version = "2.0.0-rc.2", features = ["serde"] } -rusqlite = { version = "0.28.0", default-features = false, optional = true } +rusqlite = { version = "0.28.0", features = ["bundled"] } bytemuck = "1.13.0" @@ -32,11 +32,10 @@ features = [ optional = true [features] -# should be enabled at librashader crate level. -cache = ["rusqlite/bundled"] d3d = ["windows"] -docsrs = ["blake3/pure"] + +# hack to get building on docsrs +docsrs = ["blake3/pure", "rusqlite/in_gecko"] [package.metadata.docs.rs] features = ["docsrs"] -no-default-features = true diff --git a/librashader-cache/src/cache.rs b/librashader-cache/src/cache.rs index ebe7e19..0e39a72 100644 --- a/librashader-cache/src/cache.rs +++ b/librashader-cache/src/cache.rs @@ -1,7 +1,6 @@ use crate::cacheable::Cacheable; use crate::key::CacheKey; -#[cfg(feature = "cache")] pub(crate) mod internal { use platform_dirs::AppDirs; use rusqlite::{Connection, DatabaseName}; @@ -66,8 +65,6 @@ pub(crate) mod internal { } } - -#[cfg(feature = "cache")] /// Cache a shader object (usually bytecode) created by the keyed objects. /// /// - `factory` is the function that compiles the values passed as keys to a shader object. @@ -122,7 +119,6 @@ where Ok(load(blob)?) } -#[cfg(feature = "cache")] /// Cache a pipeline state object. /// /// Keys are not used to create the object and are only used to uniquely identify the pipeline state. @@ -182,9 +178,3 @@ where Ok(pipeline) } - -#[cfg(not(feature = "cache"))] -pub use crate::docsrs::cache_pipeline; - -#[cfg(not(feature = "cache"))] -pub use crate::docsrs::cache_shader_object; \ No newline at end of file diff --git a/librashader-cache/src/compilation.rs b/librashader-cache/src/compilation.rs index c90572b..ef1ad16 100644 --- a/librashader-cache/src/compilation.rs +++ b/librashader-cache/src/compilation.rs @@ -9,7 +9,6 @@ pub struct CachedCompilation { compilation: T, } -#[cfg(feature = "cache")] impl serde::Deserialize<'de> + serde::Serialize + Clone> ShaderCompilation for CachedCompilation { @@ -57,17 +56,6 @@ impl serde::Deserialize<'de> + serde::Serialize } } -#[cfg(not(feature = "cache"))] -impl serde::Deserialize<'de> + serde::Serialize + Clone> -ShaderCompilation for CachedCompilation -{ - fn compile(source: &ShaderSource) -> Result { - Ok(CachedCompilation { - compilation: T::compile(source)? - }) - } -} - impl FromCompilation> for DXIL { type Target = >::Target; type Options = >::Options; diff --git a/librashader-cache/src/docsrs.rs b/librashader-cache/src/docsrs.rs deleted file mode 100644 index bf60119..0000000 --- a/librashader-cache/src/docsrs.rs +++ /dev/null @@ -1,42 +0,0 @@ -use crate::{CacheKey, Cacheable}; -/// Cache a pipeline state object. -/// -/// Keys are not used to create the object and are only used to uniquely identify the pipeline state. -/// -/// - `restore_pipeline` tries to restore the pipeline with either a cached binary pipeline state -/// cache, or create a new pipeline if no cached value is available. -/// - `fetch_pipeline_state` fetches the new pipeline state cache after the pipeline was created. -#[allow(unused_variables)] -pub fn cache_pipeline( - index: &str, - keys: &[&dyn CacheKey; KEY_SIZE], - restore_pipeline: impl Fn(Option>) -> Result, - fetch_pipeline_state: impl FnOnce(&R) -> Result, - bypass_cache: bool, -) -> Result - where - T: Cacheable, -{ - eprintln!("[librashader:warn] Cache support was not built, you must rebuild librashader with the cache feature."); - return Ok(restore_pipeline(None)?); -} - -/// Cache a shader object (usually bytecode) created by the keyed objects. -/// -/// - `factory` is the function that compiles the values passed as keys to a shader object. -/// - `load` tries to load a compiled shader object to a driver-specialized result. -#[allow(unused_variables)] -pub fn cache_shader_object( - index: &str, - keys: &[H; KEY_SIZE], - factory: impl FnOnce(&[H; KEY_SIZE]) -> Result, - load: impl Fn(T) -> Result, - bypass_cache: bool, -) -> Result - where - H: CacheKey, - T: Cacheable, -{ - eprintln!("[librashader:warn] Cache support was not built, you must rebuild librashader with the cache feature."); - return Ok(load(factory(keys)?)?); -} \ No newline at end of file diff --git a/librashader-cache/src/lib.rs b/librashader-cache/src/lib.rs index 79c12b5..e5d9a1d 100644 --- a/librashader-cache/src/lib.rs +++ b/librashader-cache/src/lib.rs @@ -22,7 +22,3 @@ pub use cache::cache_shader_object; #[cfg(all(target_os = "windows", feature = "d3d"))] mod d3d; - - -#[cfg(not(feature = "cache"))] -mod docsrs; \ No newline at end of file diff --git a/librashader-capi/Cargo.toml b/librashader-capi/Cargo.toml index d67a32f..e90f2e2 100644 --- a/librashader-capi/Cargo.toml +++ b/librashader-capi/Cargo.toml @@ -15,7 +15,7 @@ description = "RetroArch shaders for all." crate-type = [ "cdylib", "staticlib" ] [features] -default = ["runtime-all", "librashader/cache" ] +default = ["runtime-all" ] runtime-all = ["runtime-opengl", "runtime-d3d11", "runtime-d3d12", "runtime-vulkan"] runtime-opengl = ["gl", "librashader/runtime-gl"] runtime-d3d11 = ["windows", "librashader/runtime-d3d11", "windows/Win32_Graphics_Direct3D11"] @@ -35,9 +35,6 @@ spirv_cross = { package = "librashader-spirv-cross", version = "0.23" } version = "0.44.0" optional = true -[package.metadata.cargo-post.dependencies] - [package.metadata.docs.rs] targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"] -no-default-features = true -features = ["runtime-all", "librashader/docsrs"] \ No newline at end of file +features = ["librashader/docsrs"] \ No newline at end of file diff --git a/librashader-runtime-d3d11/Cargo.toml b/librashader-runtime-d3d11/Cargo.toml index 805b8b9..418b633 100644 --- a/librashader-runtime-d3d11/Cargo.toml +++ b/librashader-runtime-d3d11/Cargo.toml @@ -57,7 +57,9 @@ features = [ [[test]] name = "triangle" -required-features = ["librashader-cache/cache"] [dev-dependencies] gfx-maths = "0.2.8" + +[package.metadata.docs.rs] +features = ["librashader-cache/docsrs"] diff --git a/librashader-runtime-d3d12/Cargo.toml b/librashader-runtime-d3d12/Cargo.toml index 24f4c90..cbe3ddc 100644 --- a/librashader-runtime-d3d12/Cargo.toml +++ b/librashader-runtime-d3d12/Cargo.toml @@ -65,7 +65,9 @@ features = [ [[test]] name = "triangle" -required-features = ["librashader-cache/cache"] [dev-dependencies] gfx-maths = "0.2.8" + +[package.metadata.docs.rs] +features = ["librashader-cache/docsrs"] diff --git a/librashader-runtime-gl/Cargo.toml b/librashader-runtime-gl/Cargo.toml index a1b3744..23be501 100644 --- a/librashader-runtime-gl/Cargo.toml +++ b/librashader-runtime-gl/Cargo.toml @@ -31,4 +31,6 @@ glfw = "0.47.0" [[test]] name = "triangle" -required-features = ["librashader-cache/cache"] + +[package.metadata.docs.rs] +features = ["librashader-cache/docsrs"] diff --git a/librashader-runtime-vk/Cargo.toml b/librashader-runtime-vk/Cargo.toml index 1df93aa..2c32e1e 100644 --- a/librashader-runtime-vk/Cargo.toml +++ b/librashader-runtime-vk/Cargo.toml @@ -40,4 +40,6 @@ ash-window = "0.12.0" [[test]] name = "triangle" -required-features = ["librashader-cache/cache"] + +[package.metadata.docs.rs] +features = ["librashader-cache/docsrs"] diff --git a/librashader/Cargo.toml b/librashader/Cargo.toml index 56a2dfb..b5ec466 100644 --- a/librashader/Cargo.toml +++ b/librashader/Cargo.toml @@ -23,7 +23,7 @@ librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.1.0-rc.5", optional = true } librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.1.0-rc.5", optional = true } -librashader-cache = { path = "../librashader-cache", version = "0.1.0-rc.5", default-features = false } +librashader-cache = { path = "../librashader-cache", version = "0.1.0-rc.5" } ash = { version = "0.37.1+1.3.235", optional = true } @@ -52,13 +52,14 @@ runtime-all = ["runtime-gl", "runtime-d3d11", "runtime-d3d12", "runtime-vk"] reflect-all = ["reflect-cross", "reflect-dxil"] # enable all features by default -default = [ "runtime-all", "reflect-all", "preprocess", "presets" ] +default = [ "full" ] internal = [] -cache = ["librashader-cache/cache"] +full = ["runtime-all", "reflect-all", "preprocess", "presets"] + +# cache hack docsrs = ["librashader-cache/docsrs"] [package.metadata.docs.rs] targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"] -no-default-features = true features = [ "librashader-cache/docsrs" ]