116
edits
Changes
TeamDS
,→GPU Optimized Phase 1
=== GPU Optimized Phase 1 ===
First step of optimizing is by finding a way to use less sqrtf function. It turns out that we are using lots of sqrtf for comparing distances to see if one is larger than the other. However, when squaring two numbers, it does not change which is the larger number. We can take advantage of this by comparing the squared distance, not using sqrtf function then comparethe actual distance. This way we only need to use sqrtf once per pixel! Below is the optimized kernel:
<syntaxhighlight lang="cpp">