mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add check that Intel OpenGl is used
before return device_id in clGetGlContextInfoKHR Change-Id: Ic6dce407a1666909d468d89a8576c907abc63b61
This commit is contained in:

committed by
sys_ocldev

parent
cdd77a34fa
commit
72f17d6435
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2017-2018 Intel Corporation
|
||||
# Copyright (C) 2017-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@ -16,9 +16,13 @@ if(WIN32)
|
||||
set(IGDRCL_SRCS_mock_opengl32
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_opengl32.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_opengl32.def
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/helpers/windows/mock_function.cpp
|
||||
)
|
||||
|
||||
add_library(mock_opengl32 SHARED ${IGDRCL_SRCS_mock_opengl32})
|
||||
add_dependencies(unit_tests mock_opengl32)
|
||||
set_target_properties(mock_opengl32 PROPERTIES FOLDER "test mocks")
|
||||
target_include_directories(mock_opengl32 PRIVATE $<TARGET_PROPERTY:${NEO_MOCKABLE_LIB_NAME},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
target_compile_definitions(mock_opengl32 PRIVATE $<TARGET_PROPERTY:${NEO_MOCKABLE_LIB_NAME},INTERFACE_COMPILE_DEFINITIONS>)
|
||||
endif()
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -7,9 +7,33 @@
|
||||
|
||||
#include <string.h>
|
||||
#include "unit_tests/helpers/windows/mock_function.h"
|
||||
#include "GL/gl.h"
|
||||
|
||||
#undef wglGetProcAddress
|
||||
#pragma warning(disable : 4273)
|
||||
|
||||
extern "C" {
|
||||
void *__stdcall wglGetProcAddress(const char *name) { return nullptr; }
|
||||
const char *glString = "Intel";
|
||||
const char *glVersion = "4.0";
|
||||
const unsigned char *_stdcall glGetString(unsigned int name) {
|
||||
if (name == GL_VENDOR)
|
||||
return reinterpret_cast<const unsigned char *>(glString);
|
||||
if (name == GL_VERSION)
|
||||
return reinterpret_cast<const unsigned char *>(glVersion);
|
||||
return reinterpret_cast<const unsigned char *>("");
|
||||
};
|
||||
void glSetString(const char *name, unsigned int var) {
|
||||
if (var == GL_VENDOR) {
|
||||
glString = name;
|
||||
} else if (var == GL_VERSION) {
|
||||
glVersion = name;
|
||||
}
|
||||
};
|
||||
|
||||
PROC WINAPI wglGetProcAddress(LPCSTR name) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *__stdcall mockLoader(const char *name) {
|
||||
if (strcmp(name, "realFunction") == 0) {
|
||||
return *realFunction;
|
||||
|
@ -20,5 +20,7 @@
|
||||
|
||||
LIBRARY "gdi32_mock"
|
||||
EXPORTS
|
||||
glGetString
|
||||
wglGetProcAddress
|
||||
glSetString
|
||||
mockLoader
|
Reference in New Issue
Block a user