Skip to content

Commit

Permalink
Bug 1514735 - Update webrender to commit 4de718f9ea3435c099cabafc02e8…
Browse files Browse the repository at this point in the history
…b51da539bc62 (WR PR #3428). r=kats

servo/webrender#3428

Differential Revision: https://phabricator.services.mozilla.com/D14823

--HG--
extra : moz-landing-system : lando
  • Loading branch information
WR Updater Bot committed Dec 18, 2018
1 parent b7296f0 commit 0000d47
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gfx/webrender_bindings/revision.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3a4ce4b66a7bc9bd10773744d20530c609a61e90
4de718f9ea3435c099cabafc02e8b51da539bc62
59 changes: 41 additions & 18 deletions gfx/wr/webrender/src/device/gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,11 +1046,18 @@ impl<'a> From<DrawTarget<'a>> for ReadTarget<'a> {

impl Device {
pub fn new(
gl: Rc<gl::Gl>,
mut gl: Rc<gl::Gl>,
resource_override_path: Option<PathBuf>,
upload_method: UploadMethod,
cached_programs: Option<Rc<ProgramCache>>,
) -> 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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<i32>,
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,
Expand Down
2 changes: 1 addition & 1 deletion gfx/wr/webrender/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0000d47

Please sign in to comment.