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