00001 /* 00002 * OpenCL device header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_OPENCL_DEVICE_H__ 00009 #define __SP_OPENCL_DEVICE_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 00014 #if defined(SP_COMPILE_WITH_OPENCL) 00015 00016 00017 #include "Base/spInputOutputString.hpp" 00018 #include "Framework/OpenCL/spOpenCLCoreHeader.hpp" 00019 #include "Framework/OpenCL/spOpenCLBuffer.hpp" 00020 #include "Framework/OpenCL/spOpenCLProgram.hpp" 00021 00022 #include <list> 00023 00024 00025 namespace sp 00026 { 00027 namespace video 00028 { 00029 00030 00036 class SP_EXPORT OpenCLDevice 00037 { 00038 00039 public: 00040 00041 OpenCLDevice(); 00042 ~OpenCLDevice(); 00043 00044 /* === Functions === */ 00045 00047 io::stringc getVersion() const; 00048 io::stringc getDescription() const; 00049 io::stringc getVendor() const; 00050 io::stringc getExtensionString() const; 00051 00065 OpenCLProgram* createProgram(const io::stringc &SourceString, const io::stringc &CompilationOptions = ""); 00066 00071 OpenCLProgram* loadProgram(const io::stringc &Filename, const io::stringc &CompilationOptions = ""); 00072 00074 void deleteProgram(OpenCLProgram* Program); 00075 00082 OpenCLBuffer* createBuffer(const EOpenCLBufferStates State, u32 BufferSize); 00083 OpenCLBuffer* createBuffer(const EOpenCLBufferStates State, video::Texture* TexBuffer); 00084 OpenCLBuffer* createBuffer(const EOpenCLBufferStates State, video::MeshBuffer* MeshBuffer); 00085 00086 void deleteBuffer(OpenCLBuffer* Buffer); 00087 00088 private: 00089 00090 friend class OpenCLBuffer; 00091 friend class OpenCLProgram; 00092 00093 /* === Functions === */ 00094 00095 OpenCLBuffer* addBufferToList(OpenCLBuffer* NewBuffer); 00096 00097 bool loadExtensions(); 00098 00099 static io::stringc getPlatformInfo(cl_platform_info Info); 00100 static io::stringc getDeviceInfo(cl_device_info Info); 00101 00102 static io::stringc getErrorString(cl_int Error); 00103 static void checkForError(cl_int Error, const io::stringc &Message); 00104 00105 /* === Members === */ 00106 00107 static cl_platform_id clPlatform_; 00108 static cl_context clContext_; 00109 static cl_command_queue clQueue_; 00110 static cl_device_id clDevice_; 00111 00112 std::list<OpenCLProgram*> ProgramList_; 00113 std::list<OpenCLBuffer*> BufferList_; 00114 00115 }; 00116 00117 00118 } // /namespace video 00119 00120 } // /namespace sp 00121 00122 00123 #endif 00124 00125 #endif 00126 00127 00128 00129 // ================================================================================