Move glDllHelper out of windows directory and rename

Change-Id: I87a4ee3108465efa9b73f43f31dec06f4042cbf8
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban
2020-04-02 13:26:04 +00:00
committed by sys_ocldev
parent a0c13490e5
commit a52aaca401
11 changed files with 39 additions and 40 deletions

View File

@ -12,7 +12,7 @@
#include "opencl/test/unit_test/api/cl_api_tests.h"
#include "opencl/test/unit_test/mocks/mock_device.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "opencl/test/unit_test/sharings/gl/windows/gl_dll_helper.h"
#include "opencl/test/unit_test/sharings/gl/gl_dll_helper.h"
using namespace NEO;
@ -83,7 +83,7 @@ TEST_F(clGetGLContextInfoKHR_, givenContextFromNoIntelOpenGlDriverWhenCallClGetG
cl_device_id retDevice = 0;
size_t retSize = 0;
const cl_context_properties properties[] = {CL_GL_CONTEXT_KHR, 1, CL_WGL_HDC_KHR, 2, 0};
glDllHelper setDllParam;
GlDllHelper setDllParam;
setDllParam.glSetString("NoIntel", GL_VENDOR);
retVal = clGetGLContextInfoKHR(properties, 0, sizeof(cl_device_id), &retDevice, &retSize);
@ -96,7 +96,7 @@ TEST_F(clGetGLContextInfoKHR_, givenNullVersionFromIntelOpenGlDriverWhenCallClGe
cl_device_id retDevice = 0;
size_t retSize = 0;
const cl_context_properties properties[] = {CL_GL_CONTEXT_KHR, 1, CL_WGL_HDC_KHR, 2, 0};
glDllHelper setDllParam;
GlDllHelper setDllParam;
setDllParam.glSetString("", GL_VERSION);
retVal = clGetGLContextInfoKHR(properties, 0, sizeof(cl_device_id), &retDevice, &retSize);

View File

@ -327,7 +327,7 @@ void memParam() {
memset(&bufferInfoOutput, 0, sizeof(CL_GL_BUFFER_INFO));
memset(&textureInfoInput, 0, sizeof(CL_GL_RESOURCE_INFO));
memset(&textureInfoOutput, 0, sizeof(CL_GL_RESOURCE_INFO));
memset(&glMockReturnedValues, 0, sizeof(GLMockReturnedValues));
memset(&glMockReturnedValues, 0, sizeof(NEO::GLMockReturnedValues));
};
void loadBuffer(CL_GL_BUFFER_INFO buff) { bufferInfoOutput = buff; };
void loadTexture(CL_GL_RESOURCE_INFO texture) { textureInfoOutput = texture; };

View File

@ -23,7 +23,7 @@ GLXBkpContextParams glxBkpContextParams = {0};
void GlSharingFunctionsMock::initMembers() {
GLSharingFunctionsWindows::initGLFunctions();
glDllHelper dllParam;
GlDllHelper dllParam;
dllParam.setGLSetSharedOCLContextStateReturnedValue(1u);
dllParam.resetParam("");
dllParam.loadTexture({0});

View File

@ -8,7 +8,7 @@
#pragma once
#include "opencl/extensions/public/cl_gl_private_intel.h"
#include "opencl/source/sharings/gl/windows/gl_sharing_windows.h"
#include "opencl/test/unit_test/sharings/gl/windows/gl_dll_helper.h"
#include "opencl/test/unit_test/sharings/gl/gl_dll_helper.h"
#include "config.h"
@ -170,7 +170,7 @@ class MockGlSharing {
}
std::unique_ptr<GlSharingFunctionsMock> sharingFunctions = std::make_unique<GlSharingFunctionsMock>();
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
std::unique_ptr<GlDllHelper> dllParam = std::make_unique<GlDllHelper>();
CL_GL_RESOURCE_INFO m_clGlResourceInfo = {0};
GL_CL_RESOURCE_INFO m_glClResourceInfo = {0};
CL_GL_BUFFER_INFO m_bufferInfoOutput = {0};
@ -191,7 +191,7 @@ class MockGLSharingFunctions : public GLSharingFunctionsWindows {
};
using GLSharingFunctionsWindows::glGetIntegerv;
using GLSharingFunctionsWindows::glGetString;
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
std::unique_ptr<GlDllHelper> dllParam = std::make_unique<GlDllHelper>();
MockGLSharingFunctions() {
GLSharingFunctionsWindows::initGLFunctions();
MockGLSharingFunctions::SharingEnabled = 1;

View File

@ -6,6 +6,7 @@
set(IGDRCL_SRCS_tests_sharings_gl
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gl_dll_helper.h
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_sharings_gl})
add_subdirectories()

View File

@ -12,17 +12,16 @@
#include "opencl/extensions/public/cl_gl_private_intel.h"
#include "Gl/gl.h"
#include "GL/gl.h"
#include <memory>
using namespace NEO;
namespace Os {
extern const char *openglDllName;
}
namespace NEO {
struct GLMockReturnedValues;
}
using GLString = void (*)(const char *, unsigned int);
using GLSharedOCLContext = void (*)(GLboolean);
@ -36,9 +35,9 @@ using TextureInfo = CL_GL_RESOURCE_INFO (*)();
using GLMockValue = GLMockReturnedValues (*)();
using setGLMockValue = void (*)(GLMockReturnedValues);
struct glDllHelper {
struct GlDllHelper {
public:
glDllHelper() {
GlDllHelper() {
glDllLoad.reset(OsLibrary::load(Os::openglDllName));
if (glDllLoad) {
glSetString = (*glDllLoad)["glSetString"];
@ -69,7 +68,7 @@ struct glDllHelper {
UNRECOVERABLE_IF(setGlMockReturnedValues == nullptr);
}
}
~glDllHelper() {
~GlDllHelper() {
if (glDllLoad) {
glSetString("Intel", GL_VENDOR);
glSetString("4.0", GL_VERSION);
@ -83,14 +82,14 @@ struct glDllHelper {
glBoolean getGLSetSharedOCLContextStateReturnedValue;
Void resetParam;
Int getParam;
BufferParam loadBuffer;
TextureParam loadTexture;
BuffInfo getBufferInfo;
TextureInfo getTextureInfo;
TextureParam loadTexture;
GLMockValue getGlMockReturnedValues;
setGLMockValue setGlMockReturnedValues;
private:
std::unique_ptr<OsLibrary> glDllLoad;
};
} // namespace NEO

View File

@ -9,7 +9,6 @@ if(WIN32)
${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_dll_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_library_name.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_os_sharing_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_reused_buffers_tests.cpp

View File

@ -57,7 +57,7 @@ TEST(glSharingBasicTest, GivenSharingFunctionsWhenItIsConstructedThenBackupConte
GLContext GLHGLRCHandle = 0;
GLDisplay GLHDCHandle = 0;
int32_t expectedContextAttrs[3] = {0};
glDllHelper dllHelper;
GlDllHelper dllHelper;
auto glSharingFunctions = new GlSharingFunctionsMock(GLHDCType, GLHGLRCHandle, GLHGLRCHandle, GLHDCHandle);

View File

@ -94,10 +94,10 @@ TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenCreating
}
TEST_F(GlReusedBufferTests, givenGlobalShareHandleChangedWhenAcquiringSharedBufferThenChangeGraphicsAllocation) {
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam->getBufferInfo();
GlDllHelper dllParam;
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam.getBufferInfo();
bufferInfoOutput.globalShareHandle = 40;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
auto clBuffer = std::unique_ptr<Buffer>(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal));
auto glBuffer = clBuffer->peekSharingHandler();
auto oldGraphicsAllocation = clBuffer->getGraphicsAllocation();
@ -105,7 +105,7 @@ TEST_F(GlReusedBufferTests, givenGlobalShareHandleChangedWhenAcquiringSharedBuff
ASSERT_EQ(40, oldGraphicsAllocation->peekSharedHandle());
bufferInfoOutput.globalShareHandle = 41;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
glBuffer->acquire(clBuffer.get());
auto newGraphicsAllocation = clBuffer->getGraphicsAllocation();
@ -126,11 +126,11 @@ TEST_F(GlReusedBufferTests, givenGlobalShareHandleDidNotChangeWhenAcquiringShare
GlBuffer::resolveGraphicsAllocationChange(currentSharedHandle, updateData);
}
};
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam->getBufferInfo();
GlDllHelper dllParam;
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam.getBufferInfo();
bufferInfoOutput.globalShareHandle = 40;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
auto clBuffer = std::unique_ptr<Buffer>(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal));
auto glBuffer = new MyGlBuffer(context.getSharing<GLSharingFunctions>(), bufferId1);
clBuffer->setSharingHandler(glBuffer);
@ -151,26 +151,26 @@ TEST_F(GlReusedBufferTests, givenGlobalShareHandleChangedWhenAcquiringSharedBuff
GlBuffer::resolveGraphicsAllocationChange(currentSharedHandle, updateData);
}
};
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam->getBufferInfo();
GlDllHelper dllParam;
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam.getBufferInfo();
bufferInfoOutput.globalShareHandle = 40;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
auto clBuffer = std::unique_ptr<Buffer>(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal));
auto glBuffer = new MyGlBuffer(context.getSharing<GLSharingFunctions>(), bufferId1);
clBuffer->setSharingHandler(glBuffer);
bufferInfoOutput.globalShareHandle = 41;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
glBuffer->acquire(clBuffer.get());
glBuffer->release(clBuffer.get());
}
TEST_F(GlReusedBufferTests, givenMultipleBuffersAndGlobalShareHandleChangedWhenAcquiringSharedBufferDeleteOldGfxAllocationFromReuseVector) {
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam->getBufferInfo();
GlDllHelper dllParam;
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam.getBufferInfo();
bufferInfoOutput.globalShareHandle = 40;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
auto clBuffer1 = std::unique_ptr<Buffer>(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal));
auto clBuffer2 = std::unique_ptr<Buffer>(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal));
auto graphicsAllocation1 = clBuffer1->getGraphicsAllocation();
@ -180,7 +180,7 @@ TEST_F(GlReusedBufferTests, givenMultipleBuffersAndGlobalShareHandleChangedWhenA
ASSERT_EQ(1, graphicsAllocationsForGlBufferReuse->size());
bufferInfoOutput.globalShareHandle = 41;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
clBuffer1->peekSharingHandler()->acquire(clBuffer1.get());
auto newGraphicsAllocation = clBuffer1->getGraphicsAllocation();
EXPECT_EQ(1, graphicsAllocationsForGlBufferReuse->size());
@ -199,16 +199,16 @@ TEST_F(GlReusedBufferTests, givenGraphicsAllocationCreationReturnsNullptrWhenAcq
auto suceedingMemoryManager = context.getMemoryManager();
auto failingMemoryManager = std::unique_ptr<FailingMemoryManager>(new FailingMemoryManager());
std::unique_ptr<glDllHelper> dllParam = std::make_unique<glDllHelper>();
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam->getBufferInfo();
GlDllHelper dllParam;
CL_GL_BUFFER_INFO bufferInfoOutput = dllParam.getBufferInfo();
bufferInfoOutput.globalShareHandle = 40;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
auto clBuffer = std::unique_ptr<Buffer>(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal));
auto glBuffer = clBuffer->peekSharingHandler();
bufferInfoOutput.globalShareHandle = 41;
dllParam->loadBuffer(bufferInfoOutput);
dllParam.loadBuffer(bufferInfoOutput);
context.memoryManager = failingMemoryManager.get();
auto result = glBuffer->acquire(clBuffer.get());

View File

@ -637,7 +637,7 @@ TEST(glSharingBasicTest, GivenSharingFunctionsWhenItIsConstructedThenOglContextF
GLType GLHDCType = 0;
GLContext GLHGLRCHandle = 0;
GLDisplay GLHDCHandle = 0;
glDllHelper getDllParam;
GlDllHelper getDllParam;
GlSharingFunctionsMock glSharingFunctions(GLHDCType, GLHGLRCHandle, GLHGLRCHandle, GLHDCHandle);
EXPECT_EQ(1, getDllParam.getGLSetSharedOCLContextStateReturnedValue());
@ -1080,7 +1080,7 @@ TEST(glSharingContextSwitch, givenZeroCurrentContextWhenSwitchAttemptedThenMakeS
TEST(glSharingContextSwitch, givenSharingFunctionsWhenGlDeleteContextIsNotPresentThenItIsNotCalled) {
auto glSharingFunctions = new GLSharingFunctionsWindows();
glDllHelper dllParam;
GlDllHelper dllParam;
auto currentGlDeleteContextCalledCount = dllParam.getParam("GLDeleteContextCalled");
delete glSharingFunctions;
EXPECT_EQ(currentGlDeleteContextCalledCount, dllParam.getParam("GLDeleteContextCalled"));

View File

@ -135,7 +135,7 @@ TEST_F(GlSharingTextureTests, givenMockGlWhenGlTextureIsCreatedFromWrongHandleTh
GLboolean OSAPI mockGLAcquireSharedTexture(GLDisplay, GLContext, GLContext, GLvoid *pResourceInfo) {
auto pTextureInfo = (CL_GL_RESOURCE_INFO *)pResourceInfo;
glDllHelper dllParam;
GlDllHelper dllParam;
pTextureInfo->globalShareHandle = dllParam.getTextureInfo().globalShareHandle;
pTextureInfo->globalShareHandleMCS = dllParam.getTextureInfo().globalShareHandleMCS;