capi(d3d9): expose d3d9 in capi

This commit is contained in:
chyyran 2024-03-07 19:37:39 -05:00 committed by Ronny Chan
parent b7071958bd
commit 8c8e386a6c
17 changed files with 1450 additions and 844 deletions

3
Cargo.lock generated
View file

@ -1473,6 +1473,7 @@ dependencies = [
"librashader-runtime",
"librashader-runtime-d3d11",
"librashader-runtime-d3d12",
"librashader-runtime-d3d9",
"librashader-runtime-gl",
"librashader-runtime-mtl",
"librashader-runtime-vk",
@ -1647,7 +1648,7 @@ dependencies = [
[[package]]
name = "librashader-runtime-d3d9"
version = "0.2.4"
version = "0.2.6"
dependencies = [
"array-concat",
"bytemuck",

File diff suppressed because it is too large Load diff

View file

@ -393,6 +393,49 @@ libra_error_t __librashader__noop_d3d12_filter_chain_get_active_pass_count(
}
#endif
#if defined(LIBRA_RUNTIME_D3D9)
libra_error_t __librashader__noop_d3d9_filter_chain_create(
libra_shader_preset_t *preset, IDirect3DDevice9 *device,
const struct filter_chain_d3d9_opt_t *options,
libra_d3d9_filter_chain_t *out) {
*out = NULL;
return NULL;
}
libra_error_t __librashader__noop_d3d9_filter_chain_frame(
libra_d3d9_filter_chain_t *chain, size_t frame_count,
IDirect3DTexture9 *image, struct libra_viewport_t viewport,
IDirect3DSurface9 * out, const float *mvp,
const struct frame_d3d9_opt_t *opt) {
return NULL;
}
libra_error_t __librashader__noop_d3d9_filter_chain_free(
libra_d3d9_filter_chain_t *chain) {
return NULL;
}
libra_error_t __librashader__noop_d3d9_filter_chain_set_param(
libra_d3d9_filter_chain_t *chain, const char *param_name, float value) {
return NULL;
}
libra_error_t __librashader__noop_d3d9_filter_chain_get_param(
libra_d3d9_filter_chain_t *chain, const char *param_name, float *out) {
return NULL;
}
libra_error_t __librashader__noop_d3d9_filter_chain_set_active_pass_count(
libra_d3d9_filter_chain_t *chain, uint32_t value) {
return NULL;
}
libra_error_t __librashader__noop_d3d9_filter_chain_get_active_pass_count(
libra_d3d9_filter_chain_t *chain, uint32_t *out) {
return NULL;
}
#endif
#if defined(LIBRA_RUNTIME_METAL)
libra_error_t __librashader__noop_mtl_filter_chain_create(
libra_shader_preset_t *preset, id<MTLCommandQueue> queue,
@ -1163,6 +1206,79 @@ typedef struct libra_instance_t {
PFN_libra_d3d12_filter_chain_set_param d3d12_filter_chain_set_param;
#endif
#if defined(LIBRA_RUNTIME_D3D9)
/// Create the filter chain given the shader preset.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// If this function is not loaded, `out` will unconditionally be set to
/// null. If this function returns an error, the state of `out` is
/// unspecified.
///
/// ## Safety:
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
PFN_libra_d3d9_filter_chain_create d3d9_filter_chain_create;
/// Draw a frame with the given parameters for the given filter chain.
///
/// ## Safety
/// - `chain` may be null, invalid, but not uninitialized. If `chain` is
/// null or invalid, this
/// function will return an error.
/// - `mvp` may be null, or if it is not null, must be an aligned pointer to
/// 16 consecutive `float`
/// values for the model view projection matrix.
/// - `opt` may be null, or if it is not null, must be an aligned pointer to
/// a valid `frame_d3d9_opt_t`
/// struct.
PFN_libra_d3d9_filter_chain_frame d3d9_filter_chain_frame;
/// Free a D3D9 filter chain.
///
/// The resulting value in `chain` then becomes null.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an
/// initialized `libra_d3d9_filter_chain_t`.
PFN_libra_d3d9_filter_chain_free d3d9_filter_chain_free;
/// Gets the number of active passes for this chain.
///
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an
/// initialized `libra_d3d9_filter_chain_t`.
PFN_libra_d3d9_filter_chain_get_active_pass_count
d3d9_filter_chain_get_active_pass_count;
/// Sets the number of active passes for this chain.
///
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an
/// initialized `libra_d3d9_filter_chain_t`.
PFN_libra_d3d9_filter_chain_set_active_pass_count
d3d9_filter_chain_set_active_pass_count;
/// Gets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an
/// initialized `libra_d3d9_filter_chain_t`.
/// - `param_name` must be either null or a null terminated string.
PFN_libra_d3d9_filter_chain_get_param d3d9_filter_chain_get_param;
/// Sets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an
/// initialized `libra_d3d9_filter_chain_t`.
/// - `param_name` must be either null or a null terminated string.
PFN_libra_d3d9_filter_chain_set_param d3d9_filter_chain_set_param;
#endif
#if defined(LIBRA_RUNTIME_METAL)
/// Create the filter chain given the shader preset.
///
@ -1399,6 +1515,25 @@ libra_instance_t __librashader_make_null_instance(void) {
__librashader__noop_d3d12_filter_chain_set_param;
#endif
#if defined(LIBRA_RUNTIME_D3D9)
instance.d3d9_filter_chain_create =
__librashader__noop_d3d9_filter_chain_create;
instance.d3d9_filter_chain_create_deferred =
__librashader__noop_d3d9_filter_chain_create_deferred;
instance.d3d9_filter_chain_frame =
__librashader__noop_d3d9_filter_chain_frame;
instance.d3d9_filter_chain_free =
__librashader__noop_d3d9_filter_chain_free;
instance.d3d9_filter_chain_get_active_pass_count =
__librashader__noop_d3d9_filter_chain_get_active_pass_count;
instance.d3d9_filter_chain_set_active_pass_count =
__librashader__noop_d3d9_filter_chain_set_active_pass_count;
instance.d3d9_filter_chain_get_param =
__librashader__noop_d3d9_filter_chain_get_param;
instance.d3d9_filter_chain_set_param =
__librashader__noop_d3d9_filter_chain_set_param;
#endif
#if defined(LIBRA_RUNTIME_METAL)
instance.mtl_filter_chain_create =
__librashader__noop_mtl_filter_chain_create;
@ -1539,6 +1674,18 @@ libra_instance_t librashader_load_instance(void) {
d3d12_filter_chain_set_active_pass_count);
#endif
#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)
_LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_create);
_LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_frame);
_LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_free);
_LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_get_param);
_LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_set_param);
_LIBRASHADER_ASSIGN(librashader, instance,
d3d9_filter_chain_get_active_pass_count);
_LIBRASHADER_ASSIGN(librashader, instance,
d3d9_filter_chain_set_active_pass_count);
#endif
#if defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL)
_LIBRASHADER_ASSIGN(librashader, instance, mtl_filter_chain_create);
_LIBRASHADER_ASSIGN(librashader, instance,

View file

@ -16,10 +16,12 @@ crate-type = [ "cdylib", "staticlib" ]
[features]
default = ["runtime-all" ]
runtime-all = ["runtime-opengl", "runtime-d3d11", "runtime-d3d12", "runtime-vulkan", "runtime-metal"]
runtime-all = ["runtime-opengl", "runtime-d3d9", "runtime-d3d11", "runtime-d3d12", "runtime-vulkan", "runtime-metal"]
runtime-opengl = ["gl", "librashader/runtime-gl"]
runtime-d3d11 = ["windows", "librashader/runtime-d3d11", "windows/Win32_Graphics_Direct3D11"]
runtime-d3d12 = ["windows", "librashader/runtime-d3d12", "windows/Win32_Graphics_Direct3D12"]
runtime-d3d9 = ["windows", "librashader/runtime-d3d9", "windows/Win32_Graphics_Direct3D9"]
runtime-vulkan = ["ash", "librashader/runtime-vk"]
runtime-metal = ["__cbindgen_internal_objc", "librashader/runtime-metal"]

View file

@ -38,6 +38,9 @@ after_includes = """
#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)
#include <d3d12.h>
#endif
#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)
#include <D3D9.h>
#endif
#if defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)
#import <Metal/Metal.h>
#endif
@ -51,6 +54,7 @@ after_includes = """
"feature = runtime-vulkan" = "LIBRA_RUNTIME_VULKAN"
"feature = runtime-d3d11" = "LIBRA_RUNTIME_D3D11"
"feature = runtime-d3d12" = "LIBRA_RUNTIME_D3D12"
"feature = runtime-d3d9" = "LIBRA_RUNTIME_D3D9"
"feature = runtime-metal" = "LIBRA_RUNTIME_METAL"
"feature = __cbindgen_internal_objc" = "__OBJC__"
@ -137,6 +141,14 @@ include = [
"PFN_libra_d3d11_filter_chain_get_active_pass_count",
"PFN_libra_d3d11_filter_chain_free",
# d3d11
"PFN_libra_d3d9_filter_chain_create",
"PFN_libra_d3d9_filter_chain_frame",
"PFN_libra_d3d9_filter_chain_set_param",
"PFN_libra_d3d9_filter_chain_get_param",
"PFN_libra_d3d9_filter_chain_set_active_pass_count",
"PFN_libra_d3d9_filter_chain_get_active_pass_count",
"PFN_libra_d3d9_filter_chain_free",
# d3d12
"PFN_libra_d3d12_filter_chain_create",
@ -176,6 +188,7 @@ exclude = [
"FilterChainVulkan" = "_filter_chain_vk"
"FilterChainD3D11" = "_filter_chain_d3d11"
"FilterChainD3D12" = "_filter_chain_d3d12"
"FilterChainD3D9" = "_filter_chain_d3d9"
"FilterChainMetal" = "_filter_chain_mtl"
# vulkan renames
@ -193,6 +206,11 @@ exclude = [
"ID3D11RenderTargetView" = "ID3D11RenderTargetView *"
"ID3D11ShaderResourceView" = "ID3D11ShaderResourceView *"
# hack to get proper pointer indirection for COM pointers
"IDirect3DDevice9" = "IDirect3DDevice9 *"
"IDirect3DSurface9" = "IDirect3DSurface9 *"
"IDirect3DTexture9" = "IDirect3DTexture9 *"
# hack to force cbindgen to not generate option type for nullable ID3D11DeviceContext.
"Option_ID3D11DeviceContext" = "ID3D11DeviceContext *"

View file

@ -90,6 +90,21 @@ use librashader::runtime::d3d12::FilterChain as FilterChainD3D12;
))]
pub type libra_d3d12_filter_chain_t = Option<NonNull<FilterChainD3D12>>;
/// A handle to a Direct3D 9 filter chain.
#[cfg(any(
feature = "__cbindgen_internal",
all(target_os = "windows", feature = "runtime-d3d9")
))]
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(any(
feature = "__cbindgen_internal",
all(target_os = "windows", feature = "runtime-d3d9")
))]
pub type libra_d3d9_filter_chain_t = Option<NonNull<FilterChainD3D9>>;
#[cfg(feature = "runtime-vulkan")]
use librashader::runtime::vk::FilterChain as FilterChainVulkan;
/// A handle to a Vulkan filter chain.
@ -192,6 +207,8 @@ mod __cbindgen_opaque_forward_declarations {
FilterChainD3D11;
/// Opaque struct for a Direct3D 12 filter chain.
FilterChainD3D12;
/// Opaque struct for a Direct3D 9 filter chain.
FilterChainD3D9;
/// Opaque struct for a Vulkan filter chain.
FilterChainVulkan;
/// Opaque struct for a Metal filter chain.

View file

@ -37,6 +37,10 @@ pub enum LibrashaderError {
#[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")))]
#[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"))]
#[error("There was an error in the Vulkan filter chain.")]
@ -189,6 +193,8 @@ impl LibrashaderError {
LibrashaderError::D3D11FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
#[cfg(all(target_os = "windows", feature = "runtime-d3d12"))]
LibrashaderError::D3D12FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
#[cfg(all(target_os = "windows", feature = "runtime-d3d9"))]
LibrashaderError::D3D9FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
#[cfg(feature = "runtime-vulkan")]
LibrashaderError::VulkanFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR,
#[cfg(all(target_vendor = "apple", feature = "runtime-metal"))]

View file

@ -0,0 +1,259 @@
use crate::ctypes::{
config_struct, libra_d3d9_filter_chain_t, libra_shader_preset_t, libra_viewport_t, FromUninit,
};
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
use crate::ffi::extern_fn;
use librashader::runtime::d3d9::{FilterChain, FilterChainOptions, FrameOptions};
use std::ffi::c_char;
use std::ffi::CStr;
use std::mem::{ManuallyDrop, MaybeUninit};
use std::ptr::NonNull;
use std::slice;
use windows::Win32::Graphics::Direct3D9::{IDirect3DDevice9, IDirect3DSurface9, IDirect3DTexture9};
use crate::LIBRASHADER_API_VERSION;
use librashader::runtime::{FilterChainParameters, Viewport};
/// Options for Direct3D 11 filter chain creation.
#[repr(C)]
#[derive(Default, Debug, Clone)]
pub struct filter_chain_d3d9_opt_t {
/// The librashader API version.
pub version: LIBRASHADER_API_VERSION,
/// Whether or not to explicitly disable mipmap
/// generation regardless of shader preset settings.
pub force_no_mipmaps: bool,
/// Disable the shader object cache. Shaders will be
/// recompiled rather than loaded from the cache.
pub disable_cache: bool,
}
config_struct! {
impl FilterChainOptions => filter_chain_d3d9_opt_t {
0 => [force_no_mipmaps, disable_cache];
}
}
/// Options for each Direct3D 11 shader frame.
#[repr(C)]
#[derive(Default, Debug, Clone)]
pub struct frame_d3d9_opt_t {
/// The librashader API version.
pub version: LIBRASHADER_API_VERSION,
/// Whether or not to clear the history buffers.
pub clear_history: bool,
/// The direction of rendering.
/// -1 indicates that the frames are played in reverse order.
pub frame_direction: i32,
/// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg.
pub rotation: u32,
/// The total number of subframes ran. Default is 1.
pub total_subframes: u32,
/// The current sub frame. Default is 1.
pub current_subframe: u32,
}
config_struct! {
impl FrameOptions => frame_d3d9_opt_t {
0 => [clear_history, frame_direction];
1 => [rotation, total_subframes, current_subframe]
}
}
extern_fn! {
/// Create the filter chain given the shader preset.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
/// - `device` must not be null.
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
fn libra_d3d9_filter_chain_create(
preset: *mut libra_shader_preset_t,
device: ManuallyDrop<IDirect3DDevice9>,
options: *const MaybeUninit<filter_chain_d3d9_opt_t>,
out: *mut MaybeUninit<libra_d3d9_filter_chain_t>
) {
assert_non_null!(preset);
let preset = unsafe {
let preset_ptr = &mut *preset;
let preset = preset_ptr.take();
Box::from_raw(preset.unwrap().as_ptr())
};
let options = if options.is_null() {
None
} else {
Some(unsafe { options.read() })
};
let options = options.map(FromUninit::from_uninit);
unsafe {
let chain = FilterChain::load_from_preset(
*preset,
&device,
options.as_ref(),
)?;
out.write(MaybeUninit::new(NonNull::new(Box::into_raw(Box::new(
chain,
)))))
}
}
}
extern_fn! {
/// Draw a frame with the given parameters for the given filter chain.
///
///
/// ## Safety
/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or invalid, this
/// function will return an error.
/// - `mvp` may be null, or if it is not null, must be an aligned pointer to 16 consecutive `float`
/// values for the model view projection matrix.
/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_d3d9_opt_t`
/// struct.
/// - `out` must not be null.
/// - `image` must not be null.
/// - You must ensure that only one thread has access to `chain` before you call this function. Only one
/// thread at a time may call this function.
nopanic fn libra_d3d9_filter_chain_frame(
chain: *mut libra_d3d9_filter_chain_t,
frame_count: usize,
image: ManuallyDrop<IDirect3DTexture9>,
viewport: libra_viewport_t,
out: ManuallyDrop<IDirect3DSurface9>,
mvp: *const f32,
options: *const MaybeUninit<frame_d3d9_opt_t>
) mut |chain| {
assert_some_ptr!(mut chain);
let mvp = if mvp.is_null() {
None
} else {
Some(<&[f32; 16]>::try_from(unsafe { slice::from_raw_parts(mvp, 16) }).unwrap())
};
let options = if options.is_null() {
None
} else {
Some(unsafe { options.read() })
};
let viewport = Viewport {
x: viewport.x,
y: viewport.y,
output: ManuallyDrop::into_inner(out.clone()),
mvp,
};
let options = options.map(FromUninit::from_uninit);
unsafe {
chain.frame(ManuallyDrop::into_inner(image.clone()), &viewport, frame_count, options.as_ref())?;
}
}
}
extern_fn! {
/// Sets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d9_filter_chain_t`.
/// - `param_name` must be either null or a null terminated string.
fn libra_d3d9_filter_chain_set_param(
chain: *mut libra_d3d9_filter_chain_t,
param_name: *const c_char,
value: f32
) mut |chain| {
assert_some_ptr!(mut chain);
assert_non_null!(param_name);
unsafe {
let name = CStr::from_ptr(param_name);
let name = name.to_str()?;
if chain.set_parameter(name, value).is_none() {
return LibrashaderError::UnknownShaderParameter(param_name).export()
}
}
}
}
extern_fn! {
/// Gets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d9_filter_chain_t`.
/// - `param_name` must be either null or a null terminated string.
fn libra_d3d9_filter_chain_get_param(
chain: *mut libra_d3d9_filter_chain_t,
param_name: *const c_char,
out: *mut MaybeUninit<f32>
) mut |chain| {
assert_some_ptr!(mut chain);
assert_non_null!(param_name);
unsafe {
let name = CStr::from_ptr(param_name);
let name = name.to_str()?;
let Some(value) = chain.get_parameter(name) else {
return LibrashaderError::UnknownShaderParameter(param_name).export()
};
out.write(MaybeUninit::new(value));
}
}
}
extern_fn! {
/// Sets the number of active passes for this chain.
///
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d9_filter_chain_t`.
fn libra_d3d9_filter_chain_set_active_pass_count(
chain: *mut libra_d3d9_filter_chain_t,
value: u32
) mut |chain| {
assert_some_ptr!(mut chain);
chain.set_enabled_pass_count(value as usize);
}
}
extern_fn! {
/// Gets the number of active passes for this chain.
///
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d9_filter_chain_t`.
fn libra_d3d9_filter_chain_get_active_pass_count(
chain: *mut libra_d3d9_filter_chain_t,
out: *mut MaybeUninit<u32>
) mut |chain| {
assert_some_ptr!(mut chain);
unsafe {
let value = chain.get_enabled_pass_count();
out.write(MaybeUninit::new(value as u32))
}
}
}
extern_fn! {
/// Free a d3d9 filter chain.
///
/// The resulting value in `chain` then becomes null.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d9_filter_chain_t`.
fn libra_d3d9_filter_chain_free(chain: *mut libra_d3d9_filter_chain_t) {
assert_non_null!(chain);
unsafe {
let chain_ptr = &mut *chain;
let chain = chain_ptr.take();
drop(Box::from_raw(chain.unwrap().as_ptr()))
};
}
}

View file

@ -0,0 +1,5 @@
//! C API for the librashader D3D9 Runtime (`libra_d3d9_*`).
mod filter_chain;
pub use filter_chain::*;
const _: () = crate::assert_thread_safe::<librashader::runtime::d3d11::FilterChain>();

View file

@ -14,6 +14,13 @@ pub mod vk;
))]
pub mod d3d11;
#[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(any(
feature = "__cbindgen_internal",

View file

@ -44,7 +44,6 @@ impl From<Direct3D9::D3DFORMAT> for ImageFormat {
}
}
impl From<WrapMode> for Direct3D9::D3DTEXTUREADDRESS {
fn from(value: WrapMode) -> Self {
match value {

View file

@ -3,7 +3,7 @@ name = "librashader-runtime-d3d9"
edition = "2021"
license = "MPL-2.0 OR GPL-3.0-only"
version = "0.2.4"
version = "0.2.6"
authors = ["Ronny Chan <ronny@ronnychan.ca>"]
repository = "https://github.com/SnowflakePowered/librashader"
readme = "../README.md"

View file

@ -33,6 +33,8 @@ pub mod raw {
}
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[inline]
pub unsafe fn D3DXCompileShader<P1, P2, P3>(
psrcdata: *const c_void,
@ -69,6 +71,8 @@ where
#[repr(transparent)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct ID3DXConstantTable(windows::core::IUnknown);
#[allow(dead_code)]
impl ID3DXConstantTable {
#[allow(non_snake_case)]
pub unsafe fn GetShaderConstantTable(
@ -370,6 +374,7 @@ pub struct D3DXCONSTANT_DESC {
#[derive(PartialEq, Eq, Debug)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
#[allow(dead_code)]
pub enum D3DXREGISTER_SET {
D3DXRS_BOOL = 0,
D3DXRS_INT4 = 1,
@ -382,6 +387,7 @@ pub enum D3DXREGISTER_SET {
#[derive(PartialEq, Eq, Debug)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
#[allow(dead_code)]
pub enum D3DXPARAMETER_CLASS {
D3DXPC_SCALAR = 0,
D3DXPC_VECTOR = 1,
@ -396,6 +402,7 @@ pub enum D3DXPARAMETER_CLASS {
#[derive(Debug)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
#[allow(dead_code)]
pub enum D3DXPARAMETER_TYPE {
D3DXPT_VOID = 0,
D3DXPT_BOOL = 1,

View file

@ -2,17 +2,17 @@
#![feature(type_alias_impl_trait)]
#![feature(error_generic_member_access)]
mod binding;
mod d3dx;
mod draw_quad;
pub mod error;
mod filter_chain;
mod filter_pass;
mod graphics_pipeline;
mod luts;
pub mod options;
mod samplers;
mod texture;
mod util;
mod d3dx;
pub mod error;
pub mod options;
use librashader_runtime::impl_filter_chain_parameters;
impl_filter_chain_parameters!(FilterChainD3D9);

View file

@ -8,7 +8,7 @@ use librashader_runtime::binding::TextureInput;
use librashader_runtime::scaling::{ScaleFramebuffer, ViewportSize};
use windows::Win32::Graphics::Direct3D9::{
IDirect3DDevice9, IDirect3DSurface9, IDirect3DTexture9, D3DCLEAR_TARGET, D3DFORMAT,
D3DPOOL_DEFAULT, D3DTEXF_LINEAR, D3DUSAGE_DYNAMIC, D3DUSAGE_RENDERTARGET,
D3DPOOL_DEFAULT, D3DTEXF_LINEAR, D3DUSAGE_RENDERTARGET,
};
/// An image view for use as a shader resource.

View file

@ -21,6 +21,7 @@ librashader-cache = { path = "../librashader-cache", version = "0.2.6" }
librashader-runtime = { path = "../librashader-runtime", version = "0.2.6" }
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.2.6", optional = true }
librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.2.6", optional = true }
librashader-runtime-d3d9 = { path = "../librashader-runtime-d3d9", version = "0.2.6", optional = true }
librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.2.6", optional = true }
librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.2.6", optional = true }
librashader-runtime-mtl = { path = "../librashader-runtime-mtl", version = "0.2.6", optional = true }
@ -53,6 +54,8 @@ presets = []
runtime-gl = [ "runtime", "reflect-cross", "librashader-common/opengl", "librashader-runtime-gl" ]
runtime-d3d11 = [ "runtime", "reflect-cross","librashader-common/d3d11", "librashader-runtime-d3d11", "windows/Win32_Graphics_Direct3D11" ]
runtime-d3d12 = [ "runtime", "reflect-cross", "reflect-dxil", "librashader-common/d3d12", "librashader-runtime-d3d12", "windows/Win32_Graphics_Direct3D12" ]
runtime-d3d9 = [ "runtime", "reflect-cross", "librashader-common/d3d9", "librashader-runtime-d3d9", "windows/Win32_Graphics_Direct3D9" ]
runtime-vk = ["runtime", "reflect-cross", "librashader-common/vulkan", "librashader-runtime-vk", "ash" ]
runtime-wgpu = [ "runtime", "reflect-naga", "librashader-common/wgpu", "librashader-runtime-wgpu", "wgpu", "wgpu-types" ]
runtime-metal = [ "runtime", "reflect-naga", "reflect-cross", "librashader-common/metal", "librashader-runtime-mtl", "icrate", "objc2" ]

View file

@ -24,6 +24,9 @@
//! The Vulkan runtime can use [`VK_KHR_dynamic_rendering`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_dynamic_rendering.html)
//! for improved performance, if the underlying hardware supports it.
//!
//! Direct3D 9 support is experimental and is not guaranteed to work with all shaders. In particular, history and feedback is currently not supported.
//! Many shaders will also fail to compile due to missing or insufficient features in Direct3D 9.
//!
//! wgpu support is not available in the librashader C API.
//!
//! | **API** | **Status** | **`librashader` feature** |
@ -31,6 +34,7 @@
//! | OpenGL 3.3+ | ✔ | `gl` |
//! | OpenGL 4.6 | ✔ | `gl` |
//! | Vulkan | ✔ | `vk` |
//! | Direct3D 9 | ⚠️ | `d3d9` |
//! | Direct3D 11 | ✔ | `d3d11` |
//! | Direct3D 12 | ✔ | `d3d12` |
//! | wgpu | ✔ | `wgpu` |
@ -270,6 +274,19 @@ pub mod runtime {
};
}
#[cfg(all(target_os = "windows", feature = "runtime-d3d9"))]
#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))]
/// Shader runtime for Direct3D 9.
pub mod d3d9 {
pub use librashader_runtime_d3d9::{
error,
options::{
FilterChainOptionsD3D9 as FilterChainOptions, FrameOptionsD3D9 as FrameOptions,
},
FilterChainD3D9 as FilterChain,
};
}
#[cfg(feature = "runtime-vk")]
#[doc(cfg(feature = "runtime-vk"))]
/// Shader runtime for Vulkan.