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

105 lines
3.5 KiB
Rust
Raw Normal View History

#![cfg(target_os = "windows")]
2023-01-16 23:09:07 -05: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 01:56:39 -05:00
#![feature(type_alias_impl_trait)]
2022-11-26 02:38:15 -05:00
#![feature(let_chains)]
2022-11-30 17:59:55 -05:00
#[cfg(test)]
mod hello_triangle;
2022-11-22 01:56:39 -05:00
2022-11-30 19:05:12 -05:00
pub mod error;
2022-11-30 17:59:55 -05:00
mod filter_chain;
2022-11-26 02:38:15 -05:00
mod filter_pass;
2022-11-30 01:38:05 -05:00
mod framebuffer;
2022-11-30 19:05:12 -05:00
pub mod options;
2022-12-21 21:39:31 -05:00
mod parameters;
mod draw_quad;
2022-11-30 01:38:05 -05:00
mod render_target;
mod samplers;
2022-11-26 02:38:15 -05:00
mod texture;
mod util;
2022-11-07 00:25:11 -05:00
pub use filter_chain::FilterChainD3D11;
2023-01-13 02:54:16 -05:00
pub use texture::D3D11InputView;
pub use texture::D3D11OutputView;
2022-11-30 19:10:04 -05:00
2022-11-07 00:25:11 -05:00
#[cfg(test)]
mod tests {
use super::*;
use crate::options::FilterChainOptionsD3D11;
2023-01-29 21:26:34 -05:00
use librashader_runtime::image::{Image, UVDirection};
2023-02-05 16:17:23 -05:00
use std::env;
2022-11-07 00:25:11 -05:00
2023-01-30 19:48:54 -05: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",
// "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// "../test/null.slangp",
const FILTER_PATH: &str = "../test/slang-shaders/scalefx/scalefx-9x.slangp";
2023-01-30 19:48:54 -05:00
// const FILTER_PATH: &str = "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp";
2023-01-31 17:50:47 -05:00
const IMAGE_PATH: &str = "../test/finalfightlong.png";
2022-11-07 00:25:11 -05:00
#[test]
2023-01-30 19:48:54 -05:00
fn triangle_d3d11_args() {
let mut args = env::args();
let _ = args.next();
let _ = args.next();
let filter = args.next();
2023-02-05 16:17:23 -05:00
let image = args
.next()
2023-01-30 19:48:54 -05:00
.and_then(|f| Image::load(f, UVDirection::TopLeft).ok())
.or_else(|| Some(Image::load(IMAGE_PATH, UVDirection::TopLeft).unwrap()))
.unwrap();
2022-11-30 01:38:05 -05:00
let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
2023-01-30 19:48:54 -05:00
filter.as_deref().unwrap_or(FILTER_PATH),
Some(&FilterChainOptionsD3D11 {
use_deferred_context: false,
force_no_mipmaps: false,
}),
2023-01-30 19:48:54 -05:00
// replace below with 'None' for the triangle
2023-02-05 16:17:23 -05:00
Some(image),
2022-11-30 01:38:05 -05:00
)
.unwrap();
// let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new(
2022-11-30 19:05:12 -05:00
// "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// Some(&FilterChainOptions {
// use_deferred_context: true,
// })
// )
// .unwrap();
2022-11-30 01:35:20 -05:00
// let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new("../test/basic.slangp").unwrap();
2022-11-28 21:00:54 -05:00
2022-11-26 02:38:15 -05:00
hello_triangle::main(sample).unwrap();
2022-11-07 00:25:11 -05:00
}
2023-01-30 19:48:54 -05: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,
Some(Image::load(IMAGE_PATH, UVDirection::TopLeft).unwrap())
2023-01-30 19:48:54 -05:00
)
2023-02-05 16:17:23 -05:00
.unwrap();
2023-01-30 19:48:54 -05: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 00:25:11 -05:00
}