2018-08-21 17:36:08 +02:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2020-2021 Intel Corporation
|
2018-09-18 09:11:08 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2018-08-21 17:36:08 +02:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/windows/os_context_win.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/windows/os_interface.h"
|
|
|
|
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
|
|
|
|
#include "shared/source/os_interface/windows/wddm/wddm_interface.h"
|
2018-08-21 17:36:08 +02:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-08-23 17:53:58 +02:00
|
|
|
|
2019-03-13 15:00:07 +01:00
|
|
|
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
|
2021-03-08 18:50:32 +00:00
|
|
|
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
|
2019-02-27 11:17:17 +01:00
|
|
|
if (osInterface) {
|
2021-03-08 18:50:32 +00:00
|
|
|
return new OsContextWin(*osInterface->get()->getWddm(), contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
|
2019-02-27 11:17:17 +01:00
|
|
|
}
|
2021-03-08 18:50:32 +00:00
|
|
|
return new OsContext(contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
|
2019-02-27 11:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 15:00:07 +01:00
|
|
|
OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, DeviceBitfield deviceBitfield,
|
2021-03-08 18:50:32 +00:00
|
|
|
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice)
|
|
|
|
|
: OsContext(contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice),
|
2020-03-03 23:33:31 +01:00
|
|
|
wddm(wddm),
|
2021-04-15 16:14:04 +00:00
|
|
|
residencyController(wddm, contextId) {}
|
2019-02-27 11:17:17 +01:00
|
|
|
|
2021-04-15 16:14:04 +00:00
|
|
|
void OsContextWin::initializeContext() {
|
2018-08-21 17:36:08 +02:00
|
|
|
auto wddmInterface = wddm.getWddmInterface();
|
2021-04-12 16:17:35 +00:00
|
|
|
UNRECOVERABLE_IF(!wddm.createContext(*this));
|
|
|
|
|
|
2018-08-21 17:36:08 +02:00
|
|
|
if (wddmInterface->hwQueuesSupported()) {
|
2021-04-12 16:17:35 +00:00
|
|
|
UNRECOVERABLE_IF(!wddmInterface->createHwQueue(*this));
|
2018-08-21 17:36:08 +02:00
|
|
|
}
|
2021-04-12 16:17:35 +00:00
|
|
|
UNRECOVERABLE_IF(!wddmInterface->createMonitoredFence(*this));
|
|
|
|
|
|
2019-02-27 11:17:17 +01:00
|
|
|
residencyController.registerCallback();
|
2021-04-12 16:17:35 +00:00
|
|
|
UNRECOVERABLE_IF(!residencyController.isInitialized());
|
2018-08-21 17:36:08 +02:00
|
|
|
};
|
2019-02-27 11:17:17 +01:00
|
|
|
|
|
|
|
|
OsContextWin::~OsContextWin() {
|
2021-04-15 16:14:04 +00:00
|
|
|
if (contextInitialized) {
|
|
|
|
|
wddm.getWddmInterface()->destroyHwQueue(hardwareQueue.handle);
|
|
|
|
|
wddm.getWddmInterface()->destroyMonitorFence(residencyController.getMonitoredFence());
|
|
|
|
|
wddm.destroyContext(wddmContextHandle);
|
|
|
|
|
}
|
2018-08-21 17:36:08 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|