| 1 |
/* |
| 2 |
* Copyright (C) 2019-2024 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "shared/source/helpers/debug_helpers.h" |
| 11 |
#include "shared/source/os_interface/os_library.h" |
| 12 |
|
| 13 |
#include "opencl/extensions/public/cl_gl_private_intel.h" |
| 14 |
|
| 15 |
#include "GL/gl.h" |
| 16 |
|
| 17 |
#include <memory> |
| 18 |
|
| 19 |
namespace Os { |
| 20 |
extern const char *openglDllName; |
| 21 |
} // namespace Os |
| 22 |
|
| 23 |
namespace NEO { |
| 24 |
struct GLMockReturnedValues; |
| 25 |
|
| 26 |
using GLString = void (*)(const char *, unsigned int); |
| 27 |
using GLSharedOCLContext = void (*)(GLboolean); |
| 28 |
using glBoolean = GLboolean (*)(); |
| 29 |
using Void = void (*)(const char *); |
| 30 |
using Int = int (*)(const char *); |
| 31 |
using BufferParam = void (*)(CL_GL_BUFFER_INFO); |
| 32 |
using TextureParam = void (*)(CL_GL_RESOURCE_INFO); |
| 33 |
using BuffInfo = CL_GL_BUFFER_INFO (*)(); |
| 34 |
using TextureInfo = CL_GL_RESOURCE_INFO (*)(); |
| 35 |
using GLMockValue = GLMockReturnedValues (*)(); |
| 36 |
using setGLMockValue = void (*)(GLMockReturnedValues); |
| 37 |
|
| 38 |
struct GlDllHelper { |
| 39 |
public: |
| 40 |
GlDllHelper() { |
| 41 |
glDllLoad.reset(OsLibrary::loadFunc(Os::openglDllName)); |
| 42 |
if (glDllLoad) { |
| 43 |
glSetString = (*glDllLoad)["glSetString"]; |
| 44 |
UNRECOVERABLE_IF(glSetString == nullptr); |
| 45 |
glSetStringi = (*glDllLoad)["glSetStringi"]; |
| 46 |
UNRECOVERABLE_IF(glSetStringi == nullptr); |
| 47 |
resetParam = (*glDllLoad)["resetParam"]; |
| 48 |
UNRECOVERABLE_IF(resetParam == nullptr); |
| 49 |
getParam = (*glDllLoad)["getParam"]; |
| 50 |
UNRECOVERABLE_IF(getParam == nullptr); |
| 51 |
loadBuffer = (*glDllLoad)["loadBuffer"]; |
| 52 |
UNRECOVERABLE_IF(loadBuffer == nullptr); |
| 53 |
getBufferInfo = (*glDllLoad)["getBufferInfo"]; |
| 54 |
UNRECOVERABLE_IF(getBufferInfo == nullptr); |
| 55 |
getTextureInfo = (*glDllLoad)["getTextureInfo"]; |
| 56 |
UNRECOVERABLE_IF(getTextureInfo == nullptr); |
| 57 |
Void memParam = (*glDllLoad)["memParam"]; |
| 58 |
UNRECOVERABLE_IF(memParam == nullptr); |
| 59 |
loadTexture = (*glDllLoad)["loadTexture"]; |
| 60 |
UNRECOVERABLE_IF(loadTexture == nullptr); |
| 61 |
getGlMockReturnedValues = (*glDllLoad)["getGlMockReturnedValues"]; |
| 62 |
setGlMockReturnedValues = (*glDllLoad)["setGlMockReturnedValues"]; |
| 63 |
setGLSetSharedOCLContextStateReturnedValue = (*glDllLoad)["setGLSetSharedOCLContextStateReturnedValue"]; |
| 64 |
getGLSetSharedOCLContextStateReturnedValue = (*glDllLoad)["getGLSetSharedOCLContextStateReturnedValue"]; |
| 65 |
} |
| 66 |
} |
| 67 |
~GlDllHelper() { |
| 68 |
if (glDllLoad) { |
| 69 |
glSetString("Intel", GL_VENDOR); |
| 70 |
glSetString("4.0", GL_VERSION); |
| 71 |
glSetStringi("GL_OES_framebuffer_object", 0); |
| 72 |
glSetStringi("GL_EXT_framebuffer_object", 1); |
| 73 |
} |
| 74 |
} |
| 75 |
GLString glSetString; |
| 76 |
GLString glSetStringi; |
| 77 |
GLSharedOCLContext setGLSetSharedOCLContextStateReturnedValue; |
| 78 |
glBoolean getGLSetSharedOCLContextStateReturnedValue; |
| 79 |
Void resetParam; |
| 80 |
Int getParam; |
| 81 |
BufferParam loadBuffer; |
| 82 |
BuffInfo getBufferInfo; |
| 83 |
TextureInfo getTextureInfo; |
| 84 |
TextureParam loadTexture; |
| 85 |
GLMockValue getGlMockReturnedValues; |
| 86 |
setGLMockValue setGlMockReturnedValues; |
| 87 |
|
| 88 |
private: |
| 89 |
std::unique_ptr<OsLibrary> glDllLoad; |
| 90 |
}; |
| 91 |
} // namespace NEO |