Bug 1615694. Declare our render targets up front to ANGLE. r=kvark

This should remove the allocation and copy in
TextureD3D::ensureRenderTarget() in some situations.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Muizelaar 2020-02-18 14:59:03 +00:00
parent 83fce38774
commit 260a5680ee
22 changed files with 236 additions and 79 deletions

8
Cargo.lock generated
View File

@ -1637,9 +1637,9 @@ dependencies = [
[[package]]
name = "gl_generator"
version = "0.11.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39a23d5e872a275135d66895d954269cf5e8661d234eb1c2480f4ce0d586acbd"
checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
dependencies = [
"khronos_api",
"log",
@ -1648,9 +1648,9 @@ dependencies = [
[[package]]
name = "gleam"
version = "0.6.17"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f46fd8874e043ffac0d638ed1567a2584f7814f6d72b4db37ab1689004a26c4"
checksum = "332d1f4e6c6181ed07178f84a552b2387d43ecf6821a86c22cfb3883ea3fb1b9"
dependencies = [
"gl_generator",
]

View File

@ -13,7 +13,7 @@ num_cpus = "1.7.0"
thread_profiler = "0.1.1"
euclid = { version = "0.20.0", features = ["serde"] }
app_units = "0.7"
gleam = "0.6.14"
gleam = "0.9.2"
log = "0.4"
nsstring = { path = "../../xpcom/rust/nsstring" }
bincode = "1.0"

40
gfx/wr/Cargo.lock generated
View File

@ -188,7 +188,7 @@ name = "cgl"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -242,7 +242,7 @@ name = "compositor"
version = "0.1.0"
dependencies = [
"compositor-windows 0.1.0",
"gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.61.0",
]
@ -415,7 +415,7 @@ name = "direct-composition"
version = "0.1.0"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.61.0",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -593,11 +593,29 @@ dependencies = [
]
[[package]]
name = "gleam"
version = "0.6.17"
name = "gl_generator"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gleam"
version = "0.6.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gleam"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1753,7 +1771,7 @@ dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1787,7 +1805,7 @@ dependencies = [
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.61.0",
@ -1914,7 +1932,7 @@ dependencies = [
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"font-loader 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2059,7 +2077,9 @@ dependencies = [
"checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592"
"checksum gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39a23d5e872a275135d66895d954269cf5e8661d234eb1c2480f4ce0d586acbd"
"checksum gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a"
"checksum gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7f46fd8874e043ffac0d638ed1567a2584f7814f6d72b4db37ab1689004a26c4"
"checksum gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
"checksum gleam 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "cae10d7c99d0e77b4766e850a60898a17c1abaf01075531f1066f03dc7dc5fc5"
"checksum gleam 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332d1f4e6c6181ed07178f84a552b2387d43ecf6821a86c22cfb3883ea3fb1b9"
"checksum glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb26027a84c3b9e1949ef0df0b6a3db8d0c124243a5c161ea25c7def90cb1474"
"checksum glutin_egl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "23f48987ab6cb2b61ad903b59e54a2fd0c380a7baff68cffd6826b69a73dd326"
"checksum glutin_emscripten_sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "245b3fdb08df6ffed7585365851f8404af9c7e2dd4b59f15262e968b6a95a0c7"

View File

@ -7,7 +7,7 @@ edition = "2018"
[target.'cfg(windows)'.dependencies]
euclid = "0.20"
gleam = "0.6.2"
gleam = "0.9.2"
mozangle = {version = "0.3.1", features = ["egl"]}
webrender = {path = "../webrender"}
winapi = {version = "0.3", features = ["winerror", "d3d11", "dcomp"]}

View File

@ -7,7 +7,7 @@ license = "MPL-2.0"
[dependencies]
webrender = { path = "../../webrender" }
gleam = "0.6.2"
gleam = "0.9.2"
[target.'cfg(windows)'.dependencies]
compositor-windows = { path = "../compositor-windows" }

View File

@ -61,7 +61,7 @@ debug = ["webrender/capture", "webrender/debugger", "webrender/profiler"]
app_units = "0.7"
env_logger = "0.5"
euclid = "0.20"
gleam = "0.6.2"
gleam = "0.9.2"
glutin = "0.21"
rayon = "1"
webrender = { path = "../webrender" }

View File

@ -32,7 +32,7 @@ cfg-if = "0.1.2"
cstr = "0.1.2"
euclid = { version = "0.20.0", features = ["serde"] }
fxhash = "0.2.1"
gleam = "0.6.17"
gleam = "0.9.2"
image_loader = { optional = true, version = "0.22", package = "image", default-features = false, features = ["png_codec"] }
lazy_static = "1"
log = "0.4"

View File

@ -949,6 +949,8 @@ pub struct Capabilities {
/// Whether the driver supports uploading to textures from a non-zero
/// offset within a PBO.
pub supports_nonzero_pbo_offsets: bool,
/// Whether the driver supports specifying the texture usage up front.
pub supports_texture_usage: bool,
}
#[derive(Clone, Debug)]
@ -1309,6 +1311,8 @@ impl Device {
gl.provoking_vertex_angle(gl::FIRST_VERTEX_CONVENTION);
}
let supports_texture_usage = supports_extension(&extensions, "GL_ANGLE_texture_usage");
// Our common-case image data in Firefox is BGRA, so we make an effort
// to use BGRA as the internal texture storage format to avoid the need
// to swizzle during upload. Currently we only do this on GLES (and thus
@ -1480,6 +1484,7 @@ impl Device {
supports_khr_debug,
supports_texture_swizzle,
supports_nonzero_pbo_offsets,
supports_texture_usage,
},
color_formats,
@ -2084,6 +2089,10 @@ impl Device {
self.bind_texture(DEFAULT_TEXTURE, &texture, Swizzle::default());
self.set_texture_parameters(texture.target, filter);
if self.capabilities.supports_texture_usage && render_target.is_some() {
self.gl.tex_parameter_i(texture.target, gl::TEXTURE_USAGE_ANGLE, gl::FRAMEBUFFER_ATTACHMENT_ANGLE as gl::GLint);
}
// Allocate storage.
let desc = self.gl_describe_format(texture.format);
let is_array = match texture.target {

View File

@ -12,7 +12,7 @@ bincode = "1.0"
byteorder = "1.0"
env_logger = { version = "0.5", optional = true }
euclid = "0.20"
gleam = "0.6.2"
gleam = "0.9.2"
glutin = "0.21"
app_units = "0.7"
clap = { version = "2", features = ["yaml"] }

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"e1a5f54814bdc0073585819a8bf8cbdba3e9b1cfb7fa1a5bd7fbb8d8670a3673","README.md":"52d8fee4681c879f2c964fd30e3faf0c907e8bf676eab7b44beab5c5bbd5c284","generators/debug_struct_gen.rs":"73164956c9c5fe848a568aac1a7518947a0786ad6118618d78b4f0208c3f442e","generators/global_gen.rs":"486384b1d7fc234dbe55815bd99e5fbd69144f361f8cefdf4aa9841db1d7832a","generators/mod.rs":"100a1da965bf11eaa9fad48a06c7856b60f48363a4a707e34ba97938bedae0b8","generators/static_gen.rs":"925a9401e27358a466baadfb660056a24394cf2fa21f5613e2d7f50ab8935e71","generators/static_struct_gen.rs":"eb08e6e59b0e0947c4ab263a0749efbb28430c5741634c413a2be011fcdad88f","generators/struct_gen.rs":"13444b524e992d88fdd2f4b0990e06bdee292b076047b274b7f607f3de12a85d","generators/templates/types/egl.rs":"d1785a30f1098e101302ba74ba4c22cf95ac44b17edf221dbb9d890f4bd635a2","generators/templates/types/gl.rs":"f71f3a2200c0fa13f09687ef05e51c28c5b11c1bb841acd402c0097d8f9130bd","generators/templates/types/glx.rs":"f444166d117b96afed2d8d13db6cd3369d6c59704f296e76202269f411bbd4a8","generators/templates/types/wgl.rs":"9d626e0959374c694c19a36d4dd34dae2f37acf3cb94e9bd4d242a16b41a970d","lib.rs":"6f47da878479b503b5202bda84ad8935607264ac03c0b68203109fad9cd479db","registry/mod.rs":"84eed5c113b322e5267b2b130987e6bb726b4e7c38ce50292cd6cc57b8e06994","registry/parse.rs":"c201ee463663878d4546a7d94194303a3d3c27f2bcb2cdbedd892f0446583795"},"package":"39a23d5e872a275135d66895d954269cf5e8661d234eb1c2480f4ce0d586acbd"}
{"files":{"Cargo.toml":"f586015aa2816b3c34d89f5e6a6539172efcd7f3ed055a0fab433ea83e2a0f0f","README.md":"52d8fee4681c879f2c964fd30e3faf0c907e8bf676eab7b44beab5c5bbd5c284","generators/debug_struct_gen.rs":"6fecccf8e57d4be93ea2657328d6e111ca44bc69542a5522cd7360d80ca64630","generators/global_gen.rs":"1696013af16bb92a3fa7cf3802a57ec6f7ba460322ede33aa2af30fc9911bd98","generators/mod.rs":"100a1da965bf11eaa9fad48a06c7856b60f48363a4a707e34ba97938bedae0b8","generators/static_gen.rs":"925a9401e27358a466baadfb660056a24394cf2fa21f5613e2d7f50ab8935e71","generators/static_struct_gen.rs":"eb08e6e59b0e0947c4ab263a0749efbb28430c5741634c413a2be011fcdad88f","generators/struct_gen.rs":"fa1bcda4501a597922be7c7ef4ad13738536a9c97529996671e264acd709c680","generators/templates/types/egl.rs":"d1785a30f1098e101302ba74ba4c22cf95ac44b17edf221dbb9d890f4bd635a2","generators/templates/types/gl.rs":"d72f91355febec875c40899a44c5575bd04993f7cf5c6e289eec872a2a161b20","generators/templates/types/glx.rs":"f444166d117b96afed2d8d13db6cd3369d6c59704f296e76202269f411bbd4a8","generators/templates/types/wgl.rs":"9d626e0959374c694c19a36d4dd34dae2f37acf3cb94e9bd4d242a16b41a970d","lib.rs":"6f47da878479b503b5202bda84ad8935607264ac03c0b68203109fad9cd479db","registry/mod.rs":"84eed5c113b322e5267b2b130987e6bb726b4e7c38ce50292cd6cc57b8e06994","registry/parse.rs":"5cb781082014f143b06ef7d3678f3c4ca59133a5732d4e136fd750b78fb9453f"},"package":"1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"}

View File

@ -12,7 +12,7 @@
[package]
name = "gl_generator"
version = "0.11.0"
version = "0.14.0"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>", "Corey Richardson", "Arseny Kapoulkine"]
description = "Code generators for creating bindings to the Khronos OpenGL APIs."
homepage = "https://github.com/brendanzab/gl-rs/"

View File

@ -187,7 +187,7 @@ where
#[allow(dead_code, unused_variables)]
pub fn load_with<F>(mut loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::raw::c_void {{
#[inline(never)]
fn do_metaloadfn(loadfn: &mut FnMut(&'static str) -> *const __gl_imports::raw::c_void,
fn do_metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void,
symbol: &'static str,
symbols: &[&'static str])
-> *const __gl_imports::raw::c_void {{

View File

@ -63,7 +63,7 @@ where
dest,
r#"
#[inline(never)]
fn metaloadfn(loadfn: &mut FnMut(&'static str) -> *const __gl_imports::raw::c_void,
fn metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void,
symbol: &'static str,
fallbacks: &[&'static str]) -> *const __gl_imports::raw::c_void {{
let mut ptr = loadfn(symbol);
@ -285,12 +285,14 @@ where
/// ~~~
#[allow(dead_code)]
pub fn load_with<F>(mut loadfn: F) where F: FnMut(&'static str) -> *const __gl_imports::raw::c_void {{
#[inline(never)]
fn inner(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void) {{
"));
for c in &registry.cmds {
try!(writeln!(
dest,
"{cmd_name}::load_with(&mut loadfn);",
"{cmd_name}::load_with(&mut *loadfn);",
cmd_name = &c.proto.ident[..]
));
}
@ -298,6 +300,9 @@ where
writeln!(
dest,
"
}}
inner(&mut loadfn)
}}
"
)

View File

@ -187,7 +187,7 @@ where
#[allow(dead_code, unused_variables)]
pub fn load_with<F>(mut loadfn: F) -> {api} where F: FnMut(&'static str) -> *const __gl_imports::raw::c_void {{
#[inline(never)]
fn do_metaloadfn(loadfn: &mut FnMut(&'static str) -> *const __gl_imports::raw::c_void,
fn do_metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const __gl_imports::raw::c_void,
symbol: &'static str,
symbols: &[&'static str])
-> *const __gl_imports::raw::c_void {{

View File

@ -46,27 +46,27 @@ pub type GLsync = *const __GLsync;
pub enum _cl_context {}
pub enum _cl_event {}
pub type GLDEBUGPROC = extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCARB = extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCKHR = extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROC = Option<extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void)>;
pub type GLDEBUGPROCARB = Option<extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void)>;
pub type GLDEBUGPROCKHR = Option<extern "system" fn(source: GLenum,
gltype: GLenum,
id: GLuint,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void)>;
// GLES 1 types
// "pub type GLclampx = i32;",
@ -98,11 +98,11 @@ pub type GLDEBUGPROCKHR = extern "system" fn(source: GLenum,
// GLES 2 types (none currently)
// Vendor extension types
pub type GLDEBUGPROCAMD = extern "system" fn(id: GLuint,
category: GLenum,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void);
pub type GLDEBUGPROCAMD = Option<extern "system" fn(id: GLuint,
category: GLenum,
severity: GLenum,
length: GLsizei,
message: *const GLchar,
userParam: *mut super::__gl_imports::raw::c_void)>;
pub type GLhalfNV = super::__gl_imports::raw::c_ushort;
pub type GLvdpauSurfaceNV = GLintptr;

View File

@ -201,7 +201,7 @@ fn make_egl_enum(ident: String, ty: Option<String>, value: String, alias: Option
}
} else {
match value.chars().next() {
Some('-') | Some('0'...'9') => (),
Some('-') | Some('0'..='9') => (),
_ => panic!("Unexpected value format: {}", value),
}
@ -1041,6 +1041,7 @@ pub fn to_rust_ty<T: AsRef<str>>(ty: T) -> Cow<'static, str> {
"EGLAttrib" => "types::EGLAttrib",
"EGLAttrib *" => "*mut types::EGLAttrib",
"const EGLAttrib *" => "*const types::EGLAttrib",
"const EGLattrib *" => "*const types::EGLAttrib", // Due to a typo in khronos_api/api_angle/scripts/egl_angle_ext.xml - see brendanzab/gl-rs#491
"EGLConfig" => "types::EGLConfig",
"EGLConfig *" => "*mut types::EGLConfig",
"EGLContext" => "types::EGLContext",

View File

@ -1 +1 @@
{"files":{"COPYING":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"40dda1b03ff20d8a3b4b544683f37a8d2b2137cfbb4d545122167352690d6b16","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"1acb12040be43a3582d5897f11870b3ffdcd7ce0f4f32de158175bb6b33ec0b7","build.rs":"2d3833a24fee9d1f669f4cd7347b4ca8444a138d473ab9188f4d65f6981c4191","rustfmt.toml":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","src/gl.rs":"b7791f77dbbea690a7a0d33e3c083337a6b04a233a192dc8c96d4fe481a4a7ed","src/gl_fns.rs":"f88cd940691e0fca169cabbe2a95418300d09392d91a020079cfbdd5bacd753b","src/gles_fns.rs":"3766f2b76aa4038774a4754ce89cdcbb50286ab5bcf07cb0bb6e88f0de31f96f","src/lib.rs":"16610c19b45a3f26d56b379a3591aa2e4fc9477e7bd88f86b31c6ea32e834861"},"package":"7f46fd8874e043ffac0d638ed1567a2584f7814f6d72b4db37ab1689004a26c4"}
{"files":{"COPYING":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"834f409ac81917f5b5730483c90611e3193a8fb7400c87d30e7988d866bc5740","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"1acb12040be43a3582d5897f11870b3ffdcd7ce0f4f32de158175bb6b33ec0b7","build.rs":"b6b30972ee2be2e151af0ca93b30ccc3c8bce2cfeef4217244d6b413b6bd0c9d","rustfmt.toml":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","src/gl.rs":"e923f4ccfeae5112e6cea8f78ff279e8a26c041dcfb5cfb63d9713e733d249c3","src/gl_fns.rs":"67b5eac2a686f4a58201b8d51fc27db1aca6d597dfaa5c8ad4007170ffb18887","src/gles_fns.rs":"1c206adf96e6b9767d526aad54ddfb48e99aa0f5766d3cb72019470f4bdd88f9","src/lib.rs":"16610c19b45a3f26d56b379a3591aa2e4fc9477e7bd88f86b31c6ea32e834861"},"package":"332d1f4e6c6181ed07178f84a552b2387d43ecf6821a86c22cfb3883ea3fb1b9"}

View File

@ -12,7 +12,7 @@
[package]
name = "gleam"
version = "0.6.17"
version = "0.9.2"
authors = ["The Servo Project Developers"]
build = "build.rs"
description = "Generated OpenGL bindings and wrapper for Servo."
@ -20,4 +20,4 @@ documentation = "https://doc.servo.org/gleam/"
license = "Apache-2.0/MIT"
repository = "https://github.com/servo/gleam"
[build-dependencies.gl_generator]
version = "0.11"
version = "0.14"

View File

@ -17,6 +17,7 @@ fn main() {
"GL_APPLE_client_storage",
"GL_APPLE_fence",
"GL_APPLE_texture_range",
"GL_APPLE_vertex_array_object",
"GL_ARB_blend_func_extended",
"GL_ARB_copy_image",
"GL_ARB_get_program_binary",
@ -54,6 +55,8 @@ fn main() {
"GL_OES_texture_half_float",
"GL_EXT_shader_pixel_local_storage",
"GL_ANGLE_provoking_vertex",
"GL_ANGLE_texture_usage",
"GL_CHROMIUM_copy_texture",
"GL_KHR_debug",
"GL_KHR_blend_equation_advanced",
"GL_KHR_blend_equation_advanced_coherent",

View File

@ -23,7 +23,7 @@ pub use ffi::*;
pub use ffi_gl::Gl as GlFfi;
pub use ffi_gles::Gles2 as GlesFfi;
#[derive(Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum GlType {
Gl,
Gles,
@ -74,13 +74,22 @@ pub struct DebugMessage {
pub severity: GLenum,
}
mod private {
// Private marker trait extended by the Gl public trait so that no one
// else outside this crate can implement Gl. Why? So that adding new methods
// to it don't lead to a breaking change.
pub trait Sealed {}
}
use self::private::Sealed;
macro_rules! declare_gl_apis {
// garbo is a hack to handle unsafe methods.
($($(unsafe $([$garbo:expr])*)* fn $name:ident(&self $(, $arg:ident: $t:ty)* $(,)*) $(-> $retty:ty)* ;)+) => {
pub trait Gl {
pub trait Gl: Sealed {
$($(unsafe $($garbo)*)* fn $name(&self $(, $arg:$t)*) $(-> $retty)* ;)+
}
impl Sealed for ErrorCheckingGl {}
impl Gl for ErrorCheckingGl {
$($(unsafe $($garbo)*)* fn $name(&self $(, $arg:$t)*) $(-> $retty)* {
let rv = self.gl.$name($($arg,)*);
@ -89,7 +98,8 @@ macro_rules! declare_gl_apis {
})+
}
impl<F: Fn(&Gl, &str, GLenum)> Gl for ErrorReactingGl<F> {
impl<F> Sealed for ErrorReactingGl<F> {}
impl<F: Fn(&dyn Gl, &str, GLenum)> Gl for ErrorReactingGl<F> {
$($(unsafe $($garbo)*)* fn $name(&self $(, $arg:$t)*) $(-> $retty)* {
let rv = self.gl.$name($($arg,)*);
let error = self.gl.get_error();
@ -100,6 +110,7 @@ macro_rules! declare_gl_apis {
})+
}
impl<F> Sealed for ProfilingGl<F> {}
impl<F: Fn(&str, Duration)> Gl for ProfilingGl<F> {
$($(unsafe $($garbo)*)* fn $name(&self $(, $arg:$t)*) $(-> $retty)* {
let start = Instant::now();
@ -169,6 +180,7 @@ declare_gl_apis! {
fn gen_framebuffers(&self, n: GLsizei) -> Vec<GLuint>;
fn gen_textures(&self, n: GLsizei) -> Vec<GLuint>;
fn gen_vertex_arrays(&self, n: GLsizei) -> Vec<GLuint>;
fn gen_vertex_arrays_apple(&self, n: GLsizei) -> Vec<GLuint>;
fn gen_queries(&self, n: GLsizei) -> Vec<GLuint>;
fn begin_query(&self, target: GLenum, id: GLuint);
fn end_query(&self, target: GLenum);
@ -179,6 +191,7 @@ declare_gl_apis! {
fn get_query_object_ui64v(&self, id: GLuint, pname: GLenum) -> u64;
fn delete_queries(&self, queries: &[GLuint]);
fn delete_vertex_arrays(&self, vertex_arrays: &[GLuint]);
fn delete_vertex_arrays_apple(&self, vertex_arrays: &[GLuint]);
fn delete_buffers(&self, buffers: &[GLuint]);
fn delete_renderbuffers(&self, renderbuffers: &[GLuint]);
fn delete_framebuffers(&self, framebuffers: &[GLuint]);
@ -209,6 +222,7 @@ declare_gl_apis! {
uniform_block_binding: GLuint);
fn bind_buffer(&self, target: GLenum, buffer: GLuint);
fn bind_vertex_array(&self, vao: GLuint);
fn bind_vertex_array_apple(&self, vao: GLuint);
fn bind_renderbuffer(&self, target: GLenum, renderbuffer: GLuint);
fn bind_framebuffer(&self, target: GLenum, framebuffer: GLuint);
fn bind_texture(&self, target: GLenum, texture: GLuint);
@ -549,6 +563,7 @@ declare_gl_apis! {
fn stencil_op(&self, sfail: GLenum, dpfail: GLenum, dppass: GLenum);
fn stencil_op_separate(&self, face: GLenum, sfail: GLenum, dpfail: GLenum, dppass: GLenum);
fn egl_image_target_texture2d_oes(&self, target: GLenum, image: GLeglImageOES);
fn egl_image_target_renderbuffer_storage_oes(&self, target: GLenum, image: GLeglImageOES);
fn generate_mipmap(&self, target: GLenum);
fn insert_event_marker_ext(&self, message: &str);
fn push_group_marker_ext(&self, message: &str);
@ -588,49 +603,61 @@ declare_gl_apis! {
// GL_KHR_debug
fn get_debug_messages(&self) -> Vec<DebugMessage>;
// GL_ANGLE_provoking_vertex.
// GL_ANGLE_provoking_vertex
fn provoking_vertex_angle(&self, mode: GLenum);
// GL_CHROMIUM_copy_texture
fn copy_texture_chromium(&self,
source_id: GLuint, source_level: GLint,
dest_target: GLenum, dest_id: GLuint, dest_level: GLint,
internal_format: GLint, dest_type: GLenum,
unpack_flip_y: GLboolean, unpack_premultiply_alpha: GLboolean, unpack_unmultiply_alpha: GLboolean);
fn copy_sub_texture_chromium(&self,
source_id: GLuint, source_level: GLint,
dest_target: GLenum, dest_id: GLuint, dest_level: GLint,
x_offset: GLint, y_offset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei,
unpack_flip_y: GLboolean, unpack_premultiply_alpha: GLboolean, unpack_unmultiply_alpha: GLboolean);
}
//#[deprecated(since = "0.6.11", note = "use ErrorReactingGl instead")]
pub struct ErrorCheckingGl {
gl: Rc<Gl>,
gl: Rc<dyn Gl>,
}
impl ErrorCheckingGl {
pub fn wrap(fns: Rc<Gl>) -> Rc<Gl> {
Rc::new(ErrorCheckingGl { gl: fns }) as Rc<Gl>
pub fn wrap(fns: Rc<dyn Gl>) -> Rc<dyn Gl> {
Rc::new(ErrorCheckingGl { gl: fns }) as Rc<dyn Gl>
}
}
/// A wrapper around GL context that calls a specified callback on each GL error.
pub struct ErrorReactingGl<F> {
gl: Rc<Gl>,
gl: Rc<dyn Gl>,
callback: F,
}
impl<F: 'static + Fn(&Gl, &str, GLenum)> ErrorReactingGl<F> {
pub fn wrap(fns: Rc<Gl>, callback: F) -> Rc<Gl> {
Rc::new(ErrorReactingGl { gl: fns, callback }) as Rc<Gl>
impl<F: 'static + Fn(&dyn Gl, &str, GLenum)> ErrorReactingGl<F> {
pub fn wrap(fns: Rc<dyn Gl>, callback: F) -> Rc<dyn Gl> {
Rc::new(ErrorReactingGl { gl: fns, callback }) as Rc<dyn Gl>
}
}
/// A wrapper around GL context that times each call and invokes the callback
/// if the call takes longer than the threshold.
pub struct ProfilingGl<F> {
gl: Rc<Gl>,
gl: Rc<dyn Gl>,
threshold: Duration,
callback: F,
}
impl<F: 'static + Fn(&str, Duration)> ProfilingGl<F> {
pub fn wrap(fns: Rc<Gl>, threshold: Duration, callback: F) -> Rc<Gl> {
Rc::new(ProfilingGl { gl: fns, threshold, callback }) as Rc<Gl>
pub fn wrap(fns: Rc<dyn Gl>, threshold: Duration, callback: F) -> Rc<dyn Gl> {
Rc::new(ProfilingGl { gl: fns, threshold, callback }) as Rc<dyn Gl>
}
}
#[inline]
pub fn buffer_data<T>(gl_: &Gl, target: GLenum, data: &[T], usage: GLenum) {
pub fn buffer_data<T>(gl_: &dyn Gl, target: GLenum, data: &[T], usage: GLenum) {
gl_.buffer_data_untyped(
target,
(data.len() * size_of::<T>()) as GLsizeiptr,
@ -640,7 +667,7 @@ pub fn buffer_data<T>(gl_: &Gl, target: GLenum, data: &[T], usage: GLenum) {
}
#[inline]
pub fn buffer_data_raw<T>(gl_: &Gl, target: GLenum, data: &T, usage: GLenum) {
pub fn buffer_data_raw<T>(gl_: &dyn Gl, target: GLenum, data: &T, usage: GLenum) {
gl_.buffer_data_untyped(
target,
size_of::<T>() as GLsizeiptr,
@ -650,7 +677,7 @@ pub fn buffer_data_raw<T>(gl_: &Gl, target: GLenum, data: &T, usage: GLenum) {
}
#[inline]
pub fn buffer_sub_data<T>(gl_: &Gl, target: GLenum, offset: isize, data: &[T]) {
pub fn buffer_sub_data<T>(gl_: &dyn Gl, target: GLenum, offset: isize, data: &[T]) {
gl_.buffer_sub_data_untyped(
target,
offset,

View File

@ -12,15 +12,16 @@ pub struct GlFns {
}
impl GlFns {
pub unsafe fn load_with<'a, F>(loadfn: F) -> Rc<Gl>
pub unsafe fn load_with<'a, F>(loadfn: F) -> Rc<dyn Gl>
where
F: FnMut(&str) -> *const c_void,
{
let ffi_gl_ = GlFfi::load_with(loadfn);
Rc::new(GlFns { ffi_gl_: ffi_gl_ }) as Rc<Gl>
Rc::new(GlFns { ffi_gl_: ffi_gl_ }) as Rc<dyn Gl>
}
}
impl Sealed for GlFns {}
impl Gl for GlFns {
fn get_type(&self) -> GlType {
GlType::Gl
@ -221,7 +222,15 @@ impl Gl for GlFns {
fn gen_vertex_arrays(&self, n: GLsizei) -> Vec<GLuint> {
let mut result = vec![0 as GLuint; n as usize];
unsafe {
self.ffi_gl_.GenVertexArrays(n, result.as_mut_ptr());
self.ffi_gl_.GenVertexArrays(n, result.as_mut_ptr())
}
result
}
fn gen_vertex_arrays_apple(&self, n: GLsizei) -> Vec<GLuint> {
let mut result = vec![0 as GLuint; n as usize];
unsafe {
self.ffi_gl_.GenVertexArraysAPPLE(n, result.as_mut_ptr())
}
result
}
@ -298,6 +307,13 @@ impl Gl for GlFns {
}
}
fn delete_vertex_arrays_apple(&self, vertex_arrays: &[GLuint]) {
unsafe {
self.ffi_gl_
.DeleteVertexArraysAPPLE(vertex_arrays.len() as GLsizei, vertex_arrays.as_ptr());
}
}
fn delete_buffers(&self, buffers: &[GLuint]) {
unsafe {
self.ffi_gl_
@ -464,6 +480,12 @@ impl Gl for GlFns {
}
}
fn bind_vertex_array_apple(&self, vao: GLuint) {
unsafe {
self.ffi_gl_.BindVertexArrayAPPLE(vao)
}
}
fn bind_renderbuffer(&self, target: GLenum, renderbuffer: GLuint) {
unsafe {
self.ffi_gl_.BindRenderbuffer(target, renderbuffer);
@ -1916,6 +1938,11 @@ impl Gl for GlFns {
panic!("not supported")
}
#[allow(unused_variables)]
fn egl_image_target_renderbuffer_storage_oes(&self, target: GLenum, image: GLeglImageOES) {
panic!("not supported")
}
fn generate_mipmap(&self, target: GLenum) {
unsafe { self.ffi_gl_.GenerateMipmap(target) }
}
@ -2153,4 +2180,22 @@ impl Gl for GlFns {
}
}
}
// GL_CHROMIUM_copy_texture
fn copy_texture_chromium(&self,
_source_id: GLuint, _source_level: GLint,
_dest_target: GLenum, _dest_id: GLuint, _dest_level: GLint,
_internal_format: GLint, _dest_type: GLenum,
_unpack_flip_y: GLboolean, _unpack_premultiply_alpha: GLboolean, _unpack_unmultiply_alpha: GLboolean)
{
unimplemented!("This extension is GLES only");
}
fn copy_sub_texture_chromium(&self,
_source_id: GLuint, _source_level: GLint,
_dest_target: GLenum, _dest_id: GLuint, _dest_level: GLint,
_x_offset: GLint, _y_offset: GLint, _x: GLint, _y: GLint, _width: GLsizei, _height: GLsizei,
_unpack_flip_y: GLboolean, _unpack_premultiply_alpha: GLboolean, _unpack_unmultiply_alpha: GLboolean)
{
unimplemented!("This extension is GLES only");
}
}

View File

@ -12,15 +12,16 @@ pub struct GlesFns {
}
impl GlesFns {
pub unsafe fn load_with<'a, F>(loadfn: F) -> Rc<Gl>
pub unsafe fn load_with<'a, F>(loadfn: F) -> Rc<dyn Gl>
where
F: FnMut(&str) -> *const c_void,
{
let ffi_gl_ = GlesFfi::load_with(loadfn);
Rc::new(GlesFns { ffi_gl_: ffi_gl_ }) as Rc<Gl>
Rc::new(GlesFns { ffi_gl_: ffi_gl_ }) as Rc<dyn Gl>
}
}
impl Sealed for GlesFns {}
impl Gl for GlesFns {
fn get_type(&self) -> GlType {
GlType::Gles
@ -221,6 +222,10 @@ impl Gl for GlesFns {
result
}
fn gen_vertex_arrays_apple(&self, _n: GLsizei) -> Vec<GLuint> {
panic!("not supported")
}
fn gen_queries(&self, n: GLsizei) -> Vec<GLuint> {
if !self.ffi_gl_.GenQueriesEXT.is_loaded() {
return Vec::new();
@ -320,6 +325,10 @@ impl Gl for GlesFns {
}
}
fn delete_vertex_arrays_apple(&self, _vertex_arrays: &[GLuint]) {
panic!("not supported")
}
fn delete_buffers(&self, buffers: &[GLuint]) {
unsafe {
self.ffi_gl_
@ -486,6 +495,10 @@ impl Gl for GlesFns {
}
}
fn bind_vertex_array_apple(&self, _vao: GLuint) {
panic!("not supported")
}
fn bind_renderbuffer(&self, target: GLenum, renderbuffer: GLuint) {
unsafe {
self.ffi_gl_.BindRenderbuffer(target, renderbuffer);
@ -1922,6 +1935,12 @@ impl Gl for GlesFns {
}
}
fn egl_image_target_renderbuffer_storage_oes(&self, target: GLenum, image: GLeglImageOES) {
unsafe {
self.ffi_gl_.EGLImageTargetRenderbufferStorageOES(target, image);
}
}
fn generate_mipmap(&self, target: GLenum) {
unsafe { self.ffi_gl_.GenerateMipmap(target) }
}
@ -2120,4 +2139,32 @@ impl Gl for GlesFns {
}
}
}
// GL_CHROMIUM_copy_texture
fn copy_texture_chromium(&self,
source_id: GLuint, source_level: GLint,
dest_target: GLenum, dest_id: GLuint, dest_level: GLint,
internal_format: GLint, dest_type: GLenum,
unpack_flip_y: GLboolean, unpack_premultiply_alpha: GLboolean, unpack_unmultiply_alpha: GLboolean)
{
unsafe {
self.ffi_gl_.CopyTextureCHROMIUM(source_id, source_level, dest_target, dest_id, dest_level,
internal_format, dest_type,
unpack_flip_y, unpack_premultiply_alpha, unpack_unmultiply_alpha,
);
}
}
fn copy_sub_texture_chromium(&self,
source_id: GLuint, source_level: GLint,
dest_target: GLenum, dest_id: GLuint, dest_level: GLint,
x_offset: GLint, y_offset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei,
unpack_flip_y: GLboolean, unpack_premultiply_alpha: GLboolean, unpack_unmultiply_alpha: GLboolean)
{
unsafe {
self.ffi_gl_.CopySubTextureCHROMIUM(source_id, source_level, dest_target, dest_id, dest_level,
x_offset, y_offset, x, y, width, height,
unpack_flip_y, unpack_premultiply_alpha, unpack_unmultiply_alpha,
);
}
}
}