gKitGL
|
00001 00002 #ifndef _CL_IMAGE_H 00003 #define _CL_IMAGE_H 00004 00005 #include <CL/CLPlatform.h> 00006 00007 #include "CLResource.h" 00008 00009 00010 namespace gk { 00011 00012 struct ImageOrigin 00013 { 00014 size_t x; 00015 size_t y; 00016 size_t z; 00017 00018 ImageOrigin( const size_t _x, const size_t _y, const size_t _z= 0 ) 00019 : 00020 x(_x), 00021 y(_y), 00022 z(_z) 00023 {} 00024 00025 operator const size_t *( ) const 00026 { 00027 return &x; 00028 } 00029 }; 00030 00031 struct ImageRegion 00032 { 00033 size_t width; 00034 size_t height; 00035 size_t depth; 00036 00037 ImageRegion( const size_t w, const size_t h, const size_t d= 1 ) 00038 : 00039 width(w), 00040 height(h), 00041 depth(d) 00042 {} 00043 00044 operator const size_t *( ) const 00045 { 00046 return &width; 00047 } 00048 }; 00049 00050 00051 class CLImage : public CLResource 00052 { 00053 protected: 00054 cl_mem m_image; 00055 size_t m_width; 00056 size_t m_height; 00057 size_t m_row_pitch; 00058 00059 public: 00060 CLImage( const cl_mem_flags flags, const unsigned int glname, const unsigned int texture_target, const int level ); 00061 CLImage( const cl_mem_flags flags, const cl_image_format *format, const size_t width, const size_t height, void *data= NULL, const size_t pitch= 0 ); 00062 ~CLImage( ) {} 00063 00064 int createCLResource( ); 00065 int releaseCLResource( ); 00066 00067 int update( const ImageOrigin& origin, const ImageRegion& region, const void *data, const cl_bool block= CL_FALSE, cl_event *wait= NULL ); 00068 int update( const void *data, cl_bool block= CL_FALSE, cl_event *wait= NULL ); 00069 int update( const size_t x, const size_t y, const size_t w, const size_t h, const void *data, const cl_bool block= CL_FALSE, cl_event *wait= NULL ); 00070 00071 int get( const ImageOrigin& origin, const ImageRegion& region, void *data, const cl_bool block= CL_FALSE, cl_event *wait= NULL ); 00072 int get( void *data, const cl_bool block= CL_FALSE, cl_event *wait= NULL ); 00073 int get( const size_t x, const size_t y, const size_t w, const size_t h, void *data, const cl_bool block= CL_FALSE, cl_event *wait= NULL ); 00074 00075 const cl_mem *object( ) const 00076 { 00077 return &m_image; 00078 } 00079 00080 cl_mem *object( ) 00081 { 00082 return &m_image; 00083 } 00084 00085 cl_mem image( ) const 00086 { 00087 return m_image; 00088 } 00089 }; 00090 00091 00092 CLImage *createImage( const cl_mem_flags flags, const cl_image_format *format, const size_t width, const size_t height, void *data= NULL, const size_t pitch= 0 ); 00093 CLImage *createReadImage( const cl_image_format *format, const size_t width, const size_t height, void *data= NULL, const size_t pitch= 0 ); 00094 CLImage *createWriteImage( const cl_image_format *format, const size_t width, const size_t height, const size_t pitch= 0 ); 00095 00096 CLImage *createGLObjectImage( const cl_mem_flags flags, const unsigned int glname, const unsigned int texture_target, const int level= 0 ); 00097 00098 //~ CLImage *createReadGLObjectImage( const unsigned int glname, const unsigned int texture_target, const int level= 0 ); 00099 //~ CLImage *createWriteGLObjectImage( const unsigned int glname, const unsigned int texture_target, const int level= 0 ); 00100 00101 //~ + integration avec gKitGL : createReadImage( GLTexture * texture ); 00102 00103 } 00104 00105 #endif