mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Switch from servo/angle to the mozangle crate
https://github.com/servo/mozangle
This commit is contained in:
parent
324e22db03
commit
67d983cb12
5 changed files with 81 additions and 28 deletions
37
Cargo.lock
generated
37
Cargo.lock
generated
|
@ -26,15 +26,6 @@ name = "android_injected_glue"
|
|||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "angle"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/servo/angle?branch=servo#1599c1d067b4ccbe502f660181d08d49d69e26eb"
|
||||
dependencies = [
|
||||
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.10.2"
|
||||
|
@ -312,8 +303,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.1"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
|
@ -395,7 +389,7 @@ name = "cmake"
|
|||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1332,7 +1326,7 @@ name = "jemalloc-sys"
|
|||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1579,7 +1573,7 @@ name = "libz-sys"
|
|||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1791,6 +1785,15 @@ name = "mitochondria"
|
|||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "mozangle"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mozjs"
|
||||
version = "0.1.11"
|
||||
|
@ -2066,7 +2069,7 @@ name = "openssl-sys"
|
|||
version = "0.9.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2423,7 +2426,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
name = "script"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"angle 0.5.0 (git+https://github.com/servo/angle?branch=servo)",
|
||||
"app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"audio-video-metadata 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2460,6 +2462,7 @@ dependencies = [
|
|||
"mime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozangle 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"net_traits 0.0.1",
|
||||
|
@ -3693,7 +3696,6 @@ dependencies = [
|
|||
"checksum alloc-no-stdlib 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b21f6ad9c9957eb5d70c3dee16d31c092b3cab339628f821766b05e6833d72b8"
|
||||
"checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"
|
||||
"checksum android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "80b9e34fcbf29c0563547cb2ecce9b49504597cad6166769b1e4efb45c6c2951"
|
||||
"checksum angle 0.5.0 (git+https://github.com/servo/angle?branch=servo)" = "<none>"
|
||||
"checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455"
|
||||
"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
|
||||
"checksum app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c4720c83543de184d9f6add2fdb8e8031543497b8506620884c16e125b493c09"
|
||||
|
@ -3721,7 +3723,7 @@ dependencies = [
|
|||
"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23"
|
||||
"checksum bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c129aff112dcc562970abb69e2508b40850dd24c274761bb50fb8a0067ba6c27"
|
||||
"checksum caseless 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3261638034d9db4f94a666ebb16494846341ae5a8456c05c1616d66980cf39a"
|
||||
"checksum cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c674f0870e3dbd4105184ea035acb1c32c8ae69939c9e228d2b11bbfe29efad"
|
||||
"checksum cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9be26b24e988625409b19736d130f0c7d224f01d06454b5f81d8d23d6c1a618f"
|
||||
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
|
||||
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
||||
"checksum cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "86765cb42c2a2c497e142af72517c1b4d7ae5bb2f25dfa77a5c69642f2342d89"
|
||||
|
@ -3839,6 +3841,7 @@ dependencies = [
|
|||
"checksum mio 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9e965267d4d58496fc4f740e9861118367f13570cadf66316ed2c3f2f14d87c7"
|
||||
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
|
||||
"checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f"
|
||||
"checksum mozangle 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4d916e4f2d39a00eeeb082ceb7c63c741e7c9d4f7915945f9225ae5e3b284092"
|
||||
"checksum mozjs 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "199f707066bf05b559ef6e46741c20e4f7bca8ae3a9c9d953d728dbb840f4eaa"
|
||||
"checksum mozjs_sys 0.50.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e61a792a125b1364c5ec50255ed8343ce02dc56098f8868dd209d472c8de006a"
|
||||
"checksum mp3-metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ab5f1d2693586420208d1200ce5a51cd44726f055b635176188137aff42c7de"
|
||||
|
|
|
@ -99,4 +99,4 @@ webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
|||
webvr_traits = {path = "../webvr_traits"}
|
||||
|
||||
[target.'cfg(not(target_os = "ios"))'.dependencies]
|
||||
angle = {git = "https://github.com/servo/angle", branch = "servo"}
|
||||
mozangle = "0.1"
|
||||
|
|
|
@ -31,6 +31,46 @@ pub struct WebGLProgram {
|
|||
renderer: WebGLMsgSender,
|
||||
}
|
||||
|
||||
/// ANGLE adds a `_u` prefix to variable names:
|
||||
///
|
||||
/// https://chromium.googlesource.com/angle/angle/+/855d964bd0d05f6b2cb303f625506cf53d37e94f
|
||||
///
|
||||
/// To avoid hard-coding this we would need to use the `sh::GetAttributes` and `sh::GetUniforms`
|
||||
/// API to look up the `x.name` and `x.mappedName` members,
|
||||
/// then build a data structure for bi-directional lookup (so either linear scan or two hashmaps).
|
||||
/// Even then, this would probably only support plain variable names like "foo".
|
||||
/// Strings passed to e.g. `GetUniformLocation` can be expressions like "foo[0].bar",
|
||||
/// with the mapping for that "bar" name in yet another part of ANGLE’s API.
|
||||
const ANGLE_NAME_PREFIX: &'static str = "_u";
|
||||
|
||||
fn to_name_in_compiled_shader(s: &str) -> String {
|
||||
map_dot_separated(s, |s, mapped| {
|
||||
mapped.push_str(ANGLE_NAME_PREFIX);
|
||||
mapped.push_str(s);
|
||||
})
|
||||
}
|
||||
|
||||
fn from_name_in_compiled_shader(s: &str) -> String {
|
||||
map_dot_separated(s, |s, mapped| {
|
||||
mapped.push_str(if s.starts_with(ANGLE_NAME_PREFIX) {
|
||||
&s[ANGLE_NAME_PREFIX.len()..]
|
||||
} else {
|
||||
s
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn map_dot_separated<F: Fn(&str, &mut String)>(s: &str, f: F) -> String {
|
||||
let mut iter = s.split('.');
|
||||
let mut mapped = String::new();
|
||||
f(iter.next().unwrap(), &mut mapped);
|
||||
for s in iter {
|
||||
mapped.push('.');
|
||||
f(s, &mut mapped);
|
||||
}
|
||||
mapped
|
||||
}
|
||||
|
||||
impl WebGLProgram {
|
||||
fn new_inherited(renderer: WebGLMsgSender,
|
||||
id: WebGLProgramId)
|
||||
|
@ -213,8 +253,10 @@ impl WebGLProgram {
|
|||
return Err(WebGLError::InvalidOperation);
|
||||
}
|
||||
|
||||
let name = to_name_in_compiled_shader(&name);
|
||||
|
||||
self.renderer
|
||||
.send(WebGLCommand::BindAttribLocation(self.id, index, String::from(name)))
|
||||
.send(WebGLCommand::BindAttribLocation(self.id, index, name))
|
||||
.unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
@ -228,8 +270,10 @@ impl WebGLProgram {
|
|||
.send(WebGLCommand::GetActiveUniform(self.id, index, sender))
|
||||
.unwrap();
|
||||
|
||||
receiver.recv().unwrap().map(|(size, ty, name)|
|
||||
WebGLActiveInfo::new(self.global().as_window(), size, ty, DOMString::from(name)))
|
||||
receiver.recv().unwrap().map(|(size, ty, name)| {
|
||||
let name = DOMString::from(from_name_in_compiled_shader(&name));
|
||||
WebGLActiveInfo::new(self.global().as_window(), size, ty, name)
|
||||
})
|
||||
}
|
||||
|
||||
/// glGetActiveAttrib
|
||||
|
@ -242,8 +286,10 @@ impl WebGLProgram {
|
|||
.send(WebGLCommand::GetActiveAttrib(self.id, index, sender))
|
||||
.unwrap();
|
||||
|
||||
receiver.recv().unwrap().map(|(size, ty, name)|
|
||||
WebGLActiveInfo::new(self.global().as_window(), size, ty, DOMString::from(name)))
|
||||
receiver.recv().unwrap().map(|(size, ty, name)| {
|
||||
let name = DOMString::from(from_name_in_compiled_shader(&name));
|
||||
WebGLActiveInfo::new(self.global().as_window(), size, ty, name)
|
||||
})
|
||||
}
|
||||
|
||||
/// glGetAttribLocation
|
||||
|
@ -264,9 +310,11 @@ impl WebGLProgram {
|
|||
return Ok(None);
|
||||
}
|
||||
|
||||
let name = to_name_in_compiled_shader(&name);
|
||||
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
self.renderer
|
||||
.send(WebGLCommand::GetAttribLocation(self.id, String::from(name), sender))
|
||||
.send(WebGLCommand::GetAttribLocation(self.id, name, sender))
|
||||
.unwrap();
|
||||
Ok(receiver.recv().unwrap())
|
||||
}
|
||||
|
@ -285,9 +333,11 @@ impl WebGLProgram {
|
|||
return Ok(None);
|
||||
}
|
||||
|
||||
let name = to_name_in_compiled_shader(&name);
|
||||
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
self.renderer
|
||||
.send(WebGLCommand::GetUniformLocation(self.id, String::from(name), sender))
|
||||
.send(WebGLCommand::GetUniformLocation(self.id, name, sender))
|
||||
.unwrap();
|
||||
Ok(receiver.recv().unwrap())
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||
use angle::hl::{BuiltInResources, Output, ShaderValidator};
|
||||
use canvas_traits::webgl::{WebGLSLVersion, WebGLVersion};
|
||||
use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLMsgSender, WebGLParameter, WebGLResult, WebGLShaderId};
|
||||
use dom::bindings::cell::DomRefCell;
|
||||
|
@ -16,6 +15,7 @@ use dom::webgl_extensions::ext::oesstandardderivatives::OESStandardDerivatives;
|
|||
use dom::webglobject::WebGLObject;
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use mozangle::shaders::{BuiltInResources, Output, ShaderValidator};
|
||||
use std::cell::Cell;
|
||||
use std::sync::{ONCE_INIT, Once};
|
||||
|
||||
|
@ -47,7 +47,7 @@ impl WebGLShader {
|
|||
id: WebGLShaderId,
|
||||
shader_type: u32)
|
||||
-> WebGLShader {
|
||||
GLSLANG_INITIALIZATION.call_once(|| ::angle::hl::initialize().unwrap());
|
||||
GLSLANG_INITIALIZATION.call_once(|| ::mozangle::shaders::initialize().unwrap());
|
||||
WebGLShader {
|
||||
webgl_object: WebGLObject::new_inherited(),
|
||||
id: id,
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#![plugin(script_plugins)]
|
||||
#![cfg_attr(not(feature = "unrooted_must_root_lint"), allow(unknown_lints))]
|
||||
|
||||
extern crate angle;
|
||||
extern crate app_units;
|
||||
extern crate audio_video_metadata;
|
||||
extern crate base64;
|
||||
|
@ -64,6 +63,7 @@ extern crate metrics;
|
|||
extern crate mime;
|
||||
extern crate mime_guess;
|
||||
extern crate mitochondria;
|
||||
extern crate mozangle;
|
||||
#[macro_use]
|
||||
extern crate mozjs as js;
|
||||
extern crate msg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue