Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions Cpp/Source/MathSimd.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#pragma once
#if defined(_MSC_VER)
#define VM_INLINE __forceinline
#else
#define VM_INLINE __attribute__((unused, always_inline, nodebug)) inline
#endif

#if defined(_MSC_VER)
#define VM_INLINE __forceinline
#else
#define VM_INLINE __attribute__((unused, always_inline, nodebug)) inline
#endif

#define kSimdWidth 4

#if !defined(__arm__) && !defined(__arm64__) && !defined(__EMSCRIPTEN__)

// ---- SSE implementation

#include <xmmintrin.h>
#include <emmintrin.h>
#if defined(_MSC_VER)
#include <intrin.h>
#else
#include <xmmintrin.h>
#include <emmintrin.h>
#include <smmintrin.h>
#endif

#define SHUFFLE4(V, X,Y,Z,W) float4(_mm_shuffle_ps((V).m, (V).m, _MM_SHUFFLE(W,Z,Y,X)))

Expand All @@ -25,12 +29,12 @@ struct float4
VM_INLINE explicit float4(float x, float y, float z, float w) { m = _mm_set_ps(w, z, y, x); }
VM_INLINE explicit float4(float v) { m = _mm_set_ps1(v); }
VM_INLINE explicit float4(__m128 v) { m = v; }

VM_INLINE float getX() const { return _mm_cvtss_f32(m); }
VM_INLINE float getY() const { return _mm_cvtss_f32(_mm_shuffle_ps(m, m, _MM_SHUFFLE(1, 1, 1, 1))); }
VM_INLINE float getZ() const { return _mm_cvtss_f32(_mm_shuffle_ps(m, m, _MM_SHUFFLE(2, 2, 2, 2))); }
VM_INLINE float getW() const { return _mm_cvtss_f32(_mm_shuffle_ps(m, m, _MM_SHUFFLE(3, 3, 3, 3))); }

__m128 m;
};

Expand Down Expand Up @@ -105,12 +109,12 @@ struct float4
VM_INLINE explicit float4(float x, float y, float z, float w) { float v[4] = {x, y, z, w}; m = vld1q_f32(v); }
VM_INLINE explicit float4(float v) { m = vdupq_n_f32(v); }
VM_INLINE explicit float4(float32x4_t v) { m = v; }

VM_INLINE float getX() const { return vgetq_lane_f32(m, 0); }
VM_INLINE float getY() const { return vgetq_lane_f32(m, 1); }
VM_INLINE float getZ() const { return vgetq_lane_f32(m, 2); }
VM_INLINE float getW() const { return vgetq_lane_f32(m, 3); }

float32x4_t m;
};

Expand Down Expand Up @@ -189,4 +193,4 @@ VM_INLINE float4 splatY(float32x4_t v) { return float4(vdupq_lane_f32(vget_low_f
VM_INLINE float4 splatZ(float32x4_t v) { return float4(vdupq_lane_f32(vget_high_f32(v), 0)); }
VM_INLINE float4 splatW(float32x4_t v) { return float4(vdupq_lane_f32(vget_high_f32(v), 1)); }

#endif
#endif
16 changes: 14 additions & 2 deletions Cpp/Windows/ToyPathTracer.sln
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
# Visual Studio Version 17
VisualStudioVersion = 17.14.35906.104
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToyPathTracer", "ToyPathTracer.vcxproj", "{4F84B756-87F5-4B92-827B-DA087DAE1900}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Debug|ARM64EC = Debug|ARM64EC
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM64 = Release|ARM64
Release|ARM64EC = Release|ARM64EC
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|ARM64.ActiveCfg = Debug|ARM64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|ARM64.Build.0 = Debug|ARM64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|ARM64EC.Build.0 = Debug|ARM64EC
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x64.ActiveCfg = Debug|x64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x64.Build.0 = Debug|x64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x86.ActiveCfg = Debug|Win32
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x86.Build.0 = Debug|Win32
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|ARM64.ActiveCfg = Release|ARM64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|ARM64.Build.0 = Release|ARM64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|ARM64EC.ActiveCfg = Release|ARM64EC
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|ARM64EC.Build.0 = Release|ARM64EC
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|x64.ActiveCfg = Release|x64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|x64.Build.0 = Release|x64
{4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|x86.ActiveCfg = Release|Win32
Expand Down
Loading