All Projects → redorav → Hlslpp

redorav / Hlslpp

Licence: mit
Math library using hlsl syntax with SSE/NEON support

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Hlslpp

Cglm
📽 Highly Optimized Graphics Math (glm) for C
Stars: ✭ 887 (+479.74%)
Mutual labels:  matrix, vector, sse, neon, math, avx
Libxsmm
Library for specialized dense and sparse matrix operations, and deep learning primitives.
Stars: ✭ 518 (+238.56%)
Mutual labels:  matrix, vector, sse, avx
hlml
vectorized high-level math library
Stars: ✭ 42 (-72.55%)
Mutual labels:  math, matrix, sse, hlsl
Mipp
MIPP is a portable wrapper for SIMD instructions written in C++11. It supports NEON, SSE, AVX and AVX-512.
Stars: ✭ 253 (+65.36%)
Mutual labels:  vector, sse, neon, avx
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+7545.75%)
Mutual labels:  game-development, shaders, hlsl
Joml
A Java math library for OpenGL rendering calculations
Stars: ✭ 479 (+213.07%)
Mutual labels:  matrix, vector, math
Simd
C++ image processing and machine learning library with using of SIMD: SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX-512, VMX(Altivec) and VSX(Power7), NEON for ARM.
Stars: ✭ 1,263 (+725.49%)
Mutual labels:  sse, neon, avx
Directxmath
DirectXMath is an all inline SIMD C++ linear algebra library for use in games and graphics apps
Stars: ✭ 859 (+461.44%)
Mutual labels:  sse, neon, avx
Algebra
means completeness and balancing, from the Arabic word الجبر
Stars: ✭ 92 (-39.87%)
Mutual labels:  matrix, vector, math
Umesimd
UME::SIMD A library for explicit simd vectorization.
Stars: ✭ 66 (-56.86%)
Mutual labels:  vector, neon, avx
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-76.47%)
Mutual labels:  matrix, vector, math
Std Simd
std::experimental::simd for GCC [ISO/IEC TS 19570:2018]
Stars: ✭ 275 (+79.74%)
Mutual labels:  sse, neon, avx
Xsimd
C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, NEON, AVX512)
Stars: ✭ 964 (+530.07%)
Mutual labels:  sse, neon, avx
Vc
SIMD Vector Classes for C++
Stars: ✭ 985 (+543.79%)
Mutual labels:  sse, neon, avx
vec-la-fp
↗️ A tiny (functional) 2d linear algebra library
Stars: ✭ 21 (-86.27%)
Mutual labels:  math, vector, matrix
SoftLight
A shader-based Software Renderer Using The LightSky Framework.
Stars: ✭ 2 (-98.69%)
Mutual labels:  shaders, neon, sse
Unisimd Assembler
SIMD macro assembler unified for ARM, MIPS, PPC and x86
Stars: ✭ 63 (-58.82%)
Mutual labels:  sse, neon, avx
Tensor
A library and extension that provides objects for scientific computing in PHP.
Stars: ✭ 146 (-4.58%)
Mutual labels:  math, vector, matrix
oversimple
A library for audio oversampling, which tries to offer a simple api while wrapping HIIR, by Laurent De Soras, for minimum phase antialiasing, and r8brain-free-src, by Aleksey Vaneev, for linear phase antialiasing.
Stars: ✭ 25 (-83.66%)
Mutual labels:  neon, avx, sse
Quadray Engine
Realtime raytracer using SIMD on ARM, MIPS, PPC and x86
Stars: ✭ 13 (-91.5%)
Mutual labels:  sse, neon, avx

MIT License AppVeyor

HLSL++

Small header-only math library for C++ with the same syntax as the hlsl shading language. It supports any SSE (x86/x64 devices like PC, Mac, PS4, Xbox One) and NEON (ARM devices like Android, iOS, Switch) platforms. It features swizzling and all the operators and functions from the hlsl documentation. The library is aimed mainly at game developers as it's meant to ease the C++ to shader bridge by providing common syntax, but can be used for any application requiring fast, portable math. It also adds some functionality that hlsl doesn't natively provide, such as convenient matrix functions, quaternions and extended vectors such as float8 (8-component float) that take advantage of wide SSE registers.

Example

hlsl++ allows you to be as expressive in C++ as when programming in the shader language. Constructs such as the following are possible.

float4 foo4 = float4(1, 2, 3, 4);
float3 bar3 = foo4.xzy;
float2 logFoo2 = log(bar3.xz);
foo4.wx = logFoo2.yx;
float4 baz4 = float4(logFoo2, foo4.zz);
float4x4 fooMatrix4x4 = float4x4( 1, 2, 3, 4,
                                  5, 6, 7, 8,
                                  8, 7, 6, 5,
                                  4, 3, 2, 1);
float4 myTransformedVector = mul(fooMatrix4x4, baz4);
int2 ifoo2 = int2(1, 2);
int4 ifoo4 = int4(1, 2, 3, 4) + ifoo2.xyxy;
float4 fooCast4 = ifoo4.wwyx;

float8 foo8 = float8(1, 2, 3, 4, 5, 6, 7, 8);
float8 bar8 = float8(1, 2, 3, 4, 5, 6, 7, 8);
float8 add8 = foo8 + bar8;

The natvis files provided for Visual Studio debugging allow you to see both vectors and the result of the swizzling in the debugging window in a programmer-friendly way.

Swizzle Natvis Preview

Requirements

The only required features are a C++ compiler supporting anonymous unions, and SSE or NEON depending on your target platform. If your target platform does not have SIMD support, it can also fall back to a scalar implementation. As a curiosity it also includes an Xbox 360 implementation.

How to use

#include "hlsl++.h"

Remember to also add an include path to "hlslpp/include". hlsl++.h pulls in other headers that live in the same folder. To force the scalar version of the library, define HLSLPP_SCALAR.

Features

  • SSE/AVX/AVX2, NEON, Xbox360, and scalar versions
  • float1, float2, float3, float4, float8
  • int1, int2, int3, int4
  • uint1, uint2, uint3, uint4
  • double1, double2, double3, double4
  • floatNxM
  • quaternion
  • Conversion construction and assignment, e.g. float4(float2, float2) and int4(float2, int2)
  • Efficient swizzling for all vector types
  • Basic operators +, *, -, / for all vector and matrix types
  • Per-component comparison operators ==, !=, >, <, >=, <= (no ternary operator as overloading is disallowed in C++)
  • hlsl vector functions: abs, acos, all, any, asin, atan, atan2, ceil, clamp, cos, cosh, cross, degrees, dot, floor, fmod, frac, exp, exp2, isfinite, isinf, isnan, length, lerp, log, log2, log10, max, mad, min, modf, normalize, pow, radians, reflect, refract, round, rsqrt, saturate, sign, sin, sincos, sinh, smoothstep, sqrt, step, trunc, tan, tanh
  • Additional matrix functions: determinant, transpose, inverse (not in hlsl but very useful)
  • Matrix multiplication for all NxM matrix combinations
  • Transformation matrices for scale, rotation and translation, as well as world-to-view look_at and view-to-projection orthographic/perspective coordinate transformations. These static functions are optionally available for matrix types float2x2, float3x3, float4x4 when hlsl++.h is compiled with HLSLPP_FEATURE_TRANSFORM definition.
  • Native visualizers for Visual Studio (.natvis files) which correctly parse with both MSVC and Clang in Windows

Missing/planned:

  • floatNxM _m00_m01 style swizzling (rows implemented but missing columns)
  • boolN types
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].