From 0000d47534cfb9f64adbfb4cd36b20ac6e139be1 Mon Sep 17 00:00:00 2001 From: WR Updater Bot Date: Tue, 18 Dec 2018 01:32:52 +0000 Subject: [PATCH] Bug 1514735 - Update webrender to commit 4de718f9ea3435c099cabafc02e8b51da539bc62 (WR PR #3428). r=kats https://github.com/servo/webrender/pull/3428 Differential Revision: https://phabricator.services.mozilla.com/D14823 --HG-- extra : moz-landing-system : lando --- gfx/webrender_bindings/revision.txt | 2 +- gfx/wr/webrender/src/device/gl.rs | 59 ++++++++++++++++++++--------- gfx/wr/webrender/src/renderer.rs | 2 +- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/gfx/webrender_bindings/revision.txt b/gfx/webrender_bindings/revision.txt index f111efb7ea137..7a9e98867416a 100644 --- a/gfx/webrender_bindings/revision.txt +++ b/gfx/webrender_bindings/revision.txt @@ -1 +1 @@ -3a4ce4b66a7bc9bd10773744d20530c609a61e90 +4de718f9ea3435c099cabafc02e8b51da539bc62 diff --git a/gfx/wr/webrender/src/device/gl.rs b/gfx/wr/webrender/src/device/gl.rs index 5ca831cf89bc2..9e25719596373 100644 --- a/gfx/wr/webrender/src/device/gl.rs +++ b/gfx/wr/webrender/src/device/gl.rs @@ -1046,11 +1046,18 @@ impl<'a> From> for ReadTarget<'a> { impl Device { pub fn new( - gl: Rc, + mut gl: Rc, resource_override_path: Option, upload_method: UploadMethod, cached_programs: Option>, ) -> Device { + // On debug builds, assert that each GL call is error-free. We don't do + // this on release builds because the synchronous call can stall the + // pipeline. + if cfg!(debug_assertions) { + gl = gl::ErrorCheckingGl::wrap(gl); + } + let mut max_texture_size = [0]; let mut max_texture_layers = [0]; unsafe { @@ -1151,11 +1158,6 @@ impl Device { let supports_copy_image_sub_data = supports_extension(&extensions, "GL_EXT_copy_image") || supports_extension(&extensions, "GL_ARB_copy_image"); - // 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, @@ -1289,20 +1291,10 @@ 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 { @@ -1435,8 +1427,15 @@ impl Device { ); } + /// Creates an unbound FBO object. Additional attachment API calls are + /// required to make it complete. + pub fn create_fbo(&mut self) -> FBOId { + FBOId(self.gl.gen_framebuffers(1)[0]) + } + + /// Creates an FBO with the given texture bound as the color attachment. pub fn create_fbo_for_external_texture(&mut self, texture_id: u32) -> FBOId { - let fbo = FBOId(self.gl.gen_framebuffers(1)[0]); + let fbo = self.create_fbo(); fbo.bind(self.gl(), FBOTarget::Draw); self.gl.framebuffer_texture_2d( gl::DRAW_FRAMEBUFFER, @@ -1445,6 +1444,11 @@ impl Device { texture_id, 0, ); + debug_assert_eq!( + self.gl.check_frame_buffer_status(gl::DRAW_FRAMEBUFFER), + gl::FRAMEBUFFER_COMPLETE, + "Incomplete framebuffer", + ); self.bound_draw_fbo.bind(self.gl(), FBOTarget::Draw); fbo } @@ -1867,6 +1871,12 @@ impl Device { depth_rb.0, ); } + + debug_assert_eq!( + self.gl.check_frame_buffer_status(gl::DRAW_FRAMEBUFFER), + gl::FRAMEBUFFER_COMPLETE, + "Incomplete framebuffer", + ); } self.bind_external_draw_target(original_bound_fbo); } @@ -2886,11 +2896,24 @@ impl<'a, T> Drop for TextureUploader<'a, T> { impl<'a, T> TextureUploader<'a, T> { pub fn upload( &mut self, - rect: DeviceIntRect, + mut rect: DeviceIntRect, layer_index: i32, stride: Option, data: &[T], ) -> usize { + // Textures dimensions may have been clamped by the hardware. Crop the + // upload region to match. + let cropped = rect.intersection( + &DeviceIntRect::new(DeviceIntPoint::zero(), self.target.texture.get_dimensions()) + ); + if cfg!(debug_assertions) && cropped.map_or(true, |r| r != rect) { + warn!("Cropping texture upload {:?} to {:?}", rect, cropped); + } + rect = match cropped { + None => return 0, + Some(r) => r, + }; + let bytes_pp = self.target.texture.format.bytes_per_pixel(); let upload_size = match stride { Some(stride) => ((rect.size.height - 1) * stride + rect.size.width * bytes_pp) as usize, diff --git a/gfx/wr/webrender/src/renderer.rs b/gfx/wr/webrender/src/renderer.rs index ee6d9517e1a8e..30b92dfe0827b 100644 --- a/gfx/wr/webrender/src/renderer.rs +++ b/gfx/wr/webrender/src/renderer.rs @@ -1969,7 +1969,7 @@ impl Renderer { let ext_debug_marker = device.supports_extension("GL_EXT_debug_marker"); let gpu_profile = GpuProfiler::new(Rc::clone(device.rc_gl()), ext_debug_marker); #[cfg(feature = "capture")] - let read_fbo = device.create_fbo_for_external_texture(0); + let read_fbo = device.create_fbo(); let mut renderer = Renderer { result_rx,