Add OsContext class in shared code

Change-Id: If5aea2126abe1b892068af9ca53e7f448e5b85a6
This commit is contained in:
Mateusz Jablonski
2018-08-23 17:53:58 +02:00
committed by sys_ocldev
parent bc12389312
commit 4b29b30db1
13 changed files with 189 additions and 15 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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){};