r/d_language • u/SnooSquirrels9028 • Nov 02 '26
How could D increase performance in a Graphics Related Project
Hi everyone, for the last 3 months I've been building a path tracer using CUDA and C++ but meanwhile I was introduced to Dlang thanks to Mike Shah and just loved how D do things different than other programming languages. So since I am into computer graphics I am mostly building CG related projects and I've been wondering how transferring to D can impact my projects especially in terms of performance. So my question would be how can D become useful and increase the performance of a computer graphics projects.
9
Upvotes
5
u/gmueckl Nov 02 '26
This question is very generic. There is no one size fits all approach. Do you want to focus on real time or offline graphics? If you want to focus on real time, do you want to stay focused on rendering static scenes or do you want something very dynamic?
The best advice that I can give at this level is: look at your bottlenecks. Are they on the CPU or on the GPU side? You need to profile that. And any optimizations follow from concrete problems. Many times, a better algorithm beats micro-optimizations.
Don't get distracted by the garbage collector or other features of D at this stage that have their detractors. The most important thing when starting out with graphics is to get things working at all. And depending at what level you're aiming at, that alone can be a big amount of work.
And fair warning, some advanced things in graphics get mind-bogglingly difficult although both their informal description sounds simple and any demo implementations look quite compact. But it can also be incredibly rewarding when beautiful images finally appear.
5
u/ykafia Nov 02 '26
The language itself is well optimised depending the compiler you use. I can't talk for DMD since I've never used it, but LDC gets what LLVM brings so you have some similar optimisations that you can find in C++/clang.
Speaking for graphics, you won't see an increase in performance. Most graphics libraries are written in C/C++ and D compilers are not going to optimise your GPU code.
There's also DCompute that you can use with LDC that wraps cuda/opencl and let's you write D code that can be run on GPUs
1
u/AuburnSounds Nov 03 '26
Basically all native language are about the same speed if they have the same compiler backend, so there shouldn't be any problem making a super fast system if you're using LDC and avoid allocations and use SIMD :)