mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
replace packed_simd
with new simd, reenabled simd on world
This commit is contained in:
parent
5f41aefacb
commit
667d1aa8f0
@ -20,7 +20,7 @@ bin_compression = [
|
||||
]
|
||||
cli = ["clap", "signal-hook", "indicatif"]
|
||||
|
||||
default = []
|
||||
default = ["simd"]
|
||||
|
||||
[dependencies]
|
||||
common = { package = "veloren-common", path = "../common" }
|
||||
|
@ -23,7 +23,7 @@ use common::{
|
||||
generation::{ChunkSupplement, EntityInfo},
|
||||
lottery::Lottery,
|
||||
terrain::{Block, BlockKind, SpriteKind},
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, WriteVol},
|
||||
vol::{ReadVol, RectSizedVol, WriteVol},
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use noise::NoiseFn;
|
||||
@ -576,7 +576,7 @@ pub fn apply_caves_supplement<'a>(
|
||||
dynamic_rng: &mut impl Rng,
|
||||
wpos2d: Vec2<i32>,
|
||||
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
vol: &(impl BaseVol<Vox = Block> + RectSizedVol + ReadVol + WriteVol),
|
||||
vol: &(impl RectSizedVol<Vox = Block> + ReadVol + WriteVol),
|
||||
index: IndexRef,
|
||||
supplement: &mut ChunkSupplement,
|
||||
) {
|
||||
|
@ -6,7 +6,7 @@ use common::{
|
||||
resources::TimeOfDay,
|
||||
terrain::{BiomeKind, Block},
|
||||
time::DayPeriod,
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, WriteVol},
|
||||
vol::{ReadVol, RectSizedVol, WriteVol},
|
||||
};
|
||||
use rand::prelude::*;
|
||||
use serde::Deserialize;
|
||||
@ -554,7 +554,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
||||
dynamic_rng: &mut R,
|
||||
wpos2d: Vec2<i32>,
|
||||
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
vol: &(impl BaseVol<Vox = Block> + RectSizedVol + ReadVol + WriteVol),
|
||||
vol: &(impl RectSizedVol<Vox = Block> + ReadVol + WriteVol),
|
||||
index: IndexRef,
|
||||
chunk: &SimChunk,
|
||||
supplement: &mut ChunkSupplement,
|
||||
@ -587,8 +587,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
||||
|
||||
let entity_group = scatter
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(_i, (entry, get_density))| {
|
||||
.filter_map(|(entry, get_density)| {
|
||||
let density = get_density(chunk, col_sample) * wildlife_density_modifier;
|
||||
(density > 0.0)
|
||||
.then(|| {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#![allow(clippy::branches_sharing_code)] // TODO: evaluate
|
||||
#![deny(clippy::clone_on_ref_ptr)]
|
||||
#![feature(option_zip, let_chains)]
|
||||
#![cfg_attr(feature = "simd", feature(portable_simd))]
|
||||
|
||||
mod all;
|
||||
mod block;
|
||||
|
@ -13,14 +13,12 @@ use itertools::izip;
|
||||
use noise::NoiseFn;
|
||||
use num::{Float, Zero};
|
||||
use ordered_float::NotNan;
|
||||
#[cfg(feature = "simd")] use packed_simd::m32;
|
||||
use rayon::prelude::*;
|
||||
use std::{
|
||||
cmp::{Ordering, Reverse},
|
||||
collections::BinaryHeap,
|
||||
f32, fmt, mem,
|
||||
fmt, mem,
|
||||
time::Instant,
|
||||
u32,
|
||||
};
|
||||
use vek::*;
|
||||
|
||||
@ -609,15 +607,17 @@ fn get_max_slope(
|
||||
#[cfg(not(feature = "simd"))]
|
||||
#[derive(Copy, Clone)]
|
||||
#[allow(non_camel_case_types)]
|
||||
struct m32(u32);
|
||||
struct M32(u32);
|
||||
#[cfg(not(feature = "simd"))]
|
||||
impl m32 {
|
||||
impl M32 {
|
||||
#[inline]
|
||||
fn new(x: bool) -> Self { if x { Self(u32::MAX) } else { Self(u32::MIN) } }
|
||||
fn splat(x: bool) -> Self { if x { Self(u32::MAX) } else { Self(u32::MIN) } }
|
||||
|
||||
#[inline]
|
||||
fn test(&self) -> bool { self.0 != 0 }
|
||||
fn test(&self, cmp: u32) -> bool { self.0 != cmp }
|
||||
}
|
||||
#[cfg(feature = "simd")]
|
||||
type M32 = std::simd::Mask<i32, 1>;
|
||||
|
||||
/// Erode all chunks by amount.
|
||||
///
|
||||
@ -862,7 +862,7 @@ fn erode(
|
||||
let mid_slope = (30.0 / 360.0 * 2.0 * std::f64::consts::PI).tan();
|
||||
|
||||
type SimdType = f32;
|
||||
type MaskType = m32;
|
||||
type MaskType = M32;
|
||||
|
||||
// Precompute factors for Stream Power Law.
|
||||
let czero = <SimdType as Zero>::zero();
|
||||
@ -1316,7 +1316,7 @@ fn erode(
|
||||
let tolp = 1.0e-3;
|
||||
let mut errp = 2.0 * tolp;
|
||||
let mut rec_heights = [0.0; 8];
|
||||
let mut mask = [MaskType::new(false); 8];
|
||||
let mut mask = [MaskType::splat(false); 8];
|
||||
mrec_downhill(map_size_lg, &mrec, posi).for_each(|(kk, posj)| {
|
||||
let posj_stack = mstack_inv[posj];
|
||||
let h_j = h_stack[posj_stack];
|
||||
@ -1324,7 +1324,7 @@ fn erode(
|
||||
// + uplift(posj) as f64
|
||||
// NOTE: We also considered using old_elev_i > wh[posj] here.
|
||||
if old_elev_i > h_j {
|
||||
mask[kk] = MaskType::new(true);
|
||||
mask[kk] = MaskType::splat(true);
|
||||
rec_heights[kk] = h_j as SimdType;
|
||||
}
|
||||
});
|
||||
@ -1333,7 +1333,7 @@ fn erode(
|
||||
let mut df = 1.0;
|
||||
izip!(&mask, &rec_heights, k_fs_fact, k_df_fact).for_each(
|
||||
|(&mask_kk, &rec_heights_kk, &k_fs_fact_kk, &k_df_fact_kk)| {
|
||||
if mask_kk.test() {
|
||||
if mask_kk.test(0) {
|
||||
let h_j = rec_heights_kk;
|
||||
let elev_j = h_j;
|
||||
let dh = 0.0.max(new_h_i as SimdType - elev_j);
|
||||
|
@ -858,8 +858,7 @@ impl WorldSim {
|
||||
(gen_ctx
|
||||
.alt_nz
|
||||
.get((wposf.div(10_000.0)).into_array())
|
||||
.min(1.0)
|
||||
.max(-1.0))
|
||||
.clamp(-1.0, 1.0))
|
||||
.sub(0.05)
|
||||
.mul(0.35),
|
||||
)
|
||||
@ -871,8 +870,7 @@ impl WorldSim {
|
||||
(gen_ctx
|
||||
.alt_nz
|
||||
.get((wposf.div(5_000.0 * gen_opts.scale)).into_array())
|
||||
.min(1.0)
|
||||
.max(-1.0))
|
||||
.clamp(-1.0, 1.0))
|
||||
.add(
|
||||
0.2 - ((wposf / world_sizef) * 2.0 - 1.0)
|
||||
.magnitude_squared()
|
||||
|
@ -7,7 +7,7 @@ use common_base::prof_span;
|
||||
use noise::{MultiFractal, NoiseFn, Perlin, Seedable};
|
||||
use num::Float;
|
||||
use rayon::prelude::*;
|
||||
use std::{f32, f64, ops::Mul, u32};
|
||||
use std::ops::Mul;
|
||||
use vek::*;
|
||||
|
||||
/// Calculates the smallest distance along an axis (x, y) from an edge of
|
||||
|
@ -14,7 +14,7 @@ use crate::{
|
||||
use common::{
|
||||
generation::ChunkSupplement,
|
||||
terrain::{Block, BlockKind, SpriteKind},
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, WriteVol},
|
||||
vol::{ReadVol, RectSizedVol, WriteVol},
|
||||
};
|
||||
use core::f32;
|
||||
use rand::prelude::*;
|
||||
@ -190,7 +190,7 @@ impl Castle {
|
||||
index: IndexRef,
|
||||
wpos2d: Vec2<i32>,
|
||||
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
vol: &mut (impl BaseVol<Vox = Block> + RectSizedVol + ReadVol + WriteVol),
|
||||
vol: &mut (impl RectSizedVol<Vox = Block> + ReadVol + WriteVol),
|
||||
) {
|
||||
for y in 0..vol.size_xy().y as i32 {
|
||||
for x in 0..vol.size_xy().x as i32 {
|
||||
|
@ -30,7 +30,7 @@ use common::{
|
||||
store::{Id, Store},
|
||||
terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize},
|
||||
trade::{Good, SiteInformation},
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, RectVolSize, WriteVol},
|
||||
vol::{ReadVol, RectSizedVol, RectVolSize, WriteVol},
|
||||
};
|
||||
|
||||
use fxhash::FxHasher64;
|
||||
@ -560,7 +560,7 @@ impl Settlement {
|
||||
index: IndexRef,
|
||||
wpos2d: Vec2<i32>,
|
||||
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
|
||||
vol: &mut (impl BaseVol<Vox = Block> + RectSizedVol + ReadVol + WriteVol),
|
||||
vol: &mut (impl RectSizedVol<Vox = Block> + ReadVol + WriteVol),
|
||||
) {
|
||||
let colors = &index.colors.site.settlement;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user