From 3965df80883b76568f949f38170e6c645577114d Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Fri, 16 Nov 2018 11:07:51 +0100 Subject: [PATCH] Add debug checks for some global GL states. --- webrender/src/device/gl.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/webrender/src/device/gl.rs b/webrender/src/device/gl.rs index 8731daddc8..3d8eacf91c 100644 --- a/webrender/src/device/gl.rs +++ b/webrender/src/device/gl.rs @@ -1020,6 +1020,11 @@ impl Device { ) }; + // Explicitly set some global states to the values we expect. + gl.disable(gl::FRAMEBUFFER_SRGB); + gl.disable(gl::MULTISAMPLE); + gl.disable(gl::POLYGON_SMOOTH); + Device { gl, resource_override_path, @@ -1152,10 +1157,20 @@ impl Device { } } + // If an assertion is hit in this function, something outside of WebRender is likely + // messing with the GL context's global state. + pub fn check_gl_state(&self) { + debug_assert!(self.gl.is_enabled(gl::FRAMEBUFFER_SRGB) == 0); + debug_assert!(self.gl.is_enabled(gl::MULTISAMPLE) == 0); + debug_assert!(self.gl.is_enabled(gl::POLYGON_SMOOTH) == 0); + } + pub fn begin_frame(&mut self) -> GpuFrameId { debug_assert!(!self.inside_frame); self.inside_frame = true; + self.check_gl_state(); + // Retrieve the currently set FBO. let mut default_read_fbo = [0]; unsafe {