News for hackers. Stuff that matters.
Re:Porting a Ray Tracer to Rust, Part 1 by CyberDildonics on Wednesday December 31, 2014 @06:39AM (#8818990)
So one important question about Rust that is relevant here is how it handles dynamic stack allocation. It is in the language? C++ has alloca of course but needs a couple of macros to work across compilers. Memory allocation ends up being a very big performance concern in renderers. PBRT uses both memory arenas and an ALLOCA macro.
Re:Porting a Ray Tracer to Rust, Part 1 by berkut on Wednesday December 31, 2014 @07:02AM (#8819038)
It's quite possible to not use alloca(), but just use C++'s placement new operator to re-use memory already allocated on the stack.

I'm not sure if Rust has something similar to placement new, but I'm sure custom allocators (for memory arenas) are possible in Rust.

Re:Porting a Ray Tracer to Rust, Part 1 by steveklabnik on Wednesday December 31, 2014 @08:24AM (#8819241)
User-defined placement new and custom allocators for existing data structures are still being worked on. `box` can do a form of placement new already, and while you can use your own allocator, you can't use it with already-existing types.
Re:Porting a Ray Tracer to Rust, Part 1 by CyberDildonics on Wednesday December 31, 2014 @08:16AM (#8819210)
That is a valid and useful technique, but being able to dynamically allocate stack memory in the first place is separate from using placement new on stack memory.
Re:Porting a Ray Tracer to Rust, Part 1 by berkut on Wednesday December 31, 2014 @08:19AM (#8819226)
Of course, I was just pointing out it's not always necessary to use alloca - I've written a production-level path-tracer without needing to allocate stack memory dynamically.
Re:Porting a Ray Tracer to Rust, Part 1 by yuriks on Wednesday December 31, 2014 @07:24AM (#8819082)
I might be mistaken about this, but I believe they plan on implementing support for this at some point.
Re:Porting a Ray Tracer to Rust, Part 1 by steveklabnik on Wednesday December 31, 2014 @08:28AM (#8819260)
It's on the todo list.