mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
Change-Id: If965c79d70392db26597aea4c2f3b7ae2820fe96 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
/*
|
|
* 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
|