gl: fix redundant fbo rebind

This commit is contained in:
chyyran 2022-11-26 16:58:23 -05:00
parent 46bc8a9e70
commit bfed01435b
4 changed files with 8 additions and 5 deletions

View file

@ -593,6 +593,9 @@ impl FilterChain {
Ok(())
}
/// Process a frame with the input image.
///
/// When this frame returns, GL_FRAMEBUFFER is bound to 0.
pub fn frame(&mut self, count: usize, viewport: &Viewport, input: &GlImage, clear: bool) -> Result<()> {
if clear {
for framebuffer in &self.history_framebuffers {
@ -605,7 +608,8 @@ impl FilterChain {
}
unsafe {
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
// do not need to rebind FBO 0 here since first `draw` will
// bind automatically.
gl::BindVertexArray(self.filter_vao);
}
@ -719,8 +723,9 @@ impl FilterChain {
}
self.push_history(input)?;
// pass.draw should return framebuffer bound to 0.
unsafe {
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
gl::BindVertexArray(0);
}

View file

@ -190,7 +190,6 @@ impl FilterPass {
// todo: final pass?
unsafe {
gl::BindFramebuffer(gl::FRAMEBUFFER, framebuffer.handle);
gl::ColorMask(gl::TRUE, gl::TRUE, gl::TRUE, gl::TRUE);
gl::ClearColor(0.0f32, 0.0f32, 0.0f32, 0.0f32);
gl::Clear(gl::COLOR_BUFFER_BIT);

View file

@ -523,7 +523,6 @@ void main()
unsafe {
// texture is done now.
// draw quad to screen
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
gl::UseProgram(quad_programid);
gl::ActiveTexture(gl::TEXTURE0);

View file

@ -27,7 +27,7 @@ mod tests {
fn triangle_gl() {
let (glfw, window, events, shader, vao) = hello_triangle::setup();
let mut filter =
FilterChain::load_from_path("../test/slang-shaders/crt/crt-royale.slangp")
FilterChain::load_from_path("../test/slang-shaders/vhs/VHSPro.slangp")
.unwrap();
hello_triangle::do_loop(glfw, window, events, shader, vao, &mut filter);
}