From 1e99c169dbfb29d67ba4c0cc8e796cd1a9fb7178 Mon Sep 17 00:00:00 2001 From: chyyran Date: Fri, 27 Jan 2023 01:22:53 -0500 Subject: [PATCH] d3d11: rebind vertices each pass --- librashader-runtime-d3d11/src/filter_chain.rs | 7 ++----- librashader-runtime-d3d11/src/filter_pass.rs | 1 + librashader-runtime-gl/src/lib.rs | 4 ++-- .../librashader-capi-tests/dx11-example-2/code.cpp | 14 ++++++++++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index 878e8a7..f2c679d 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -45,7 +45,6 @@ pub struct FilterChainD3D11 { pub(crate) output_framebuffers: Box<[OwnedFramebuffer]>, pub(crate) feedback_framebuffers: Box<[OwnedFramebuffer]>, pub(crate) history_framebuffers: VecDeque, - pub(crate) draw_quad: DrawQuad, } pub(crate) struct Direct3D11 { @@ -64,6 +63,7 @@ pub(crate) struct FilterCommon { pub history_textures: Box<[Option]>, pub config: FilterMutable, pub disable_mipmaps: bool, + pub(crate) draw_quad: DrawQuad, } impl FilterChainD3D11 { @@ -163,7 +163,6 @@ impl FilterChainD3D11 { output_framebuffers: output_framebuffers.into_boxed_slice(), feedback_framebuffers: feedback_framebuffers.into_boxed_slice(), history_framebuffers, - draw_quad, common: FilterCommon { d3d11: Direct3D11 { device: device.clone(), @@ -185,6 +184,7 @@ impl FilterChainD3D11 { output_textures: output_textures.into_boxed_slice(), feedback_textures: feedback_textures.into_boxed_slice(), history_textures, + draw_quad, }, }) } @@ -433,8 +433,6 @@ impl FilterChainD3D11 { let filter = passes[0].config.filter; let wrap_mode = passes[0].config.wrap_mode; - self.draw_quad.bind_vertices(); - for ((texture, fbo), pass) in self .common .feedback_textures @@ -491,7 +489,6 @@ impl FilterChainD3D11 { for (index, pass) in pass.iter_mut().enumerate() { let target = &self.output_framebuffers[index]; let size = target.size; - pass.draw( index, &self.common, diff --git a/librashader-runtime-d3d11/src/filter_pass.rs b/librashader-runtime-d3d11/src/filter_pass.rs index 2c5061f..a5c9477 100644 --- a/librashader-runtime-d3d11/src/filter_pass.rs +++ b/librashader-runtime-d3d11/src/filter_pass.rs @@ -157,6 +157,7 @@ impl FilterPass { } } unsafe { + parent.draw_quad.bind_vertices(); context.IASetInputLayout(&self.vertex_layout); context.VSSetShader(&self.vertex_shader, None); context.PSSetShader(&self.pixel_shader, None); diff --git a/librashader-runtime-gl/src/lib.rs b/librashader-runtime-gl/src/lib.rs index 5d975d7..0aca4a6 100644 --- a/librashader-runtime-gl/src/lib.rs +++ b/librashader-runtime-gl/src/lib.rs @@ -35,7 +35,7 @@ mod tests { fn triangle_gl() { let (glfw, window, events, shader, vao) = gl::gl3::hello_triangle::setup(); let mut filter = FilterChainGL::load_from_path( - "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp", + "../test/slang-shaders/crt/crt-lottes.slangp", Some(&FilterChainOptionsGL { gl_version: 0, use_dsa: false, @@ -52,7 +52,7 @@ mod tests { let (glfw, window, events, shader, vao) = gl::gl46::hello_triangle::setup(); let mut filter = FilterChainGL::load_from_path( // "../test/slang-shaders/vhs/VHSPro.slangp", - "../test/slang-shaders/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp", + "../test/slang-shaders/crt/crt-lottes.slangp", Some(&FilterChainOptionsGL { gl_version: 0, use_dsa: true, diff --git a/test/capi-tests/librashader-capi-tests/dx11-example-2/code.cpp b/test/capi-tests/librashader-capi-tests/dx11-example-2/code.cpp index de56acc..f9fba1f 100644 --- a/test/capi-tests/librashader-capi-tests/dx11-example-2/code.cpp +++ b/test/capi-tests/librashader-capi-tests/dx11-example-2/code.cpp @@ -39,7 +39,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, ID3D11DeviceContext* baseDeviceContext; D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, - D3D11_CREATE_DEVICE_BGRA_SUPPORT, featureLevels, + D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_DEBUG, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION, &baseDevice, nullptr, &baseDeviceContext); @@ -64,8 +64,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, &preset); libra_d3d11_filter_chain_t filter_chain; + filter_chain_d3d11_opt_t opt = { + .use_deferred_context = true, + .force_no_mipmaps = false, + }; - libra.d3d11_filter_chain_create(&preset, NULL, device, &filter_chain); + libra.d3d11_filter_chain_create(&preset, &opt, device, &filter_chain); /////////////////////////////////////////////////////////////////////////////////////////////// IDXGIDevice1* dxgiDevice; @@ -392,7 +396,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, MSG msg; while (PeekMessageA(&msg, nullptr, 0, 0, PM_REMOVE)) { - //if (msg.message == WM_KEYDOWN) return 0; + if (msg.message == WM_KEYDOWN) return 0; DispatchMessageA(&msg); } @@ -476,9 +480,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, framebufferVP.Width}; libra_viewport_t vp = {0, 0, framebufferVP.Height, framebufferVP.Width}; + frame_d3d11_opt_t frame_opt = {.clear_history = false, + .frame_direction = -1}; libra.d3d11_filter_chain_frame(&filter_chain, frameCount, input, vp, - framebufferRTV, NULL, NULL); + framebufferRTV, NULL, &frame_opt); //////////////////////////////////////////////////////////////////////// swapChain->Present(1, 0);