mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
Add OsContext class in shared code
Change-Id: If5aea2126abe1b892068af9ca53e7f448e5b85a6
This commit is contained in:
committed by
sys_ocldev
parent
bc12389312
commit
4b29b30db1
@@ -23,20 +23,29 @@
|
||||
#include "runtime/os_interface/windows/os_context_win.h"
|
||||
#include "runtime/os_interface/windows/wddm/wddm.h"
|
||||
#include "runtime/os_interface/windows/wddm/wddm_interface.h"
|
||||
#include "runtime/os_interface/windows/os_interface.h"
|
||||
|
||||
namespace OCLRT {
|
||||
OsContextWin::OsContextWin(Wddm &wddm) : wddm(wddm) {
|
||||
|
||||
OsContextWin::OsContextImpl(Wddm &wddm) : wddm(wddm) {
|
||||
auto wddmInterface = wddm.getWddmInterface();
|
||||
if (!wddm.createContext(context))
|
||||
if (!wddmInterface) {
|
||||
return;
|
||||
}
|
||||
if (!wddm.createContext(context)) {
|
||||
return;
|
||||
}
|
||||
if (wddmInterface->hwQueuesSupported()) {
|
||||
if (!wddmInterface->createHwQueue(wddm.getPreemptionMode(), *this))
|
||||
if (!wddmInterface->createHwQueue(wddm.getPreemptionMode(), *this)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
initialized = wddmInterface->createMonitoredFence(*this);
|
||||
};
|
||||
OsContextWin::~OsContextWin() {
|
||||
wddm.getWddmInterface()->destroyHwQueue(hwQueueHandle);
|
||||
OsContextWin::~OsContextImpl() {
|
||||
if (wddm.getWddmInterface()) {
|
||||
wddm.getWddmInterface()->destroyHwQueue(hwQueueHandle);
|
||||
}
|
||||
wddm.destroyContext(context);
|
||||
}
|
||||
|
||||
@@ -47,4 +56,10 @@ void OsContextWin::resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cp
|
||||
monitoredFence.cpuAddress = cpuAddress;
|
||||
monitoredFence.gpuAddress = gpuAddress;
|
||||
}
|
||||
|
||||
OsContext::OsContext(OSInterface &osInterface) {
|
||||
osContextImpl = std::make_unique<OsContextWin>(*osInterface.get()->getWddm());
|
||||
}
|
||||
OsContext::~OsContext() = default;
|
||||
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -21,18 +21,20 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/os_interface/windows/windows_wrapper.h"
|
||||
#include "runtime/os_interface/windows/windows_defs.h"
|
||||
#include <d3dkmthk.h>
|
||||
|
||||
namespace OCLRT {
|
||||
class Wddm;
|
||||
|
||||
class OsContextWin {
|
||||
class Wddm;
|
||||
using OsContextWin = OsContext::OsContextImpl;
|
||||
class OsContext::OsContextImpl {
|
||||
public:
|
||||
OsContextWin() = delete;
|
||||
OsContextWin(Wddm &wddm);
|
||||
~OsContextWin();
|
||||
OsContextImpl() = delete;
|
||||
OsContextImpl(Wddm &wddm);
|
||||
~OsContextImpl();
|
||||
D3DKMT_HANDLE getContext() const {
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/os_interface/windows/windows_wrapper.h"
|
||||
#include "runtime/os_interface/windows/windows_defs.h"
|
||||
#include "runtime/os_interface/windows/wddm/wddm_interface.h"
|
||||
@@ -45,11 +46,12 @@ class Gdi;
|
||||
class Gmm;
|
||||
class LinearStream;
|
||||
class GmmPageTableMngr;
|
||||
class OsContextWin;
|
||||
struct FeatureTable;
|
||||
struct WorkaroundTable;
|
||||
struct KmDafListener;
|
||||
|
||||
using OsContextWin = OsContext::OsContextImpl;
|
||||
|
||||
enum class WddmInterfaceVersion {
|
||||
Wddm20 = 20,
|
||||
Wddm23 = 23,
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/os_interface/windows/windows_wrapper.h"
|
||||
#include <d3dkmthk.h>
|
||||
#include <cstdint>
|
||||
@@ -27,8 +28,10 @@
|
||||
|
||||
namespace OCLRT {
|
||||
class Gdi;
|
||||
class OsContextWin;
|
||||
class Wddm;
|
||||
|
||||
using OsContextWin = OsContext::OsContextImpl;
|
||||
|
||||
class WddmInterface {
|
||||
public:
|
||||
WddmInterface(Wddm &wddm) : wddm(wddm){};
|
||||
|
||||
Reference in New Issue
Block a user