diff --git a/librashader-capi/src/runtime/d3d9/filter_chain.rs b/librashader-capi/src/runtime/d3d9/filter_chain.rs index f931c62..d925cf8 100644 --- a/librashader-capi/src/runtime/d3d9/filter_chain.rs +++ b/librashader-capi/src/runtime/d3d9/filter_chain.rs @@ -160,14 +160,14 @@ extern_fn! { }; let viewport = if viewport.is_null() { - Viewport::new_render_target_sized_origin(ManuallyDrop::into_inner(out.clone()), mvp) + Viewport::new_render_target_sized_origin(out.deref(), mvp) .map_err(|e| LibrashaderError::D3D9FilterError(FilterChainError::Direct3DError(e)))? } else { let viewport = unsafe { viewport.read() }; Viewport { x: viewport.x, y: viewport.y, - output: ManuallyDrop::into_inner(out.clone()), + output: out.deref(), size: Size { height: viewport.height, width: viewport.width diff --git a/librashader-cli/src/render/d3d9.rs b/librashader-cli/src/render/d3d9.rs index cc7e8e7..77ebb0e 100644 --- a/librashader-cli/src/render/d3d9.rs +++ b/librashader-cli/src/render/d3d9.rs @@ -92,7 +92,7 @@ impl RenderTest for Direct3D9 { current_subframe: options.current_subframe, }); - let viewport = Viewport::new_render_target_sized_origin(surface.clone(), None)?; + let viewport = Viewport::new_render_target_sized_origin(&surface, None)?; for frame in 0..=frame_count { filter_chain.frame(&self.texture, &viewport, frame, options.as_ref())?; diff --git a/librashader-common/src/d3d9.rs b/librashader-common/src/d3d9.rs index f123335..a8c0997 100644 --- a/librashader-common/src/d3d9.rs +++ b/librashader-common/src/d3d9.rs @@ -64,7 +64,7 @@ impl From for Direct3D9::D3DTEXTUREFILTER { } } -impl GetSize for Direct3D9::IDirect3DSurface9 { +impl GetSize for &Direct3D9::IDirect3DSurface9 { type Error = windows::core::Error; fn size(&self) -> Result, Self::Error> { @@ -80,7 +80,14 @@ impl GetSize for Direct3D9::IDirect3DSurface9 { } } -impl GetSize for Direct3D9::IDirect3DTexture9 { +impl GetSize for Direct3D9::IDirect3DSurface9 { + type Error = windows::core::Error; + fn size(&self) -> Result, Self::Error> { + <&Self as GetSize>::size(&self) + } +} + +impl GetSize for &Direct3D9::IDirect3DTexture9 { type Error = windows::core::Error; fn size(&self) -> Result, Self::Error> { @@ -96,6 +103,13 @@ impl GetSize for Direct3D9::IDirect3DTexture9 { } } +impl GetSize for Direct3D9::IDirect3DTexture9 { + type Error = windows::core::Error; + fn size(&self) -> Result, Self::Error> { + <&Self as GetSize>::size(&self) + } +} + // impl FilterMode { // /// Get the mipmap filtering mode for the given combination. // pub fn d3d9_mip(&self, mip: FilterMode) -> Direct3D9::D3DTEXTUREFILTER { diff --git a/librashader-runtime-d3d9/src/filter_chain.rs b/librashader-runtime-d3d9/src/filter_chain.rs index eb628fe..8abd9ee 100644 --- a/librashader-runtime-d3d9/src/filter_chain.rs +++ b/librashader-runtime-d3d9/src/filter_chain.rs @@ -289,7 +289,7 @@ impl FilterChainD3D9 { pub unsafe fn frame( &mut self, input: &IDirect3DTexture9, - viewport: &Viewport, + viewport: &Viewport<&IDirect3DSurface9>, frame_count: usize, options: Option<&FrameOptionsD3D9>, ) -> error::Result<()> { diff --git a/librashader-runtime-d3d9/src/filter_pass.rs b/librashader-runtime-d3d9/src/filter_pass.rs index 8761316..ee0e15a 100644 --- a/librashader-runtime-d3d9/src/filter_pass.rs +++ b/librashader-runtime-d3d9/src/filter_pass.rs @@ -144,7 +144,7 @@ impl FilterPass { parent: &FilterCommon, frame_count: u32, options: &FrameOptionsD3D9, - viewport: &Viewport, + viewport: &Viewport<&IDirect3DSurface9>, original: &D3D9InputTexture, source: &D3D9InputTexture, output: RenderTarget, diff --git a/librashader-runtime-d3d9/tests/hello_triangle/mod.rs b/librashader-runtime-d3d9/tests/hello_triangle/mod.rs index 1f2dda2..7147863 100644 --- a/librashader-runtime-d3d9/tests/hello_triangle/mod.rs +++ b/librashader-runtime-d3d9/tests/hello_triangle/mod.rs @@ -431,13 +431,13 @@ pub mod d3d9_hello_triangle { resources .filter .frame( - resources.texture.clone(), + &resources.texture, &Viewport { x: 0.0, y: 0.0, mvp: None, - output: backbuffer.clone(), - size: backbuffer.size().unwrap(), + output: &backbuffer, + size: backbuffer.size()?, }, 0, None,