From 112af22a4e0305cbe9245e11adcaa5954efd3175 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Mon, 17 Apr 2017 18:48:56 +0200 Subject: [PATCH] Implement GetShaderPrecisionFormat WebGL command --- Cargo.lock | 30 +++++++++++++++--------------- webrender/Cargo.toml | 4 ++-- webrender_traits/Cargo.toml | 2 +- webrender_traits/src/webgl.rs | 26 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c933979630..3b17dabfc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,7 +11,7 @@ dependencies = [ "dwrote 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "font-loader 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "osmesa-src 12.0.1 (git+https://github.com/servo/osmesa-src)", @@ -21,8 +21,8 @@ dependencies = [ "serde_json 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", "servo-glutin 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender 0.32.0", - "webrender_traits 0.33.0", + "webrender 0.33.0", + "webrender_traits 0.34.0", "yaml-rust 0.3.4 (git+https://github.com/vvuk/yaml-rust)", ] @@ -117,7 +117,7 @@ name = "cgl" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gleam 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -345,7 +345,7 @@ dependencies = [ [[package]] name = "gleam" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -578,7 +578,7 @@ dependencies = [ "euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -861,7 +861,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "webrender" -version = "0.32.0" +version = "0.33.0" dependencies = [ "angle 0.1.2 (git+https://github.com/servo/angle?branch=servo)", "app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -876,7 +876,7 @@ dependencies = [ "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gamma-lut 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", @@ -884,19 +884,19 @@ dependencies = [ "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.33.0", + "webrender_traits 0.34.0", ] [[package]] name = "webrender_traits" -version = "0.33.0" +version = "0.34.0" dependencies = [ "app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -920,10 +920,10 @@ version = "0.2.0" dependencies = [ "app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "servo-glutin 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender 0.32.0", - "webrender_traits 0.33.0", + "webrender 0.33.0", + "webrender_traits 0.34.0", ] [[package]] @@ -1015,7 +1015,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" "checksum gif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01c7c19a035de94bd7afbaa62c241aadfbdf1a70f560b348d2312eafa566ca16" "checksum gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1d8edc81c5ae84605a62f5dac661a2313003b26d59839f81d47d46cf0f16a55" -"checksum gleam 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3232655dbe4fc5ab688c05024f2c816b5d20c19ad8216d5c7d85cf915b24e005" +"checksum gleam 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9c46ff982a2e6abed1f50b3077d3176836875d9720906b248335f4c93827a345" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88" "checksum image 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "979bad0502082fd60053a490282e87d6c89650942e3a270e0d4c83569c7f5899" diff --git a/webrender/Cargo.toml b/webrender/Cargo.toml index 30a91dbeba..05abaa6acf 100644 --- a/webrender/Cargo.toml +++ b/webrender/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webrender" -version = "0.32.0" +version = "0.33.0" authors = ["Glenn Watson "] license = "MPL-2.0" repository = "https://github.com/servo/webrender" @@ -19,7 +19,7 @@ bit-set = "0.4" byteorder = "1.0" euclid = "0.11" fnv = "1.0" -gleam = "0.4.2" +gleam = "0.4.3" lazy_static = "0.2" log = "0.3" num-traits = "0.1.32" diff --git a/webrender_traits/Cargo.toml b/webrender_traits/Cargo.toml index f5c73991d0..8b3961707a 100644 --- a/webrender_traits/Cargo.toml +++ b/webrender_traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webrender_traits" -version = "0.33.0" +version = "0.34.0" authors = ["Glenn Watson "] license = "MPL-2.0" repository = "https://github.com/servo/webrender" diff --git a/webrender_traits/src/webgl.rs b/webrender_traits/src/webgl.rs index e3e84b65f6..c2d6341e55 100644 --- a/webrender_traits/src/webgl.rs +++ b/webrender_traits/src/webgl.rs @@ -66,6 +66,7 @@ pub enum WebGLCommand { GetParameter(u32, MsgSender>), GetProgramParameter(WebGLProgramId, u32, MsgSender>), GetShaderParameter(WebGLShaderId, u32, MsgSender>), + GetShaderPrecisionFormat(u32, u32, MsgSender>), GetActiveAttrib(WebGLProgramId, u32, MsgSender>), GetActiveUniform(WebGLProgramId, u32, MsgSender>), GetAttribLocation(WebGLProgramId, String, MsgSender>), @@ -315,6 +316,7 @@ impl fmt::Debug for WebGLCommand { GetParameter(..) => "GetParameter", GetProgramParameter(..) => "GetProgramParameter", GetShaderParameter(..) => "GetShaderParameter", + GetShaderPrecisionFormat(..) => "GetShaderPrecisionFormat", GetActiveAttrib(..) => "GetActiveAttrib", GetActiveUniform(..) => "GetActiveUniform", GetAttribLocation(..) => "GetAttribLocation", @@ -492,6 +494,8 @@ impl WebGLCommand { Self::program_parameter(ctx.gl(), program_id, param_id, chan), WebGLCommand::GetShaderParameter(shader_id, param_id, chan) => Self::shader_parameter(ctx.gl(), shader_id, param_id, chan), + WebGLCommand::GetShaderPrecisionFormat(shader_type, precision_type, chan) => + Self::shader_precision_format(ctx.gl(), shader_type, precision_type, chan), WebGLCommand::GetUniformLocation(program_id, name, chan) => Self::uniform_location(ctx.gl(), program_id, name, chan), WebGLCommand::GetShaderInfoLog(shader_id, chan) => @@ -856,6 +860,28 @@ impl WebGLCommand { chan.send(result).unwrap(); } + fn shader_precision_format(gl: &gl::Gl, + shader_type: u32, + precision_type: u32, + chan: MsgSender>) { + + let result = match precision_type { + gl::LOW_FLOAT | + gl::MEDIUM_FLOAT | + gl::HIGH_FLOAT | + gl::LOW_INT | + gl::MEDIUM_INT | + gl::HIGH_INT => { + Ok(gl.get_shader_precision_format(shader_type, precision_type)) + }, + _=> { + Err(WebGLError::InvalidEnum) + } + }; + + chan.send(result).unwrap(); + } + fn uniform_location(gl: &gl::Gl, program_id: WebGLProgramId, name: String,