From 4e8047932b8579897ca58067705149df1d4db0a9 Mon Sep 17 00:00:00 2001 From: chyyran Date: Mon, 6 Feb 2023 23:11:39 -0500 Subject: [PATCH] gl: make input MVP apply to all internal passes --- .../src/filter_chain/filter_impl.rs | 11 +++++-- librashader-runtime-gl/src/lib.rs | 2 +- librashader-runtime-gl/src/render_target.rs | 30 +++++-------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/librashader-runtime-gl/src/filter_chain/filter_impl.rs b/librashader-runtime-gl/src/filter_chain/filter_impl.rs index 8bd2f12..257643f 100644 --- a/librashader-runtime-gl/src/filter_chain/filter_impl.rs +++ b/librashader-runtime-gl/src/filter_chain/filter_impl.rs @@ -3,7 +3,7 @@ use crate::error::FilterChainError; use crate::filter_pass::{FilterPass, UniformOffset}; use crate::gl::{DrawQuad, Framebuffer, FramebufferInterface, GLInterface, LoadLut, UboRing}; use crate::options::{FilterChainOptionsGL, FrameOptionsGL}; -use crate::render_target::RenderTarget; +use crate::render_target::{RenderTarget, GL_MVP_DEFAULT}; use crate::samplers::SamplerSet; use crate::texture::InputTexture; use crate::util::{gl_get_version, gl_u16_to_version}; @@ -426,7 +426,7 @@ impl FilterChainImpl { viewport, &original, &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); @@ -453,7 +453,12 @@ impl FilterChainImpl { viewport, &original, &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 .output diff --git a/librashader-runtime-gl/src/lib.rs b/librashader-runtime-gl/src/lib.rs index aa8223a..e9b80e4 100644 --- a/librashader-runtime-gl/src/lib.rs +++ b/librashader-runtime-gl/src/lib.rs @@ -53,7 +53,7 @@ mod tests { let (glfw, window, events, shader, vao) = gl::gl46::hello_triangle::setup(); let mut filter = FilterChainGL::load_from_path( // "../test/slang-shaders/vhs/VHSPro.slangp", - "../test/slang-shaders/crt/crt-lottes.slangp", + "../test/slang-shaders/crt/crt-royale.slangp", Some(&FilterChainOptionsGL { gl_version: 0, use_dsa: true, diff --git a/librashader-runtime-gl/src/render_target.rs b/librashader-runtime-gl/src/render_target.rs index f07369d..5b8d54b 100644 --- a/librashader-runtime-gl/src/render_target.rs +++ b/librashader-runtime-gl/src/render_target.rs @@ -1,8 +1,7 @@ use crate::gl::Framebuffer; -use librashader_common::Viewport; #[rustfmt::skip] -static DEFAULT_MVP: &[f32; 16] = &[ +pub static GL_MVP_DEFAULT: &[f32; 16] = &[ 2f32, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, @@ -18,27 +17,12 @@ pub(crate) struct RenderTarget<'a> { } impl<'a> RenderTarget<'a> { - pub fn new(backbuffer: &'a Framebuffer, mvp: Option<&'a [f32; 16]>, x: i32, y: i32) -> Self { - if let Some(mvp) = mvp { - RenderTarget { - framebuffer: backbuffer, - x, - mvp, - y, - } - } else { - RenderTarget { - framebuffer: backbuffer, - x, - mvp: DEFAULT_MVP, - y, - } + pub fn new(backbuffer: &'a Framebuffer, mvp: &'a [f32; 16], x: i32, y: i32) -> Self { + RenderTarget { + framebuffer: backbuffer, + x, + 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) - } -}