capi: allow building on stable by gating #[doc] comments

This commit is contained in:
chyyran 2024-09-15 02:10:06 -04:00 committed by Ronny Chan
parent 2f988d5b1d
commit e930f90a9c
6 changed files with 83 additions and 35 deletions

View file

@ -27,6 +27,7 @@ runtime-metal = ["__cbindgen_internal_objc", "librashader/runtime-metal"]
reflect-unstable = []
stable = ["librashader/stable"]
docsrs = []
__cbindgen_internal = ["runtime-all"]
@ -66,4 +67,4 @@ targets = [ "x86_64-pc-windows-msvc",
"aarch64-apple-ios",
"i686-pc-windows-msvc",
"i686-unknown-linux-gnu", ]
features = ["librashader/docsrs"]
features = ["docsrs", "librashader/docsrs"]

View file

@ -60,7 +60,7 @@ use librashader::runtime::gl::FilterChain as FilterChainGL;
/// A handle to a OpenGL filter chain.
#[cfg(feature = "runtime-opengl")]
#[doc(cfg(feature = "runtime-opengl"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-opengl")))]
pub type libra_gl_filter_chain_t = Option<NonNull<FilterChainGL>>;
/// A handle to a Direct3D 11 filter chain.
@ -71,7 +71,10 @@ pub type libra_gl_filter_chain_t = Option<NonNull<FilterChainGL>>;
use librashader::runtime::d3d11::FilterChain as FilterChainD3D11;
/// A handle to a Direct3D 11 filter chain.
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))
)]
#[cfg(any(
feature = "__cbindgen_internal",
all(target_os = "windows", feature = "runtime-d3d11")
@ -98,7 +101,10 @@ pub type libra_d3d12_filter_chain_t = Option<NonNull<FilterChainD3D12>>;
use librashader::runtime::d3d9::FilterChain as FilterChainD3D9;
/// A handle to a Direct3D 11 filter chain.
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))
)]
#[cfg(any(
feature = "__cbindgen_internal",
all(target_os = "windows", feature = "runtime-d3d9")
@ -109,12 +115,15 @@ pub type libra_d3d9_filter_chain_t = Option<NonNull<FilterChainD3D9>>;
use librashader::runtime::vk::FilterChain as FilterChainVulkan;
/// A handle to a Vulkan filter chain.
#[cfg(feature = "runtime-vulkan")]
#[doc(cfg(feature = "runtime-vulkan"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-vulkan")))]
pub type libra_vk_filter_chain_t = Option<NonNull<FilterChainVulkan>>;
#[cfg(all(target_os = "macos", feature = "runtime-metal"))]
use librashader::runtime::mtl::FilterChain as FilterChainMetal;
#[doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))
)]
#[cfg(any(
feature = "__cbindgen_internal",
all(

View file

@ -26,26 +26,38 @@ pub enum LibrashaderError {
#[error("The provided parameter name was invalid.")]
UnknownShaderParameter(*const c_char),
#[cfg(feature = "runtime-opengl")]
#[doc(cfg(feature = "runtime-opengl"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-opengl")))]
#[error("There was an error in the OpenGL filter chain.")]
OpenGlFilterError(#[from] librashader::runtime::gl::error::FilterChainError),
#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))
)]
#[error("There was an error in the D3D11 filter chain.")]
D3D11FilterError(#[from] librashader::runtime::d3d11::error::FilterChainError),
#[cfg(all(target_os = "windows", feature = "runtime-d3d12"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))
)]
#[error("There was an error in the D3D12 filter chain.")]
D3D12FilterError(#[from] librashader::runtime::d3d12::error::FilterChainError),
#[cfg(all(target_os = "windows", feature = "runtime-d3d9"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))
)]
#[error("There was an error in the D3D9 filter chain.")]
D3D9FilterError(#[from] librashader::runtime::d3d9::error::FilterChainError),
#[cfg(feature = "runtime-vulkan")]
#[doc(cfg(feature = "runtime-vulkan"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-vulkan")))]
#[error("There was an error in the Vulkan filter chain.")]
VulkanFilterError(#[from] librashader::runtime::vk::error::FilterChainError),
#[doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))
)]
#[cfg(all(target_vendor = "apple", feature = "runtime-metal"))]
#[error("There was an error in the D3D12 filter chain.")]
MetalFilterError(#[from] librashader::runtime::mtl::error::FilterChainError),

View file

@ -1,4 +1,3 @@
#![feature(doc_cfg)]
//! The C API for [librashader](https://docs.rs/librashader/).
//!
//! The librashader C API is designed to be loaded dynamically via `librashader_ld.h`, but static usage is also
@ -62,7 +61,7 @@
//!
//! You must ensure that only thread has access to a created filter pass **before** you call `*_frame`. `*_frame` may only be
//! called from one thread at a time.
#![cfg_attr(feature = "docsrs", feature(doc_cfg))]
#![allow(non_camel_case_types)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(deprecated)]

View file

@ -1,34 +1,46 @@
//! librashader runtime C APIs.
#[doc(cfg(feature = "runtime-opengl"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-opengl")))]
#[cfg(feature = "runtime-opengl")]
pub mod gl;
#[doc(cfg(feature = "runtime-vulkan"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-vulkan")))]
#[cfg(feature = "runtime-vulkan")]
pub mod vk;
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))
)]
#[cfg(any(
feature = "__cbindgen_internal",
all(target_os = "windows", feature = "runtime-d3d11")
))]
pub mod d3d11;
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))
)]
#[cfg(any(
feature = "__cbindgen_internal",
all(target_os = "windows", feature = "runtime-d3d9")
))]
pub mod d3d9;
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))
)]
#[cfg(any(
feature = "__cbindgen_internal",
all(target_os = "windows", feature = "runtime-d3d12")
))]
pub mod d3d12;
#[doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))
)]
#[cfg(any(
feature = "__cbindgen_internal",
all(

View file

@ -1,5 +1,5 @@
#![forbid(missing_docs)]
#![feature(doc_cfg)]
#![cfg_attr(feature = "docsrs", feature(doc_cfg))]
//! RetroArch shader preset compiler and runtime.
//!
//! librashader provides convenient and safe access to RetroArch ['slang' shaders](https://github.com/libretro/slang-shaders).
@ -53,7 +53,7 @@ pub use librashader_common::map::FastHashMap;
pub use librashader_common::map::ShortString;
#[cfg(feature = "presets")]
#[doc(cfg(feature = "presets"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "presets")))]
/// Parsing and usage of shader presets.
///
/// This module contains facilities and types for parsing `.slangp` shader presets files.
@ -87,7 +87,7 @@ pub mod presets {
}
#[cfg(feature = "preprocess")]
#[doc(cfg(feature = "preprocess"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "preprocess")))]
/// Loading and preprocessing of 'slang' shader source files.
///
/// This module contains facilities and types for resolving `#include` directives in `.slang`
@ -101,7 +101,7 @@ pub mod preprocess {
}
#[cfg(feature = "reflect")]
#[doc(cfg(feature = "reflect"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "reflect")))]
/// Shader reflection and cross-compilation.
///
/// The `type_alias_impl_trait` nightly feature is required. You should choose your
@ -171,7 +171,7 @@ pub mod reflect {
/// Reflection via SPIRV-Cross.
#[cfg(feature = "reflect-cross")]
#[doc(cfg(feature = "reflect-cross"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "reflect-cross")))]
pub mod cross {
pub use librashader_reflect::reflect::cross::SpirvCross;
@ -198,7 +198,10 @@ pub mod reflect {
/// DXIL reflection via spirv-to-dxil.
#[cfg(all(target_os = "windows", feature = "reflect-dxil"))]
#[doc(cfg(all(target_os = "windows", feature = "reflect-dxil")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "reflect-dxil")))
)]
pub mod dxil {
/// The maximum shader model to use when compiling the DXIL blob.
pub use librashader_reflect::back::dxil::ShaderModel;
@ -209,7 +212,7 @@ pub mod reflect {
/// Reflection via Naga
#[cfg(feature = "reflect-naga")]
#[doc(cfg(feature = "reflect-naga"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "reflect-naga")))]
pub mod naga {
pub use librashader_reflect::back::wgsl::NagaWgslContext;
pub use librashader_reflect::reflect::naga::Naga;
@ -233,14 +236,14 @@ pub mod reflect {
/// Shader runtimes to execute a filter chain on a GPU surface.
#[cfg(feature = "runtime")]
#[doc(cfg(feature = "runtime"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime")))]
pub mod runtime {
pub use librashader_common::{Size, Viewport};
pub use librashader_runtime::parameters::FilterChainParameters;
pub use librashader_runtime::parameters::RuntimeParameters;
#[cfg(feature = "runtime-gl")]
#[doc(cfg(feature = "runtime-gl"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-gl")))]
/// Shader runtime for OpenGL 3.3+.
///
/// DSA support requires OpenGL 4.6.
@ -256,7 +259,10 @@ pub mod runtime {
}
#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))
)]
/// Shader runtime for Direct3D 11.
pub mod d3d11 {
pub use librashader_runtime_d3d11::{
@ -269,7 +275,10 @@ pub mod runtime {
}
#[cfg(all(target_os = "windows", feature = "runtime-d3d12"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))
)]
/// Shader runtime for Direct3D 12.
pub mod d3d12 {
pub use librashader_runtime_d3d12::{
@ -282,7 +291,10 @@ pub mod runtime {
}
#[cfg(all(target_os = "windows", feature = "runtime-d3d9"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))
)]
/// Shader runtime for Direct3D 9.
pub mod d3d9 {
pub use librashader_runtime_d3d9::{
@ -295,7 +307,7 @@ pub mod runtime {
}
#[cfg(feature = "runtime-vk")]
#[doc(cfg(feature = "runtime-vk"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-vk")))]
/// Shader runtime for Vulkan.
pub mod vk {
pub use librashader_runtime_vk::{
@ -308,7 +320,10 @@ pub mod runtime {
}
#[cfg(all(target_vendor = "apple", feature = "runtime-metal"))]
#[doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))]
#[cfg_attr(
feature = "docsrs",
doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))
)]
/// Shader runtime for Metal.
pub mod mtl {
pub use librashader_runtime_mtl::{
@ -321,7 +336,7 @@ pub mod runtime {
}
#[cfg(feature = "runtime-wgpu")]
#[doc(cfg(feature = "runtime-wgpu"))]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "runtime-wgpu")))]
/// Shader runtime for wgpu.
pub mod wgpu {
pub use librashader_runtime_wgpu::{