build: only build d3d11 stuff for windows

This commit is contained in:
chyyran 2023-01-21 01:54:06 -05:00
parent 7f01c9aad3
commit 9cdf646681
11 changed files with 35 additions and 36 deletions

View file

@ -20,9 +20,6 @@ runtime-opengl = ["gl", "librashader/gl"]
runtime-d3d11 = ["windows", "librashader/d3d11"]
runtime-vulkan = ["ash", "librashader/vk"]
# Do not enable, for docs.rs build only.
docsrs = []
[dependencies]
librashader = { path = "../librashader", version = "0.1.0-beta.7", features = ["internal"] }
thiserror = "1.0.37"
@ -31,7 +28,7 @@ gl = { version = "0.14.0", optional = true }
rustc-hash = "1.1.0"
ash = { version = "0.37.2+1.3.238", optional = true }
[dependencies.windows]
[target.'cfg(windows)'.dependencies.windows]
version = "0.44.0"
features = [
"Win32_Graphics_Direct3D11",
@ -42,4 +39,4 @@ optional = true
cbindgen = { git = "https://github.com/eqrion/cbindgen" }
[package.metadata.docs.rs]
features = ["docsrs"]
targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"]

View file

@ -11,15 +11,18 @@ pub type libra_error_t = Option<NonNull<LibrashaderError>>;
/// A handle to a OpenGL filter chain.
#[cfg(feature = "runtime-opengl")]
#[doc(cfg(feature = "runtime-opengl"))]
pub type libra_gl_filter_chain_t = Option<NonNull<librashader::runtime::gl::capi::FilterChainGL>>;
/// A handle to a Direct3D11 filter chain.
#[cfg(all(feature = "runtime-d3d11"))]
#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))]
pub type libra_d3d11_filter_chain_t =
Option<NonNull<librashader::runtime::d3d11::capi::FilterChainD3D11>>;
/// A handle to a Vulkan filter chain.
#[cfg(feature = "runtime-vulkan")]
#[doc(cfg(feature = "runtime-vulkan"))]
pub type libra_vk_filter_chain_t =
Option<NonNull<librashader::runtime::vk::capi::FilterChainVulkan>>;

View file

@ -26,15 +26,15 @@ pub enum LibrashaderError {
#[error("The provided parameter name was invalid.")]
UnknownShaderParameter(*const c_char),
#[cfg(feature = "runtime-opengl")]
#[doc(cfg(feature = "runtime-opengl"))]
#[error("There was an error in the OpenGL filter chain.")]
OpenGlFilterError(#[from] librashader::runtime::gl::error::FilterChainError),
#[cfg(any(
feature = "docsrs",
all(target_os = "windows", feature = "runtime-d3d11")
))]
#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))]
#[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(feature = "runtime-vulkan")]
#[doc(cfg(feature = "runtime-vulkan"))]
#[error("There was an error in the Vulkan filter chain.")]
VulkanFilterError(#[from] librashader::runtime::vk::error::FilterChainError),
}
@ -181,10 +181,7 @@ impl LibrashaderError {
LibrashaderError::UnknownShaderParameter(_) => LIBRA_ERRNO::SHADER_PARAMETER_ERROR,
#[cfg(feature = "runtime-opengl")]
LibrashaderError::OpenGlFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
#[cfg(any(
feature = "docsrs",
all(target_os = "windows", feature = "runtime-d3d11")
))]
#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))]
LibrashaderError::D3D11FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
#[cfg(feature = "runtime-vulkan")]
LibrashaderError::VulkanFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,

View file

@ -1,3 +1,4 @@
#![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

View file

@ -1,12 +1,12 @@
//! librashader runtime C APIs
#[doc(cfg(feature = "runtime-opengl"))]
#[cfg(feature = "runtime-opengl")]
pub mod gl;
#[cfg(any(
feature = "docsrs",
all(target_os = "windows", feature = "runtime-d3d11")
))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))]
#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))]
pub mod d3d11;
#[doc(cfg(feature = "runtime-vulkan"))]
#[cfg(feature = "runtime-vulkan")]
pub mod vk;

View file

@ -24,7 +24,7 @@ ash = { version = "0.37.1+1.3.235", optional = true }
num-traits = "0.2.15"
[dependencies.windows]
[target.'cfg(windows)'.dependencies.windows]
optional = true
version = "0.44.0"
features = [

View file

@ -9,11 +9,11 @@ pub mod gl;
pub mod vk;
/// DXGI common conversions.
#[cfg(feature = "dxgi")]
#[cfg(all(target_os = "windows", feature = "dxgi"))]
pub mod dxgi;
/// Direct3D 11 common conversions.
#[cfg(feature = "d3d11")]
#[cfg(all(target_os = "windows", feature = "d3d11"))]
pub mod d3d11;
mod viewport;

View file

@ -23,7 +23,7 @@ spirv_cross = "0.23.1"
rustc-hash = "1.1.0"
bytemuck = "1.12.3"
[dependencies.windows]
[target.'cfg(windows)'.dependencies.windows]
version = "0.44.0"
features = [
"Win32_Foundation",

View file

@ -1,3 +1,4 @@
#![cfg(target_os = "windows")]
//! librashader Direct3D 11 runtime
//!
//! This crate should not be used directly.

View file

@ -25,7 +25,7 @@ librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.1.0-
ash = { version = "0.37.1+1.3.235", optional = true }
spirv_cross = { version = "0.23.1", optional = true, features = ["glsl"] }
[dependencies.windows]
[target.'cfg(windows)'.dependencies.windows]
version = "0.44.0"
features = [
"Win32_Graphics_Direct3D11",
@ -42,3 +42,6 @@ reflect = []
preprocess = []
presets = []
internal = []
[package.metadata.docs.rs]
targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"]

View file

@ -34,7 +34,7 @@
//! or [`librashader.h`](https://github.com/SnowflakePowered/librashader/blob/master/include/librashader.h).
#[cfg(feature = "presets")]
#[doc(cfg(presets))]
#[doc(cfg(feature = "presets"))]
/// Parsing and usage of shader presets.
///
/// This module contains facilities and types for parsing `.slangp` shader presets files.
@ -60,7 +60,7 @@ pub mod presets {
}
#[cfg(feature = "preprocess")]
#[doc(cfg(preprocess))]
#[doc(cfg(feature = "preprocess"))]
/// Loading and preprocessing of 'slang' shader source files.
///
/// This module contains facilities and types for resolving `#include` directives in `.slang`
@ -74,7 +74,7 @@ pub mod preprocess {
}
#[cfg(feature = "reflect")]
#[doc(cfg(reflect))]
#[doc(cfg(feature = "reflect"))]
/// Shader reflection and cross-compilation.
///
/// The `type_alias_impl_trait` nightly feature is required. You should choose your
@ -117,7 +117,7 @@ pub mod preprocess {
/// [naga](https://docs.rs/naga/latest/naga/index.html), a pure-Rust shader compiler, when it has
/// matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012).
///
/// In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::front::GlslangCompilation),
/// In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::reflect::cross::GlslangCompilation),
/// which does transpilation via [shaderc](https://github.com/google/shaderc) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross).
pub mod reflect {
/// Supported shader compiler targets.
@ -140,14 +140,11 @@ pub mod reflect {
pub mod cross {
pub use librashader_reflect::front::GlslangCompilation;
#[cfg(feature = "gl")]
/// The version of GLSL to compile to.
pub use spirv_cross::glsl::Version as GlslVersion;
#[cfg(feature = "gl")]
pub use librashader_reflect::back::cross::CrossGlslContext;
#[cfg(any(feature = "d3d11", feature = "d3d12"))]
pub use librashader_reflect::back::cross::CrossHlslContext;
pub use librashader_reflect::reflect::cross::CompiledAst;
@ -171,13 +168,13 @@ pub mod reflect {
/// Shader runtimes to execute a filter chain on a GPU surface.
#[cfg(feature = "runtime")]
#[doc(cfg(runtime))]
#[doc(cfg(feature = "runtime"))]
pub mod runtime {
pub use librashader_common::{Size, Viewport};
pub use librashader_runtime::parameters::FilterChainParameters;
#[cfg(feature = "gl")]
#[doc(cfg(gl))]
#[doc(cfg(feature = "gl"))]
/// Shader runtime for OpenGL 3.3+.
///
/// DSA support requires OpenGL 4.6.
@ -201,8 +198,8 @@ pub mod runtime {
}
}
#[cfg(feature = "d3d11")]
#[doc(cfg(d3d11))]
#[cfg(all(target_os = "windows", feature = "d3d11"))]
#[doc(cfg(all(target_os = "windows", feature = "d3d11")))]
/// Shader runtime for Direct3D 11.
pub mod d3d11 {
pub use librashader_runtime_d3d11::{
@ -224,7 +221,7 @@ pub mod runtime {
}
#[cfg(feature = "vk")]
#[doc(cfg(vk))]
#[doc(cfg(feature = "vk"))]
/// Shader runtime for Vulkan 1.3+.
pub mod vk {
pub use librashader_runtime_vk::{