Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update webrender #22598

Merged
merged 3 commits into from Jan 18, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Large diffs are not rendered by default.

@@ -26,7 +26,7 @@ half = "1"
ipc-channel = "0.11"
log = "0.4"
num-traits = "0.2"
offscreen_gl_context = {version = "0.21", features = ["serde", "osmesa"]}
offscreen_gl_context = {version = "0.22", features = ["serde", "osmesa"]}
pixels = {path = "../pixels"}
serde_bytes = "0.10"
servo_config = {path = "../config"}
@@ -8,7 +8,7 @@ use compositing::compositor_thread::{self, CompositorProxy};
use euclid::Size2D;
use gleam::gl;
use offscreen_gl_context::{
ColorAttachmentType, GLContext, GLContextAttributes, GLContextDispatcher,
ColorAttachmentType, DrawBuffer, GLContext, GLContextAttributes, GLContextDispatcher,
};
use offscreen_gl_context::{GLLimits, GLVersion};
use offscreen_gl_context::{NativeGLContext, NativeGLContextHandle, NativeGLContextMethods};
@@ -207,7 +207,7 @@ impl GLContextWrapper {
}
}

pub fn resize(&mut self, size: Size2D<u32>) -> Result<(), &'static str> {
pub fn resize(&mut self, size: Size2D<u32>) -> Result<DrawBuffer, &'static str> {
match *self {
GLContextWrapper::Native(ref mut ctx) => {
// FIXME(nox): Why are those i32 values?
@@ -9,7 +9,9 @@ use euclid::Size2D;
use fnv::FnvHashMap;
use gleam::gl;
use half::f16;
use offscreen_gl_context::{GLContext, GLContextAttributes, GLLimits, NativeGLContextMethods};
use offscreen_gl_context::{
DrawBuffer, GLContext, GLContextAttributes, GLLimits, NativeGLContextMethods,
};
use pixels::{self, PixelFormat};
use std::borrow::Cow;
use std::thread;
@@ -228,6 +230,7 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
Self::make_current_if_needed(context_id, &self.contexts, &mut self.bound_context_id)
.expect("WebGLContext not found in a WebGLMsg::Lock message");
let info = self.cached_context_info.get_mut(&context_id).unwrap();
info.render_state = ContextRenderState::Locked(None);
// Insert a OpenGL Fence sync object that sends a signal when all the WebGL commands are finished.
// The related gl().wait_sync call is performed in the WR thread. See WebGLExternalImageApi for mor details.
let gl_sync = data.ctx.gl().fence_sync(gl::SYNC_GPU_COMMANDS_COMPLETE, 0);
@@ -247,6 +250,7 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
Self::make_current_if_needed(context_id, &self.contexts, &mut self.bound_context_id)
.expect("WebGLContext not found in a WebGLMsg::Unlock message");
let info = self.cached_context_info.get_mut(&context_id).unwrap();
info.render_state = ContextRenderState::Unlocked;
if let Some(gl_sync) = info.gl_sync.take() {
// Release the GLSync object.
data.ctx.gl().delete_sync(gl_sync);
@@ -299,6 +303,7 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
image_key: None,
share_mode,
gl_sync: None,
render_state: ContextRenderState::Unlocked,
},
);

@@ -319,9 +324,19 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
)
.expect("Missing WebGL context!");
match data.ctx.resize(size) {
Ok(_) => {
Ok(old_draw_buffer) => {
let (real_size, texture_id, _) = data.ctx.get_info();
let info = self.cached_context_info.get_mut(&context_id).unwrap();
if let ContextRenderState::Locked(ref mut in_use) = info.render_state {
// If there's already an outdated draw buffer present, we can ignore
// the newly resized one since it's not in use by the renderer.
if in_use.is_none() {
// We're resizing the context while WR is actively rendering
// it, so we need to retain the GL resources until WR is
// finished with them.
*in_use = Some(old_draw_buffer);
}
}
// Update webgl texture size. Texture id may change too.
info.texture_id = texture_id;
info.size = real_size;
@@ -682,6 +697,14 @@ impl<VR: WebVRRenderHandler + 'static> Drop for WebGLThread<VR> {
}
}

enum ContextRenderState {
/// The context is not being actively rendered.
Unlocked,
/// The context is actively being rendered. If a DrawBuffer value is present,
/// it is outdated but in use as long as the context is locked.
Locked(Option<DrawBuffer>),
}

/// Helper struct to store cached WebGLContext information.
struct WebGLContextInfo {
/// Render to texture identifier used by the WebGLContext.
@@ -696,6 +719,8 @@ struct WebGLContextInfo {
share_mode: WebGLContextShareMode,
/// GLSync Object used for a correct synchronization with Webrender external image callbacks.
gl_sync: Option<gl::GLsync>,
/// The status of this context with respect to external consumers.
render_state: ContextRenderState,
}

/// This trait is used as a bridge between the `WebGLThreads` implementation and
@@ -21,7 +21,7 @@ gleam = "0.6.7"
lazy_static = "1"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = "0.1"
offscreen_gl_context = {version = "0.21", features = ["serde"]}
offscreen_gl_context = {version = "0.22", features = ["serde"]}
pixels = {path = "../pixels"}
serde = "1.0"
serde_bytes = "0.10"
@@ -106,7 +106,7 @@ pub fn draw_img(

gl.bind_framebuffer(gl::FRAMEBUFFER, 0);

gl.delete_buffers(&render_target_info.texture_ids);
gl.delete_textures(&render_target_info.texture_ids);

This comment has been minimized.

Copy link
@nox

nox Jan 17, 2019

Member

Ouch. :)

gl.delete_renderbuffers(&render_target_info.renderbuffer_ids);
gl.delete_framebuffers(&render_target_info.framebuffer_ids);

@@ -63,5 +63,5 @@ servo-fontconfig = "0.2.1"
xml5ever = {version = "0.12"}

[target.'cfg(target_os = "windows")'.dependencies]
dwrote = "0.6"
dwrote = "0.7"
truetype = "0.26"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.