2018-08-27 22:30:40 +08:00
|
|
|
/*
|
2020-01-08 17:39:51 +08:00
|
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
2018-08-27 22:30:40 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-08-27 22:30:40 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/os_library.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/sharings/sharing.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
|
|
|
#include "CL/cl.h"
|
2018-08-27 22:30:40 +08:00
|
|
|
#include "GL/gl.h"
|
|
|
|
#include "GL/glext.h"
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <mutex>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
struct _tagCLGLSyncInfo;
|
|
|
|
typedef struct _tagCLGLSyncInfo CL_GL_SYNC_INFO, *PCL_GL_SYNC_INFO;
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-08-27 22:30:40 +08:00
|
|
|
class Event;
|
|
|
|
class GlArbSyncEvent;
|
|
|
|
class GLSharingFunctions;
|
|
|
|
class OSInterface;
|
2018-10-22 22:43:20 +08:00
|
|
|
class OsContext;
|
2018-08-27 22:30:40 +08:00
|
|
|
|
|
|
|
typedef unsigned int OS_HANDLE;
|
|
|
|
|
|
|
|
typedef struct CLGLContextInfo {
|
|
|
|
OS_HANDLE DeviceHandle;
|
|
|
|
OS_HANDLE ContextHandle;
|
|
|
|
} ContextInfo;
|
|
|
|
|
|
|
|
class GLSharingFunctions : public SharingFunctions {
|
|
|
|
public:
|
|
|
|
GLSharingFunctions() = default;
|
|
|
|
|
|
|
|
uint32_t getId() const override {
|
|
|
|
return GLSharingFunctions::sharingId;
|
|
|
|
}
|
|
|
|
static const uint32_t sharingId;
|
|
|
|
|
2019-05-29 18:33:09 +08:00
|
|
|
static cl_int getSupportedFormats(cl_mem_flags flags,
|
|
|
|
cl_mem_object_type imageType,
|
|
|
|
size_t numEntries,
|
|
|
|
cl_GLenum *formats,
|
|
|
|
uint32_t *numImageFormats);
|
|
|
|
|
2020-01-08 17:39:51 +08:00
|
|
|
virtual GLboolean initGLFunctions() = 0;
|
|
|
|
virtual bool isOpenGlSharingSupported() = 0;
|
2018-08-27 22:30:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class GlSharing : public SharingHandler {
|
|
|
|
public:
|
|
|
|
GlSharing(GLSharingFunctions *sharingFunctions, unsigned int glObjectType, unsigned int glObjectId)
|
|
|
|
: sharingFunctions(sharingFunctions), clGlObjectType(glObjectType), clGlObjectId(glObjectId){};
|
|
|
|
GLSharingFunctions *peekFunctionsHandler() { return sharingFunctions; }
|
|
|
|
void getGlObjectInfo(unsigned int *pClGlObjectType, unsigned int *pClGlObjectId) {
|
|
|
|
if (pClGlObjectType) {
|
|
|
|
*pClGlObjectType = clGlObjectType;
|
|
|
|
}
|
|
|
|
if (pClGlObjectId) {
|
|
|
|
*pClGlObjectId = clGlObjectId;
|
|
|
|
}
|
|
|
|
}
|
2019-05-29 18:33:09 +08:00
|
|
|
static const std::unordered_map<GLenum, const cl_image_format> gLToCLFormats;
|
2018-08-27 22:30:40 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
int synchronizeHandler(UpdateData &updateData) override;
|
|
|
|
GLSharingFunctions *sharingFunctions = nullptr;
|
|
|
|
unsigned int clGlObjectType = 0u;
|
|
|
|
unsigned int clGlObjectId = 0u;
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|