Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_OPENCL_BUFFER_H__
00009 #define __SP_OPENCL_BUFFER_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #if defined(SP_COMPILE_WITH_OPENCL)
00015
00016
00017 #include "Framework/OpenCL/spOpenCLCoreHeader.hpp"
00018
00019
00020 namespace sp
00021 {
00022 namespace video
00023 {
00024
00025
00026 class Texture;
00027 class MeshBuffer;
00028
00030 enum EOpenCLBufferStates
00031 {
00032 OCLBUFFER_READ,
00033 OCLBUFFER_WRITE,
00034 OCLBUFFER_READ_WRITE,
00035 };
00036
00037
00042 class SP_EXPORT OpenCLBuffer
00043 {
00044
00045 public:
00046
00047 OpenCLBuffer(const EOpenCLBufferStates State, u32 BufferSize);
00048 OpenCLBuffer(const EOpenCLBufferStates State, video::Texture* TexBuffer);
00049 OpenCLBuffer(const EOpenCLBufferStates State, video::MeshBuffer* MeshBuffer);
00050 ~OpenCLBuffer();
00051
00052
00053
00054 void writeBuffer(const void* Buffer, u32 Size, u32 Offset = 0);
00055 void readBuffer(void* Buffer, u32 Size, u32 Offset = 0);
00056
00057 void lock();
00058 void unlock();
00059
00060
00061
00063 inline u32 getBufferSize() const
00064 {
00065 return BufferSize_;
00066 }
00067 inline EOpenCLBufferStates getState() const
00068 {
00069 return State_;
00070 }
00071
00076 inline bool isCustomBuffer() const
00077 {
00078 return CustomBuffer_;
00079 }
00080
00081 private:
00082
00083 friend class OpenCLProgram;
00084
00085
00086
00087 cl_mem_flags getMemFlags() const;
00088
00089 void createBuffer(cl_mem_flags Flags, void* Buffer);
00090
00091
00092
00093 cl_mem clBuffer_;
00094
00095 EOpenCLBufferStates State_;
00096 u32 BufferSize_;
00097
00098 bool CustomBuffer_;
00099
00100 };
00101
00102
00103 }
00104
00105 }
00106
00107
00108 #endif
00109
00110 #endif
00111
00112
00113
00114