GPU based effects and comparisons to CPU
This started out as a bit of a personal research project but I wanted to share the code and get some opinions.
There has been a lot of talk about using the GPU for general purpose computation (GPGPU) so I wanted to see if Paint.net effects could benefit from this technique. Using DirectCompute and compute shaders could they out perform a CPU by enough of a margin to make dealing with the extra dependencies worthwhile. Short answer is yes, yes they can.
I ran a few tests on my middle aged computer to confirm with the standard Motion Blur effect. The GPU version produces the same image (Slight color variations due to rounding differences)
Intel Core 2 Duo E6400
NVIDIA 8800 GTS 320MB
Test image: 960 x 1280 photo 72dpi
Effect Settings: Motion Blur, Direction = 25.00, Centered = ticked
Blur Distance CPU (Approx Times) GPU Speed Increase (Approx) 10 2400ms 311ms 671% 50 10600ms 348ms 2,945% 100 20100ms 398ms 4,950% 200 38000ms 498ms 7,530%
It is interesting that even with the overhead of having to copy the entire image to be used by the video card even the smallest computation is notably faster.
Let’s up the image size a bit.
Test image: Resized 400%, 3840 x 5120
Blur Distance CPU (Approx Times) GPU Speed Increase (Approx) 200 10min 42.7s 5567ms 11,444%
Test image: Resized 500%, 4800 x 6400
Blur Distance CPU (Approx Times) GPU Speed Increase (Approx) 200 16min 47.6s 8281ms 12,067%
Well that’s pretty impressive, seems the GPU loves the large data sets. Obviously this is a relative comparison and if I had a quad core the difference would be about half but even that is pretty good. As I am a gamer I aimed for the dual core and the 8800 to be fairly balanced when I bought them so that one wouldn’t be a bottle neck for the other. So I think this is a fair comparison.
Anyways enough talk. Time for you to try. For now this is a manual install. Here is what you need:
- Windows 7 or Windows Vista with the DirectX 11 platform update (x86, x64).
- SlimDX Runtime (February 2010)
- Latest Video Drivers. Direct Compute support hasn’t been around for long so you will need to update your video drivers to get it. Download GPU-Z and confirm that the DirectCompute checkbox is checked. If it isn’t you either have an unsupported video card or don’t have the latest drivers. The GPU effect will fall back to the reference driver (software) if an unsupported device is found which is incredibly slow.
I haven’t got an AMD/ATI card to try it out so I would be interested to hear if all is well on those cards plus how a newer NVIDIA card performs.
Extract this zip file into the Paint.net effects folder.
If you want to see the render time, drop this config file into the effects folder along with the other dll. It will show a message box when the render is complete when processing a full image selection. Remove the config file when you are done.
Known issues: Current getting an Out of Memory exception well before using the available video card memory. Haven’t investigated this one yet. I know I need enough memory for the image and the output buffer but it seems well short of it.
Edited by Bruce Bowyer-Smyth, 10 July 2010 - 10:19 PM.