#include <simple_task.h>
Public Member Functions | |
void | addActiveKernel (Kernel *) |
void | addCompilerParamsToActiveKernel (const std::string &Parameters) |
Add compiler parameters to active kernel. | |
void | addDataToActiveKernel (const Data &data) |
Transfer data from CPU side to GPU side. | |
void | addResultToActiveKernel (Data &result) |
void | compile () |
Compiles this task. | |
void | compute () |
Performs computation and stores result in Data pointer. | |
Kernel * | getActiveKernel () const |
Returns active kernel. | |
const std::string & | getClassName () const |
Returns name of class of our object. | |
const std::string & | getObjectName () const |
Returns name of our object. | |
Data & | getResultData () const |
void | getSpecificParameter (const std::string &ParameterName, void *ParameterValue) |
Method for obtaining some specific parameters, such as texture specific params, and so on. | |
bool | isLocked () const |
returns state of object. | |
void | removeDataFromActiveKernel (const Data &) |
Removes data from active kernel. | |
void | removeKernel (Kernel *kernel) |
Removes kernel from our Task. | |
void | removeResultFromActiveKernel (const Data &result) |
~SimpleTask () | |
Protected Types | |
typedef std::list< const Data * > | DataVector |
Protected Member Functions | |
void | addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size) |
void | computeOneKernel (Texture *RenderTarget) |
void | lock () |
SimpleTask (const std::string &TaskName) | |
void | unlock () |
Protected Attributes | |
FrameBuffer * | mActiveFrameBuffer |
Kernel * | mActiveKernel |
std::string | mCompilerParams |
DataVector | mDataVector |
GraphicCore * | mDefaultGraphicCore |
ShaderSystem * | mDefaultShaderSystem |
Texture * | mRenderTarget |
Data * | mResultData |
Friends | |
class | SimpleTaskManager |
In this task all resources are created and deleted internally (textures, uniforms).
Definition at line 50 of file simple_task.h.
typedef std::list<const Data *> gpucalc::SimpleTask::DataVector [protected] |
Definition at line 120 of file simple_task.h.
gpucalc::SimpleTask::~SimpleTask | ( | ) |
Definition at line 64 of file simple_task.cpp.
00065 { 00066 mActiveKernel->removeShader(); 00067 mDefaultGraphicCore->destroy(mActiveKernel->removeFrameBuffer()); 00068 mDefaultGraphicCore->destroy(mRenderTarget); 00069 delete mActiveKernel; 00070 LogManager::getSingleton().logMessage(this, "Successfully destroyed.", LML_Trivial); 00071 }
gpucalc::SimpleTask::SimpleTask | ( | const std::string & | TaskName | ) | [protected] |
Definition at line 49 of file simple_task.cpp.
00049 : Task(_SimpleTaskClassName, TaskName), 00050 mActiveKernel(0), mActiveFrameBuffer(0), mResultData(0), mRenderTarget(0), mDefaultGraphicCore(Application::getSingleton().getDefaultGraphicCore()), 00051 mDefaultShaderSystem(Application::getSingleton().getCompatibleShaderSystem()), mCompilerParams() 00052 { 00053 mActiveKernel = new Kernel(TaskName + "_kernel", mDefaultGraphicCore); 00054 mActiveFrameBuffer = mDefaultGraphicCore->create(TaskName + "_framebuffer"); 00055 mActiveKernel->setFrameBuffer(mActiveFrameBuffer); 00056 Shader * shader = mDefaultShaderSystem->getShaderByName(TaskName + "_shader"); 00057 mRenderTarget = mDefaultGraphicCore->create(TaskName + "_render_target", TU_Render); 00058 00059 mActiveKernel->setShader(shader); 00060 LogManager::getSingleton().logMessage(this, "Successfully created.", LML_Trivial); 00061 }
void gpucalc::SimpleTask::addActiveKernel | ( | Kernel * | ) | [inline, virtual] |
void gpucalc::SimpleTask::addCompilerParamsToActiveKernel | ( | const std::string & | Parameters | ) | [virtual] |
Add compiler parameters to active kernel.
Implements gpucalc::Task.
Definition at line 116 of file simple_task.cpp.
00117 { 00118 mCompilerParams = Parameters; 00119 }
void gpucalc::SimpleTask::addDataToActiveKernel | ( | const Data & | data | ) | [virtual] |
Transfer data from CPU side to GPU side.
Data can be represented as Array or as Element.
Implements gpucalc::Task.
Definition at line 74 of file simple_task.cpp.
00075 { 00076 Uniform * uniform = 0; 00077 if (!data.isArray()) 00078 { 00079 uniform = mDefaultShaderSystem->create(data); 00080 } 00081 else 00082 { 00083 Texture * texture = 0; 00084 if (mDefaultGraphicCore->isTextureCreated(data.getObjectName())) 00085 { 00086 texture = mDefaultGraphicCore->getTextureByName(data.getObjectName()); 00087 } 00088 else 00089 { 00090 texture = mDefaultGraphicCore->create(data.getObjectName(), TU_Static); 00091 } 00092 texture->reInitialize(data); 00093 texture->uploadToGPU(); 00094 00095 uniform = mDefaultShaderSystem->create(texture); 00096 } 00097 00098 uniform->initialize(); 00099 uniform->uploadToGPU(); 00100 mActiveKernel->getShader()->addUniform(uniform); 00101 }
void gpucalc::SimpleTask::addResultToActiveKernel | ( | Data & | result | ) | [virtual] |
Implements gpucalc::Task.
Definition at line 104 of file simple_task.cpp.
00105 { 00106 mResultData = &result; 00107 }
void gpucalc::Object::addSpecificParameter | ( | const std::string & | ParameterName, | |
void * | ParameterValue, | |||
size_t | Size | |||
) | [inline, protected, inherited] |
Definition at line 254 of file object.h.
00255 { 00256 SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName); 00257 if (i != mSpecificParameters.end()) 00258 { 00259 mSpecificParameters.erase(i); 00260 } 00261 mSpecificParameters[ParameterName] = Any(ParameterValue, Size); 00262 }
void gpucalc::SimpleTask::compile | ( | ) | [virtual] |
Compiles this task.
Implements gpucalc::Task.
Definition at line 134 of file simple_task.cpp.
00135 { 00136 mActiveKernel->compile(mCompilerParams); 00137 LogManager::getSingleton().logMessage(this, "Task compiled.", LML_Trivial); 00138 }
void gpucalc::SimpleTask::compute | ( | ) | [virtual] |
Performs computation and stores result in Data pointer.
Resulting Data must be set by calling method Task::AddResultDataToActiveKernel()
Implements gpucalc::Task.
Definition at line 141 of file simple_task.cpp.
00142 { 00143 LogManager::getSingleton().logMessage(this, "Starting computing...", LML_Trivial); 00144 mRenderTarget->reInitialize(*mResultData); 00145 computeOneKernel(mRenderTarget); 00146 mActiveKernel->getFrameBuffer()->getData(*mResultData, mRenderTarget); 00147 LogManager::getSingleton().logMessage(this, "Computing finished.", LML_Trivial); 00148 }
void gpucalc::SimpleTask::computeOneKernel | ( | Texture * | RenderTarget | ) | [protected, virtual] |
Implements gpucalc::Task.
Definition at line 151 of file simple_task.cpp.
00152 { 00153 mActiveKernel->preCompute(); 00154 mActiveKernel->compute(RenderTarget); 00155 mActiveKernel->postCompute(); 00156 }
Kernel * gpucalc::SimpleTask::getActiveKernel | ( | ) | const [virtual] |
Returns active kernel.
Implements gpucalc::Task.
Definition at line 122 of file simple_task.cpp.
00123 { 00124 return mActiveKernel; 00125 }
const std::string& gpucalc::Object::getClassName | ( | ) | const [inline, inherited] |
Returns name of class of our object.
Definition at line 92 of file object.h.
00093 { 00094 return mClassName; 00095 }
const std::string& gpucalc::Object::getObjectName | ( | ) | const [inline, inherited] |
Returns name of our object.
Definition at line 101 of file object.h.
00102 { 00103 return mObjectName; 00104 }
Data& gpucalc::SimpleTask::getResultData | ( | ) | const [inline, virtual] |
Implements gpucalc::Task.
Definition at line 86 of file simple_task.h.
00087 { 00088 return * mResultData; 00089 }
void gpucalc::Object::getSpecificParameter | ( | const std::string & | ParameterName, | |
void * | ParameterValue | |||
) | [inline, inherited] |
Method for obtaining some specific parameters, such as texture specific params, and so on.
ParameterName | - name of parameter, usually it similar to specific method of some object (for example, GLTextureID) | |
ParameterValue | - contain value of named parameter, it must be allocated and have sufficient size. |
Definition at line 128 of file object.h.
00129 { 00130 SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName); 00131 if (i != mSpecificParameters.end()) 00132 { 00133 i->second.copyValue(ParameterValue); 00134 } 00135 else 00136 { 00137 Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__); 00138 } 00139 }
bool gpucalc::Object::isLocked | ( | ) | const [inline, inherited] |
void gpucalc::Object::lock | ( | ) | [inline, protected, inherited] |
void gpucalc::SimpleTask::removeDataFromActiveKernel | ( | const Data & | data | ) | [inline, virtual] |
Removes data from active kernel.
Implements gpucalc::Task.
Definition at line 74 of file simple_task.h.
void gpucalc::SimpleTask::removeKernel | ( | Kernel * | kernel | ) | [virtual] |
Removes kernel from our Task.
Implements gpucalc::Task.
Definition at line 128 of file simple_task.cpp.
00129 { 00130 Warning<ERR_NOT_IMPLEMENTED>(this, "This type of tasks cannot remove kernels manually.", "SimpleTask::removeKernel()", __FILE__, __LINE__); 00131 }
void gpucalc::SimpleTask::removeResultFromActiveKernel | ( | const Data & | result | ) | [virtual] |
Implements gpucalc::Task.
Definition at line 110 of file simple_task.cpp.
00111 { 00112 mResultData = NULL; 00113 }
void gpucalc::Object::unlock | ( | ) | [inline, protected, inherited] |
friend class SimpleTaskManager [friend] |
Definition at line 58 of file simple_task.h.
FrameBuffer* gpucalc::SimpleTask::mActiveFrameBuffer [protected] |
Definition at line 111 of file simple_task.h.
Kernel* gpucalc::SimpleTask::mActiveKernel [protected] |
Definition at line 108 of file simple_task.h.
std::string gpucalc::SimpleTask::mCompilerParams [protected] |
Definition at line 130 of file simple_task.h.
DataVector gpucalc::SimpleTask::mDataVector [protected] |
Definition at line 121 of file simple_task.h.
GraphicCore* gpucalc::SimpleTask::mDefaultGraphicCore [protected] |
Definition at line 124 of file simple_task.h.
ShaderSystem* gpucalc::SimpleTask::mDefaultShaderSystem [protected] |
Definition at line 127 of file simple_task.h.
Texture* gpucalc::SimpleTask::mRenderTarget [protected] |
Definition at line 117 of file simple_task.h.
Data* gpucalc::SimpleTask::mResultData [protected] |
Definition at line 114 of file simple_task.h.