How to create Task and be happy.

When programmer requests Task object from TaskManager, TaskManager creates Task object without Kernel and FrameBuffer. User can create them by calling method TaskcreateActiveKernel()
Later programmer must create Shader object from file which contatin shader source code, or from string which contain shader source code.
After that Task object is ready for compiling, programmer may compile it.
After compilation programmer may upload data to GPU side by calling method Task::addData()
When all necessary data are in GPU side you must allocate buffer for results and obtain results by calling method Task::computeTask()

 #include "gpucalc.h"
 using namespace gpucalc;
 
 //...
 
 Application * app = new Application(argc, argv, "name_of_app", "name_of_app_log.log", "plugins.cfg");
 app->loadLibrary("filename_of_your_library_with_graphic_core");
 app->loadLibrary("filename_of_your_library_with_shader_system");
 GraphicCore * Core = app->getDefaultGraphicCore();
 Core->start(argc, argv);
 
 //...
 
 Task * t = Application::getSingleton()->getDefaultTaskManager()->createTask("name_of_your_task");
 Kernel * k = t->getActiveKernel();
 Shader * sh = k->getShader();
 sh->fromSource("source_code_of_your_shader");
 
 //...
 
 t->compile();

 //...


 Data data("data_name");
 data.createArray(Array2D, pointer1, length_of_pointer1,
     number_of_components1, internal_array_size_x1, internal_array_size_y1);
 t->addDataToActiveKernel(data);

 //...

 Data result("result_name");
 result.createArray(Array2D, allocated_pointer_to_result2, length_of_pointer2,
     number_of_components2, internal_array_size_x2, internal_array_size_y2);
 t->addResultToActiveKernel(r)

 //...


 t->compute();

 //...
 Application::getSingleton().getDefaultShaderSystem()->deleteShader(t->getActiveKernel()->removeShader());
 Application::getSingleton()->getDefaultTaskManager()->deleteTask(t);

 Core->stop();

 app->unloadLibrary("filename_of_your_library_with_shader_system"); 
 app->unloadLibrary("filename_of_your_library_with_graphic_core");
 delete app;
When computations finish, allocated_pointer_to_result2 will contain results of computation.
!!!Note!!! Names of data, which programmer upload to GPU side must comply with names of uniform variables in shader code!!!
See also:
Task, Data, TaskManager, Application, GraphicCore, ShaderSystem

Generated on Thu Mar 5 22:36:42 2009 for gpucalc by  doxygen 1.5.6