librashader/librashader-runtime-d3d11/src/lib.rs

105 lines
3.6 KiB
Rust
Raw Normal View History

#![cfg(target_os = "windows")]
2023-01-17 15:09:07 +11:00
//! librashader Direct3D 11 runtime
//!
//! This crate should not be used directly.
//! See [`librashader::runtime::d3d11`](https://docs.rs/librashader/latest/librashader/runtime/d3d11/index.html) instead.
2022-11-22 17:56:39 +11:00
#![feature(type_alias_impl_trait)]
2022-11-26 18:38:15 +11:00
#![feature(let_chains)]
2022-12-01 09:59:55 +11:00
#[cfg(test)]
mod hello_triangle;
2022-11-22 17:56:39 +11:00
2023-02-07 13:56:30 +11:00
mod draw_quad;
2022-12-01 11:05:12 +11:00
pub mod error;
2022-12-01 09:59:55 +11:00
mod filter_chain;
2022-11-26 18:38:15 +11:00
mod filter_pass;
2022-11-30 17:38:05 +11:00
mod framebuffer;
2022-12-01 11:05:12 +11:00
pub mod options;
2022-12-22 13:39:31 +11:00
mod parameters;
2022-11-30 17:38:05 +11:00
mod render_target;
mod samplers;
2022-11-26 18:38:15 +11:00
mod texture;
mod util;
2022-11-07 16:25:11 +11:00
pub use filter_chain::FilterChainD3D11;
2023-01-13 18:54:16 +11:00
pub use texture::D3D11InputView;
pub use texture::D3D11OutputView;
2022-12-01 11:10:04 +11:00
2022-11-07 16:25:11 +11:00
#[cfg(test)]
mod tests {
use super::*;
use crate::options::FilterChainOptionsD3D11;
2023-01-30 13:26:34 +11:00
use librashader_runtime::image::{Image, UVDirection};
2023-02-06 08:17:23 +11:00
use std::env;
2022-11-07 16:25:11 +11:00
2023-01-31 11:48:54 +11:00
// "../test/slang-shaders/scalefx/scalefx-9x.slangp",
// "../test/slang-shaders/bezel/koko-aio/monitor-bloom.slangp",
// "../test/slang-shaders/presets/crt-geom-ntsc-upscale-sharp.slangp",
const FILTER_PATH: &str = "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp";
2023-01-31 11:48:54 +11:00
// "../test/null.slangp",
// const FILTER_PATH: &str = "../test/slang-shaders/scalefx/scalefx-9x.slangp";
2023-01-31 11:48:54 +11:00
// const FILTER_PATH: &str = "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp";
2023-02-01 09:50:47 +11:00
const IMAGE_PATH: &str = "../test/finalfightlong.png";
// #[test]
// fn triangle_d3d11_args() {
// let mut args = env::args();
// let _ = args.next();
// let _ = args.next();
// let filter = args.next();
// let image = args
// .next()
// .and_then(|f| Image::load(f, UVDirection::TopLeft).ok())
// .or_else(|| Some(Image::load(IMAGE_PATH, UVDirection::TopLeft).unwrap()))
// .unwrap();
//
// let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
// filter.as_deref().unwrap_or(FILTER_PATH),
// Some(&FilterChainOptionsD3D11 {
// use_deferred_context: false,
// force_no_mipmaps: false,
// }),
// // replace below with 'None' for the triangle
// Some(image),
// )
// .unwrap();
// // let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new(
// // "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// // Some(&FilterChainOptions {
// // use_deferred_context: true,
// // })
// // )
// // .unwrap();
//
// // let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new("../test/basic.slangp").unwrap();
//
// hello_triangle::main(sample).unwrap();
// }
2023-01-31 11:48:54 +11:00
#[test]
fn triangle_d3d11() {
let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
FILTER_PATH,
Some(&FilterChainOptionsD3D11 {
use_deferred_context: false,
force_no_mipmaps: false,
}),
// replace below with 'None' for the triangle
// None,
2023-02-07 13:56:30 +11:00
Some(Image::load(IMAGE_PATH, UVDirection::TopLeft).unwrap()),
2023-01-31 11:48:54 +11:00
)
2023-02-06 08:17:23 +11:00
.unwrap();
2023-01-31 11:48:54 +11:00
// let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new(
// "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// Some(&FilterChainOptions {
// use_deferred_context: true,
// })
// )
// .unwrap();
// let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new("../test/basic.slangp").unwrap();
hello_triangle::main(sample).unwrap();
}
2022-11-07 16:25:11 +11:00
}