Browse Source

Add links to README. Add union to simd::Vector for serially accessing vector elements.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
aa088e369a
4 changed files with 27 additions and 14 deletions
  1. +5
    -1
      README.md
  2. +1
    -1
      include/helpers.hpp
  3. +19
    -12
      include/simd/vector.hpp
  4. +2
    -0
      src/plugin/Plugin.cpp

+ 5
- 1
README.md View File

@@ -2,4 +2,8 @@

*Rack* is the engine for the VCV open-source virtual modular synthesizer.

For information about the software, go to the [VCV website](https://vcvrack.com/) or the [VCV Rack manual](https://vcvrack.com/manual/).
- [VCV website](https://vcvrack.com/)
- [Manual](https://vcvrack.com/manual/index.html)
- [Building](https://vcvrack.com/manual/Building.html)
- [Communities](https://vcvrack.com/manual/Communities.html)
- [Licenses](LICENSE.md)

+ 1
- 1
include/helpers.hpp View File

@@ -17,7 +17,7 @@ namespace rack {


template <class TModule, class TModuleWidget, typename... Tags>
plugin::Model *createModel(std::string slug) {
plugin::Model *createModel(const std::string &slug) {
struct TModel : plugin::Model {
engine::Module *createModule() override {
TModule *m = new TModule;


+ 19
- 12
include/simd/vector.hpp View File

@@ -48,32 +48,41 @@ struct Vector;
*/
template <>
struct Vector<float, 4> {
__m128 v;
union {
__m128 v;
float f[4];
};

/** Constructs an uninitialized vector. */
Vector<float, 4>() {}
Vector() {}

/** Constructs a vector from a native `__m128` type. */
Vector<float, 4>(__m128 v) : v(v) {}
Vector(__m128 v) : v(v) {}

/** Constructs a vector with all elements set to `x`. */
Vector<float, 4>(float x) {
Vector(float x) {
v = _mm_set_ps1(x);
}

/** Constructs a vector from four values. */
Vector<float, 4>(float x1, float x2, float x3, float x4) {
Vector(float x1, float x2, float x3, float x4) {
v = _mm_set_ps(x1, x2, x3, x4);
}

/** Returns a vector initialized to zero. */
static Vector<float, 4> zero() {
return Vector<float, 4>(_mm_setzero_ps());
static Vector zero() {
return Vector(_mm_setzero_ps());
}

/** Returns a vector with all 1 bits. */
static Vector mask() {
__m128 zero = _mm_setzero_ps();
return Vector(_mm_cmpeq_ps(zero, zero));
}

/** Reads an array of 4 values. */
static Vector<float, 4> load(const float *x) {
return Vector<float, 4>(_mm_loadu_ps(x));
static Vector load(const float *x) {
return Vector(_mm_loadu_ps(x));
}

/** Writes an array of 4 values. */
@@ -178,9 +187,7 @@ inline float_4 operator--(float_4 &a, int) {

/** `~a` */
inline float_4 operator~(const float_4 &a) {
float_4 mask = float_4::zero();
mask = (mask == mask);
return a ^ mask;
return a ^ float_4::mask();
}




+ 2
- 0
src/plugin/Plugin.cpp View File

@@ -1,5 +1,6 @@
#include <plugin/Plugin.hpp>
#include <plugin/Model.hpp>
#include <plugin.hpp>


namespace rack {
@@ -13,6 +14,7 @@ Plugin::~Plugin() {
}

void Plugin::addModel(Model *model) {
assert(isSlugValid(model->slug));
assert(!model->plugin);
model->plugin = this;
models.push_back(model);


Loading…
Cancel
Save