Another week of work on my OpenCL/Concurrency utility belt I call Ocius. I finished a basic GL interop sample, where I generate vertices from OpenCL straight into the VBO, never leaving the GPUs VRAM. I then draw it as a line loop. It can even does a nice spinning animation:
After that, I really couldn't figure out anything more OpenCL related you'd want do to so I started on the Concurrency part of the project. I've written a Linked List Blocking Queue for passing data around and on top of that I wrote a very simplistic Message Passing Interface. First you create a Hub, which keeps track of everything. From the Hub you create Channels, which are like mail boxes, you can recv() messages, and send() messages, given that you know a valid adress. The Hub can easily be extended to send messages over network, oblivious to all channels.
Sending a package looks like this:
master->send("worker", {"data", &aBuffer});
I can't say I'm all that well fared with C++ yet, and thus I have a problem with this code. By putting a printf() in the packet types destructor, I can tell that every message is destroyed twice. Even though I explicitly use shared_ptr, make_shared() and std::move() everywhere. Is this because make_shared() always puts its result on the heap? And destroys it from the stack? Even though I use std::move()? I thought that was going to solve it. I really hate copying things around. I would also much prefer to use unique_ptrs for the channels/queues rather than shared_ptr, it would feel safer. But I can't seem to get that to work. Does it mean I have to pass in a unique_ptr or *T argument to push()? Because I havn't tried that yet, but I'd rather avoid leaving memory management (yes, creating pointers is memory management) to the user of the queue. But I guess that's better than deleting temporary values. If anyone could check out the source(LinkedLockQueue and Hub classes) and tell me what's wrong I would be very thankful.
I tried to write some lock free datastructures, but there doesn't appear to be full support for the C++11 atomic operations (more specifically, CAS on shared_ptrs) yet, so I had to skip that.
As a final addition to the features of my concurrency utilities I would like to write a reusable thread pool. However I know for a fact some features are not implemented in my compilers yet so I've put that on ice for now. I am also reluctant to writing such code without knowing fully how I would like to be able to use it later. Maybe I'll run into some situations where I can concretely say how an ideal thread pool will work and be able to write one then. We'll see.
Starting tomorrow I will be beginning work on a game engine using my newly developed code. With an ocius::Environment at its heart maybe I can do some cool things. I have looked a little on AMDs Froblins Demo and figured I could do something similar. A Settlers themed game perhaps. I do have some ideas. So currently I'm rereading my Game Code Complete book to refresh my brain cells with game engine knowledge. I think I have a cool idea for a multicore renderer, similar to what I've read about Doom 3. That would be cool if that worked. That's it for now. I have a lot of coding ahead of me and I'll come back i a week with another report.