Random Chitchat 2012-2016
Bearbin's birthday was celebrated only a few days before... So close.


Attached Files Thumbnail(s)
   
Thanks given by:
Do you draw these yourself? Smile
Thanks given by:
Ha!


...no :(

I predicted that someone would ask that.
Thanks given by:
I just found a great bit of cmake goodness to help with MSVC2013:
When you add the following line to your CMakeCache.txt file, it will disable the ZERO_CHECK project that MSVC always tries to build when running MCS:
CMAKE_SUPPRESS_REGENERATION:BOOL=TRUE
On the other hand, it means that you have to run cmake manually after each change to any of the the CMakeLists.txt files. But I can live with that, much more than with MSVC's constant begging to rebuild the ZERO_CHECK project Smile
Thanks given by:
Oh dear, we have a terrible problem.

We're using globals with constructors, and the C++ standard doesn't guarantee the order in which the constructors for these are called. We have been lucky (?) so far in that the order has been good for us, but I've made some unrelated changes and suddenly the whole thing won't start up. The global prefabs used for the nether fort generator require the blockhandlers to be initialized, but they aren't.

What now?
Thanks given by:
There is a hacky way to get around it. Makes use of static function initialisation. Create a template registerIntitalizer
Code:
template<void InitFunc*()>
class registerInitializer
{
    registerInitalizer()
    {
         InitFunc();
    }
}
Then you can declare any function as being executed on startup with
Code:
registerInitalizer<func> global;

Then move the init code into functions with a static to check for init:
Code:
initfunc
{
static bool initialised = false;
if (!initalised)
{
    initalised = true;
    // call dependent init functions
    // do init
}
}
Thanks given by:
Seems too hacky for my taste. I've done a much simpler thing - added a global flag and the accessor function now checks the flag and initializes, if needed.
Thanks given by:
Now we just need to make sure the accessor is called at least once during startup. Smile

Also, looking at the existing code, my template looks like a generalised form of cBlockInfoInitializer. Might be useful more generally.
Thanks given by:
Actually the cBlockInfoInitializer method fails, because that's the very case that has the non-deterministic startup order. If you have several global classes, C++ provides no means of specifying which of the classes is to be initialized first. If you want specific initialization order, you need to do it like me by using an accessor. Also you need to make sure that the accessor is run before the program goes multithreaded, there's really no way to prevent race conditions in the accessor (because you would need a mutex for that, but you need to initialize the mutex before the accessor -> you need an accessor for the mutex -> loop forever).
Thanks given by:
I've just discovered a new level of debugging problems. OpenCL pointer issues. The only feedback you get is crashes in the driver and oblique OPENCL_OUT_OF_RESOURCES error message.

Found the problem. I was passing the dimensions in the wrong order to the previous kernel.
Thanks given by:




Users browsing this thread: 6 Guest(s)