2018-08-21 17:36:08 +02:00
|
|
|
/*
|
2021-12-16 02:13:00 +00:00
|
|
|
* Copyright (C) 2020-2022 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
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#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
|
|
|
|
2021-08-11 17:36:00 +00:00
|
|
|
OsContext *OsContextWin::create(OSInterface *osInterface, uint32_t contextId, const EngineDescriptor &engineDescriptor) {
|
2019-02-27 11:17:17 +01:00
|
|
|
if (osInterface) {
|
2021-08-11 17:36:00 +00:00
|
|
|
return new OsContextWin(*osInterface->getDriverModel()->as<Wddm>(), contextId, engineDescriptor);
|
2019-02-27 11:17:17 +01:00
|
|
|
}
|
2021-08-11 17:36:00 +00:00
|
|
|
return new OsContext(contextId, engineDescriptor);
|
2019-02-27 11:17:17 +01:00
|
|
|
}
|
|
|
|
|
2021-08-11 17:36:00 +00:00
|
|
|
OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, const EngineDescriptor &engineDescriptor)
|
|
|
|
: OsContext(contextId, engineDescriptor),
|
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
|
|
|
|
2021-12-16 02:13:00 +00:00
|
|
|
void OsContextWin::reInitializeContext() {
|
|
|
|
if (contextInitialized && (false == this->wddm.skipResourceCleanup())) {
|
|
|
|
wddm.destroyContext(wddmContextHandle);
|
|
|
|
}
|
|
|
|
UNRECOVERABLE_IF(!wddm.createContext(*this));
|
|
|
|
};
|
|
|
|
|
2019-02-27 11:17:17 +01:00
|
|
|
OsContextWin::~OsContextWin() {
|
2021-11-19 22:58:46 +01:00
|
|
|
if (contextInitialized && (false == this->wddm.skipResourceCleanup())) {
|
2021-04-15 16:14:04 +00:00
|
|
|
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
|