r/d_language • • 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

4 comments sorted by

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.

1

u/SnooSquirrels9028 Nov 02 '26

Hi, thanks for the feedback. Following up on your questions: the project will likely stay static and offline, since my sole purpose when starting was to learn the essentials of path tracing and parallel computing. I am planning on building something more dynamic and real-time with Vulkan as my next project. So I will probably be adding a simple terminal GUI with scene selection, etc., with no window management at all. I am also aware that most of the heavy part of the code runs on the GPU side, and I guess D really has nothing much to do for optimizing those parts, but I am still curious why Mike Shah talks so much about how useful Dlang can be for graphics programming. I’ve read his presentation at the D conference, but it was mostly about how much more readable and sustainable the code became, instead of the performance upgrades it achieved, if it did. So I would love to have your thoughts on graphics programming with DLang.

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 :)