common: unify viewport types
This commit is contained in:
parent
abaebe56cc
commit
e2ac7a1bfa
|
@ -3,7 +3,7 @@ use crate::ctypes::{
|
|||
};
|
||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||
use crate::ffi::ffi_body;
|
||||
use librashader::runtime::d3d11::{D3D11ImageView, Viewport};
|
||||
use librashader::runtime::d3d11::{D3D11InputView, D3D11OutputView};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr::NonNull;
|
||||
use std::slice;
|
||||
|
@ -13,6 +13,8 @@ use windows::Win32::Graphics::Direct3D11::{
|
|||
|
||||
pub use librashader::runtime::d3d11::options::FilterChainOptions;
|
||||
pub use librashader::runtime::d3d11::options::FrameOptions;
|
||||
|
||||
use librashader::runtime::Viewport;
|
||||
use librashader::Size;
|
||||
|
||||
/// OpenGL parameters for the source image.
|
||||
|
@ -26,14 +28,14 @@ pub struct libra_source_image_d3d11_t {
|
|||
pub height: u32,
|
||||
}
|
||||
|
||||
impl TryFrom<libra_source_image_d3d11_t> for D3D11ImageView {
|
||||
impl TryFrom<libra_source_image_d3d11_t> for D3D11InputView {
|
||||
type Error = LibrashaderError;
|
||||
|
||||
fn try_from(value: libra_source_image_d3d11_t) -> Result<Self, Self::Error> {
|
||||
let handle = value.handle;
|
||||
assert_non_null!(noexport handle);
|
||||
|
||||
Ok(D3D11ImageView {
|
||||
Ok(D3D11InputView {
|
||||
handle: unsafe { (&*handle).clone() },
|
||||
size: Size::new(value.width, value.height),
|
||||
})
|
||||
|
@ -139,8 +141,10 @@ pub unsafe extern "C" fn libra_d3d11_filter_chain_frame(
|
|||
let viewport = Viewport {
|
||||
x: viewport.x,
|
||||
y: viewport.y,
|
||||
size: Size::new(viewport.width, viewport.height),
|
||||
output: unsafe { (&*out).clone() },
|
||||
output: D3D11OutputView {
|
||||
size: Size::new(viewport.width, viewport.height),
|
||||
handle: unsafe { (&*out).clone() },
|
||||
},
|
||||
mvp,
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::ctypes::{
|
|||
};
|
||||
use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError};
|
||||
use crate::ffi::ffi_body;
|
||||
use librashader::runtime::gl::{Framebuffer, GLImage, Viewport};
|
||||
use librashader::runtime::gl::{Framebuffer, GLImage};
|
||||
use std::ffi::{c_char, c_void, CString};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr::NonNull;
|
||||
|
@ -11,6 +11,7 @@ use std::slice;
|
|||
|
||||
pub use librashader::runtime::gl::options::FilterChainOptions;
|
||||
pub use librashader::runtime::gl::options::FrameOptions;
|
||||
use librashader::runtime::Viewport;
|
||||
use librashader::Size;
|
||||
|
||||
/// A GL function loader that librashader needs to be initialized with.
|
||||
|
|
|
@ -14,6 +14,9 @@ pub mod dxgi;
|
|||
#[cfg(feature = "d3d11")]
|
||||
pub mod d3d11;
|
||||
|
||||
mod viewport;
|
||||
pub use viewport::Viewport;
|
||||
|
||||
use num_traits::AsPrimitive;
|
||||
use std::convert::Infallible;
|
||||
use std::str::FromStr;
|
||||
|
|
12
librashader-common/src/viewport.rs
Normal file
12
librashader-common/src/viewport.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
/// The rendering output of a filter chain.
|
||||
pub struct Viewport<'a, T> {
|
||||
/// The x offset to start rendering from.
|
||||
pub x: f32,
|
||||
/// The y offset to begin rendering from.
|
||||
pub y: f32,
|
||||
/// An optional pointer to an MVP to use when rendering
|
||||
/// to the viewport.
|
||||
pub mvp: Option<&'a [f32; 16]>,
|
||||
/// The output handle to render the final image to.
|
||||
pub output: T,
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
use crate::texture::{D3D11ImageView, LutTexture, Texture};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use crate::texture::{D3D11InputView, LutTexture, InputTexture};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
use librashader_reflect::back::cross::CrossHlslContext;
|
||||
|
@ -24,8 +24,7 @@ use crate::quad_render::DrawQuad;
|
|||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::util::d3d11_compile_bound_shader;
|
||||
use crate::viewport::Viewport;
|
||||
use crate::{error, util};
|
||||
use crate::{D3D11OutputView, error, util};
|
||||
use librashader_runtime::uniforms::UniformStorage;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
ID3D11Buffer, ID3D11Device, ID3D11DeviceContext, D3D11_BIND_CONSTANT_BUFFER, D3D11_BUFFER_DESC,
|
||||
|
@ -67,9 +66,9 @@ pub(crate) struct FilterCommon {
|
|||
pub(crate) d3d11: Direct3D11,
|
||||
pub(crate) luts: FxHashMap<usize, LutTexture>,
|
||||
pub samplers: SamplerSet,
|
||||
pub output_textures: Box<[Option<Texture>]>,
|
||||
pub feedback_textures: Box<[Option<Texture>]>,
|
||||
pub history_textures: Box<[Option<Texture>]>,
|
||||
pub output_textures: Box<[Option<InputTexture>]>,
|
||||
pub feedback_textures: Box<[Option<InputTexture>]>,
|
||||
pub history_textures: Box<[Option<InputTexture>]>,
|
||||
pub config: FilterMutable,
|
||||
pub disable_mipmaps: bool,
|
||||
}
|
||||
|
@ -317,7 +316,7 @@ impl FilterChain {
|
|||
device: &ID3D11Device,
|
||||
context: &ID3D11DeviceContext,
|
||||
filters: &Vec<FilterPass>,
|
||||
) -> error::Result<(VecDeque<OwnedFramebuffer>, Box<[Option<Texture>]>)> {
|
||||
) -> error::Result<(VecDeque<OwnedFramebuffer>, Box<[Option<InputTexture>]>)> {
|
||||
let mut required_images = 0;
|
||||
|
||||
for pass in filters {
|
||||
|
@ -365,7 +364,7 @@ impl FilterChain {
|
|||
Ok((framebuffers, history_textures.into_boxed_slice()))
|
||||
}
|
||||
|
||||
fn push_history(&mut self, input: &D3D11ImageView) -> error::Result<()> {
|
||||
fn push_history(&mut self, input: &D3D11InputView) -> error::Result<()> {
|
||||
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
||||
back.copy_from(input)?;
|
||||
self.history_framebuffers.push_front(back)
|
||||
|
@ -465,8 +464,8 @@ impl FilterChain {
|
|||
/// Process a frame with the input image.
|
||||
pub fn frame(
|
||||
&mut self,
|
||||
input: D3D11ImageView,
|
||||
viewport: &Viewport,
|
||||
input: D3D11InputView,
|
||||
viewport: &Viewport<D3D11OutputView>,
|
||||
frame_count: usize,
|
||||
options: Option<&FrameOptions>,
|
||||
) -> error::Result<()> {
|
||||
|
@ -496,7 +495,7 @@ impl FilterChain {
|
|||
.zip(self.feedback_framebuffers.iter())
|
||||
.zip(passes.iter())
|
||||
{
|
||||
*texture = Some(Texture::from_framebuffer(
|
||||
*texture = Some(InputTexture::from_framebuffer(
|
||||
fbo,
|
||||
pass.config.wrap_mode,
|
||||
pass.config.filter,
|
||||
|
@ -509,10 +508,10 @@ impl FilterChain {
|
|||
.iter_mut()
|
||||
.zip(self.history_framebuffers.iter())
|
||||
{
|
||||
*texture = Some(Texture::from_framebuffer(fbo, wrap_mode, filter)?);
|
||||
*texture = Some(InputTexture::from_framebuffer(fbo, wrap_mode, filter)?);
|
||||
}
|
||||
|
||||
let original = Texture {
|
||||
let original = InputTexture {
|
||||
view: input.clone(),
|
||||
filter,
|
||||
wrap_mode,
|
||||
|
@ -525,7 +524,7 @@ impl FilterChain {
|
|||
self.output_framebuffers[index].scale(
|
||||
pass.config.scaling.clone(),
|
||||
pass.get_format(),
|
||||
&viewport.size,
|
||||
&viewport.output.size,
|
||||
&original,
|
||||
&source,
|
||||
)?;
|
||||
|
@ -533,7 +532,7 @@ impl FilterChain {
|
|||
self.feedback_framebuffers[index].scale(
|
||||
pass.config.scaling.clone(),
|
||||
pass.get_format(),
|
||||
&viewport.size,
|
||||
&viewport.output.size,
|
||||
&original,
|
||||
&source,
|
||||
)?;
|
||||
|
@ -561,8 +560,8 @@ impl FilterChain {
|
|||
RenderTarget::new(target.as_output_framebuffer()?, None),
|
||||
)?;
|
||||
|
||||
source = Texture {
|
||||
view: D3D11ImageView {
|
||||
source = InputTexture {
|
||||
view: D3D11InputView {
|
||||
handle: target.create_shader_resource_view()?,
|
||||
size,
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::filter_chain::FilterCommon;
|
||||
use crate::texture::Texture;
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use crate::texture::InputTexture;
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::ShaderPassConfig;
|
||||
use librashader_reflect::back::cross::CrossHlslContext;
|
||||
|
@ -16,10 +16,9 @@ use windows::Win32::Graphics::Direct3D11::{
|
|||
ID3D11ShaderResourceView, ID3D11VertexShader, D3D11_MAP_WRITE_DISCARD,
|
||||
};
|
||||
|
||||
use crate::error;
|
||||
use crate::{D3D11OutputView, error};
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::viewport::Viewport;
|
||||
use librashader_runtime::uniforms::{UniformStorage, UniformStorageAccess};
|
||||
|
||||
pub struct ConstantBufferBinding {
|
||||
|
@ -69,7 +68,7 @@ impl FilterPass {
|
|||
texture_binding: &mut [Option<ID3D11ShaderResourceView>; 16],
|
||||
sampler_binding: &mut [Option<ID3D11SamplerState>; 16],
|
||||
binding: &TextureBinding,
|
||||
texture: &Texture,
|
||||
texture: &InputTexture,
|
||||
) {
|
||||
texture_binding[binding.binding as usize] = Some(texture.view.handle.clone());
|
||||
sampler_binding[binding.binding as usize] =
|
||||
|
@ -86,8 +85,8 @@ impl FilterPass {
|
|||
frame_direction: i32,
|
||||
fb_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
original: &Texture,
|
||||
source: &Texture,
|
||||
original: &InputTexture,
|
||||
source: &InputTexture,
|
||||
) -> (
|
||||
[Option<ID3D11ShaderResourceView>; 16],
|
||||
[Option<ID3D11SamplerState>; 16],
|
||||
|
@ -354,9 +353,9 @@ impl FilterPass {
|
|||
parent: &FilterCommon,
|
||||
frame_count: u32,
|
||||
frame_direction: i32,
|
||||
viewport: &Viewport,
|
||||
original: &Texture,
|
||||
source: &Texture,
|
||||
viewport: &Viewport<D3D11OutputView>,
|
||||
original: &InputTexture,
|
||||
source: &InputTexture,
|
||||
output: RenderTarget,
|
||||
) -> error::Result<()> {
|
||||
let _device = &parent.d3d11.device;
|
||||
|
@ -380,7 +379,7 @@ impl FilterPass {
|
|||
frame_count,
|
||||
frame_direction,
|
||||
output.output.size,
|
||||
viewport.size,
|
||||
viewport.output.size,
|
||||
original,
|
||||
source,
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::error;
|
||||
use crate::texture::{D3D11ImageView, Texture};
|
||||
use crate::texture::{D3D11InputView, InputTexture};
|
||||
use crate::util::d3d11_get_closest_format;
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_presets::Scale2D;
|
||||
|
@ -61,8 +61,8 @@ impl OwnedFramebuffer {
|
|||
scaling: Scale2D,
|
||||
format: ImageFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
_original: &Texture,
|
||||
source: &Texture,
|
||||
_original: &InputTexture,
|
||||
source: &InputTexture,
|
||||
) -> error::Result<Size<u32>> {
|
||||
if self.is_raw {
|
||||
return Ok(self.size);
|
||||
|
@ -152,7 +152,7 @@ impl OwnedFramebuffer {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn copy_from(&mut self, image: &D3D11ImageView) -> error::Result<()> {
|
||||
pub fn copy_from(&mut self, image: &D3D11InputView) -> error::Result<()> {
|
||||
let original_resource: ID3D11Texture2D = unsafe {
|
||||
let mut resource = None;
|
||||
image.handle.GetResource(&mut resource);
|
||||
|
|
|
@ -228,11 +228,12 @@ pub mod d3d11_hello_triangle {
|
|||
use crate::filter_chain::FilterChain;
|
||||
|
||||
use crate::options::FilterChainOptions;
|
||||
use crate::texture::D3D11ImageView;
|
||||
use crate::texture::D3D11InputView;
|
||||
use crate::viewport::Viewport;
|
||||
use librashader_common::Size;
|
||||
use librashader_common::{Size, Viewport};
|
||||
use std::slice;
|
||||
use std::time::Instant;
|
||||
use crate::D3D11OutputView;
|
||||
|
||||
pub struct Sample {
|
||||
pub dxgi_factory: IDXGIFactory4,
|
||||
|
@ -492,7 +493,7 @@ pub mod d3d11_hello_triangle {
|
|||
|
||||
self.filter
|
||||
.frame(
|
||||
D3D11ImageView {
|
||||
D3D11InputView {
|
||||
handle: srv,
|
||||
size: Size {
|
||||
width: tex2d_desc.Width,
|
||||
|
@ -502,11 +503,13 @@ pub mod d3d11_hello_triangle {
|
|||
&Viewport {
|
||||
x: resources.viewport.TopLeftX,
|
||||
y: resources.viewport.TopLeftY,
|
||||
size: Size {
|
||||
width: tex2d_desc.Width,
|
||||
height: tex2d_desc.Height,
|
||||
output: D3D11OutputView {
|
||||
size: Size {
|
||||
width: tex2d_desc.Width,
|
||||
height: tex2d_desc.Height,
|
||||
},
|
||||
handle: resources.rtv.clone(),
|
||||
},
|
||||
output: resources.rtv.clone(),
|
||||
mvp: None,
|
||||
},
|
||||
resources.frame_count,
|
||||
|
|
|
@ -15,11 +15,10 @@ mod render_target;
|
|||
mod samplers;
|
||||
mod texture;
|
||||
mod util;
|
||||
mod viewport;
|
||||
|
||||
pub use filter_chain::FilterChain;
|
||||
pub use texture::D3D11ImageView;
|
||||
pub use viewport::Viewport;
|
||||
pub use texture::D3D11InputView;
|
||||
pub use texture::D3D11OutputView;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::framebuffer::OutputFramebuffer;
|
||||
use crate::viewport::Viewport;
|
||||
use windows::Win32::Graphics::Direct3D11::D3D11_VIEWPORT;
|
||||
use librashader_common::Viewport;
|
||||
use crate::D3D11OutputView;
|
||||
|
||||
#[rustfmt::skip]
|
||||
static DEFAULT_MVP: &[f32; 16] = &[
|
||||
|
@ -32,17 +33,17 @@ impl<'a> RenderTarget<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&Viewport<'a>> for RenderTarget<'a> {
|
||||
fn from(value: &Viewport<'a>) -> Self {
|
||||
impl<'a> From<&Viewport<'a, D3D11OutputView>> for RenderTarget<'a> {
|
||||
fn from(value: &Viewport<'a, D3D11OutputView>) -> Self {
|
||||
RenderTarget::new(
|
||||
OutputFramebuffer {
|
||||
rtv: value.output.clone(),
|
||||
size: value.size,
|
||||
rtv: value.output.handle.clone(),
|
||||
size: value.output.size,
|
||||
viewport: D3D11_VIEWPORT {
|
||||
TopLeftX: value.x,
|
||||
TopLeftY: value.y,
|
||||
Width: value.size.width as f32,
|
||||
Height: value.size.height as f32,
|
||||
Width: value.output.size.width as f32,
|
||||
Height: value.output.size.height as f32,
|
||||
MinDepth: 0.0,
|
||||
MaxDepth: 1.0,
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ use librashader_common::{FilterMode, Size, WrapMode};
|
|||
use librashader_runtime::image::Image;
|
||||
use windows::Win32::Graphics::Direct3D::D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
ID3D11Device, ID3D11DeviceContext, ID3D11ShaderResourceView, ID3D11Texture2D, D3D11_BIND_FLAG,
|
||||
ID3D11Device, ID3D11DeviceContext, ID3D11ShaderResourceView, ID3D11RenderTargetView, ID3D11Texture2D, D3D11_BIND_FLAG,
|
||||
D3D11_BIND_RENDER_TARGET, D3D11_BIND_SHADER_RESOURCE, D3D11_BOX, D3D11_CPU_ACCESS_FLAG,
|
||||
D3D11_CPU_ACCESS_WRITE, D3D11_RESOURCE_MISC_FLAG, D3D11_RESOURCE_MISC_GENERATE_MIPS,
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC, D3D11_SHADER_RESOURCE_VIEW_DESC_0, D3D11_SUBRESOURCE_DATA,
|
||||
|
@ -14,25 +14,32 @@ use crate::error::Result;
|
|||
use crate::framebuffer::OwnedFramebuffer;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct D3D11ImageView {
|
||||
pub struct D3D11InputView {
|
||||
pub handle: ID3D11ShaderResourceView,
|
||||
pub size: Size<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct Texture {
|
||||
pub view: D3D11ImageView,
|
||||
pub struct D3D11OutputView {
|
||||
pub handle: ID3D11RenderTargetView,
|
||||
pub size: Size<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct InputTexture {
|
||||
pub view: D3D11InputView,
|
||||
pub filter: FilterMode,
|
||||
pub wrap_mode: WrapMode,
|
||||
}
|
||||
|
||||
impl Texture {
|
||||
impl InputTexture {
|
||||
pub fn from_framebuffer(
|
||||
fbo: &OwnedFramebuffer,
|
||||
wrap_mode: WrapMode,
|
||||
filter: FilterMode,
|
||||
) -> Result<Self> {
|
||||
Ok(Texture {
|
||||
view: D3D11ImageView {
|
||||
Ok(InputTexture {
|
||||
view: D3D11InputView {
|
||||
handle: fbo.create_shader_resource_view()?,
|
||||
size: fbo.size,
|
||||
},
|
||||
|
@ -49,7 +56,7 @@ pub(crate) struct LutTexture {
|
|||
pub handle: ID3D11Texture2D,
|
||||
#[allow(dead_code)]
|
||||
pub desc: D3D11_TEXTURE2D_DESC,
|
||||
pub image: Texture,
|
||||
pub image: InputTexture,
|
||||
}
|
||||
|
||||
impl LutTexture {
|
||||
|
@ -166,8 +173,8 @@ impl LutTexture {
|
|||
handle,
|
||||
// staging,
|
||||
desc,
|
||||
image: Texture {
|
||||
view: D3D11ImageView {
|
||||
image: InputTexture {
|
||||
view: D3D11InputView {
|
||||
handle: srv,
|
||||
size: source.size,
|
||||
},
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
use librashader_common::Size;
|
||||
use windows::Win32::Graphics::Direct3D11::ID3D11RenderTargetView;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Viewport<'a> {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub size: Size<u32>,
|
||||
pub output: ID3D11RenderTargetView,
|
||||
pub mvp: Option<&'a [f32; 16]>,
|
||||
}
|
|
@ -7,9 +7,9 @@ use crate::render_target::RenderTarget;
|
|||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::Texture;
|
||||
use crate::util::{gl_get_version, gl_u16_to_version};
|
||||
use crate::{error, util, GLImage, Viewport};
|
||||
use crate::{error, util, GLImage};
|
||||
use gl::types::{GLenum, GLint, GLuint};
|
||||
use librashader_common::{FilterMode, Size, WrapMode};
|
||||
use librashader_common::{FilterMode, Size, Viewport, WrapMode};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
use librashader_reflect::back::cross::{CrossGlslContext, GlslVersion};
|
||||
|
@ -419,7 +419,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
pub fn frame(
|
||||
&mut self,
|
||||
count: usize,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
input: &GLImage,
|
||||
options: Option<&FrameOptions>,
|
||||
) -> error::Result<()> {
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::error::{FilterChainError, Result};
|
|||
use crate::filter_chain::filter_impl::FilterChainImpl;
|
||||
use crate::filter_chain::inner::FilterChainDispatch;
|
||||
use crate::options::{FilterChainOptions, FrameOptions};
|
||||
use crate::{Framebuffer, GLImage, Viewport};
|
||||
use crate::{Framebuffer, GLImage};
|
||||
use librashader_presets::ShaderPreset;
|
||||
|
||||
mod filter_impl;
|
||||
|
@ -14,7 +14,7 @@ mod inner;
|
|||
mod parameters;
|
||||
|
||||
pub(crate) use filter_impl::FilterCommon;
|
||||
use librashader_common::Size;
|
||||
use librashader_common::{Size, Viewport};
|
||||
|
||||
pub struct FilterChain {
|
||||
pub(in crate::filter_chain) filter: FilterChainDispatch,
|
||||
|
@ -60,7 +60,7 @@ impl FilterChain {
|
|||
pub fn frame(
|
||||
&mut self,
|
||||
input: &GLImage,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
frame_count: usize,
|
||||
options: Option<&FrameOptions>,
|
||||
) -> Result<()> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use librashader_reflect::back::cross::CrossGlslContext;
|
|||
use librashader_reflect::back::ShaderCompilerOutput;
|
||||
use librashader_reflect::reflect::ShaderReflection;
|
||||
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::ShaderPassConfig;
|
||||
use librashader_reflect::reflect::semantics::{
|
||||
|
@ -13,9 +13,9 @@ use rustc_hash::FxHashMap;
|
|||
|
||||
use crate::binding::{GlUniformStorage, UniformLocation, VariableLocation};
|
||||
use crate::filter_chain::FilterCommon;
|
||||
use crate::Framebuffer;
|
||||
use crate::gl::{BindTexture, GLInterface, UboRing};
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::viewport::Viewport;
|
||||
|
||||
use crate::texture::Texture;
|
||||
|
||||
|
@ -38,7 +38,7 @@ impl<T: GLInterface> FilterPass<T> {
|
|||
parent: &FilterCommon,
|
||||
frame_count: u32,
|
||||
frame_direction: i32,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
original: &Texture,
|
||||
source: &Texture,
|
||||
output: RenderTarget,
|
||||
|
@ -123,7 +123,7 @@ impl<T: GLInterface> FilterPass<T> {
|
|||
frame_count: u32,
|
||||
frame_direction: i32,
|
||||
fb_size: Size<u32>,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
original: &Texture,
|
||||
source: &Texture,
|
||||
) {
|
||||
|
|
|
@ -2,9 +2,8 @@ use crate::error::Result;
|
|||
use crate::framebuffer::GLImage;
|
||||
use crate::gl::FramebufferInterface;
|
||||
use crate::texture::Texture;
|
||||
use crate::viewport::Viewport;
|
||||
use gl::types::{GLenum, GLuint};
|
||||
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
|
||||
use librashader_common::{FilterMode, ImageFormat, Size, Viewport, WrapMode};
|
||||
use librashader_presets::Scale2D;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -50,7 +49,7 @@ impl Framebuffer {
|
|||
&mut self,
|
||||
scaling: Scale2D,
|
||||
format: ImageFormat,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
original: &Texture,
|
||||
source: &Texture,
|
||||
mipmap: bool,
|
||||
|
|
|
@ -3,9 +3,8 @@ use crate::framebuffer::GLImage;
|
|||
use crate::gl::framebuffer::Framebuffer;
|
||||
use crate::gl::FramebufferInterface;
|
||||
use crate::texture::Texture;
|
||||
use crate::viewport::Viewport;
|
||||
use gl::types::{GLenum, GLint, GLsizei, GLuint};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_presets::Scale2D;
|
||||
use librashader_runtime::scaling::{MipmapSize, ViewportSize};
|
||||
|
||||
|
@ -39,7 +38,7 @@ impl FramebufferInterface for Gl3Framebuffer {
|
|||
fb: &mut Framebuffer,
|
||||
scaling: Scale2D,
|
||||
format: ImageFormat,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
_original: &Texture,
|
||||
source: &Texture,
|
||||
mipmap: bool,
|
||||
|
|
|
@ -3,9 +3,8 @@ use crate::framebuffer::GLImage;
|
|||
use crate::gl::framebuffer::Framebuffer;
|
||||
use crate::gl::FramebufferInterface;
|
||||
use crate::texture::Texture;
|
||||
use crate::viewport::Viewport;
|
||||
use gl::types::{GLenum, GLint, GLsizei, GLuint};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_presets::Scale2D;
|
||||
use librashader_runtime::scaling::{MipmapSize, ViewportSize};
|
||||
|
||||
|
@ -32,12 +31,12 @@ impl FramebufferInterface for Gl46Framebuffer {
|
|||
is_raw: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn scale(
|
||||
fb: &mut Framebuffer,
|
||||
scaling: Scale2D,
|
||||
format: ImageFormat,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
_original: &Texture,
|
||||
source: &Texture,
|
||||
mipmap: bool,
|
||||
|
|
|
@ -7,10 +7,9 @@ use crate::error::Result;
|
|||
use crate::framebuffer::GLImage;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::Texture;
|
||||
use crate::viewport::Viewport;
|
||||
pub use framebuffer::Framebuffer;
|
||||
use gl::types::{GLenum, GLuint};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_presets::{Scale2D, TextureConfig};
|
||||
use librashader_reflect::reflect::semantics::{TextureBinding, UboReflection};
|
||||
use librashader_runtime::uniforms::UniformStorageAccess;
|
||||
|
@ -42,7 +41,7 @@ pub trait FramebufferInterface {
|
|||
fb: &mut Framebuffer,
|
||||
scaling: Scale2D,
|
||||
format: ImageFormat,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
_original: &Texture,
|
||||
source: &Texture,
|
||||
mipmap: bool,
|
||||
|
|
|
@ -15,12 +15,10 @@ mod texture;
|
|||
|
||||
pub mod error;
|
||||
pub mod options;
|
||||
mod viewport;
|
||||
|
||||
pub use crate::gl::Framebuffer;
|
||||
pub use filter_chain::FilterChain;
|
||||
pub use framebuffer::GLImage;
|
||||
pub use viewport::Viewport;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use librashader_common::Viewport;
|
||||
use crate::gl::Framebuffer;
|
||||
use crate::viewport::Viewport;
|
||||
|
||||
#[rustfmt::skip]
|
||||
static DEFAULT_MVP: &[f32; 16] = &[
|
||||
|
@ -37,8 +37,8 @@ impl<'a> RenderTarget<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&Viewport<'a>> for RenderTarget<'a> {
|
||||
fn from(value: &Viewport<'a>) -> Self {
|
||||
impl<'a> From<&Viewport<'a, &'a Framebuffer>> for RenderTarget<'a> {
|
||||
fn from(value: &Viewport<'a, &'a Framebuffer>) -> Self {
|
||||
RenderTarget::new(value.output, value.mvp, value.x as i32, value.y as i32)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
use crate::gl::Framebuffer;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Viewport<'a> {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub output: &'a Framebuffer,
|
||||
pub mvp: Option<&'a [f32; 16]>,
|
||||
}
|
|
@ -8,11 +8,10 @@ use crate::render_target::{RenderTarget, DEFAULT_MVP};
|
|||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::{InputImage, OwnedImage, VulkanImage};
|
||||
use crate::ubo_ring::VkUboRing;
|
||||
use crate::viewport::Viewport;
|
||||
use crate::vulkan_state::VulkanGraphicsPipeline;
|
||||
use crate::{error, util};
|
||||
use ash::vk;
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
use librashader_reflect::back::targets::SpirV;
|
||||
|
@ -562,7 +561,7 @@ impl FilterChainVulkan {
|
|||
pub fn frame(
|
||||
&mut self,
|
||||
count: usize,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<VulkanImage>,
|
||||
input: &VulkanImage,
|
||||
cmd: vk::CommandBuffer,
|
||||
options: Option<FrameOptions>,
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use crate::error;
|
||||
use crate::{error, VulkanImage};
|
||||
use crate::filter_chain::FilterCommon;
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::InputImage;
|
||||
use crate::ubo_ring::VkUboRing;
|
||||
use crate::viewport::Viewport;
|
||||
use crate::vulkan_state::VulkanGraphicsPipeline;
|
||||
use ash::vk;
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::ShaderPassConfig;
|
||||
use librashader_reflect::reflect::semantics::{
|
||||
|
@ -76,7 +75,7 @@ impl FilterPass {
|
|||
parent: &FilterCommon,
|
||||
frame_count: u32,
|
||||
frame_direction: i32,
|
||||
viewport: &Viewport,
|
||||
viewport: &Viewport<VulkanImage>,
|
||||
original: &InputImage,
|
||||
source: &InputImage,
|
||||
output: &RenderTarget,
|
||||
|
|
|
@ -16,7 +16,6 @@ mod samplers;
|
|||
mod texture;
|
||||
mod ubo_ring;
|
||||
mod util;
|
||||
mod viewport;
|
||||
mod vulkan_primitives;
|
||||
mod vulkan_state;
|
||||
|
||||
|
@ -25,7 +24,6 @@ pub use filter_chain::FilterChainVulkan;
|
|||
pub use filter_chain::Vulkan;
|
||||
pub use filter_chain::VulkanInstance;
|
||||
pub use texture::VulkanImage;
|
||||
pub use viewport::Viewport;
|
||||
|
||||
pub mod error;
|
||||
pub mod options;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
use crate::texture::VulkanImage;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Viewport<'a> {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub output: VulkanImage,
|
||||
pub mvp: Option<&'a [f32; 16]>,
|
||||
}
|
|
@ -92,6 +92,7 @@ pub mod reflect {
|
|||
#[cfg(feature = "runtime")]
|
||||
pub mod runtime {
|
||||
pub use librashader_runtime::parameters::FilterChainParameters;
|
||||
pub use librashader_common::Viewport;
|
||||
|
||||
#[cfg(feature = "gl")]
|
||||
/// Shader runtime for OpenGL 3.3+.
|
||||
|
|
Loading…
Reference in a new issue