Optimizing a raytracer

Jacob Carlborg doob at me.com
Wed Oct 16 06:18:45 PDT 2013


On 2013-10-16 14:02, "Róbert László Páli" wrote:
> Hello!
>
> I am writing an unbiased raytrace renderer in D. I have good progress,
> but I want to make it as fast as possible where I can do it without
> compromises.
>
> I use a struct with three doubles for vector and color calculations and
> I have operator overloading for them. Many vectors and colors are
> created during the tracing calculations.
>
> I thought, using classes may require too much memory, because they are
> not destructed on scope end, and maybe speed reduction when GC kicks in.
>
> Is my assumptions that in this case struct are more wise?
>
> To avoid the constructing many vectors and colors, I thought to use ref
> arguments, but I also heard that ref functions are not inlined. What
> would generate the fastest code for a cross-product for example?
>
> What compiler and compilations flags should I use to generate the
> fastest code? My main target is sixty-four bit machines, cross-platform.
> What optimizations can I assume for various compilers? Are only once
> used local variables inlined? So it secure to extract local variables
> only to make the code more easy to understand?

I would say use structs. For compiler I would go with LDC or GDC. Both 
of these are faster for floating point calculations than DMD. You can 
always benchmark.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list