Move GL sharing to windows directory

Change-Id: I9aeb60d31d5c49c0464b2cd8296dc5d79ec41d63
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban
2020-01-08 10:39:51 +01:00
committed by sys_ocldev
parent 2e95ef42ae
commit 9865003cc2
33 changed files with 612 additions and 522 deletions

View File

@ -15,7 +15,7 @@
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include <GL/gl.h>
@ -59,8 +59,10 @@ void cleanupArbSyncObject(OSInterface &osInterface, CL_GL_SYNC_INFO *glSyncInfo)
}
bool setupArbSyncObject(GLSharingFunctions &sharing, OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
glSyncInfo.hContextToBlock = static_cast<D3DKMT_HANDLE>(sharing.getGLContextHandle());
auto glDevice = static_cast<D3DKMT_HANDLE>(sharing.getGLDeviceHandle());
auto &sharingFunctions = static_cast<GLSharingFunctionsWindows &>(sharing);
glSyncInfo.hContextToBlock = static_cast<D3DKMT_HANDLE>(sharingFunctions.getGLContextHandle());
auto glDevice = static_cast<D3DKMT_HANDLE>(sharingFunctions.getGLDeviceHandle());
auto wddm = osInterface.get()->getWddm();
D3DKMT_CREATESYNCHRONIZATIONOBJECT serverSyncInitInfo = {0};

View File

@ -1,14 +1,16 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "core/os_interface/windows/windows_wrapper.h"
#include <cstdint>
#define OSAPI WINAPI
typedef uint32_t GLType;
typedef HDC GLDisplay;
typedef HGLRC GLContext;
// Windows OpenGL functions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -7,8 +7,9 @@
#include "core/os_interface/windows/windows_wrapper.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/helpers/windows/gl_helper.h"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include <algorithm>
#include <cstdint>
@ -20,121 +21,6 @@ extern const char *openglDllName;
namespace NEO {
GLboolean GLSharingFunctions::makeCurrent(GLContext contextHandle, GLDisplay displayHandle) {
if (displayHandle == 0) {
displayHandle = GLHDCHandle;
}
return this->wglMakeCurrent(displayHandle, contextHandle);
}
GLSharingFunctions::~GLSharingFunctions() {
if (pfnWglDeleteContext) {
pfnWglDeleteContext(GLHGLRCHandleBkpCtx);
}
}
GLboolean GLSharingFunctions::initGLFunctions() {
glLibrary.reset(OsLibrary::load(Os::openglDllName));
if (glLibrary->isLoaded()) {
glFunctionHelper wglLibrary(glLibrary.get(), "wglGetProcAddress");
GLGetCurrentContext = (*glLibrary)["wglGetCurrentContext"];
GLGetCurrentDisplay = (*glLibrary)["wglGetCurrentDC"];
glGetString = (*glLibrary)["glGetString"];
glGetIntegerv = (*glLibrary)["glGetIntegerv"];
pfnWglCreateContext = (*glLibrary)["wglCreateContext"];
pfnWglDeleteContext = (*glLibrary)["wglDeleteContext"];
pfnWglShareLists = (*glLibrary)["wglShareLists"];
wglMakeCurrent = (*glLibrary)["wglMakeCurrent"];
GLSetSharedOCLContextState = wglLibrary["wglSetSharedOCLContextStateINTEL"];
GLAcquireSharedBuffer = wglLibrary["wglAcquireSharedBufferINTEL"];
GLReleaseSharedBuffer = wglLibrary["wglReleaseSharedBufferINTEL"];
GLAcquireSharedRenderBuffer = wglLibrary["wglAcquireSharedRenderBufferINTEL"];
GLReleaseSharedRenderBuffer = wglLibrary["wglReleaseSharedRenderBufferINTEL"];
GLAcquireSharedTexture = wglLibrary["wglAcquireSharedTextureINTEL"];
GLReleaseSharedTexture = wglLibrary["wglReleaseSharedTextureINTEL"];
GLRetainSync = wglLibrary["wglRetainSyncINTEL"];
GLReleaseSync = wglLibrary["wglReleaseSyncINTEL"];
GLGetSynciv = wglLibrary["wglGetSyncivINTEL"];
glGetStringi = wglLibrary["glGetStringi"];
}
this->pfnGlArbSyncObjectCleanup = cleanupArbSyncObject;
this->pfnGlArbSyncObjectSetup = setupArbSyncObject;
this->pfnGlArbSyncObjectSignal = signalArbSyncObject;
this->pfnGlArbSyncObjectWaitServer = serverWaitForArbSyncObject;
return 1;
}
bool GLSharingFunctions::isGlSharingEnabled() {
static bool oglLibAvailable = std::unique_ptr<OsLibrary>(OsLibrary::load(Os::openglDllName)).get() != nullptr;
return oglLibAvailable;
}
bool GLSharingFunctions::isOpenGlExtensionSupported(const unsigned char *pExtensionString) {
bool LoadedNull = (glGetStringi == nullptr) || (glGetIntegerv == nullptr);
if (LoadedNull) {
return false;
}
cl_int NumberOfExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &NumberOfExtensions);
for (cl_int i = 0; i < NumberOfExtensions; i++) {
std::basic_string<unsigned char> pString = glGetStringi(GL_EXTENSIONS, i);
if (pString == pExtensionString) {
return true;
}
}
return false;
}
bool GLSharingFunctions::isOpenGlSharingSupported() {
std::basic_string<unsigned char> Vendor = glGetString(GL_VENDOR);
const unsigned char intelVendor[] = "Intel";
if ((Vendor.empty()) || (Vendor != intelVendor)) {
return false;
}
std::basic_string<unsigned char> Version = glGetString(GL_VERSION);
if (Version.empty()) {
return false;
}
bool IsOpenGLES = false;
const unsigned char versionES[] = "OpenGL ES";
if (Version.find(versionES) != std::string::npos) {
IsOpenGLES = true;
}
if (IsOpenGLES == true) {
const unsigned char versionES1[] = "OpenGL ES 1.";
if (Version.find(versionES1) != std::string::npos) {
const unsigned char supportGLOES[] = "GL_OES_framebuffer_object";
if (isOpenGlExtensionSupported(supportGLOES) == false) {
return false;
}
}
} else {
if (Version[0] < '3') {
const unsigned char supportGLEXT[] = "GL_EXT_framebuffer_object";
if (isOpenGlExtensionSupported(supportGLEXT) == false) {
return false;
}
}
}
return true;
}
void GLSharingFunctions::createBackupContext() {
if (pfnWglCreateContext) {
GLHGLRCHandleBkpCtx = pfnWglCreateContext(GLHDCHandle);
pfnWglShareLists(GLHGLRCHandle, GLHGLRCHandleBkpCtx);
}
}
cl_int GLSharingFunctions::getSupportedFormats(cl_mem_flags flags,
cl_mem_object_type imageType,
size_t numEntries,

View File

@ -1,27 +1,27 @@
#
# Copyright (C) 2017-2019 Intel Corporation
# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
set(RUNTIME_SRCS_SHARINGS_GL
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cl_gl_api.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cl_gl_api_intel.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_buffer.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_buffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_cl_image_format.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_context_guard.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sync_event.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_sync_event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_texture.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_texture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cl_gl_api.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cl_gl_api_intel.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_buffer.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_cl_image_format.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_context_guard.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_sync_event.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_texture.h
)
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_SHARINGS_GL})
add_subdirectories()
set(ADDITIONAL_EXPORTS "clEnqueueMarkerWithSyncObjectINTEL"
"clGetCLObjectInfoINTEL"
"clGetCLEventInfoINTEL"
@ -29,9 +29,4 @@ if(WIN32)
foreach(EXPORT_NAME ${ADDITIONAL_EXPORTS})
set(MSVC_DEF_ADDITIONAL_EXPORTS "${MSVC_DEF_ADDITIONAL_EXPORTS}\n${EXPORT_NAME}")
endforeach(EXPORT_NAME)
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_SHARINGS_GL})
set(MSVC_DEF_ADDITIONAL_EXPORTS "${MSVC_DEF_ADDITIONAL_EXPORTS}" PARENT_SCOPE)
target_sources(${SHARINGS_ENABLE_LIB_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/win_enable_gl.cpp)
endif()

View File

@ -19,9 +19,9 @@
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/platform/platform.h"
#include "runtime/sharings/gl/gl_buffer.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/gl_sync_event.h"
#include "runtime/sharings/gl/gl_texture.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "runtime/tracing/tracing_notify.h"
#include "CL/cl.h"
@ -337,7 +337,7 @@ cl_int CL_API_CALL clGetGLContextInfoKHR(const cl_context_properties *properties
return retVal;
}
auto glSharing = std::make_unique<GLSharingFunctions>();
auto glSharing = std::make_unique<GLSharingFunctionsWindows>();
glSharing->initGLFunctions();
if (glSharing->isOpenGlSharingSupported() == false) {
retVal = CL_INVALID_CONTEXT;

View File

@ -1,34 +0,0 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/sharings/gl/gl_sharing.h"
namespace NEO {
GLContextGuard::GLContextGuard(GLSharingFunctions &sharingFcns) : sharingFunctions(&sharingFcns) {
currentContextHandle = sharingFcns.getCurrentContext();
currentDisplayHandle = sharingFcns.getCurrentDisplay();
auto ctxToMakeCurrent = sharingFcns.getContextHandle();
if (currentContextHandle == 0) {
ctxToMakeCurrent = sharingFcns.getBackupContextHandle();
}
if (currentContextHandle != sharingFcns.getContextHandle() && currentContextHandle != sharingFcns.getBackupContextHandle()) {
if (sharingFcns.makeCurrent(ctxToMakeCurrent) == GL_FALSE) {
while (sharingFcns.makeCurrent(sharingFcns.getBackupContextHandle()) == GL_FALSE) {
;
}
}
}
}
GLContextGuard::~GLContextGuard() {
if (currentContextHandle != sharingFunctions->getContextHandle()) {
sharingFunctions->makeCurrent(currentContextHandle, currentDisplayHandle);
}
}
} // namespace NEO

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/os_interface/windows/gl/gl_sharing_os.h"
#include "runtime/sharings/gl/gl_sharing.h"
namespace NEO {
class GLContextGuard {
public:
GLContextGuard() = delete;
GLContextGuard(GLSharingFunctions &sharingFcns);
~GLContextGuard();
protected:
GLSharingFunctions *sharingFunctions;
GLContext currentContextHandle;
GLDisplay currentDisplayHandle;
};
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -8,9 +8,9 @@
#include "runtime/sharings/gl/gl_sharing.h"
#include "core/helpers/string.h"
#include "runtime/context/context.h"
#include "runtime/context/context.inl"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
#include "runtime/sharings/gl/gl_context_guard.h"
#include "runtime/sharings/sharing_factory.h"
#include <unordered_map>
@ -70,35 +70,6 @@ int GlSharing::synchronizeHandler(UpdateData &updateData) {
return CL_SUCCESS;
}
template <>
GLSharingFunctions *Context::getSharing() {
if (GLSharingFunctions::sharingId >= sharingFunctions.size()) {
DEBUG_BREAK_IF(GLSharingFunctions::sharingId >= sharingFunctions.size());
return nullptr;
}
return reinterpret_cast<GLSharingFunctions *>(sharingFunctions[GLSharingFunctions::sharingId].get());
}
GlArbSyncEvent *GLSharingFunctions::getGlArbSyncEvent(Event &baseEvent) {
std::lock_guard<std::mutex> lock{glArbEventMutex};
auto it = glArbEventMapping.find(&baseEvent);
if (it != glArbEventMapping.end()) {
return it->second;
}
return nullptr;
}
void GLSharingFunctions::removeGlArbSyncEventMapping(Event &baseEvent) {
std::lock_guard<std::mutex> lock{glArbEventMutex};
auto it = glArbEventMapping.find(&baseEvent);
if (it == glArbEventMapping.end()) {
DEBUG_BREAK_IF(it == glArbEventMapping.end());
return;
}
glArbEventMapping.erase(it);
}
char *createArbSyncEventName() {
static std::atomic<uint32_t> synchCounter{0};
uint32_t id = synchCounter++;
@ -113,4 +84,7 @@ char *createArbSyncEventName() {
}
void destroyArbSyncEventName(char *name) { delete[] name; }
template GLSharingFunctions *Context::getSharing<GLSharingFunctions>();
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -8,8 +8,6 @@
#pragma once
#include "core/os_interface/os_library.h"
#include "runtime/helpers/windows/gl_helper.h"
#include "runtime/os_interface/windows/gl/gl_sharing_os.h"
#include "runtime/sharings/sharing.h"
#include "CL/cl.h"
@ -32,37 +30,6 @@ class OsContext;
typedef unsigned int OS_HANDLE;
//OpenGL API names
typedef GLboolean(OSAPI *PFNOGLSetSharedOCLContextStateINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLboolean state, GLvoid *pContextInfo);
typedef GLboolean(OSAPI *PFNOGLAcquireSharedBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pBufferInfo);
typedef GLboolean(OSAPI *PFNOGLAcquireSharedRenderBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLboolean(OSAPI *PFNOGLAcquireSharedTextureINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSharedBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pBufferInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSharedRenderBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSharedTextureINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLContext(OSAPI *PFNOGLGetCurrentContext)();
typedef GLDisplay(OSAPI *PFNOGLGetCurrentDisplay)();
typedef GLboolean(OSAPI *PFNOGLMakeCurrent)(GLDisplay hdcHandle, void *draw, void *read, GLContext contextHandle);
typedef GLboolean(OSAPI *PFNOGLRetainSyncINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pSyncInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSyncINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pSync);
typedef void(OSAPI *PFNOGLGetSyncivINTEL)(GLvoid *pSync, GLenum pname, GLint *value);
typedef const GLubyte *(OSAPI *PFNglGetString)(GLenum name);
typedef const GLubyte *(OSAPI *PFNglGetStringi)(GLenum name, GLuint index);
typedef void(OSAPI *PFNglGetIntegerv)(GLenum pname, GLint *params);
typedef void(OSAPI *PFNglBindTexture)(GLenum target, GLuint texture);
//wgl
typedef BOOL(OSAPI *PFNwglMakeCurrent)(HDC, HGLRC);
typedef GLContext(OSAPI *PFNwglCreateContext)(GLDisplay hdcHandle);
typedef int(OSAPI *PFNwglShareLists)(GLContext contextHandle, GLContext backupContextHandle);
typedef BOOL(OSAPI *PFNwglDeleteContext)(HGLRC hglrcHandle);
typedef bool (*PFNglArbSyncObjectSetup)(GLSharingFunctions &sharing, OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo);
typedef void (*PFNglArbSyncObjectCleanup)(OSInterface &osInterface, CL_GL_SYNC_INFO *glSyncInfo);
typedef void (*PFNglArbSyncObjectSignal)(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo);
typedef void (*PFNglArbSyncObjectWaitServer)(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo);
typedef struct CLGLContextInfo {
OS_HANDLE DeviceHandle;
OS_HANDLE ContextHandle;
@ -70,190 +37,21 @@ typedef struct CLGLContextInfo {
class GLSharingFunctions : public SharingFunctions {
public:
~GLSharingFunctions() override;
GLSharingFunctions() = default;
GLSharingFunctions(GLType glhdcType, GLContext glhglrcHandle, GLContext glhglrcHandleBkpCtx, GLDisplay glhdcHandle) : GLHDCType(glhdcType), GLHGLRCHandle(glhglrcHandle), GLHGLRCHandleBkpCtx(glhglrcHandleBkpCtx), GLHDCHandle(glhdcHandle) {
initGLFunctions();
updateOpenGLContext();
createBackupContext();
}
uint32_t getId() const override {
return GLSharingFunctions::sharingId;
}
static const uint32_t sharingId;
void updateOpenGLContext() {
if (GLSetSharedOCLContextState) {
setSharedOCLContextState();
}
}
// Interface
GLboolean initGLFunctions();
static bool isGlSharingEnabled();
static cl_int getSupportedFormats(cl_mem_flags flags,
cl_mem_object_type imageType,
size_t numEntries,
cl_GLenum *formats,
uint32_t *numImageFormats);
GLboolean setSharedOCLContextState() {
ContextInfo CtxInfo = {0};
GLboolean retVal = GLSetSharedOCLContextState(GLHDCHandle, GLHGLRCHandle, CL_TRUE, &CtxInfo);
if (retVal == GL_FALSE) {
return GL_FALSE;
}
GLContextHandle = CtxInfo.ContextHandle;
GLDeviceHandle = CtxInfo.DeviceHandle;
return retVal;
}
GLboolean acquireSharedBufferINTEL(GLvoid *pBufferInfo) {
return GLAcquireSharedBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pBufferInfo);
}
GLboolean releaseSharedBufferINTEL(GLvoid *pBufferInfo) {
return GLReleaseSharedBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pBufferInfo);
}
GLboolean acquireSharedRenderBuffer(GLvoid *pResourceInfo) {
return GLAcquireSharedRenderBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean releaseSharedRenderBuffer(GLvoid *pResourceInfo) {
return GLReleaseSharedRenderBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean acquireSharedTexture(GLvoid *pResourceInfo) {
return GLAcquireSharedTexture(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean releaseSharedTexture(GLvoid *pResourceInfo) {
return GLReleaseSharedTexture(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean retainSync(GLvoid *pSyncInfo) {
return GLRetainSync(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pSyncInfo);
}
GLboolean releaseSync(GLvoid *pSync) {
return GLReleaseSync(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pSync);
}
void getSynciv(GLvoid *pSync, GLenum pname, GLint *value) {
return GLGetSynciv(pSync, pname, value);
}
GLContext getCurrentContext() {
return GLGetCurrentContext();
}
GLDisplay getCurrentDisplay() {
return GLGetCurrentDisplay();
}
GLboolean makeCurrent(GLContext contextHandle, GLDisplay displayHandle = 0);
GLContext getBackupContextHandle() {
return GLHGLRCHandleBkpCtx;
}
GLContext getContextHandle() {
return GLHGLRCHandle;
}
void createBackupContext();
bool isOpenGlExtensionSupported(const unsigned char *pExtentionString);
bool isOpenGlSharingSupported();
std::mutex mutex;
std::vector<std::pair<unsigned int, GraphicsAllocation *>> graphicsAllocationsForGlBufferReuse;
GlArbSyncEvent *getGlArbSyncEvent(Event &baseEvent);
template <typename EventType = GlArbSyncEvent>
auto getOrCreateGlArbSyncEvent(Event &baseEvent) -> decltype(EventType::create(baseEvent)) {
std::lock_guard<std::mutex> lock{glArbEventMutex};
auto it = glArbEventMapping.find(&baseEvent);
if (it != glArbEventMapping.end()) {
return it->second;
}
auto arbEvent = EventType::create(baseEvent);
if (nullptr == arbEvent) {
return arbEvent;
}
glArbEventMapping[&baseEvent] = arbEvent;
return arbEvent;
}
void removeGlArbSyncEventMapping(Event &baseEvent);
bool glArbSyncObjectSetup(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
return pfnGlArbSyncObjectSetup(*this, osInterface, glSyncInfo);
}
void glArbSyncObjectCleanup(OSInterface &osInterface, CL_GL_SYNC_INFO *glSyncInfo) {
pfnGlArbSyncObjectCleanup(osInterface, glSyncInfo);
}
void glArbSyncObjectSignal(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo) { pfnGlArbSyncObjectSignal(osContext, glSyncInfo); }
void glArbSyncObjectWaitServer(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
pfnGlArbSyncObjectWaitServer(osInterface, glSyncInfo);
}
OS_HANDLE getGLDeviceHandle() const {
return GLDeviceHandle;
}
OS_HANDLE getGLContextHandle() const {
return GLContextHandle;
}
protected:
std::unique_ptr<OsLibrary> glLibrary;
GLType GLHDCType = 0;
GLContext GLHGLRCHandle = 0;
GLContext GLHGLRCHandleBkpCtx = 0;
GLDisplay GLHDCHandle = 0;
OS_HANDLE GLDeviceHandle = 0;
OS_HANDLE GLContextHandle = 0;
PFNOGLSetSharedOCLContextStateINTEL GLSetSharedOCLContextState = nullptr;
PFNOGLAcquireSharedBufferINTEL GLAcquireSharedBuffer = nullptr;
PFNOGLReleaseSharedBufferINTEL GLReleaseSharedBuffer = nullptr;
PFNOGLAcquireSharedRenderBufferINTEL GLAcquireSharedRenderBuffer = nullptr;
PFNOGLReleaseSharedRenderBufferINTEL GLReleaseSharedRenderBuffer = nullptr;
PFNOGLAcquireSharedTextureINTEL GLAcquireSharedTexture = nullptr;
PFNOGLReleaseSharedTextureINTEL GLReleaseSharedTexture = nullptr;
PFNOGLGetCurrentContext GLGetCurrentContext = nullptr;
PFNOGLGetCurrentDisplay GLGetCurrentDisplay = nullptr;
PFNglGetString glGetString = nullptr;
PFNglGetStringi glGetStringi = nullptr;
PFNglGetIntegerv glGetIntegerv = nullptr;
PFNwglCreateContext pfnWglCreateContext = nullptr;
PFNwglMakeCurrent wglMakeCurrent = nullptr;
PFNwglShareLists pfnWglShareLists = nullptr;
PFNwglDeleteContext pfnWglDeleteContext = nullptr;
PFNOGLRetainSyncINTEL GLRetainSync = nullptr;
PFNOGLReleaseSyncINTEL GLReleaseSync = nullptr;
PFNOGLGetSyncivINTEL GLGetSynciv = nullptr;
PFNglArbSyncObjectSetup pfnGlArbSyncObjectSetup = nullptr;
PFNglArbSyncObjectCleanup pfnGlArbSyncObjectCleanup = nullptr;
PFNglArbSyncObjectSignal pfnGlArbSyncObjectSignal = nullptr;
PFNglArbSyncObjectWaitServer pfnGlArbSyncObjectWaitServer = nullptr;
// support for GL_ARB_cl_event
std::mutex glArbEventMutex;
std::unordered_map<Event *, GlArbSyncEvent *> glArbEventMapping;
virtual GLboolean initGLFunctions() = 0;
virtual bool isOpenGlSharingSupported() = 0;
};
class GlSharing : public SharingHandler {
@ -278,17 +76,4 @@ class GlSharing : public SharingHandler {
unsigned int clGlObjectId = 0u;
};
class GLContextGuard {
public:
GLContextGuard() = delete;
GLContextGuard(GLSharingFunctions &sharingFcns);
~GLContextGuard();
protected:
GLSharingFunctions *sharingFunctions;
GLContext currentContextHandle;
GLDisplay currentDisplayHandle;
};
} // namespace NEO

View File

@ -0,0 +1,27 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
set(RUNTIME_SRCS_SHARINGS_GL_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_buffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_context_guard.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sync_event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_texture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/win_enable_gl.h
)
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_SHARINGS_GL_WINDOWS})
set(RUNTIME_SRCS_SHARINGS_GL_ENABLE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/win_enable_gl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/win_enable_gl.h
)
target_sources(${SHARINGS_ENABLE_LIB_NAME} PRIVATE ${RUNTIME_SRCS_SHARINGS_GL_ENABLE_WINDOWS})
endif()

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -13,7 +13,7 @@
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/helpers/base_object.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include <GL/gl.h>
@ -30,7 +30,7 @@ bool GlArbSyncEvent::setBaseEvent(Event &ev) {
auto cmdQueue = ev.getCommandQueue();
auto osInterface = cmdQueue->getGpgpuCommandStreamReceiver().getOSInterface();
UNRECOVERABLE_IF(osInterface == nullptr);
if (false == ctx->getSharing<NEO::GLSharingFunctions>()->glArbSyncObjectSetup(*osInterface, *glSyncInfo)) {
if (false == ctx->getSharing<GLSharingFunctionsWindows>()->glArbSyncObjectSetup(*osInterface, *glSyncInfo)) {
return false;
}
@ -45,7 +45,7 @@ bool GlArbSyncEvent::setBaseEvent(Event &ev) {
GlArbSyncEvent::~GlArbSyncEvent() {
if (baseEvent != nullptr) {
ctx->getSharing<NEO::GLSharingFunctions>()->glArbSyncObjectCleanup(*osInterface, glSyncInfo.get());
ctx->getSharing<GLSharingFunctionsWindows>()->glArbSyncObjectCleanup(*osInterface, glSyncInfo.get());
baseEvent->decRefInternal();
}
}
@ -69,8 +69,8 @@ void GlArbSyncEvent::unblockEventBy(Event &event, uint32_t taskLevel, int32_t tr
return;
}
ctx->getSharing<NEO::GLSharingFunctions>()->glArbSyncObjectSignal(event.getCommandQueue()->getGpgpuCommandStreamReceiver().getOsContext(), *glSyncInfo);
ctx->getSharing<NEO::GLSharingFunctions>()->glArbSyncObjectWaitServer(*osInterface, *glSyncInfo);
ctx->getSharing<GLSharingFunctionsWindows>()->glArbSyncObjectSignal(event.getCommandQueue()->getGpgpuCommandStreamReceiver().getOsContext(), *glSyncInfo);
ctx->getSharing<GLSharingFunctionsWindows>()->glArbSyncObjectWaitServer(*osInterface, *glSyncInfo);
}
} // namespace NEO
@ -104,7 +104,7 @@ clGetCLEventInfoINTEL(cl_event event, PCL_GL_SYNC_INFO *pSyncInfoHandleRet, cl_c
return CL_SUCCESS;
}
auto sharing = neoEvent->getContext()->getSharing<NEO::GLSharingFunctions>();
auto sharing = neoEvent->getContext()->getSharing<NEO::GLSharingFunctionsWindows>();
if (sharing == nullptr) {
return CL_INVALID_OPERATION;
}
@ -128,8 +128,8 @@ clReleaseGlSharedEventINTEL(cl_event event) {
if (nullptr == neoEvent) {
return CL_INVALID_EVENT;
}
auto arbSyncEvent = neoEvent->getContext()->getSharing<NEO::GLSharingFunctions>()->getGlArbSyncEvent(*neoEvent);
neoEvent->getContext()->getSharing<NEO::GLSharingFunctions>()->removeGlArbSyncEventMapping(*neoEvent);
auto arbSyncEvent = neoEvent->getContext()->getSharing<NEO::GLSharingFunctionsWindows>()->getGlArbSyncEvent(*neoEvent);
neoEvent->getContext()->getSharing<NEO::GLSharingFunctionsWindows>()->removeGlArbSyncEventMapping(*neoEvent);
if (nullptr != arbSyncEvent) {
arbSyncEvent->release();
}

View File

@ -5,7 +5,7 @@
*
*/
#include "gl_buffer.h"
#include "runtime/sharings/gl/gl_buffer.h"
// clang-format off
#include "public/cl_gl_private_intel.h"
@ -16,6 +16,7 @@
#include "runtime/helpers/get_info.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "config.h"
@ -26,7 +27,7 @@ Buffer *GlBuffer::createSharedGlBuffer(Context *context, cl_mem_flags flags, uns
CL_GL_BUFFER_INFO bufferInfo = {0};
bufferInfo.bufferName = bufferId;
GLSharingFunctions *sharingFunctions = context->getSharing<GLSharingFunctions>();
GLSharingFunctionsWindows *sharingFunctions = context->getSharing<GLSharingFunctionsWindows>();
if (sharingFunctions->acquireSharedBufferINTEL(&bufferInfo) == GL_FALSE) {
errorCode.set(CL_INVALID_GL_OBJECT);
return nullptr;
@ -43,7 +44,8 @@ Buffer *GlBuffer::createSharedGlBuffer(Context *context, cl_mem_flags flags, uns
}
void GlBuffer::synchronizeObject(UpdateData &updateData) {
const auto currentSharedHandle = updateData.memObject->getGraphicsAllocation()->peekSharedHandle();
auto sharingFunctions = static_cast<GLSharingFunctionsWindows *>(this->sharingFunctions);
CL_GL_BUFFER_INFO bufferInfo = {};
bufferInfo.bufferName = this->clGlObjectId;
sharingFunctions->acquireSharedBufferINTEL(&bufferInfo);
@ -52,6 +54,7 @@ void GlBuffer::synchronizeObject(UpdateData &updateData) {
updateData.synchronizationStatus = SynchronizeStatus::ACQUIRE_SUCCESFUL;
updateData.memObject->getGraphicsAllocation()->setAllocationOffset(bufferInfo.bufferOffset);
const auto currentSharedHandle = updateData.memObject->getGraphicsAllocation()->peekSharedHandle();
if (currentSharedHandle != updateData.sharedHandle) {
updateData.updateData = new CL_GL_BUFFER_INFO(bufferInfo);
}
@ -81,6 +84,8 @@ void GlBuffer::resolveGraphicsAllocationChange(osHandle currentSharedHandle, Upd
}
void GlBuffer::popGraphicsAllocationFromReuse(GraphicsAllocation *graphicsAllocation) {
auto sharingFunctions = static_cast<GLSharingFunctionsWindows *>(this->sharingFunctions);
std::unique_lock<std::mutex> lock(sharingFunctions->mutex);
auto &graphicsAllocations = sharingFunctions->graphicsAllocationsForGlBufferReuse;
@ -96,6 +101,8 @@ void GlBuffer::popGraphicsAllocationFromReuse(GraphicsAllocation *graphicsAlloca
}
void GlBuffer::releaseReusedGraphicsAllocation() {
auto sharingFunctions = static_cast<GLSharingFunctionsWindows *>(this->sharingFunctions);
std::unique_lock<std::mutex> lock(sharingFunctions->mutex);
auto &allocationsVector = sharingFunctions->graphicsAllocationsForGlBufferReuse;
@ -113,7 +120,7 @@ void GlBuffer::releaseReusedGraphicsAllocation() {
}
GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigned int bufferId, _tagCLGLBufferInfo &bufferInfo) {
GLSharingFunctions *sharingFunctions = context->getSharing<GLSharingFunctions>();
GLSharingFunctionsWindows *sharingFunctions = context->getSharing<GLSharingFunctionsWindows>();
auto &allocationsVector = sharingFunctions->graphicsAllocationsForGlBufferReuse;
GraphicsAllocation *graphicsAllocation = nullptr;
bool reusedAllocation = false;
@ -155,6 +162,7 @@ GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigne
}
void GlBuffer::releaseResource(MemObj *memObject) {
auto sharingFunctions = static_cast<GLSharingFunctionsWindows *>(this->sharingFunctions);
CL_GL_BUFFER_INFO bufferInfo = {};
bufferInfo.bufferName = this->clGlObjectId;
sharingFunctions->releaseSharedBufferINTEL(&bufferInfo);

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/sharings/gl/gl_context_guard.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
namespace NEO {
GLContextGuard::GLContextGuard(GLSharingFunctions &sharingFcns) : sharingFunctions(&sharingFcns) {
auto &sharing = *static_cast<GLSharingFunctionsWindows *>(sharingFunctions);
currentContextHandle = sharing.getCurrentContext();
currentDisplayHandle = sharing.getCurrentDisplay();
auto ctxToMakeCurrent = sharing.getContextHandle();
if (currentContextHandle == 0) {
ctxToMakeCurrent = sharing.getBackupContextHandle();
}
if (currentContextHandle != sharing.getContextHandle() && currentContextHandle != sharing.getBackupContextHandle()) {
if (sharing.makeCurrent(ctxToMakeCurrent) == GL_FALSE) {
while (sharing.makeCurrent(sharing.getBackupContextHandle()) == GL_FALSE) {
;
}
}
}
}
GLContextGuard::~GLContextGuard() {
auto &sharing = *static_cast<GLSharingFunctionsWindows *>(sharingFunctions);
if (currentContextHandle != sharing.getContextHandle()) {
sharing.makeCurrent(currentContextHandle, currentDisplayHandle);
}
}
} // namespace NEO

View File

@ -0,0 +1,162 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "runtime/context/context.inl"
#include "runtime/helpers/windows/gl_helper.h"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
namespace NEO {
GLSharingFunctionsWindows::GLSharingFunctionsWindows(GLType glhdcType, GLContext glhglrcHandle, GLContext glhglrcHandleBkpCtx, GLDisplay glhdcHandle)
: GLHDCType(glhdcType), GLHGLRCHandle(glhglrcHandle), GLHGLRCHandleBkpCtx(glhglrcHandleBkpCtx), GLHDCHandle(glhdcHandle) {
initGLFunctions();
updateOpenGLContext();
createBackupContext();
}
GLSharingFunctionsWindows::~GLSharingFunctionsWindows() {
if (pfnWglDeleteContext) {
pfnWglDeleteContext(GLHGLRCHandleBkpCtx);
}
}
bool GLSharingFunctionsWindows::isGlSharingEnabled() {
static bool oglLibAvailable = std::unique_ptr<OsLibrary>(OsLibrary::load(Os::openglDllName)).get() != nullptr;
return oglLibAvailable;
}
void GLSharingFunctionsWindows::createBackupContext() {
if (pfnWglCreateContext) {
GLHGLRCHandleBkpCtx = pfnWglCreateContext(GLHDCHandle);
pfnWglShareLists(GLHGLRCHandle, GLHGLRCHandleBkpCtx);
}
}
GLboolean GLSharingFunctionsWindows::setSharedOCLContextState() {
ContextInfo CtxInfo = {0};
GLboolean retVal = GLSetSharedOCLContextState(GLHDCHandle, GLHGLRCHandle, CL_TRUE, &CtxInfo);
if (retVal == GL_FALSE) {
return GL_FALSE;
}
GLContextHandle = CtxInfo.ContextHandle;
GLDeviceHandle = CtxInfo.DeviceHandle;
return retVal;
}
bool GLSharingFunctionsWindows::isOpenGlExtensionSupported(const unsigned char *pExtensionString) {
bool LoadedNull = (glGetStringi == nullptr) || (glGetIntegerv == nullptr);
if (LoadedNull) {
return false;
}
cl_int NumberOfExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &NumberOfExtensions);
for (cl_int i = 0; i < NumberOfExtensions; i++) {
std::basic_string<unsigned char> pString = glGetStringi(GL_EXTENSIONS, i);
if (pString == pExtensionString) {
return true;
}
}
return false;
}
bool GLSharingFunctionsWindows::isOpenGlSharingSupported() {
std::basic_string<unsigned char> Vendor = glGetString(GL_VENDOR);
const unsigned char intelVendor[] = "Intel";
if ((Vendor.empty()) || (Vendor != intelVendor)) {
return false;
}
std::basic_string<unsigned char> Version = glGetString(GL_VERSION);
if (Version.empty()) {
return false;
}
bool IsOpenGLES = false;
const unsigned char versionES[] = "OpenGL ES";
if (Version.find(versionES) != std::string::npos) {
IsOpenGLES = true;
}
if (IsOpenGLES == true) {
const unsigned char versionES1[] = "OpenGL ES 1.";
if (Version.find(versionES1) != std::string::npos) {
const unsigned char supportGLOES[] = "GL_OES_framebuffer_object";
if (isOpenGlExtensionSupported(supportGLOES) == false) {
return false;
}
}
} else {
if (Version[0] < '3') {
const unsigned char supportGLEXT[] = "GL_EXT_framebuffer_object";
if (isOpenGlExtensionSupported(supportGLEXT) == false) {
return false;
}
}
}
return true;
}
GlArbSyncEvent *GLSharingFunctionsWindows::getGlArbSyncEvent(Event &baseEvent) {
std::lock_guard<std::mutex> lock{glArbEventMutex};
auto it = glArbEventMapping.find(&baseEvent);
if (it != glArbEventMapping.end()) {
return it->second;
}
return nullptr;
}
void GLSharingFunctionsWindows::removeGlArbSyncEventMapping(Event &baseEvent) {
std::lock_guard<std::mutex> lock{glArbEventMutex};
auto it = glArbEventMapping.find(&baseEvent);
if (it == glArbEventMapping.end()) {
DEBUG_BREAK_IF(it == glArbEventMapping.end());
return;
}
glArbEventMapping.erase(it);
}
GLboolean GLSharingFunctionsWindows::initGLFunctions() {
glLibrary.reset(OsLibrary::load(Os::openglDllName));
if (glLibrary->isLoaded()) {
glFunctionHelper wglLibrary(glLibrary.get(), "wglGetProcAddress");
GLGetCurrentContext = (*glLibrary)["wglGetCurrentContext"];
GLGetCurrentDisplay = (*glLibrary)["wglGetCurrentDC"];
glGetString = (*glLibrary)["glGetString"];
glGetIntegerv = (*glLibrary)["glGetIntegerv"];
pfnWglCreateContext = (*glLibrary)["wglCreateContext"];
pfnWglDeleteContext = (*glLibrary)["wglDeleteContext"];
pfnWglShareLists = (*glLibrary)["wglShareLists"];
wglMakeCurrent = (*glLibrary)["wglMakeCurrent"];
GLSetSharedOCLContextState = wglLibrary["wglSetSharedOCLContextStateINTEL"];
GLAcquireSharedBuffer = wglLibrary["wglAcquireSharedBufferINTEL"];
GLReleaseSharedBuffer = wglLibrary["wglReleaseSharedBufferINTEL"];
GLAcquireSharedRenderBuffer = wglLibrary["wglAcquireSharedRenderBufferINTEL"];
GLReleaseSharedRenderBuffer = wglLibrary["wglReleaseSharedRenderBufferINTEL"];
GLAcquireSharedTexture = wglLibrary["wglAcquireSharedTextureINTEL"];
GLReleaseSharedTexture = wglLibrary["wglReleaseSharedTextureINTEL"];
GLRetainSync = wglLibrary["wglRetainSyncINTEL"];
GLReleaseSync = wglLibrary["wglReleaseSyncINTEL"];
GLGetSynciv = wglLibrary["wglGetSyncivINTEL"];
glGetStringi = wglLibrary["glGetStringi"];
}
this->pfnGlArbSyncObjectCleanup = cleanupArbSyncObject;
this->pfnGlArbSyncObjectSetup = setupArbSyncObject;
this->pfnGlArbSyncObjectSignal = signalArbSyncObject;
this->pfnGlArbSyncObjectWaitServer = serverWaitForArbSyncObject;
return 1;
}
template GLSharingFunctionsWindows *Context::getSharing<GLSharingFunctionsWindows>();
} // namespace NEO

View File

@ -0,0 +1,194 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/os_interface/windows/gl/gl_sharing_os.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include <GL/gl.h>
namespace NEO {
//OpenGL API names
typedef GLboolean(OSAPI *PFNOGLSetSharedOCLContextStateINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLboolean state, GLvoid *pContextInfo);
typedef GLboolean(OSAPI *PFNOGLAcquireSharedBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pBufferInfo);
typedef GLboolean(OSAPI *PFNOGLAcquireSharedRenderBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLboolean(OSAPI *PFNOGLAcquireSharedTextureINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSharedBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pBufferInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSharedRenderBufferINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSharedTextureINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pResourceInfo);
typedef GLContext(OSAPI *PFNOGLGetCurrentContext)();
typedef GLDisplay(OSAPI *PFNOGLGetCurrentDisplay)();
typedef GLboolean(OSAPI *PFNOGLMakeCurrent)(GLDisplay hdcHandle, void *draw, void *read, GLContext contextHandle);
typedef GLboolean(OSAPI *PFNOGLRetainSyncINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pSyncInfo);
typedef GLboolean(OSAPI *PFNOGLReleaseSyncINTEL)(GLDisplay hdcHandle, GLContext contextHandle, GLContext backupContextHandle, GLvoid *pSync);
typedef void(OSAPI *PFNOGLGetSyncivINTEL)(GLvoid *pSync, GLenum pname, GLint *value);
typedef const GLubyte *(OSAPI *PFNglGetString)(GLenum name);
typedef const GLubyte *(OSAPI *PFNglGetStringi)(GLenum name, GLuint index);
typedef void(OSAPI *PFNglGetIntegerv)(GLenum pname, GLint *params);
typedef void(OSAPI *PFNglBindTexture)(GLenum target, GLuint texture);
//wgl
typedef BOOL(OSAPI *PFNwglMakeCurrent)(HDC, HGLRC);
typedef GLContext(OSAPI *PFNwglCreateContext)(GLDisplay hdcHandle);
typedef int(OSAPI *PFNwglShareLists)(GLContext contextHandle, GLContext backupContextHandle);
typedef BOOL(OSAPI *PFNwglDeleteContext)(HGLRC hglrcHandle);
typedef bool (*PFNglArbSyncObjectSetup)(GLSharingFunctions &sharing, OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo);
typedef void (*PFNglArbSyncObjectCleanup)(OSInterface &osInterface, CL_GL_SYNC_INFO *glSyncInfo);
typedef void (*PFNglArbSyncObjectSignal)(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo);
typedef void (*PFNglArbSyncObjectWaitServer)(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo);
class GLSharingFunctionsWindows : public GLSharingFunctions {
public:
GLSharingFunctionsWindows() = default;
GLSharingFunctionsWindows(GLType glhdcType, GLContext glhglrcHandle, GLContext glhglrcHandleBkpCtx, GLDisplay glhdcHandle);
~GLSharingFunctionsWindows() override;
OS_HANDLE getGLDeviceHandle() const { return GLDeviceHandle; }
OS_HANDLE getGLContextHandle() const { return GLContextHandle; }
GLboolean initGLFunctions() override;
bool isOpenGlSharingSupported() override;
static bool isGlSharingEnabled();
// Arb sync event
template <typename EventType = GlArbSyncEvent>
auto getOrCreateGlArbSyncEvent(Event &baseEvent) -> decltype(EventType::create(baseEvent));
GlArbSyncEvent *getGlArbSyncEvent(Event &baseEvent);
void removeGlArbSyncEventMapping(Event &baseEvent);
// Gl functions
GLboolean acquireSharedBufferINTEL(GLvoid *pBufferInfo) {
return GLAcquireSharedBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pBufferInfo);
}
GLboolean releaseSharedBufferINTEL(GLvoid *pBufferInfo) {
return GLReleaseSharedBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pBufferInfo);
}
GLboolean acquireSharedRenderBuffer(GLvoid *pResourceInfo) {
return GLAcquireSharedRenderBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean releaseSharedRenderBuffer(GLvoid *pResourceInfo) {
return GLReleaseSharedRenderBuffer(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean acquireSharedTexture(GLvoid *pResourceInfo) {
return GLAcquireSharedTexture(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean releaseSharedTexture(GLvoid *pResourceInfo) {
return GLReleaseSharedTexture(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pResourceInfo);
}
GLboolean retainSync(GLvoid *pSyncInfo) {
return GLRetainSync(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pSyncInfo);
}
GLboolean releaseSync(GLvoid *pSync) {
return GLReleaseSync(GLHDCHandle, GLHGLRCHandle, GLHGLRCHandleBkpCtx, pSync);
}
void getSynciv(GLvoid *pSync, GLenum pname, GLint *value) {
return GLGetSynciv(pSync, pname, value);
}
GLContext getCurrentContext() {
return GLGetCurrentContext();
}
GLDisplay getCurrentDisplay() {
return GLGetCurrentDisplay();
}
GLboolean makeCurrent(GLContext contextHandle, GLDisplay displayHandle = 0) {
if (displayHandle == 0) {
displayHandle = GLHDCHandle;
}
return this->wglMakeCurrent(displayHandle, contextHandle);
}
GLContext getBackupContextHandle() {
return GLHGLRCHandleBkpCtx;
}
GLContext getContextHandle() {
return GLHGLRCHandle;
}
bool glArbSyncObjectSetup(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
return pfnGlArbSyncObjectSetup(*this, osInterface, glSyncInfo);
}
void glArbSyncObjectCleanup(OSInterface &osInterface, CL_GL_SYNC_INFO *glSyncInfo) {
pfnGlArbSyncObjectCleanup(osInterface, glSyncInfo);
}
void glArbSyncObjectSignal(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo) {
pfnGlArbSyncObjectSignal(osContext, glSyncInfo);
}
void glArbSyncObjectWaitServer(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
pfnGlArbSyncObjectWaitServer(osInterface, glSyncInfo);
}
// Buffer reuse
std::mutex mutex;
std::vector<std::pair<unsigned int, GraphicsAllocation *>> graphicsAllocationsForGlBufferReuse;
protected:
void updateOpenGLContext() {
if (GLSetSharedOCLContextState) {
setSharedOCLContextState();
}
}
GLboolean setSharedOCLContextState();
void createBackupContext();
bool isOpenGlExtensionSupported(const unsigned char *pExtentionString);
// Handles
GLType GLHDCType = 0;
GLContext GLHGLRCHandle = 0;
GLContext GLHGLRCHandleBkpCtx = 0;
GLDisplay GLHDCHandle = 0;
OS_HANDLE GLDeviceHandle = 0;
OS_HANDLE GLContextHandle = 0;
// GL functions
std::unique_ptr<OsLibrary> glLibrary;
PFNOGLSetSharedOCLContextStateINTEL GLSetSharedOCLContextState = nullptr;
PFNOGLAcquireSharedBufferINTEL GLAcquireSharedBuffer = nullptr;
PFNOGLReleaseSharedBufferINTEL GLReleaseSharedBuffer = nullptr;
PFNOGLAcquireSharedRenderBufferINTEL GLAcquireSharedRenderBuffer = nullptr;
PFNOGLReleaseSharedRenderBufferINTEL GLReleaseSharedRenderBuffer = nullptr;
PFNOGLAcquireSharedTextureINTEL GLAcquireSharedTexture = nullptr;
PFNOGLReleaseSharedTextureINTEL GLReleaseSharedTexture = nullptr;
PFNOGLGetCurrentContext GLGetCurrentContext = nullptr;
PFNOGLGetCurrentDisplay GLGetCurrentDisplay = nullptr;
PFNglGetString glGetString = nullptr;
PFNglGetStringi glGetStringi = nullptr;
PFNglGetIntegerv glGetIntegerv = nullptr;
PFNwglCreateContext pfnWglCreateContext = nullptr;
PFNwglMakeCurrent wglMakeCurrent = nullptr;
PFNwglShareLists pfnWglShareLists = nullptr;
PFNwglDeleteContext pfnWglDeleteContext = nullptr;
PFNOGLRetainSyncINTEL GLRetainSync = nullptr;
PFNOGLReleaseSyncINTEL GLReleaseSync = nullptr;
PFNOGLGetSyncivINTEL GLGetSynciv = nullptr;
PFNglArbSyncObjectSetup pfnGlArbSyncObjectSetup = nullptr;
PFNglArbSyncObjectCleanup pfnGlArbSyncObjectCleanup = nullptr;
PFNglArbSyncObjectSignal pfnGlArbSyncObjectSignal = nullptr;
PFNglArbSyncObjectWaitServer pfnGlArbSyncObjectWaitServer = nullptr;
// support for GL_ARB_cl_event
std::mutex glArbEventMutex;
std::unordered_map<Event *, GlArbSyncEvent *> glArbEventMapping;
};
template <typename EventType>
inline auto GLSharingFunctionsWindows::getOrCreateGlArbSyncEvent(Event &baseEvent) -> decltype(EventType::create(baseEvent)) {
std::lock_guard<std::mutex> lock{glArbEventMutex};
auto it = glArbEventMapping.find(&baseEvent);
if (it != glArbEventMapping.end()) {
return it->second;
}
auto arbEvent = EventType::create(baseEvent);
if (nullptr == arbEvent) {
return arbEvent;
}
glArbEventMapping[&baseEvent] = arbEvent;
return arbEvent;
}
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -16,7 +16,8 @@
#include "runtime/helpers/get_info.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/platform/platform.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/gl_context_guard.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
namespace NEO {
GlSyncEvent::GlSyncEvent(Context &context, const GL_CL_SYNC_INFO &sync)
@ -25,15 +26,17 @@ GlSyncEvent::GlSyncEvent(Context &context, const GL_CL_SYNC_INFO &sync)
transitionExecutionStatus(CL_SUBMITTED);
}
GlSyncEvent::~GlSyncEvent() { ctx->getSharing<GLSharingFunctions>()->releaseSync(glSync->pSync); }
GlSyncEvent::~GlSyncEvent() {
ctx->getSharing<GLSharingFunctionsWindows>()->releaseSync(glSync->pSync);
}
GlSyncEvent *GlSyncEvent::create(Context &context, cl_GLsync sync, cl_int *errCode) {
GLContextGuard guard(*context.getSharing<GLSharingFunctions>());
GLContextGuard guard(*context.getSharing<GLSharingFunctionsWindows>());
ErrorCodeHelper err(errCode, CL_SUCCESS);
GL_CL_SYNC_INFO syncInfo = {sync, nullptr};
context.getSharing<GLSharingFunctions>()->retainSync(&syncInfo);
context.getSharing<GLSharingFunctionsWindows>()->retainSync(&syncInfo);
DEBUG_BREAK_IF(!syncInfo.pSync);
EventBuilder eventBuilder;
@ -42,10 +45,10 @@ GlSyncEvent *GlSyncEvent::create(Context &context, cl_GLsync sync, cl_int *errCo
}
void GlSyncEvent::updateExecutionStatus() {
GLContextGuard guard(*ctx->getSharing<GLSharingFunctions>());
GLContextGuard guard(*ctx->getSharing<GLSharingFunctionsWindows>());
int retVal = 0;
ctx->getSharing<GLSharingFunctions>()->getSynciv(glSync->pSync, GL_SYNC_STATUS, &retVal);
ctx->getSharing<GLSharingFunctionsWindows>()->getSynciv(glSync->pSync, GL_SYNC_STATUS, &retVal);
if (retVal == GL_SIGNALED) {
setStatus(CL_COMPLETE);
}

View File

@ -19,6 +19,7 @@
#include "runtime/helpers/get_info.h"
#include "runtime/mem_obj/image.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "CL/cl_gl.h"
#include "config.h"
@ -38,7 +39,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
texInfo.name = texture;
texInfo.target = getBaseTargetType(target);
GLSharingFunctions *sharingFunctions = context->getSharing<GLSharingFunctions>();
GLSharingFunctionsWindows *sharingFunctions = context->getSharing<GLSharingFunctionsWindows>();
if (target == GL_RENDERBUFFER_EXT) {
sharingFunctions->acquireSharedRenderBuffer(&texInfo);
@ -151,6 +152,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
} // namespace NEO
void GlTexture::synchronizeObject(UpdateData &updateData) {
auto sharingFunctions = static_cast<GLSharingFunctionsWindows *>(this->sharingFunctions);
CL_GL_RESOURCE_INFO resourceInfo = {0};
resourceInfo.name = this->clGlObjectId;
if (target == GL_RENDERBUFFER_EXT) {
@ -246,6 +248,7 @@ cl_GLenum GlTexture::getBaseTargetType(cl_GLenum target) {
}
void GlTexture::releaseResource(MemObj *memObject) {
auto sharingFunctions = static_cast<GLSharingFunctionsWindows *>(this->sharingFunctions);
if (target == GL_RENDERBUFFER_EXT) {
sharingFunctions->releaseSharedRenderBuffer(&textureInfo);
} else {

View File

@ -1,16 +1,17 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/sharings/gl/windows/win_enable_gl.h"
#include "core/debug_settings/debug_settings_manager.h"
#include "runtime/context/context.h"
#include "runtime/context/context.inl"
#include "runtime/sharings/gl/cl_gl_api_intel.h"
#include "runtime/sharings/gl/enable_gl.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "runtime/sharings/sharing_factory.h"
#include "runtime/sharings/sharing_factory.inl"
@ -58,8 +59,8 @@ bool GlSharingContextBuilder::finalizeProperties(Context &context, int32_t &errc
return true;
if (contextData->GLHGLRCHandle) {
context.registerSharing(
new GLSharingFunctions(contextData->GLHDCType, contextData->GLHGLRCHandle, nullptr, contextData->GLHDCHandle));
context.registerSharing(new GLSharingFunctionsWindows(contextData->GLHDCType, contextData->GLHGLRCHandle,
nullptr, contextData->GLHDCHandle));
}
contextData.reset(nullptr);
@ -90,7 +91,7 @@ std::string GlSharingBuilderFactory::getExtensions() {
"cl_khr_gl_depth_images "
"cl_khr_gl_event "
"cl_khr_gl_msaa_sharing ";
} else if (GLSharingFunctions::isGlSharingEnabled()) {
} else if (GLSharingFunctionsWindows::isGlSharingEnabled()) {
return "cl_khr_gl_sharing "
"cl_khr_gl_depth_images "
"cl_khr_gl_event "
@ -108,5 +109,5 @@ void *GlSharingBuilderFactory::getExtensionFunctionAddress(const std::string &fu
return nullptr;
}
static SharingFactory::RegisterSharing<GlSharingBuilderFactory, GLSharingFunctions> glSharing;
static SharingFactory::RegisterSharing<GlSharingBuilderFactory, GLSharingFunctionsWindows> glSharing;
} // namespace NEO

View File

@ -1,12 +1,12 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "runtime/sharings/sharing_factory.h"
#include <memory>

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -8,7 +8,6 @@
#include "core/helpers/preamble.h"
#include "core/memory_manager/graphics_allocation.h"
#include "core/memory_manager/memory_constants.h"
#include "core/os_interface/windows/windows_wrapper.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/sharings/gl/gl_buffer.h"
#include "unit_tests/command_queue/enqueue_fixture.h"

View File

@ -11,7 +11,7 @@
#include "runtime/device/device.h"
#include "runtime/device_queue/device_queue.h"
#include "runtime/os_interface/windows/gl/gl_sharing_os.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "unit_tests/fixtures/platform_fixture.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_deferred_deleter.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -22,7 +22,7 @@ EGLBkpContextParams eglBkpContextParams = {0};
GLXBkpContextParams glxBkpContextParams = {0};
void GlSharingFunctionsMock::initMembers() {
GLSharingFunctions::initGLFunctions();
GLSharingFunctionsWindows::initGLFunctions();
glDllHelper dllParam;
dllParam.setGLSetSharedOCLContextStateReturnedValue(1u);
dllParam.resetParam("");

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -7,7 +7,7 @@
#pragma once
#include "public/cl_gl_private_intel.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "unit_tests/os_interface/windows/gl/gl_dll_helper.h"
#include "config.h"
@ -70,7 +70,7 @@ static const unsigned int supportedTargets[] = {
};
}
class GlSharingFunctionsMock : public GLSharingFunctions {
class GlSharingFunctionsMock : public GLSharingFunctionsWindows {
void initMembers();
@ -81,38 +81,40 @@ class GlSharingFunctionsMock : public GLSharingFunctions {
};
~GlSharingFunctionsMock() override = default;
using GLSharingFunctions::GLAcquireSharedBuffer;
using GLSharingFunctions::GLAcquireSharedRenderBuffer;
using GLSharingFunctions::GLAcquireSharedTexture;
using GLSharingFunctions::GLGetCurrentContext;
using GLSharingFunctions::GLGetCurrentDisplay;
using GLSharingFunctions::glGetIntegerv;
using GLSharingFunctions::glGetString;
using GLSharingFunctions::glGetStringi;
using GLSharingFunctions::GLGetSynciv;
using GLSharingFunctions::GLReleaseSharedBuffer;
using GLSharingFunctions::GLReleaseSharedRenderBuffer;
using GLSharingFunctions::GLReleaseSharedTexture;
using GLSharingFunctions::GLReleaseSync;
using GLSharingFunctions::GLRetainSync;
using GLSharingFunctions::GLSetSharedOCLContextState;
using GLSharingFunctions::pfnWglCreateContext;
using GLSharingFunctions::pfnWglDeleteContext;
using GLSharingFunctions::pfnWglShareLists;
using GLSharingFunctions::wglMakeCurrent;
using GLSharingFunctionsWindows::GLAcquireSharedBuffer;
using GLSharingFunctionsWindows::GLAcquireSharedRenderBuffer;
using GLSharingFunctionsWindows::GLAcquireSharedTexture;
using GLSharingFunctionsWindows::GLGetCurrentContext;
using GLSharingFunctionsWindows::GLGetCurrentDisplay;
using GLSharingFunctionsWindows::glGetIntegerv;
using GLSharingFunctionsWindows::glGetString;
using GLSharingFunctionsWindows::glGetStringi;
using GLSharingFunctionsWindows::GLGetSynciv;
using GLSharingFunctionsWindows::GLReleaseSharedBuffer;
using GLSharingFunctionsWindows::GLReleaseSharedRenderBuffer;
using GLSharingFunctionsWindows::GLReleaseSharedTexture;
using GLSharingFunctionsWindows::GLReleaseSync;
using GLSharingFunctionsWindows::GLRetainSync;
using GLSharingFunctionsWindows::GLSetSharedOCLContextState;
using GLSharingFunctionsWindows::isOpenGlExtensionSupported;
using GLSharingFunctionsWindows::pfnWglCreateContext;
using GLSharingFunctionsWindows::pfnWglDeleteContext;
using GLSharingFunctionsWindows::pfnWglShareLists;
using GLSharingFunctionsWindows::setSharedOCLContextState;
using GLSharingFunctionsWindows::wglMakeCurrent;
using GLSharingFunctions::glArbEventMapping;
using GLSharingFunctions::GLContextHandle;
using GLSharingFunctions::GLDeviceHandle;
using GLSharingFunctionsWindows::glArbEventMapping;
using GLSharingFunctionsWindows::GLContextHandle;
using GLSharingFunctionsWindows::GLDeviceHandle;
using GLSharingFunctions::getSupportedFormats;
using GLSharingFunctions::pfnGlArbSyncObjectCleanup;
using GLSharingFunctions::pfnGlArbSyncObjectSetup;
using GLSharingFunctions::pfnGlArbSyncObjectSignal;
using GLSharingFunctions::pfnGlArbSyncObjectWaitServer;
using GLSharingFunctionsWindows::getSupportedFormats;
using GLSharingFunctionsWindows::pfnGlArbSyncObjectCleanup;
using GLSharingFunctionsWindows::pfnGlArbSyncObjectSetup;
using GLSharingFunctionsWindows::pfnGlArbSyncObjectSignal;
using GLSharingFunctionsWindows::pfnGlArbSyncObjectWaitServer;
GlSharingFunctionsMock(GLType GLHDCType, GLContext GLHGLRCHandle, GLContext GLHGLRCHandleBkpCtx, GLDisplay GLHDCHandle)
: GLSharingFunctions(GLHDCType, GLHGLRCHandle, GLHGLRCHandleBkpCtx, GLHDCHandle) {
: GLSharingFunctionsWindows(GLHDCType, GLHGLRCHandle, GLHGLRCHandleBkpCtx, GLHDCHandle) {
initMembers();
updateOpenGLContext();
createBackupContext();
@ -176,19 +178,22 @@ class MockGlSharing {
GLMockReturnedValues glMockReturnedValues = {0};
};
class MockGLSharingFunctions : public GLSharingFunctions {
class MockGLSharingFunctions : public GLSharingFunctionsWindows {
public:
using GLSharingFunctionsWindows::isOpenGlExtensionSupported;
using GLSharingFunctionsWindows::setSharedOCLContextState;
static bool SharingEnabled;
static void OSAPI glGetIntegervTest(GLenum pname, GLint *data) {
if (pname == GL_NUM_EXTENSIONS)
*data = 2;
};
using GLSharingFunctions::glGetIntegerv;
using GLSharingFunctions::glGetString;
using GLSharingFunctionsWindows::glGetIntegerv;
using GLSharingFunctionsWindows::glGetString;
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
MockGLSharingFunctions() {
GLSharingFunctions::initGLFunctions();
GLSharingFunctionsWindows::initGLFunctions();
MockGLSharingFunctions::SharingEnabled = 1;
}
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -14,7 +14,7 @@
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "unit_tests/mocks/gl/mock_gl_sharing.h"
#include "unit_tests/mocks/mock_execution_environment.h"
#include "unit_tests/os_interface/windows/wddm_fixture.h"

View File

@ -1,19 +1,11 @@
#
# Copyright (C) 2017-2018 Intel Corporation
# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
set(IGDRCL_SRCS_tests_sharings_gl
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_create_from_texture_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_reused_buffers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_enable_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_texture_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_types_tests.cpp
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_sharings_gl})
endif()
set(IGDRCL_SRCS_tests_sharings_gl
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_sharings_gl})
add_subdirectories()

View File

@ -0,0 +1,19 @@
#
# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
set(IGDRCL_SRCS_tests_sharings_gl_windows
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_create_from_texture_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_reused_buffers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_enable_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_texture_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_types_tests.cpp
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_sharings_gl_windows})
endif()

View File

@ -1,11 +1,11 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/sharings/gl/enable_gl.h"
#include "runtime/sharings/gl/windows/win_enable_gl.h"
#include "unit_tests/fixtures/memory_management_fixture.h"
#include "unit_tests/mocks/mock_context.h"

View File

@ -18,8 +18,10 @@
#include "runtime/sharings/gl/cl_gl_api_intel.h"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
#include "runtime/sharings/gl/gl_buffer.h"
#include "runtime/sharings/gl/gl_context_guard.h"
#include "runtime/sharings/gl/gl_sync_event.h"
#include "runtime/sharings/gl/gl_texture.h"
#include "runtime/sharings/gl/windows/gl_sharing.h"
#include "runtime/sharings/sharing.h"
#include "test.h"
#include "unit_tests/libult/create_command_stream.h"
@ -651,7 +653,7 @@ TEST(glSharingBasicTest, GivenSharingFunctionsWhenItIsConstructedThenOglContextF
}
TEST(glSharingBasicTest, givenInvalidExtensionNameWhenCheckGLExtensionSupportedThenReturnFalse) {
GLSharingFunctions glSharingFunctions;
MockGLSharingFunctions glSharingFunctions;
const unsigned char invalidExtension[] = "InvalidExtensionName";
bool RetVal = glSharingFunctions.isOpenGlExtensionSupported(invalidExtension);
EXPECT_FALSE(RetVal);
@ -1086,7 +1088,7 @@ TEST(glSharingContextSwitch, givenZeroCurrentContextWhenSwitchAttemptedThenMakeS
}
TEST(glSharingContextSwitch, givenSharingFunctionsWhenGlDeleteContextIsNotPresentThenItIsNotCalled) {
auto glSharingFunctions = new GLSharingFunctions();
auto glSharingFunctions = new GLSharingFunctionsWindows();
glDllHelper dllParam;
auto currentGlDeleteContextCalledCount = dllParam.getParam("GLDeleteContextCalled");
delete glSharingFunctions;
@ -1172,7 +1174,7 @@ TEST_F(glSharingTests, givenContextWhenEmptySharingTableEmptyThenReturnsNullptr)
}
TEST_F(glSharingTests, givenUnknownBaseEventWhenGetGlArbSyncEventIsCalledThenNullptrIsReturned) {
auto *sharing = context.getSharing<GLSharingFunctions>();
auto *sharing = context.getSharing<GLSharingFunctionsWindows>();
ASSERT_NE(nullptr, sharing);
auto event = new MockEvent<UserEvent>();
MockContext context;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*