Wddm interface [3/n]: Improve constructing Wddm object

- Only Wddm object owns Gdi
- Dont pass Gdi object to constructor
- Move Wddm related files to new directory

Change-Id: Iadd26634c7692db760d7d3367211c32d2c2c8121
This commit is contained in:
Dunajski, Bartosz
2018-05-10 11:42:41 +02:00
committed by sys_ocldev
parent 06287af541
commit bab9ad6cda
28 changed files with 163 additions and 171 deletions

View File

@ -55,7 +55,7 @@ set(RUNTIME_SRCS_DLL_WINDOWS
${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/gmm_memory.cpp
${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/page_table_mngr.cpp
${IGDRCL_SOURCE_DIR}/runtime/os_interface/windows/sys_calls.cpp
${IGDRCL_SOURCE_DIR}/runtime/os_interface/windows/wddm_create.cpp
${IGDRCL_SOURCE_DIR}/runtime/os_interface/windows/wddm/wddm_create.cpp
)
target_sources(${NEO_DYNAMIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_DLL_BASE})

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 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"),
@ -21,8 +21,8 @@
*/
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm.inl"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.inl"
namespace OCLRT {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 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"),
@ -21,8 +21,8 @@
*/
#include "hw_cmds.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm.inl"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.inl"
namespace OCLRT {

View File

@ -56,9 +56,6 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/source_level_debugger_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sys_calls.h
${CMAKE_CURRENT_SOURCE_DIR}/thk_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm.inl
${CMAKE_CURRENT_SOURCE_DIR}/wddm_32bit_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_allocation.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_device_command_stream.h
@ -71,6 +68,9 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/windows_inc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.inl
)
if(WIN32)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 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"),
@ -20,7 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/deferrable_deletion_win.h"
namespace OCLRT {

View File

@ -26,7 +26,7 @@
#include "runtime/os_interface/device_factory.h"
#include "runtime/os_interface/hw_info_config.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
namespace OCLRT {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 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"),
@ -20,7 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/device/driver_info.h"
#include "runtime/os_interface/windows/driver_info.h"
#include "runtime/os_interface/windows/os_interface.h"

View File

@ -22,7 +22,7 @@
#include "os_interface.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/sys_calls.h"
namespace OCLRT {

View File

@ -21,7 +21,7 @@
*/
#include <memory>
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/os_time.h"

View File

@ -27,7 +27,7 @@
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/gmm_helper/resource_info.h"
#include "runtime/gmm_helper/page_table_mngr.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/hw_info_config.h"
#include "runtime/os_interface/windows/wddm_allocation.h"
#include "runtime/os_interface/windows/registry_reader.h"
@ -53,18 +53,16 @@ Wddm::GetSystemInfoFcn Wddm::getSystemInfo = getGetSystemInfo();
Wddm::VirtualAllocFcn Wddm::virtualAllocFnc = getVirtualAlloc();
Wddm::VirtualFreeFcn Wddm::virtualFreeFnc = getVirtualFree();
Wddm::Wddm(Gdi *gdi) : initialized(false),
gdiAllocated(false),
gdi(gdi),
adapter(0),
context(0),
device(0),
pagingQueue(0),
pagingQueueSyncObject(0),
pagingFenceAddress(nullptr),
currentPagingFenceValue(0),
hwContextId(0),
trimCallbackHandle(nullptr) {
Wddm::Wddm() : initialized(false),
adapter(0),
context(0),
device(0),
pagingQueue(0),
pagingQueueSyncObject(0),
pagingFenceAddress(nullptr),
currentPagingFenceValue(0),
hwContextId(0),
trimCallbackHandle(nullptr) {
featureTable.reset(new FeatureTable());
waTable.reset(new WorkaroundTable());
gtSystemInfo.reset(new GT_SYSTEM_INFO);
@ -81,10 +79,7 @@ Wddm::Wddm(Gdi *gdi) : initialized(false),
gmmMemory = std::unique_ptr<GmmMemory>(GmmMemory::create());
minAddress = 0;
kmDafListener = std::unique_ptr<KmDafListener>(new KmDafListener);
}
Wddm::Wddm() : Wddm(new Gdi()) {
gdiAllocated = true;
gdi = std::unique_ptr<Gdi>(new Gdi());
}
Wddm::~Wddm() {
@ -95,8 +90,6 @@ Wddm::~Wddm() {
destroyPagingQueue();
destroyDevice();
closeAdapter();
if (gdiAllocated)
delete gdi;
}
bool Wddm::enumAdapters(unsigned int devNum, HardwareInfo &outHardwareInfo) {

View File

@ -50,19 +50,6 @@ struct WorkaroundTable;
struct KmDafListener;
class Wddm {
private:
struct MonitoredFence {
D3DKMT_HANDLE fenceHandle;
D3DGPU_VIRTUAL_ADDRESS gpuAddress;
volatile uint64_t *cpuAddress;
volatile uint64_t currentFenceValue;
uint64_t lastSubmittedFence;
};
protected:
Wddm();
Wddm(Gdi *gdi);
public:
typedef HRESULT(WINAPI *CreateDXGIFactoryFcn)(REFIID riid, void **ppFactory);
typedef void(WINAPI *GetSystemInfoFcn)(SYSTEM_INFO *pSystemInfo);
@ -71,7 +58,7 @@ class Wddm {
virtual ~Wddm();
static Wddm *createWddm(Gdi *gdi = nullptr);
static Wddm *createWddm();
static bool enumAdapters(unsigned int devNum, HardwareInfo &outHardwareInfo);
@ -140,7 +127,7 @@ class Wddm {
D3DKMT_HANDLE getDevice() const { return device; }
D3DKMT_HANDLE getPagingQueue() const { return pagingQueue; }
D3DKMT_HANDLE getPagingQueueSyncObject() const { return pagingQueueSyncObject; }
Gdi *getGdi() const { return gdi; }
Gdi *getGdi() const { return gdi.get(); }
PFND3DKMT_ESCAPE getEscapeHandle() const;
@ -175,8 +162,7 @@ class Wddm {
protected:
bool initialized;
bool gdiAllocated;
Gdi *gdi;
std::unique_ptr<Gdi> gdi;
D3DKMT_HANDLE adapter;
D3DKMT_HANDLE context;
D3DKMT_HANDLE device;
@ -208,6 +194,7 @@ class Wddm {
std::unique_ptr<GmmMemory> gmmMemory;
uintptr_t minAddress;
Wddm();
MOCKABLE_VIRTUAL bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, uint64_t size, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1);
MOCKABLE_VIRTUAL bool openAdapter();
bool createDevice();

View File

@ -21,7 +21,7 @@
*/
#include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
namespace OCLRT {

View File

@ -21,11 +21,11 @@
*/
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include <dxgi.h>
namespace OCLRT {
Wddm *Wddm::createWddm(Gdi *gdi) {
Wddm *Wddm::createWddm() {
return new Wddm();
}

View File

@ -29,7 +29,7 @@
#include "runtime/command_stream/preemption.h"
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/device/device.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_device_command_stream.h"
#include "runtime/helpers/ptr_math.h"
#include "runtime/helpers/translationtable_callbacks.h"

View File

@ -24,7 +24,7 @@
#include "runtime/helpers/engine_node.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include <cstdint>

View File

@ -31,7 +31,7 @@
#include "runtime/memory_manager/deferrable_deletion.h"
#include "runtime/os_interface/windows/wddm_memory_manager.h"
#include "runtime/os_interface/windows/wddm_allocation.h"
#include "runtime/os_interface/windows/wddm.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include <algorithm>
namespace OCLRT {

View File

@ -22,8 +22,19 @@
#pragma once
#include <d3dkmthk.h>
#include <cstdint>
namespace OCLRT {
constexpr uintptr_t windowsMinAddress = 0x200000;
struct MonitoredFence {
D3DKMT_HANDLE fenceHandle;
D3DGPU_VIRTUAL_ADDRESS gpuAddress;
volatile uint64_t *cpuAddress;
volatile uint64_t currentFenceValue;
uint64_t lastSubmittedFence;
};
} // namespace OCLRT