//================================================================
// lib2D plugin
//
// OpenCL definitions
//
// AUTHOR:  Gabor Nagy
// DATE:    2023-May-19 03:02:32
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved
//================================================================
#ifndef _EOpenCL_h
#define _EOpenCL_h

#define CL_TARGET_OPENCL_VERSION  220  // OpenCL 2.2 The clinfo command will give the current OpenCL version on a system
#include <CL/cl.h>

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif


typedef struct
{
	unsigned int  OpenGLID;
	cl_mem        OpenCLBuffer;
	EBool         Initialized;
} EpOpenCLGLTexture;



extern cl_context        ECL_OpenCLContext;
extern cl_device_id      ECL_OpenCLDevice;

extern pthread_mutex_t   ECL_OpenGL_mutex;
extern pthread_mutex_t   ECL_GLTexture_mutex;

EList(extern, EpOpenCLGLTexture, ECL_OpenCLGLTextures);

extern int           (*ECL_OpenGLTextureAdd)(const unsigned int PGLIndex);

extern EBool         ECL_OpenCL_OpenGLInteroperable;
extern uint16_t      ECL_Verbosity;


extern int           ECL_OpenCLInit(void);
extern void          ECL_OpenCLFree(void);

extern const char*   ECL_CodeToString(const int PCode);
extern int           ECL_Compile(cl_device_id PDevice, cl_context PContext, const char* PSource, cl_program* PCLProgramP);


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
}	// Close scope of 'extern "C"' declaration
#endif

#endif // _EOpenCL_h
