2018-08-21 17:36:08 +02:00
|
|
|
/*
|
2020-01-31 14:35:46 +01:00
|
|
|
* Copyright (C) 2018-2020 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,
|
2019-03-27 10:06:29 +01:00
|
|
|
aub_stream::EngineType engineType, PreemptionMode preemptionMode, bool lowPriority) {
|
2019-02-27 11:17:17 +01:00
|
|
|
if (osInterface) {
|
2019-03-18 13:57:59 +01:00
|
|
|
return new OsContextWin(*osInterface->get()->getWddm(), contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
2019-02-27 11:17:17 +01:00
|
|
|
}
|
2019-03-18 13:57:59 +01:00
|
|
|
return new OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
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,
|
2019-03-27 10:06:29 +01:00
|
|
|
aub_stream::EngineType engineType, PreemptionMode preemptionMode, bool lowPriority)
|
2019-03-18 13:57:59 +01:00
|
|
|
: OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority), wddm(wddm), residencyController(wddm, contextId) {
|
2019-02-27 11:17:17 +01:00
|
|
|
|
2018-08-21 17:36:08 +02:00
|
|
|
auto wddmInterface = wddm.getWddmInterface();
|
2019-03-01 12:21:30 +01:00
|
|
|
if (!wddm.createContext(*this)) {
|
2018-08-21 17:36:08 +02:00
|
|
|
return;
|
2018-08-23 17:53:58 +02:00
|
|
|
}
|
2018-08-21 17:36:08 +02:00
|
|
|
if (wddmInterface->hwQueuesSupported()) {
|
2019-02-27 11:17:17 +01:00
|
|
|
if (!wddmInterface->createHwQueue(*this)) {
|
2018-08-21 17:36:08 +02:00
|
|
|
return;
|
2018-08-23 17:53:58 +02:00
|
|
|
}
|
2018-08-21 17:36:08 +02:00
|
|
|
}
|
2019-09-13 08:13:02 +02:00
|
|
|
initialized = wddmInterface->createMonitoredFence(*this);
|
2019-02-27 11:17:17 +01:00
|
|
|
residencyController.registerCallback();
|
2018-08-21 17:36:08 +02:00
|
|
|
};
|
2019-02-27 11:17:17 +01:00
|
|
|
|
2019-12-19 14:02:05 +01:00
|
|
|
bool OsContextWin::isInitialized() const {
|
|
|
|
|
return (initialized && residencyController.isInitialized());
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 11:17:17 +01:00
|
|
|
OsContextWin::~OsContextWin() {
|
2019-09-13 08:13:02 +02:00
|
|
|
wddm.getWddmInterface()->destroyHwQueue(hardwareQueue.handle);
|
2019-12-17 15:26:00 +01:00
|
|
|
wddm.getWddmInterface()->destroyMonitorFence(residencyController.getMonitoredFence());
|
2019-03-01 12:21:30 +01:00
|
|
|
wddm.destroyContext(wddmContextHandle);
|
2018-08-21 17:36:08 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|