capi: more docs
This commit is contained in:
parent
45913c32bf
commit
6ab03ecc99
12 changed files with 58 additions and 9 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -558,6 +558,7 @@ dependencies = [
|
||||||
"paste",
|
"paste",
|
||||||
"safer-ffi",
|
"safer-ffi",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"windows",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -16,8 +16,9 @@ publish = false
|
||||||
crate-type = [ "cdylib", "staticlib", "lib" ]
|
crate-type = [ "cdylib", "staticlib", "lib" ]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
#default = ["runtime-opengl"]
|
default = ["runtime-opengl", "runtime-d3d11"]
|
||||||
runtime-opengl = ["gl", "librashader/gl"]
|
runtime-opengl = ["gl", "librashader/gl"]
|
||||||
|
runtime-d3d11 = ["windows", "librashader/d3d11"]
|
||||||
headers = ["safer-ffi/headers"]
|
headers = ["safer-ffi/headers"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -27,5 +28,23 @@ paste = "1.0.9"
|
||||||
gl = { version = "0.14.0", optional = true }
|
gl = { version = "0.14.0", optional = true }
|
||||||
safer-ffi = { version = "0.0.10", repository = "https://github.com/getditto/safer_ffi" }
|
safer-ffi = { version = "0.0.10", repository = "https://github.com/getditto/safer_ffi" }
|
||||||
|
|
||||||
|
[dependencies.windows]
|
||||||
|
version = "0.43.0"
|
||||||
|
features = [
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_Graphics_Dxgi_Common",
|
||||||
|
"Win32_Graphics_Direct3D",
|
||||||
|
"Win32_Graphics_Direct3D11",
|
||||||
|
"Win32_Graphics_Direct3D_Fxc",
|
||||||
|
"Win32_Graphics_Gdi",
|
||||||
|
"Win32_Security",
|
||||||
|
"Win32_System_LibraryLoader",
|
||||||
|
"Win32_System_Threading",
|
||||||
|
"Win32_System_WindowsProgramming",
|
||||||
|
"Win32_UI_WindowsAndMessaging",
|
||||||
|
]
|
||||||
|
optional = true
|
||||||
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cbindgen = "0.24.3"
|
cbindgen = "0.24.3"
|
||||||
|
|
|
@ -86,8 +86,6 @@ typedef struct frame_gl_opt_t {
|
||||||
int32_t frame_direction;
|
int32_t frame_direction;
|
||||||
} frame_gl_opt_t;
|
} frame_gl_opt_t;
|
||||||
|
|
||||||
typedef libra_error_t (*PFN_lbr_load_preset)(const char*, libra_shader_preset_t*);
|
|
||||||
|
|
||||||
typedef libra_error_t (*PFN_lbr_preset_free)(libra_shader_preset_t*);
|
typedef libra_error_t (*PFN_lbr_preset_free)(libra_shader_preset_t*);
|
||||||
|
|
||||||
typedef libra_error_t (*PFN_lbr_preset_set_param)(libra_shader_preset_t*, const char*, float);
|
typedef libra_error_t (*PFN_lbr_preset_set_param)(libra_shader_preset_t*, const char*, float);
|
||||||
|
@ -109,8 +107,8 @@ extern "C" {
|
||||||
/// - `out` must be either null, or an aligned pointer to an uninitialized or invalid `libra_shader_preset_t`.
|
/// - `out` must be either null, or an aligned pointer to an uninitialized or invalid `libra_shader_preset_t`.
|
||||||
/// ## Returns
|
/// ## Returns
|
||||||
/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`.
|
/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`.
|
||||||
libra_error_t libra_load_preset(const char *filename,
|
libra_error_t libra_preset_create(const char *filename,
|
||||||
libra_shader_preset_t *out);
|
libra_shader_preset_t *out);
|
||||||
|
|
||||||
/// Free the preset.
|
/// Free the preset.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! Binding types for the librashader C API.
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use librashader::presets::ShaderPreset;
|
use librashader::presets::ShaderPreset;
|
||||||
use crate::error::LibrashaderError;
|
use crate::error::LibrashaderError;
|
||||||
|
@ -8,6 +9,9 @@ pub type libra_error_t = Option<NonNull<LibrashaderError>>;
|
||||||
#[cfg(feature = "runtime-opengl")]
|
#[cfg(feature = "runtime-opengl")]
|
||||||
pub type libra_gl_filter_chain_t = Option<NonNull<librashader::runtime::gl::FilterChainGL>>;
|
pub type libra_gl_filter_chain_t = Option<NonNull<librashader::runtime::gl::FilterChainGL>>;
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-d3d11")]
|
||||||
|
pub type libra_d3d11_filter_chain_t = Option<NonNull<librashader::runtime::d3d11::FilterChainD3D11>>;
|
||||||
|
|
||||||
/// Parameters for the output viewport.
|
/// Parameters for the output viewport.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct libra_viewport_t {
|
pub struct libra_viewport_t {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! The librashader error C API. (`libra_error_*`).
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::ffi::{c_char, CStr, CString};
|
use std::ffi::{c_char, CStr, CString};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! The librashader preset C API (`libra_preset_*`).
|
||||||
use std::ffi::{c_char, CStr, CString};
|
use std::ffi::{c_char, CStr, CString};
|
||||||
use std::mem::{MaybeUninit};
|
use std::mem::{MaybeUninit};
|
||||||
use librashader::presets::ShaderPreset;
|
use librashader::presets::ShaderPreset;
|
||||||
|
@ -32,7 +33,7 @@ use std::ptr::NonNull;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub type PFN_lbr_load_preset = unsafe extern "C" fn (*const c_char, *mut MaybeUninit<libra_shader_preset_t>) -> libra_error_t;
|
pub type PFN_lbr_preset_create = unsafe extern "C" fn (*const c_char, *mut MaybeUninit<libra_shader_preset_t>) -> libra_error_t;
|
||||||
|
|
||||||
/// Load a preset.
|
/// Load a preset.
|
||||||
///
|
///
|
||||||
|
@ -42,7 +43,7 @@ pub type PFN_lbr_load_preset = unsafe extern "C" fn (*const c_char, *mut MaybeUn
|
||||||
/// ## Returns
|
/// ## Returns
|
||||||
/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`.
|
/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn libra_load_preset(filename: *const c_char, out: *mut MaybeUninit<libra_shader_preset_t>) -> libra_error_t {
|
pub unsafe extern "C" fn libra_preset_create(filename: *const c_char, out: *mut MaybeUninit<libra_shader_preset_t>) -> libra_error_t {
|
||||||
ffi_body!({
|
ffi_body!({
|
||||||
assert_non_null!(filename);
|
assert_non_null!(filename);
|
||||||
assert_non_null!(out);
|
assert_non_null!(out);
|
||||||
|
|
4
librashader-capi/src/runtime/d3d11/mod.rs
Normal file
4
librashader-capi/src/runtime/d3d11/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
//! C API for the librashader OpenGL Runtime (`libra_d3d11_*`)
|
||||||
|
|
||||||
|
mod filter_chain;
|
||||||
|
pub use filter_chain::*;
|
|
@ -1 +1,4 @@
|
||||||
pub mod filter_chain;
|
//! C API for the librashader OpenGL Runtime (`libra_gl_*`)
|
||||||
|
|
||||||
|
mod filter_chain;
|
||||||
|
pub use filter_chain::*;
|
|
@ -1,2 +1,6 @@
|
||||||
|
//! librashader runtime C APIs
|
||||||
#[cfg(feature = "runtime-opengl")]
|
#[cfg(feature = "runtime-opengl")]
|
||||||
mod gl;
|
pub mod gl;
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-d3d11")]
|
||||||
|
pub mod d3d11;
|
|
@ -1,12 +1,20 @@
|
||||||
|
/// Options for each Direct3D11 shader frame.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FrameOptionsD3D11 {
|
pub struct FrameOptionsD3D11 {
|
||||||
|
/// Whether or not to clear the history buffers.
|
||||||
pub clear_history: bool,
|
pub clear_history: bool,
|
||||||
|
/// The direction of the frame. 1 should be vertical.
|
||||||
pub frame_direction: i32,
|
pub frame_direction: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Options for Direct3D11 filter chain creation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FilterChainOptionsD3D11 {
|
pub struct FilterChainOptionsD3D11 {
|
||||||
|
/// Use a deferred context to record shader rendering state.
|
||||||
|
///
|
||||||
|
/// The deferred context will be executed on the immediate context
|
||||||
|
/// with `RenderContextState = true`.
|
||||||
pub use_deferred_context: bool,
|
pub use_deferred_context: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
|
/// Options for each OpenGL shader frame.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FrameOptionsGL {
|
pub struct FrameOptionsGL {
|
||||||
|
/// Whether or not to clear the history buffers.
|
||||||
pub clear_history: bool,
|
pub clear_history: bool,
|
||||||
|
/// The direction of the frame. 1 should be vertical.
|
||||||
pub frame_direction: i32,
|
pub frame_direction: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Options for filter chain creation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FilterChainOptionsGL {
|
pub struct FilterChainOptionsGL {
|
||||||
|
/// The GLSL version. Should be at least `330`.
|
||||||
pub gl_version: u16,
|
pub gl_version: u16,
|
||||||
|
/// Whether or not to use the Direct State Access APIs. Only available on OpenGL 4.5+.
|
||||||
pub use_dsa: bool,
|
pub use_dsa: bool,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue