gl: make input MVP apply to all internal passes

This commit is contained in:
chyyran 2023-02-06 23:11:39 -05:00
parent d6b492c614
commit 4e8047932b
3 changed files with 16 additions and 27 deletions

View file

@ -3,7 +3,7 @@ use crate::error::FilterChainError;
use crate::filter_pass::{FilterPass, UniformOffset}; use crate::filter_pass::{FilterPass, UniformOffset};
use crate::gl::{DrawQuad, Framebuffer, FramebufferInterface, GLInterface, LoadLut, UboRing}; use crate::gl::{DrawQuad, Framebuffer, FramebufferInterface, GLInterface, LoadLut, UboRing};
use crate::options::{FilterChainOptionsGL, FrameOptionsGL}; use crate::options::{FilterChainOptionsGL, FrameOptionsGL};
use crate::render_target::RenderTarget; use crate::render_target::{RenderTarget, GL_MVP_DEFAULT};
use crate::samplers::SamplerSet; use crate::samplers::SamplerSet;
use crate::texture::InputTexture; use crate::texture::InputTexture;
use crate::util::{gl_get_version, gl_u16_to_version}; use crate::util::{gl_get_version, gl_u16_to_version};
@ -426,7 +426,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
viewport, viewport,
&original, &original,
&source, &source,
RenderTarget::new(target, None, 0, 0), RenderTarget::new(target, viewport.mvp.unwrap_or(GL_MVP_DEFAULT), 0, 0),
); );
let target = target.as_texture(pass.config.filter, pass.config.wrap_mode); let target = target.as_texture(pass.config.filter, pass.config.wrap_mode);
@ -453,7 +453,12 @@ impl<T: GLInterface> FilterChainImpl<T> {
viewport, viewport,
&original, &original,
&source, &source,
viewport.into(), RenderTarget::new(
viewport.output,
viewport.mvp.unwrap_or(GL_MVP_DEFAULT),
viewport.x as i32,
viewport.y as i32,
),
); );
self.common.output_textures[passes_len - 1] = viewport self.common.output_textures[passes_len - 1] = viewport
.output .output

View file

@ -53,7 +53,7 @@ mod tests {
let (glfw, window, events, shader, vao) = gl::gl46::hello_triangle::setup(); let (glfw, window, events, shader, vao) = gl::gl46::hello_triangle::setup();
let mut filter = FilterChainGL::load_from_path( let mut filter = FilterChainGL::load_from_path(
// "../test/slang-shaders/vhs/VHSPro.slangp", // "../test/slang-shaders/vhs/VHSPro.slangp",
"../test/slang-shaders/crt/crt-lottes.slangp", "../test/slang-shaders/crt/crt-royale.slangp",
Some(&FilterChainOptionsGL { Some(&FilterChainOptionsGL {
gl_version: 0, gl_version: 0,
use_dsa: true, use_dsa: true,

View file

@ -1,8 +1,7 @@
use crate::gl::Framebuffer; use crate::gl::Framebuffer;
use librashader_common::Viewport;
#[rustfmt::skip] #[rustfmt::skip]
static DEFAULT_MVP: &[f32; 16] = &[ pub static GL_MVP_DEFAULT: &[f32; 16] = &[
2f32, 0.0, 0.0, 0.0, 2f32, 0.0, 0.0, 0.0,
0.0, 2.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 2.0, 0.0,
@ -18,27 +17,12 @@ pub(crate) struct RenderTarget<'a> {
} }
impl<'a> RenderTarget<'a> { impl<'a> RenderTarget<'a> {
pub fn new(backbuffer: &'a Framebuffer, mvp: Option<&'a [f32; 16]>, x: i32, y: i32) -> Self { pub fn new(backbuffer: &'a Framebuffer, mvp: &'a [f32; 16], x: i32, y: i32) -> Self {
if let Some(mvp) = mvp {
RenderTarget { RenderTarget {
framebuffer: backbuffer, framebuffer: backbuffer,
x, x,
mvp, mvp,
y, y,
} }
} else {
RenderTarget {
framebuffer: backbuffer,
x,
mvp: DEFAULT_MVP,
y,
}
}
}
}
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)
} }
} }