ok, let me try to describe my exact problem again and why i do not have a solution for that yet.
the user will be able to switch between cpu and gpu calculation at runtime. So i need one world-object which is in host-memory and one world object in device-memory.
World worldCPU; // instance of the ray tracer stored in host memory
__device__ World worldGPU; // instance of the ray tracer stored in device memory
The world contains many different instances of classes and i have to safe them somewhere - That is why I want to use member variables. For example if i create a instance of a Material, this instance should have member variables which keep the information about specularity, color, and so on.
…
Right now i got a new cognition. i think this will fix my problem, but first i have to try it.
The program crashes if i create an object in my main class of the world and try to call the world-init-function via kernel (global function). It crashed at the position when it tries to access the viewplane member variables. BUT if i create a new object of the viewplane in the init-function - i am allowed to access the member variables.
Summary: It seems to me, that member variables work, but DON’T work if you try to access them from the global function. So the lowest level does not work.
pseydocode - In main class:
HERE: Trying to access worlds member variable Viewplane
__device__ world;
__global kernel
{
world.init();
}
__host__ __device__ world.init()
{
_viewplane.read() <------ CRASH
}
same principle but on a deeper level - pseydocode: In world class:
HERE: Trying to access Viewplanes member variable xxx
__host__ __device__ world.init()
{
Viewplane viewplane;
viewplane.setXXX(100); <--- NO CRASH
}
it is exactly the same principle, but the first one calls it from a global function and the last one calls it from a host device function.
Everything i have to do so is:
Extracting all member variables of the world to the main class and allocating memory in the device in addition.
Then I should be able to run it on the gpu as well. - I hope so ;) that means i will have two different init- and render-implementations in my world - one for the host using the usual memory and one for the gpu using the device memory.
I will try to figure out and will post the result ;)