mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 17:00:59 +08:00
Related-To: NEO-3008 Change-Id: I4d63b8bc1f831c306ae5535067e2818155963cf5 Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
41 lines
1.5 KiB
C++
41 lines
1.5 KiB
C++
/*
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/os_interface/linux/os_context_linux.h"
|
|
|
|
#include "runtime/os_interface/linux/drm_engine_mapper.h"
|
|
#include "runtime/os_interface/linux/drm_neo.h"
|
|
#include "runtime/os_interface/linux/os_interface.h"
|
|
#include "runtime/os_interface/os_context.h"
|
|
|
|
namespace NEO {
|
|
|
|
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
|
|
aub_stream::EngineType engineType, PreemptionMode preemptionMode, bool lowPriority) {
|
|
if (osInterface) {
|
|
return new OsContextLinux(*osInterface->get()->getDrm(), contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
|
}
|
|
return new OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
|
}
|
|
|
|
OsContextLinux::OsContextLinux(Drm &drm, uint32_t contextId, DeviceBitfield deviceBitfield,
|
|
aub_stream::EngineType engineType, PreemptionMode preemptionMode, bool lowPriority)
|
|
: OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority), drm(drm) {
|
|
|
|
engineFlag = DrmEngineMapper::engineNodeMap(engineType);
|
|
this->drmContextId = drm.createDrmContext();
|
|
if (drm.isPreemptionSupported() && lowPriority) {
|
|
drm.setLowPriorityContextParam(this->drmContextId);
|
|
}
|
|
drm.bindDrmContext(this->drmContextId, deviceBitfield, engineType);
|
|
}
|
|
|
|
OsContextLinux::~OsContextLinux() {
|
|
drm.destroyDrmContext(drmContextId);
|
|
}
|
|
} // namespace NEO
|