2024-03-03 06:32:48 +11:00
|
|
|
use crate::error::Result;
|
2023-02-11 16:20:35 +11:00
|
|
|
use crate::framebuffer::OwnedImage;
|
2024-03-03 06:32:48 +11:00
|
|
|
use librashader_common::{FilterMode, Size, WrapMode};
|
|
|
|
use windows::Win32::Graphics::Direct3D11::{ID3D11RenderTargetView, ID3D11ShaderResourceView};
|
2022-11-26 18:38:15 +11:00
|
|
|
|
2023-01-13 19:19:58 +11:00
|
|
|
/// An image view for use as a shader resource.
|
|
|
|
///
|
|
|
|
/// Contains an `ID3D11ShaderResourceView`, and a size.
|
2022-11-26 18:38:15 +11:00
|
|
|
#[derive(Debug, Clone)]
|
2023-01-13 18:54:16 +11:00
|
|
|
pub struct D3D11InputView {
|
2023-01-15 07:10:40 +11:00
|
|
|
/// A handle to the shader resource view.
|
2022-11-27 18:21:36 +11:00
|
|
|
pub handle: ID3D11ShaderResourceView,
|
2023-01-15 07:10:40 +11:00
|
|
|
/// The size of the image.
|
2022-12-01 09:59:55 +11:00
|
|
|
pub size: Size<u32>,
|
2022-11-29 13:00:54 +11:00
|
|
|
}
|
2023-01-13 18:54:16 +11:00
|
|
|
|
2023-01-13 19:19:58 +11:00
|
|
|
/// An image view for use as a render target.
|
|
|
|
///
|
|
|
|
/// Contains an `ID3D11RenderTargetView`, and a size.
|
2023-01-13 18:54:16 +11:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct D3D11OutputView {
|
2023-01-15 07:10:40 +11:00
|
|
|
/// A handle to the render target view.
|
2023-01-13 18:54:16 +11:00
|
|
|
pub handle: ID3D11RenderTargetView,
|
2023-01-15 07:10:40 +11:00
|
|
|
/// The size of the image.
|
2023-01-13 18:54:16 +11:00
|
|
|
pub size: Size<u32>,
|
|
|
|
}
|
|
|
|
|
2022-11-29 13:00:54 +11:00
|
|
|
#[derive(Debug, Clone)]
|
2023-01-15 19:01:23 +11:00
|
|
|
pub struct InputTexture {
|
2023-01-13 18:54:16 +11:00
|
|
|
pub view: D3D11InputView,
|
2022-11-27 18:21:36 +11:00
|
|
|
pub filter: FilterMode,
|
|
|
|
pub wrap_mode: WrapMode,
|
2022-11-26 18:38:15 +11:00
|
|
|
}
|
|
|
|
|
2023-01-13 18:54:16 +11:00
|
|
|
impl InputTexture {
|
2023-01-15 19:01:23 +11:00
|
|
|
pub(crate) fn from_framebuffer(
|
2023-02-11 16:20:35 +11:00
|
|
|
fbo: &OwnedImage,
|
2022-12-22 13:39:31 +11:00
|
|
|
wrap_mode: WrapMode,
|
|
|
|
filter: FilterMode,
|
|
|
|
) -> Result<Self> {
|
2023-01-13 18:54:16 +11:00
|
|
|
Ok(InputTexture {
|
|
|
|
view: D3D11InputView {
|
2022-12-01 16:11:41 +11:00
|
|
|
handle: fbo.create_shader_resource_view()?,
|
|
|
|
size: fbo.size,
|
|
|
|
},
|
|
|
|
filter,
|
2022-12-22 13:39:31 +11:00
|
|
|
wrap_mode,
|
2022-12-01 16:11:41 +11:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-15 19:01:23 +11:00
|
|
|
impl AsRef<InputTexture> for InputTexture {
|
|
|
|
fn as_ref(&self) -> &InputTexture {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|