use super::*;
use crate::shared::*;
use simdeez::avx2::*;
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
use std::f32;
#[target_feature(enable = "avx2")]
pub unsafe fn cellular_2d(
x: __m256,
y: __m256,
distance_function: CellDistanceFunction,
return_type: CellReturnType,
jitter: __m256,
seed: i32,
) -> __m256 {
cellular::cellular_2d::<Avx2>(
F32x8(x),
F32x8(y),
distance_function,
return_type,
F32x8(jitter),
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn cellular_3d(
x: __m256,
y: __m256,
z: __m256,
distance_function: CellDistanceFunction,
return_type: CellReturnType,
jitter: __m256,
seed: i32,
) -> __m256 {
cellular::cellular_3d::<Avx2>(
F32x8(x),
F32x8(y),
F32x8(z),
distance_function,
return_type,
F32x8(jitter),
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn simplex_1d(x: __m256, seed: i32) -> __m256 {
simplex::simplex_1d::<Avx2>(F32x8(x), seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn fbm_1d(
x: __m256,
lacunarity: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::fbm_1d::<Avx2>(F32x8(x), F32x8(lacunarity), F32x8(gain), octaves, seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn ridge_1d(
x: __m256,
lacunarity: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::ridge_1d::<Avx2>(F32x8(x), F32x8(lacunarity), F32x8(gain), octaves, seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn turbulence_1d(
x: __m256,
lacunarity: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::turbulence_1d::<Avx2>(F32x8(x), F32x8(lacunarity), F32x8(gain), octaves, seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_1d_noise(noise_type: &NoiseType) -> (Vec<f32>, f32, f32) {
noise_helpers::get_1d_noise::<Avx2>(noise_type)
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_1d_scaled_noise(noise_type: &NoiseType) -> Vec<f32> {
let (mut noise, min, max) = get_1d_noise(noise_type);
let dim = noise_type.get_dimensions();
scale_noise::<Avx2>(dim.min, dim.max, min, max, &mut noise);
noise
}
#[target_feature(enable = "avx2")]
pub unsafe fn simplex_2d(x: __m256, y: __m256, seed: i32) -> __m256 {
simplex::simplex_2d::<Avx2>(F32x8(x), F32x8(y), seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn fbm_2d(
x: __m256,
y: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::fbm_2d::<Avx2>(F32x8(x), F32x8(y), F32x8(lac), F32x8(gain), octaves, seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn ridge_2d(
x: __m256,
y: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::ridge_2d::<Avx2>(F32x8(x), F32x8(y), F32x8(lac), F32x8(gain), octaves, seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn turbulence_2d(
x: __m256,
y: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::turbulence_2d::<Avx2>(F32x8(x), F32x8(y), F32x8(lac), F32x8(gain), octaves, seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_2d_noise(noise_type: &NoiseType) -> (Vec<f32>, f32, f32) {
noise_helpers::get_2d_noise::<Avx2>(noise_type)
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_2d_scaled_noise(noise_type: &NoiseType) -> Vec<f32> {
let (mut noise, min, max) = get_2d_noise(noise_type);
let dim = noise_type.get_dimensions();
scale_noise::<Avx2>(dim.min, dim.max, min, max, &mut noise);
noise
}
#[target_feature(enable = "avx2")]
pub unsafe fn simplex_3d(x: __m256, y: __m256, z: __m256, seed: i32) -> __m256 {
simplex::simplex_3d::<Avx2>(F32x8(x), F32x8(y), F32x8(z), seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn fbm_3d(
x: __m256,
y: __m256,
z: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::fbm_3d::<Avx2>(
F32x8(x),
F32x8(y),
F32x8(z),
F32x8(lac),
F32x8(gain),
octaves,
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn ridge_3d(
x: __m256,
y: __m256,
z: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::ridge_3d::<Avx2>(
F32x8(x),
F32x8(y),
F32x8(z),
F32x8(lac),
F32x8(gain),
octaves,
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn turbulence_3d(
x: __m256,
y: __m256,
z: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::turbulence_3d::<Avx2>(
F32x8(x),
F32x8(y),
F32x8(z),
F32x8(lac),
F32x8(gain),
octaves,
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_3d_noise(noise_type: &NoiseType) -> (Vec<f32>, f32, f32) {
noise_helpers::get_3d_noise::<Avx2>(noise_type)
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_3d_scaled_noise(noise_type: &NoiseType) -> Vec<f32> {
let (mut noise, min, max) = get_3d_noise(noise_type);
let dim = noise_type.get_dimensions();
scale_noise::<Avx2>(dim.min, dim.max, min, max, &mut noise);
noise
}
#[target_feature(enable = "avx2")]
pub unsafe fn simplex_4d(x: __m256, y: __m256, z: __m256, w: __m256, seed: i32) -> __m256 {
simplex::simplex_4d::<Avx2>(F32x8(x), F32x8(y), F32x8(z), F32x8(w), seed).0
}
#[target_feature(enable = "avx2")]
pub unsafe fn fbm_4d(
x: __m256,
y: __m256,
z: __m256,
w: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::fbm_4d::<Avx2>(
F32x8(x),
F32x8(y),
F32x8(z),
F32x8(w),
F32x8(lac),
F32x8(gain),
octaves,
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn ridge_4d(
x: __m256,
y: __m256,
z: __m256,
w: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::ridge_4d::<Avx2>(
F32x8(x),
F32x8(y),
F32x8(z),
F32x8(w),
F32x8(lac),
F32x8(gain),
octaves,
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn turbulence_4d(
x: __m256,
y: __m256,
z: __m256,
w: __m256,
lac: __m256,
gain: __m256,
octaves: u8,
seed: i32,
) -> __m256 {
simplex::turbulence_4d::<Avx2>(
F32x8(x),
F32x8(y),
F32x8(z),
F32x8(w),
F32x8(lac),
F32x8(gain),
octaves,
seed,
)
.0
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_4d_noise(noise_type: &NoiseType) -> (Vec<f32>, f32, f32) {
noise_helpers::get_4d_noise::<Avx2>(noise_type)
}
#[target_feature(enable = "avx2")]
pub unsafe fn get_4d_scaled_noise(noise_type: &NoiseType) -> Vec<f32> {
let (mut noise, min, max) = get_4d_noise(noise_type);
let dim = noise_type.get_dimensions();
scale_noise::<Avx2>(dim.min, dim.max, min, max, &mut noise);
noise
}