mirror of
https://github.com/robbert-vdh/nih-plug.git
synced 2026-07-01 02:36:54 +00:00
Update use of night SIMD API
`LaneCount` and `SupportedLaneCount` were dropped from the `portable_simd` API, which is now supposed to emulate the target lane count if the CPU does not natively support it.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
#[cfg(feature = "simd")]
|
#[cfg(feature = "simd")]
|
||||||
use std::simd::{LaneCount, Simd, SupportedLaneCount};
|
use std::simd::Simd;
|
||||||
|
|
||||||
use super::SamplesIter;
|
use super::SamplesIter;
|
||||||
|
|
||||||
@@ -226,10 +226,7 @@ impl<'slice, 'sample> Block<'slice, 'sample> {
|
|||||||
pub fn to_channel_simd<const LANES: usize>(
|
pub fn to_channel_simd<const LANES: usize>(
|
||||||
&self,
|
&self,
|
||||||
sample_index: usize,
|
sample_index: usize,
|
||||||
) -> Option<Simd<f32, LANES>>
|
) -> Option<Simd<f32, LANES>> {
|
||||||
where
|
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
if sample_index > self.samples() {
|
if sample_index > self.samples() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -258,10 +255,7 @@ impl<'slice, 'sample> Block<'slice, 'sample> {
|
|||||||
pub unsafe fn to_channel_simd_unchecked<const LANES: usize>(
|
pub unsafe fn to_channel_simd_unchecked<const LANES: usize>(
|
||||||
&self,
|
&self,
|
||||||
sample_index: usize,
|
sample_index: usize,
|
||||||
) -> Simd<f32, LANES>
|
) -> Simd<f32, LANES> {
|
||||||
where
|
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
let mut values = [0.0; LANES];
|
let mut values = [0.0; LANES];
|
||||||
for (channel_idx, value) in values.iter_mut().enumerate() {
|
for (channel_idx, value) in values.iter_mut().enumerate() {
|
||||||
*value = *(&(*self.buffers))
|
*value = *(&(*self.buffers))
|
||||||
@@ -284,10 +278,7 @@ impl<'slice, 'sample> Block<'slice, 'sample> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
sample_index: usize,
|
sample_index: usize,
|
||||||
vector: Simd<f32, LANES>,
|
vector: Simd<f32, LANES>,
|
||||||
) -> bool
|
) -> bool {
|
||||||
where
|
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
if sample_index > self.samples() {
|
if sample_index > self.samples() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -319,9 +310,7 @@ impl<'slice, 'sample> Block<'slice, 'sample> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
sample_index: usize,
|
sample_index: usize,
|
||||||
vector: Simd<f32, LANES>,
|
vector: Simd<f32, LANES>,
|
||||||
) where
|
) {
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
let values = vector.to_array();
|
let values = vector.to_array();
|
||||||
for (channel_idx, value) in values.into_iter().enumerate() {
|
for (channel_idx, value) in values.into_iter().enumerate() {
|
||||||
*(&mut (*self.buffers))
|
*(&mut (*self.buffers))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
#[cfg(feature = "simd")]
|
#[cfg(feature = "simd")]
|
||||||
use std::simd::{LaneCount, Simd, SupportedLaneCount};
|
use std::simd::Simd;
|
||||||
|
|
||||||
/// An iterator over all samples in a buffer or block, yielding iterators over each channel for
|
/// An iterator over all samples in a buffer or block, yielding iterators over each channel for
|
||||||
/// every sample. This iteration order offers good cache locality for per-sample access.
|
/// every sample. This iteration order offers good cache locality for per-sample access.
|
||||||
@@ -168,10 +168,7 @@ impl<'slice, 'sample> ChannelSamples<'slice, 'sample> {
|
|||||||
/// all values.
|
/// all values.
|
||||||
#[cfg(feature = "simd")]
|
#[cfg(feature = "simd")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_simd<const LANES: usize>(&self) -> Simd<f32, LANES>
|
pub fn to_simd<const LANES: usize>(&self) -> Simd<f32, LANES> {
|
||||||
where
|
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
let used_lanes = self.len().max(LANES);
|
let used_lanes = self.len().max(LANES);
|
||||||
let mut values = [0.0; LANES];
|
let mut values = [0.0; LANES];
|
||||||
for (channel_idx, value) in values.iter_mut().enumerate().take(used_lanes) {
|
for (channel_idx, value) in values.iter_mut().enumerate().take(used_lanes) {
|
||||||
@@ -193,10 +190,7 @@ impl<'slice, 'sample> ChannelSamples<'slice, 'sample> {
|
|||||||
/// Undefined behavior if `LANES > channels.len()`.
|
/// Undefined behavior if `LANES > channels.len()`.
|
||||||
#[cfg(feature = "simd")]
|
#[cfg(feature = "simd")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn to_simd_unchecked<const LANES: usize>(&self) -> Simd<f32, LANES>
|
pub unsafe fn to_simd_unchecked<const LANES: usize>(&self) -> Simd<f32, LANES> {
|
||||||
where
|
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
let mut values = [0.0; LANES];
|
let mut values = [0.0; LANES];
|
||||||
for (channel_idx, value) in values.iter_mut().enumerate() {
|
for (channel_idx, value) in values.iter_mut().enumerate() {
|
||||||
*value = *(&(*self.buffers))
|
*value = *(&(*self.buffers))
|
||||||
@@ -212,10 +206,7 @@ impl<'slice, 'sample> ChannelSamples<'slice, 'sample> {
|
|||||||
#[cfg(feature = "simd")]
|
#[cfg(feature = "simd")]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_simd<const LANES: usize>(&mut self, vector: Simd<f32, LANES>)
|
pub fn from_simd<const LANES: usize>(&mut self, vector: Simd<f32, LANES>) {
|
||||||
where
|
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
let used_lanes = self.len().max(LANES);
|
let used_lanes = self.len().max(LANES);
|
||||||
let values = vector.to_array();
|
let values = vector.to_array();
|
||||||
for (channel_idx, value) in values.into_iter().enumerate().take(used_lanes) {
|
for (channel_idx, value) in values.into_iter().enumerate().take(used_lanes) {
|
||||||
@@ -236,10 +227,7 @@ impl<'slice, 'sample> ChannelSamples<'slice, 'sample> {
|
|||||||
#[cfg(feature = "simd")]
|
#[cfg(feature = "simd")]
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_simd_unchecked<const LANES: usize>(&mut self, vector: Simd<f32, LANES>)
|
pub unsafe fn from_simd_unchecked<const LANES: usize>(&mut self, vector: Simd<f32, LANES>) {
|
||||||
where
|
|
||||||
LaneCount<LANES>: SupportedLaneCount,
|
|
||||||
{
|
|
||||||
let values = vector.to_array();
|
let values = vector.to_array();
|
||||||
for (channel_idx, value) in values.into_iter().enumerate() {
|
for (channel_idx, value) in values.into_iter().enumerate() {
|
||||||
*(&mut (*self.buffers))
|
*(&mut (*self.buffers))
|
||||||
|
|||||||
Reference in New Issue
Block a user