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

50 lines
1.2 KiB
Rust
Raw Normal View History

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