d3d11: properly clear history framebuffers
This commit is contained in:
parent
2adb23c01f
commit
336094cad9
|
@ -410,7 +410,7 @@ impl FilterChainD3D11 {
|
||||||
if let Some(options) = options {
|
if let Some(options) = options {
|
||||||
if options.clear_history {
|
if options.clear_history {
|
||||||
for framebuffer in &mut self.history_framebuffers {
|
for framebuffer in &mut self.history_framebuffers {
|
||||||
framebuffer.init(Size::new(1, 1), ImageFormat::R8G8B8A8Unorm)?;
|
framebuffer.clear()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ use windows::Win32::Graphics::Direct3D11::{
|
||||||
};
|
};
|
||||||
use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT, DXGI_SAMPLE_DESC};
|
use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT, DXGI_SAMPLE_DESC};
|
||||||
|
|
||||||
|
static CLEAR: &[f32; 4] = &[0.0f32, 0.0, 0.0, 0.0];
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct OwnedFramebuffer {
|
pub(crate) struct OwnedFramebuffer {
|
||||||
render: ID3D11Texture2D,
|
render: ID3D11Texture2D,
|
||||||
|
@ -97,6 +99,14 @@ impl OwnedFramebuffer {
|
||||||
Ok(size)
|
Ok(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear(&mut self) -> error::Result<()> {
|
||||||
|
let rtv = self.create_render_target_view()?;
|
||||||
|
unsafe {
|
||||||
|
self.context.ClearRenderTargetView(&rtv, CLEAR.as_ptr());
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn init(&mut self, size: Size<u32>, format: ImageFormat) -> error::Result<()> {
|
pub fn init(&mut self, size: Size<u32>, format: ImageFormat) -> error::Result<()> {
|
||||||
let format = d3d11_get_closest_format(
|
let format = d3d11_get_closest_format(
|
||||||
&self.device,
|
&self.device,
|
||||||
|
|
|
@ -30,51 +30,52 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::options::FilterChainOptionsD3D11;
|
use crate::options::FilterChainOptionsD3D11;
|
||||||
use librashader_runtime::image::{Image, UVDirection};
|
use librashader_runtime::image::{Image, UVDirection};
|
||||||
|
use std::env;
|
||||||
|
|
||||||
// "../test/slang-shaders/scalefx/scalefx-9x.slangp",
|
// "../test/slang-shaders/scalefx/scalefx-9x.slangp",
|
||||||
// "../test/slang-shaders/bezel/koko-aio/monitor-bloom.slangp",
|
// "../test/slang-shaders/bezel/koko-aio/monitor-bloom.slangp",
|
||||||
// "../test/slang-shaders/presets/crt-geom-ntsc-upscale-sharp.slangp",
|
// "../test/slang-shaders/presets/crt-geom-ntsc-upscale-sharp.slangp",
|
||||||
const FILTER_PATH: &str =
|
const FILTER_PATH: &str =
|
||||||
"../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp";
|
"../test/slang-shaders/handheld/console-border/gbc-lcd-grid-v2.slangp";
|
||||||
// "../test/null.slangp",
|
// "../test/null.slangp",
|
||||||
// const FILTER_PATH: &str = "../test/slang-shaders/crt/crt-royale.slangp";
|
// const FILTER_PATH: &str = "../test/slang-shaders/crt/crt-royale.slangp";
|
||||||
|
|
||||||
// const FILTER_PATH: &str = "../test/slang-shaders/crt/crt-royale.slangp";
|
// const FILTER_PATH: &str = "../test/slang-shaders/crt/crt-royale.slangp";
|
||||||
const IMAGE_PATH: &str = "../test/finalfightlong.png";
|
const IMAGE_PATH: &str = "../triangle.png";
|
||||||
// #[test]
|
#[test]
|
||||||
// fn triangle_d3d11_args() {
|
fn triangle_d3d11_args() {
|
||||||
// let mut args = env::args();
|
let mut args = env::args();
|
||||||
// let _ = args.next();
|
let _ = args.next();
|
||||||
// let _ = args.next();
|
let _ = args.next();
|
||||||
// let filter = args.next();
|
let filter = args.next();
|
||||||
// let image = args
|
let image = args
|
||||||
// .next()
|
.next()
|
||||||
// .and_then(|f| Image::load(f, UVDirection::TopLeft).ok())
|
.and_then(|f| Image::load(f, UVDirection::TopLeft).ok())
|
||||||
// .or_else(|| Some(Image::load(IMAGE_PATH, UVDirection::TopLeft).unwrap()))
|
.or_else(|| Some(Image::load(IMAGE_PATH, UVDirection::TopLeft).unwrap()))
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
//
|
|
||||||
// let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
|
let sample = hello_triangle::d3d11_hello_triangle::Sample::new(
|
||||||
// filter.as_deref().unwrap_or(FILTER_PATH),
|
filter.as_deref().unwrap_or(FILTER_PATH),
|
||||||
// Some(&FilterChainOptionsD3D11 {
|
Some(&FilterChainOptionsD3D11 {
|
||||||
// use_deferred_context: false,
|
use_deferred_context: false,
|
||||||
// force_no_mipmaps: false,
|
force_no_mipmaps: false,
|
||||||
// }),
|
}),
|
||||||
// // replace below with 'None' for the triangle
|
// replace below with 'None' for the triangle
|
||||||
// Some(image),
|
Some(image),
|
||||||
// )
|
)
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
// // let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new(
|
// let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new(
|
||||||
// // "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
// "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
||||||
// // Some(&FilterChainOptions {
|
// Some(&FilterChainOptions {
|
||||||
// // use_deferred_context: true,
|
// use_deferred_context: true,
|
||||||
// // })
|
// })
|
||||||
// // )
|
// )
|
||||||
// // .unwrap();
|
// .unwrap();
|
||||||
//
|
|
||||||
// // let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new("../test/basic.slangp").unwrap();
|
// let sample = hello_triangle_old::d3d11_hello_triangle::Sample::new("../test/basic.slangp").unwrap();
|
||||||
//
|
|
||||||
// hello_triangle::main(sample).unwrap();
|
hello_triangle::main(sample).unwrap();
|
||||||
// }
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn triangle_d3d11() {
|
fn triangle_d3d11() {
|
||||||
|
|
Loading…
Reference in a new issue