mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00

- don't load ze_loader.dll from file system - to perform self-open on Windows use getModuleHandleA with proper module name - don't free library loaded with getModuleHandleA - as loader may be not available during runtime teardown: - load translate handle function during global setup - load setDriverTeardown function during global teardown - when loader is not available during teardown, unset translate handle function Related-To: GSD-10147 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
/*
|
|
* Copyright (C) 2019-2024 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
|
#include "shared/source/os_interface/os_library.h"
|
|
|
|
#include "opencl/extensions/public/cl_gl_private_intel.h"
|
|
|
|
#include "GL/gl.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace Os {
|
|
extern const char *openglDllName;
|
|
} // namespace Os
|
|
|
|
namespace NEO {
|
|
struct GLMockReturnedValues;
|
|
|
|
using GLString = void (*)(const char *, unsigned int);
|
|
using GLSharedOCLContext = void (*)(GLboolean);
|
|
using glBoolean = GLboolean (*)();
|
|
using Void = void (*)(const char *);
|
|
using Int = int (*)(const char *);
|
|
using BufferParam = void (*)(CL_GL_BUFFER_INFO);
|
|
using TextureParam = void (*)(CL_GL_RESOURCE_INFO);
|
|
using BuffInfo = CL_GL_BUFFER_INFO (*)();
|
|
using TextureInfo = CL_GL_RESOURCE_INFO (*)();
|
|
using GLMockValue = GLMockReturnedValues (*)();
|
|
using setGLMockValue = void (*)(GLMockReturnedValues);
|
|
|
|
struct GlDllHelper {
|
|
public:
|
|
GlDllHelper() {
|
|
glDllLoad.reset(OsLibrary::loadFunc({Os::openglDllName}));
|
|
if (glDllLoad) {
|
|
glSetString = (*glDllLoad)["glSetString"];
|
|
UNRECOVERABLE_IF(glSetString == nullptr);
|
|
glSetStringi = (*glDllLoad)["glSetStringi"];
|
|
UNRECOVERABLE_IF(glSetStringi == nullptr);
|
|
resetParam = (*glDllLoad)["resetParam"];
|
|
UNRECOVERABLE_IF(resetParam == nullptr);
|
|
getParam = (*glDllLoad)["getParam"];
|
|
UNRECOVERABLE_IF(getParam == nullptr);
|
|
loadBuffer = (*glDllLoad)["loadBuffer"];
|
|
UNRECOVERABLE_IF(loadBuffer == nullptr);
|
|
getBufferInfo = (*glDllLoad)["getBufferInfo"];
|
|
UNRECOVERABLE_IF(getBufferInfo == nullptr);
|
|
getTextureInfo = (*glDllLoad)["getTextureInfo"];
|
|
UNRECOVERABLE_IF(getTextureInfo == nullptr);
|
|
Void memParam = (*glDllLoad)["memParam"];
|
|
UNRECOVERABLE_IF(memParam == nullptr);
|
|
loadTexture = (*glDllLoad)["loadTexture"];
|
|
UNRECOVERABLE_IF(loadTexture == nullptr);
|
|
getGlMockReturnedValues = (*glDllLoad)["getGlMockReturnedValues"];
|
|
setGlMockReturnedValues = (*glDllLoad)["setGlMockReturnedValues"];
|
|
setGLSetSharedOCLContextStateReturnedValue = (*glDllLoad)["setGLSetSharedOCLContextStateReturnedValue"];
|
|
getGLSetSharedOCLContextStateReturnedValue = (*glDllLoad)["getGLSetSharedOCLContextStateReturnedValue"];
|
|
}
|
|
}
|
|
~GlDllHelper() {
|
|
if (glDllLoad) {
|
|
glSetString("Intel", GL_VENDOR);
|
|
glSetString("4.0", GL_VERSION);
|
|
glSetStringi("GL_OES_framebuffer_object", 0);
|
|
glSetStringi("GL_EXT_framebuffer_object", 1);
|
|
}
|
|
}
|
|
GLString glSetString;
|
|
GLString glSetStringi;
|
|
GLSharedOCLContext setGLSetSharedOCLContextStateReturnedValue;
|
|
glBoolean getGLSetSharedOCLContextStateReturnedValue;
|
|
Void resetParam;
|
|
Int getParam;
|
|
BufferParam loadBuffer;
|
|
BuffInfo getBufferInfo;
|
|
TextureInfo getTextureInfo;
|
|
TextureParam loadTexture;
|
|
GLMockValue getGlMockReturnedValues;
|
|
setGLMockValue setGlMockReturnedValues;
|
|
|
|
private:
|
|
std::unique_ptr<OsLibrary> glDllLoad;
|
|
};
|
|
} // namespace NEO
|