mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Add OsContext class in shared code
Change-Id: If5aea2126abe1b892068af9ca53e7f448e5b85a6
This commit is contained in:
committed by
sys_ocldev
parent
bc12389312
commit
4b29b30db1
@@ -26,6 +26,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_BASE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_factory.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_inc_base.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.h
|
||||
|
||||
@@ -45,13 +45,14 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_null_device.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux.cpp
|
||||
|
||||
32
runtime/os_interface/linux/os_context_linux.cpp
Normal file
32
runtime/os_interface/linux/os_context_linux.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
|
||||
namespace OCLRT {
|
||||
class OsContext::OsContextImpl {};
|
||||
OsContext::OsContext(OSInterface &osInterface) {
|
||||
osContextImpl = std::make_unique<OsContext::OsContextImpl>();
|
||||
}
|
||||
|
||||
OsContext::~OsContext() = default;
|
||||
} // namespace OCLRT
|
||||
39
runtime/os_interface/os_context.h
Normal file
39
runtime/os_interface/os_context.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <memory>
|
||||
namespace OCLRT {
|
||||
class OSInterface;
|
||||
class OsContext {
|
||||
public:
|
||||
class OsContextImpl;
|
||||
OsContext(OSInterface &osInterface);
|
||||
~OsContext();
|
||||
OsContextImpl *get() const {
|
||||
return osContextImpl.get();
|
||||
};
|
||||
|
||||
protected:
|
||||
std::unique_ptr<OsContextImpl> osContextImpl;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
@@ -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