servo: Merge #15381 - Use SIMD in gfx when possible (from servo:simd); r=larsbergstrom

Source-Repo: https://github.com/servo/servo
Source-Revision: 725b805c45eedf96cd3b0b0ea10275470acf83bf

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : c119f6a9800fabce4c52edd946554f47e62a459c
This commit is contained in:
Mátyás Mustoha 2017-02-04 07:10:00 -08:00
parent c18143c779
commit 394041c153
4 changed files with 15 additions and 14 deletions

8
servo/Cargo.lock generated
View File

@ -998,7 +998,7 @@ dependencies = [
"servo_atoms 0.0.1",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"simd 0.1.1 (git+https://github.com/huonw/simd)",
"simd 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
@ -2701,8 +2701,8 @@ source = "git+https://github.com/pcwalton/signpost.git#7ed712507f343c38646b9d1fe
[[package]]
name = "simd"
version = "0.1.1"
source = "git+https://github.com/huonw/simd#0d85d25d5cc3788062b252e31ad48dd19e805e90"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "siphasher"
@ -3630,7 +3630,7 @@ dependencies = [
"checksum shell32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72f20b8f3c060374edb8046591ba28f62448c369ccbdc7b02075103fb3a9e38d"
"checksum sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c6649e43c1a1e68d29ed56d0dc3b5b6cf3b901da77cf107c4066b9e3da036df5"
"checksum signpost 0.1.0 (git+https://github.com/pcwalton/signpost.git)" = "<none>"
"checksum simd 0.1.1 (git+https://github.com/huonw/simd)" = "<none>"
"checksum simd 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a94d14a2ae1f1f110937de5fb69e494372560181c7e1739a097fcc2cee37ba0"
"checksum siphasher 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ffc669b726f2bc9a3bcff66e5e23b56ba6bf70e22a34c3d7b6d0b3450b65b84"
"checksum slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d807fd58c4181bbabed77cb3b891ba9748241a552bcc5be698faaebefc54f46e"
"checksum smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fcc8d19212aacecf95e4a7a2179b26f7aeb9732a915cf01f05b0d3e044865410"

View File

@ -56,8 +56,8 @@ core-text = "2.0"
freetype = "0.2"
servo-fontconfig = "0.2.1"
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
simd = {git = "https://github.com/huonw/simd"}
[target.'cfg(any(target_feature = "sse2", target_feature = "neon"))'.dependencies]
simd = "0.2.0"
[target.'cfg(target_os = "windows")'.dependencies]
dwrote = "0.1.5"

View File

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// For simd (currently x86_64/aarch64)
// For SIMD
#![feature(cfg_target_feature)]
#![cfg_attr(any(target_os = "linux", target_os = "android", target_os = "windows"), feature(heap_api))]
#![feature(alloc)]
@ -62,7 +63,7 @@ extern crate serde_derive;
extern crate servo_geometry;
extern crate servo_url;
#[macro_use] extern crate servo_atoms;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
extern crate simd;
extern crate smallvec;
extern crate style;

View File

@ -5,7 +5,7 @@
use app_units::Au;
use euclid::point::Point2D;
use range::{self, EachIndex, Range, RangeIndex};
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
use simd::u32x4;
use std::{fmt, mem, u16};
use std::cmp::{Ordering, PartialOrd};
@ -74,7 +74,7 @@ pub type GlyphId = u32;
// TODO: make this more type-safe.
const FLAG_CHAR_IS_SPACE: u32 = 0x40000000;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
const FLAG_CHAR_IS_SPACE_SHIFT: u32 = 30;
const FLAG_IS_SIMPLE_GLYPH: u32 = 0x80000000;
@ -591,7 +591,7 @@ impl<'a> GlyphStore {
}
#[inline]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
fn advance_for_byte_range_simple_glyphs(&self, range: &Range<ByteIndex>, extra_word_spacing: Au) -> Au {
let advance_mask = u32x4::splat(GLYPH_ADVANCE_MASK);
let space_flag_mask = u32x4::splat(FLAG_CHAR_IS_SPACE);
@ -632,16 +632,16 @@ impl<'a> GlyphStore {
Au(advance) + leftover_advance + extra_word_spacing * (spaces + leftover_spaces)
}
/// When SIMD isn't available (non-x86_x64/aarch64), fallback to the slow path.
/// When SIMD isn't available, fallback to the slow path.
#[inline]
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
#[cfg(not(any(target_feature = "sse2", target_feature = "neon")))]
fn advance_for_byte_range_simple_glyphs(&self, range: &Range<ByteIndex>, extra_word_spacing: Au) -> Au {
self.advance_for_byte_range_slow_path(range, extra_word_spacing)
}
/// Used for SIMD.
#[inline]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
#[allow(unsafe_code)]
fn transmute_entry_buffer_to_u32_buffer(&self) -> &[u32] {
unsafe { mem::transmute(self.entry_buffer.as_slice()) }