Skip to content

SIMD Vs Non ‐SIMD Demos

John Galvin edited this page Oct 28, 2024 · 2 revisions

I would recommend reading What is SIMD / NEON, as the DEMO here will greatly help you understand how all this SIMD/NEON stuff works, before reading the below, of course if you have already read it then just ignore this message.


DEMOS

There are two demos you can download and compare the speed and power of SIMD. These are Shadow Casting application.

The first demo is ShadowCast2D, you can download the demo here. This Shadow Caster was created by OneLoneCoder, a long time ago, and it is an amazing shadow caster application, beautifully written to be honest. You can watch the video here

The second demo is ShadowCast2D_SIMD, you can download the demo here. This is the exact same project as ShadowCast2D except the draw routines have been replaced with SIMD methods.

The below images compare the differences in frame rate. As stated int What is SIMD / NEON section “Frame Rate should not be used as an indication of how fast your game is running…”

But for our comparison we are going to use it anyway 🤦‍♂️

Comparisons

ShadowCast2D Debug (14 Fps):

image

ShadowCast2D_SIMD Debug (38 Fps):

image

ShadowCast2D Release (123 Fps)

image

ShadowCast2D_SIMD Release (193 Fps)

image

So what was changed?

In the above comparisons we see a mark increase in performance when the SIMD methods are been executed. So, what did we change?

Only a few methods were updated in the ShadowCast2D_SIMD for this to work, and yes it was a simple change.

In the ShadowCast2D_SIMD.cpp file we changed:

DrawSprite(fSourceX - 255, fSourceY - 255, sprLightCast); 
// To:
DrawSprite_SIMD(fSourceX - 255, fSourceY - 255, sprLightCast);


FillTriangle (…);
// To:
FillTriangle_SIMD(…);

FillRect(…);
// To:
FillRect_SIMD(…);

FillCircle(…);
// To:
FillCircle_SIMD(…);
Clone this wiki locally