Extract HwDeviceId from Wddm

Related-To: NEO-4208
Change-Id: I79f3e9488fbf641dd8237122335b52f5e44c11b9
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2020-02-05 10:49:54 +01:00 committed by sys_ocldev
parent 8cfcfd6702
commit 938f578e9a
16 changed files with 246 additions and 134 deletions

View File

@ -12,6 +12,9 @@ endif()
set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_additional_context_flags.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_engine_mapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debug_registry_reader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debug_registry_reader.h
${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion_win.cpp
@ -19,45 +22,44 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener${KMDAF_FILE_SUFFIX}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener.h
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.h
${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_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_library_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_socket.h
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_time_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_time_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/os_socket.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_additional_context_flags.cpp
${CMAKE_CURRENT_SOURCE_DIR}/page_table_manager_functions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/print.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sys_calls.h
${CMAKE_CURRENT_SOURCE_DIR}/thk_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_allocation.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_engine_mapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_engine_mapper.h
${CMAKE_CURRENT_SOURCE_DIR}/windows_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/windows_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_allocations_container.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_allocations_container.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/windows_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/windows_inc.cpp
${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_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows_wrapper.h
)
if(WIN32)

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/helpers/non_copyable_or_moveable.h"
#include "core/os_interface/windows/windows_wrapper.h"
#include <d3dkmthk.h>
#include <memory>
namespace NEO {
class Gdi;
class HwDeviceId : NonCopyableClass {
public:
HwDeviceId(D3DKMT_HANDLE adapterIn, LUID adapterLuidIn, std::unique_ptr<Gdi> gdiIn);
inline Gdi *getGdi() const {
return gdi.get();
}
constexpr D3DKMT_HANDLE getAdapter() const {
return adapter;
}
constexpr LUID getAdapterLuid() const {
return adapterLuid;
}
~HwDeviceId();
protected:
const D3DKMT_HANDLE adapter;
const LUID adapterLuid;
const std::unique_ptr<Gdi> gdi;
};
} // namespace NEO

View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "core/helpers/debug_helpers.h"
#include "core/os_interface/windows/gdi_interface.h"
#include "core/os_interface/windows/hw_device_id.h"
namespace NEO {
HwDeviceId::~HwDeviceId() {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_CLOSEADAPTER CloseAdapter = {0};
CloseAdapter.hAdapter = adapter;
status = gdi->closeAdapter(&CloseAdapter);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
}
HwDeviceId::HwDeviceId(D3DKMT_HANDLE adapterIn, LUID adapterLuidIn, std::unique_ptr<Gdi> gdiIn) : adapter(adapterIn),
adapterLuid(adapterLuidIn),
gdi(std::move(gdiIn)){};
} // namespace NEO

View File

@ -69,10 +69,7 @@ Wddm::Wddm(RootDeviceEnvironment &rootDeviceEnvironment) : rootDeviceEnvironment
memset(gtSystemInfo.get(), 0, sizeof(*gtSystemInfo));
memset(gfxPlatform.get(), 0, sizeof(*gfxPlatform));
this->registryReader.reset(new RegistryReader(false, "System\\CurrentControlSet\\Control\\GraphicsDrivers\\Scheduler"));
adapterLuid.HighPart = 0;
adapterLuid.LowPart = 0;
kmDafListener = std::unique_ptr<KmDafListener>(new KmDafListener);
gdi = std::unique_ptr<Gdi>(new Gdi());
temporaryResources = std::make_unique<WddmResidentAllocationsContainer>(this);
}
@ -80,17 +77,22 @@ Wddm::~Wddm() {
temporaryResources.reset();
destroyPagingQueue();
destroyDevice();
closeAdapter();
UNRECOVERABLE_IF(temporaryResources.get())
}
bool Wddm::init(HardwareInfo &outHardwareInfo) {
if (!gdi->isInitialized()) {
bool Wddm::openAdapter() {
hwDeviceId = discoverDevices();
if (!hwDeviceId) {
return false;
}
return true;
}
bool Wddm::init(HardwareInfo &outHardwareInfo) {
if (!openAdapter()) {
return false;
}
if (!queryAdapterInfo()) {
return false;
}
@ -144,12 +146,12 @@ bool Wddm::queryAdapterInfo() {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_QUERYADAPTERINFO QueryAdapterInfo = {0};
ADAPTER_INFO adapterInfo = {0};
QueryAdapterInfo.hAdapter = adapter;
QueryAdapterInfo.hAdapter = getAdapter();
QueryAdapterInfo.Type = KMTQAITYPE_UMDRIVERPRIVATE;
QueryAdapterInfo.pPrivateDriverData = &adapterInfo;
QueryAdapterInfo.PrivateDriverDataSize = sizeof(ADAPTER_INFO);
status = gdi->queryAdapterInfo(&QueryAdapterInfo);
status = getGdi()->queryAdapterInfo(&QueryAdapterInfo);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
// translate
@ -179,7 +181,7 @@ bool Wddm::createPagingQueue() {
CreatePagingQueue.hDevice = device;
CreatePagingQueue.Priority = D3DDDI_PAGINGQUEUE_PRIORITY_NORMAL;
NTSTATUS status = gdi->createPagingQueue(&CreatePagingQueue);
NTSTATUS status = getGdi()->createPagingQueue(&CreatePagingQueue);
if (status == STATUS_SUCCESS) {
pagingQueue = CreatePagingQueue.hPagingQueue;
@ -195,7 +197,7 @@ bool Wddm::destroyPagingQueue() {
if (pagingQueue) {
DestroyPagingQueue.hPagingQueue = pagingQueue;
NTSTATUS status = gdi->destroyPagingQueue(&DestroyPagingQueue);
NTSTATUS status = getGdi()->destroyPagingQueue(&DestroyPagingQueue);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
pagingQueue = 0;
}
@ -205,14 +207,14 @@ bool Wddm::destroyPagingQueue() {
bool Wddm::createDevice(PreemptionMode preemptionMode) {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_CREATEDEVICE CreateDevice = {{0}};
if (adapter) {
CreateDevice.hAdapter = adapter;
if (hwDeviceId) {
CreateDevice.hAdapter = getAdapter();
CreateDevice.Flags.LegacyMode = FALSE;
if (preemptionMode >= PreemptionMode::MidBatch) {
CreateDevice.Flags.DisableGpuTimeout = readEnablePreemptionRegKey();
}
status = gdi->createDevice(&CreateDevice);
status = getGdi()->createDevice(&CreateDevice);
if (status == STATUS_SUCCESS) {
device = CreateDevice.hDevice;
}
@ -226,24 +228,22 @@ bool Wddm::destroyDevice() {
if (device) {
DestroyDevice.hDevice = device;
status = gdi->destroyDevice(&DestroyDevice);
status = getGdi()->destroyDevice(&DestroyDevice);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
device = 0;
}
return true;
}
bool Wddm::closeAdapter() {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_CLOSEADAPTER CloseAdapter = {0};
CloseAdapter.hAdapter = adapter;
status = gdi->closeAdapter(&CloseAdapter);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
adapter = 0;
return true;
}
std::unique_ptr<HwDeviceId> Wddm::discoverDevices() {
auto gdi = std::make_unique<Gdi>();
D3DKMT_HANDLE adapter = 0;
LUID adapterLuid{};
if (!gdi->isInitialized()) {
return nullptr;
}
bool Wddm::openAdapter() {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_OPENADAPTERFROMLUID OpenAdapterData = {{0}};
DXGI_ADAPTER_DESC1 OpenAdapterDesc = {{0}};
@ -256,7 +256,7 @@ bool Wddm::openAdapter() {
HRESULT hr = Wddm::createDxgiFactory(__uuidof(IDXGIFactory), (void **)(&pFactory));
if ((hr != S_OK) || (pFactory == nullptr)) {
return false;
return nullptr;
}
while (pFactory->EnumAdapters1(iDevNum++, &pAdapter) != DXGI_ERROR_NOT_FOUND) {
@ -305,8 +305,10 @@ bool Wddm::openAdapter() {
adapter = OpenAdapterData.hAdapter;
adapterLuid = OpenAdapterDesc.AdapterLuid;
}
return status == STATUS_SUCCESS;
if (status == STATUS_SUCCESS) {
return std::make_unique<HwDeviceId>(adapter, adapterLuid, std::move(gdi));
}
return nullptr;
}
bool Wddm::evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim) {
@ -317,11 +319,11 @@ bool Wddm::evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_
Evict.NumAllocations = numOfHandles;
Evict.NumBytesToTrim = 0;
status = gdi->evict(&Evict);
status = getGdi()->evict(&Evict);
sizeToTrim = Evict.NumBytesToTrim;
kmDafListener->notifyEvict(featureTable->ftrKmdDaf, adapter, device, handleList, numOfHandles, gdi->escape);
kmDafListener->notifyEvict(featureTable->ftrKmdDaf, getAdapter(), device, handleList, numOfHandles, getGdi()->escape);
return status == STATUS_SUCCESS;
}
@ -339,7 +341,7 @@ bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantT
makeResident.Flags.CantTrimFurther = cantTrimFurther ? 1 : 0;
makeResident.Flags.MustSucceed = cantTrimFurther ? 1 : 0;
status = gdi->makeResident(&makeResident);
status = getGdi()->makeResident(&makeResident);
if (status == STATUS_PENDING) {
updatePagingFenceValue(makeResident.PagingFenceValue);
@ -353,7 +355,7 @@ bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantT
UNRECOVERABLE_IF(cantTrimFurther);
}
kmDafListener->notifyMakeResident(featureTable->ftrKmdDaf, adapter, device, handles, count, gdi->escape);
kmDafListener->notifyMakeResident(featureTable->ftrKmdDaf, getAdapter(), device, handles, count, getGdi()->escape);
return success;
}
@ -382,7 +384,7 @@ bool Wddm::mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_A
MapGPUVA.MinimumAddress = minimumAddress;
MapGPUVA.MaximumAddress = maximumAddress;
NTSTATUS status = gdi->mapGpuVirtualAddress(&MapGPUVA);
NTSTATUS status = getGdi()->mapGpuVirtualAddress(&MapGPUVA);
gpuPtr = GmmHelper::canonize(MapGPUVA.VirtualAddress);
if (status == STATUS_PENDING) {
@ -395,7 +397,7 @@ bool Wddm::mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_A
return false;
}
kmDafListener->notifyMapGpuVA(featureTable->ftrKmdDaf, adapter, device, handle, MapGPUVA.VirtualAddress, gdi->escape);
kmDafListener->notifyMapGpuVA(featureTable->ftrKmdDaf, getAdapter(), device, handle, MapGPUVA.VirtualAddress, getGdi()->escape);
if (gmm->isRenderCompressed && rootDeviceEnvironment.pageTableManager.get()) {
return rootDeviceEnvironment.pageTableManager->updateAuxTable(gpuPtr, gmm, true);
@ -414,7 +416,7 @@ D3DGPU_VIRTUAL_ADDRESS Wddm::reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS min
reserveGpuVirtualAddress.hPagingQueue = this->pagingQueue;
reserveGpuVirtualAddress.Size = size;
NTSTATUS status = gdi->reserveGpuVirtualAddress(&reserveGpuVirtualAddress);
NTSTATUS status = getGdi()->reserveGpuVirtualAddress(&reserveGpuVirtualAddress);
UNRECOVERABLE_IF(status != STATUS_SUCCESS);
return reserveGpuVirtualAddress.VirtualAddress;
}
@ -422,14 +424,14 @@ D3DGPU_VIRTUAL_ADDRESS Wddm::reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS min
bool Wddm::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) {
NTSTATUS status = STATUS_SUCCESS;
D3DKMT_FREEGPUVIRTUALADDRESS FreeGPUVA = {0};
FreeGPUVA.hAdapter = adapter;
FreeGPUVA.hAdapter = getAdapter();
FreeGPUVA.BaseAddress = GmmHelper::decanonize(gpuPtr);
FreeGPUVA.Size = size;
status = gdi->freeGpuVirtualAddress(&FreeGPUVA);
status = getGdi()->freeGpuVirtualAddress(&FreeGPUVA);
gpuPtr = static_cast<D3DGPU_VIRTUAL_ADDRESS>(0);
kmDafListener->notifyUnmapGpuVA(featureTable->ftrKmdDaf, adapter, device, FreeGPUVA.BaseAddress, gdi->escape);
kmDafListener->notifyUnmapGpuVA(featureTable->ftrKmdDaf, getAdapter(), device, FreeGPUVA.BaseAddress, getGdi()->escape);
return status == STATUS_SUCCESS;
}
@ -461,14 +463,14 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
CreateAllocation.pAllocationInfo = &AllocationInfo;
CreateAllocation.hDevice = device;
status = gdi->createAllocation(&CreateAllocation);
status = getGdi()->createAllocation(&CreateAllocation);
if (status != STATUS_SUCCESS) {
DEBUG_BREAK_IF(true);
return status;
}
outHandle = AllocationInfo.hAllocation;
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, outHandle, gdi->escape);
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, getAdapter(), device, outHandle, getGdi()->escape);
return status;
}
@ -490,7 +492,7 @@ bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
CreateAllocation.pAllocationInfo = &AllocationInfo;
CreateAllocation.hDevice = device;
status = gdi->createAllocation(&CreateAllocation);
status = getGdi()->createAllocation(&CreateAllocation);
if (status != STATUS_SUCCESS) {
DEBUG_BREAK_IF(true);
@ -498,7 +500,7 @@ bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
}
outHandle = AllocationInfo.hAllocation;
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, outHandle, gdi->escape);
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, getAdapter(), device, outHandle, getGdi()->escape);
return true;
}
@ -543,7 +545,7 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
CreateAllocation.hDevice = device;
while (status == STATUS_UNSUCCESSFUL) {
status = gdi->createAllocation(&CreateAllocation);
status = getGdi()->createAllocation(&CreateAllocation);
if (status != STATUS_SUCCESS) {
DBG_LOG(PrintDebugMessages, __FUNCTION__, "status: ", status);
@ -567,7 +569,7 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
allocationIndex++;
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, AllocationInfo[i].hAllocation, gdi->escape);
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, getAdapter(), device, AllocationInfo[i].hAllocation, getGdi()->escape);
}
status = STATUS_SUCCESS;
@ -587,7 +589,7 @@ bool Wddm::destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationC
DestroyAllocation.Flags.AssumeNotInUse = 1;
status = gdi->destroyAllocation2(&DestroyAllocation);
status = getGdi()->destroyAllocation2(&DestroyAllocation);
return status == STATUS_SUCCESS;
}
@ -596,7 +598,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
D3DKMT_QUERYRESOURCEINFO QueryResourceInfo = {0};
QueryResourceInfo.hDevice = device;
QueryResourceInfo.hGlobalShare = handle;
auto status = gdi->queryResourceInfo(&QueryResourceInfo);
auto status = getGdi()->queryResourceInfo(&QueryResourceInfo);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
if (QueryResourceInfo.NumAllocations == 0) {
@ -621,7 +623,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
OpenResource.pPrivateRuntimeData = resPrivateRuntimeData.get();
OpenResource.PrivateRuntimeDataSize = QueryResourceInfo.PrivateRuntimeDataSize;
status = gdi->openResource(&OpenResource);
status = getGdi()->openResource(&OpenResource);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
alloc->setDefaultHandle(allocationInfo[0].hAllocation);
@ -637,7 +639,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE queryResourceInfoFromNtHandle = {};
queryResourceInfoFromNtHandle.hDevice = device;
queryResourceInfoFromNtHandle.hNtHandle = handle;
auto status = gdi->queryResourceInfoFromNtHandle(&queryResourceInfoFromNtHandle);
auto status = getGdi()->queryResourceInfoFromNtHandle(&queryResourceInfoFromNtHandle);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
std::unique_ptr<char[]> allocPrivateData(new char[queryResourceInfoFromNtHandle.TotalPrivateDriverDataSize]);
@ -658,7 +660,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
openResourceFromNtHandle.pPrivateRuntimeData = resPrivateRuntimeData.get();
openResourceFromNtHandle.PrivateRuntimeDataSize = queryResourceInfoFromNtHandle.PrivateRuntimeDataSize;
status = gdi->openResourceFromNtHandle(&openResourceFromNtHandle);
status = getGdi()->openResourceFromNtHandle(&openResourceFromNtHandle);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
alloc->setDefaultHandle(allocationInfo2[0].hAllocation);
@ -682,7 +684,7 @@ void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPrio
lock2.hAllocation = handle;
lock2.hDevice = this->device;
status = gdi->lock2(&lock2);
status = getGdi()->lock2(&lock2);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
kmDafLock(handle);
@ -696,14 +698,14 @@ void Wddm::unlockResource(const D3DKMT_HANDLE &handle) {
unlock2.hAllocation = handle;
unlock2.hDevice = this->device;
status = gdi->unlock2(&unlock2);
status = getGdi()->unlock2(&unlock2);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, adapter, device, &handle, 1, gdi->escape);
kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, getAdapter(), device, &handle, 1, getGdi()->escape);
}
void Wddm::kmDafLock(D3DKMT_HANDLE handle) {
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, handle, 0, gdi->escape);
kmDafListener->notifyLock(featureTable->ftrKmdDaf, getAdapter(), device, handle, 0, getGdi()->escape);
}
bool Wddm::createContext(OsContextWin &osContext) {
@ -734,7 +736,7 @@ bool Wddm::createContext(OsContextWin &osContext) {
CreateContext.ClientHint = D3DKMT_CLIENTHINT_OPENCL;
CreateContext.hDevice = device;
status = gdi->createContext(&CreateContext);
status = getGdi()->createContext(&CreateContext);
osContext.setWddmContextHandle(CreateContext.hContext);
return status == STATUS_SUCCESS;
@ -746,7 +748,7 @@ bool Wddm::destroyContext(D3DKMT_HANDLE context) {
if (context != static_cast<D3DKMT_HANDLE>(0)) {
DestroyContext.hContext = context;
status = gdi->destroyContext(&DestroyContext);
status = getGdi()->destroyContext(&DestroyContext);
}
return status == STATUS_SUCCESS;
}
@ -777,7 +779,7 @@ void Wddm::getDeviceState() {
GetDevState.hDevice = device;
GetDevState.StateType = D3DKMT_DEVICESTATE_EXECUTION;
status = gdi->getDeviceState(&GetDevState);
status = getGdi()->getDeviceState(&GetDevState);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
if (status == STATUS_SUCCESS) {
DEBUG_BREAK_IF(GetDevState.ExecutionState != D3DKMT_DEVICEEXECUTION_ACTIVE);
@ -807,7 +809,7 @@ bool Wddm::waitOnGPU(D3DKMT_HANDLE context) {
uint64_t localPagingFenceValue = currentPagingFenceValue;
WaitOnGPU.MonitoredFenceValueArray = &localPagingFenceValue;
NTSTATUS status = gdi->waitForSynchronizationObjectFromGpu(&WaitOnGPU);
NTSTATUS status = getGdi()->waitForSynchronizationObjectFromGpu(&WaitOnGPU);
return status == STATUS_SUCCESS;
}
@ -823,7 +825,7 @@ bool Wddm::waitFromCpu(uint64_t lastFenceValue, const MonitoredFence &monitoredF
waitFromCpu.hDevice = device;
waitFromCpu.hAsyncEvent = NULL;
status = gdi->waitForSynchronizationObjectFromCpu(&waitFromCpu);
status = getGdi()->waitForSynchronizationObjectFromCpu(&waitFromCpu);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
}
@ -862,12 +864,12 @@ uint64_t Wddm::getMaxApplicationAddress() const {
}
NTSTATUS Wddm::escape(D3DKMT_ESCAPE &escapeCommand) {
escapeCommand.hAdapter = adapter;
return gdi->escape(&escapeCommand);
escapeCommand.hAdapter = getAdapter();
return getGdi()->escape(&escapeCommand);
};
PFND3DKMT_ESCAPE Wddm::getEscapeHandle() const {
return gdi->escape;
return getGdi()->escape;
}
VOID *Wddm::registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, WddmResidencyController &residencyController) {
@ -876,11 +878,11 @@ VOID *Wddm::registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, Wd
}
D3DKMT_REGISTERTRIMNOTIFICATION registerTrimNotification;
registerTrimNotification.Callback = callback;
registerTrimNotification.AdapterLuid = this->adapterLuid;
registerTrimNotification.AdapterLuid = hwDeviceId->getAdapterLuid();
registerTrimNotification.Context = &residencyController;
registerTrimNotification.hDevice = this->device;
registerTrimNotification.hDevice = device;
NTSTATUS status = gdi->registerTrimNotification(&registerTrimNotification);
NTSTATUS status = getGdi()->registerTrimNotification(&registerTrimNotification);
if (status == STATUS_SUCCESS) {
return registerTrimNotification.Handle;
}
@ -896,7 +898,7 @@ void Wddm::unregisterTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, V
unregisterTrimNotification.Callback = callback;
unregisterTrimNotification.Handle = trimCallbackHandle;
NTSTATUS status = gdi->unregisterTrimNotification(&unregisterTrimNotification);
NTSTATUS status = getGdi()->unregisterTrimNotification(&unregisterTrimNotification);
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
}
@ -946,24 +948,24 @@ long __stdcall notifyAubCapture(void *csrHandle, uint64_t gfxAddress, size_t gfx
}
bool Wddm::configureDeviceAddressSpace() {
GMM_DEVICE_CALLBACKS_INT deviceCallbacks{};
deviceCallbacks.Adapter.KmtHandle = adapter;
deviceCallbacks.Adapter.KmtHandle = getAdapter();
deviceCallbacks.hCsr = nullptr;
deviceCallbacks.hDevice.KmtHandle = device;
deviceCallbacks.PagingQueue = pagingQueue;
deviceCallbacks.PagingFence = pagingQueueSyncObject;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnAllocate = gdi->createAllocation;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnDeallocate = gdi->destroyAllocation;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = gdi->mapGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMakeResident = gdi->makeResident;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEvict = gdi->evict;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnReserveGPUVA = gdi->reserveGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUpdateGPUVA = gdi->updateGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnWaitFromCpu = gdi->waitForSynchronizationObjectFromCpu;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnLock = gdi->lock2;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUnLock = gdi->unlock2;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape = gdi->escape;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnFreeGPUVA = gdi->freeGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnAllocate = getGdi()->createAllocation;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnDeallocate = getGdi()->destroyAllocation;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = getGdi()->mapGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMakeResident = getGdi()->makeResident;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEvict = getGdi()->evict;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnReserveGPUVA = getGdi()->reserveGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUpdateGPUVA = getGdi()->updateGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnWaitFromCpu = getGdi()->waitForSynchronizationObjectFromCpu;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnLock = getGdi()->lock2;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUnLock = getGdi()->unlock2;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape = getGdi()->escape;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnFreeGPUVA = getGdi()->freeGpuVirtualAddress;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = notifyAubCapture;
GMM_DEVICE_INFO deviceInfo{};
@ -984,7 +986,7 @@ bool Wddm::configureDeviceAddressSpace() {
: 0u;
bool obtainMinAddress = gfxPlatform->eRenderCoreFamily == IGFX_GEN12LP_CORE;
return gmmMemory->configureDevice(adapter, device, gdi->escape, svmSize, featureTable->ftrL3IACoherency, minAddress, obtainMinAddress);
return gmmMemory->configureDevice(getAdapter(), device, getGdi()->escape, svmSize, featureTable->ftrL3IACoherency, minAddress, obtainMinAddress);
}
void Wddm::waitOnPagingFenceFromCpu() {

View File

@ -11,6 +11,7 @@
#include "core/helpers/debug_helpers.h"
#include "core/memory_manager/gfx_partition.h"
#include "core/os_interface/os_context.h"
#include "core/os_interface/windows/hw_device_id.h"
#include "core/utilities/spinlock.h"
#include "sku_info.h"
@ -28,6 +29,7 @@ class WddmAllocation;
class WddmInterface;
class WddmResidencyController;
class WddmResidentAllocationsContainer;
class HwDeviceId;
struct AllocationStorageData;
struct HardwareInfo;
@ -117,11 +119,11 @@ class Wddm {
uint64_t getMaxApplicationAddress() const;
D3DKMT_HANDLE getAdapter() const { return adapter; }
inline D3DKMT_HANDLE getAdapter() const { return hwDeviceId->getAdapter(); }
D3DKMT_HANDLE getDevice() const { return device; }
D3DKMT_HANDLE getPagingQueue() const { return pagingQueue; }
D3DKMT_HANDLE getPagingQueueSyncObject() const { return pagingQueueSyncObject; }
Gdi *getGdi() const { return gdi.get(); }
inline Gdi *getGdi() const { return hwDeviceId->getGdi(); }
PFND3DKMT_ESCAPE getEscapeHandle() const;
@ -155,9 +157,10 @@ class Wddm {
WddmVersion getWddmVersion();
static std::unique_ptr<HwDeviceId> discoverDevices();
protected:
std::unique_ptr<Gdi> gdi;
D3DKMT_HANDLE adapter = 0;
std::unique_ptr<HwDeviceId> hwDeviceId;
D3DKMT_HANDLE device = 0;
D3DKMT_HANDLE pagingQueue = 0;
D3DKMT_HANDLE pagingQueueSyncObject = 0;
@ -180,7 +183,6 @@ class Wddm {
RootDeviceEnvironment &rootDeviceEnvironment;
unsigned long hwContextId = 0;
LUID adapterLuid;
uintptr_t maximumApplicationAddress = 0;
std::unique_ptr<GmmMemory> gmmMemory;
uintptr_t minAddress = 0;
@ -192,7 +194,6 @@ class Wddm {
bool createPagingQueue();
bool destroyPagingQueue();
bool destroyDevice();
bool closeAdapter();
void getDeviceState();
void handleCompletion(OsContextWin &osContext);

View File

@ -20,6 +20,7 @@ using namespace NEO;
WddmMock::WddmMock(RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(rootDeviceEnvironment) {
this->temporaryResources = std::make_unique<MockWddmResidentAllocationsContainer>(this);
this->hwDeviceId = std::make_unique<HwDeviceId>(0, LUID{}, std::make_unique<Gdi>());
}
WddmMock::~WddmMock() {
@ -198,10 +199,16 @@ void WddmMock::setHwContextId(unsigned long hwContextId) {
}
bool WddmMock::openAdapter() {
this->adapter = ADAPTER_HANDLE;
if (getAdapter() == 0) {
this->hwDeviceId = std::make_unique<HwDeviceId>(ADAPTER_HANDLE, LUID{}, std::make_unique<Gdi>());
}
return true;
}
void WddmMock::resetGdi(Gdi *gdi) {
this->hwDeviceId = std::make_unique<HwDeviceId>(ADAPTER_HANDLE, LUID{}, std::unique_ptr<Gdi>(gdi));
}
void WddmMock::setHeap32(uint64_t base, uint64_t size) {
gfxPartition.Heap32[3].Base = base;
gfxPartition.Heap32[3].Limit = base + size;

View File

@ -26,15 +26,14 @@ constexpr auto virtualAllocAddress = is64bit ? 0x7FFFF0000000 : 0xFF000000;
class WddmMock : public Wddm {
public:
using Wddm::adapter;
using Wddm::adapterBDF;
using Wddm::currentPagingFenceValue;
using Wddm::dedicatedVideoMemory;
using Wddm::device;
using Wddm::featureTable;
using Wddm::gdi;
using Wddm::getSystemInfo;
using Wddm::gmmMemory;
using Wddm::hwDeviceId;
using Wddm::mapGpuVirtualAddress;
using Wddm::minAddress;
using Wddm::pagingFenceAddress;
@ -93,6 +92,8 @@ class WddmMock : public Wddm {
}
}
void resetGdi(Gdi *gdi);
WddmMockHelpers::MakeResidentCall makeResidentResult;
WddmMockHelpers::CallResult makeNonResidentResult;
WddmMockHelpers::CallResult mapGpuVirtualAddressResult;

View File

@ -118,7 +118,7 @@ class WddmCommandStreamWithMockGdiFixture {
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
wddm = static_cast<WddmMock *>(executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->getWddm());
gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
ASSERT_NE(wddm, nullptr);
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::ImmediateDispatch));
this->csr = new MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, 0);

View File

@ -86,7 +86,7 @@ struct GlArbSyncEventOsTest : public ::testing::Test {
sharing.GLDeviceHandle = 0x3cU;
wddm = new WddmMock(*rootDeviceEnvironment);
gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
osInterface.get()->setWddm(wddm);
}
MockExecutionEnvironment executionEnvironment;
@ -215,7 +215,7 @@ TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateEventFailsThenSetupArbS
auto wddm = new WddmMock(*rootDeviceEnvironment.get());
auto gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
@ -244,7 +244,7 @@ TEST_F(GlArbSyncEventOsTest, GivenInvalidGlSyncInfoWhenCleanupArbSyncObjectIsCal
auto wddm = new WddmMock(*rootDeviceEnvironment.get());
auto gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
@ -274,7 +274,7 @@ TEST_F(GlArbSyncEventOsTest, GivenValidGlSyncInfoWhenCleanupArbSyncObjectIsCalle
auto wddm = new WddmMock(*rootDeviceEnvironment.get());
auto gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);

View File

@ -97,6 +97,9 @@ TEST(Wddm20EnumAdaptersTest, WhenAdapterDescriptionContainsDCHDAndgdrclPathDoesn
VariableBackup<const wchar_t *> igdrclPathBackup(&SysCalls::igdrclFilePath);
igdrclPathBackup = L"intel_dch.inf";
auto hwDeviceId = Wddm::discoverDevices();
EXPECT_EQ(nullptr, hwDeviceId.get());
struct MockWddm : Wddm {
using Wddm::openAdapter;
@ -135,6 +138,9 @@ TEST(Wddm20EnumAdaptersTest, WhenAdapterDescriptionContainsDCHDAndgdrclPathConta
VariableBackup<const wchar_t *> igdrclPathBackup(&SysCalls::igdrclFilePath);
igdrclPathBackup = L"intel_dch_d.inf";
auto hwDeviceId = Wddm::discoverDevices();
EXPECT_NE(nullptr, hwDeviceId.get());
struct MockWddm : Wddm {
using Wddm::openAdapter;
@ -154,6 +160,9 @@ TEST(Wddm20EnumAdaptersTest, WhenAdapterDescriptionContainsDCHIAndgdrclPathConta
VariableBackup<const wchar_t *> igdrclPathBackup(&SysCalls::igdrclFilePath);
igdrclPathBackup = L"intel_dch_i.inf";
auto hwDeviceId = Wddm::discoverDevices();
EXPECT_NE(nullptr, hwDeviceId.get());
struct MockWddm : Wddm {
using Wddm::openAdapter;
@ -525,7 +534,7 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) {
: 0;
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(adapterHandle,
deviceHandle,
wddm->gdi->escape.mFunc,
wddm->getGdi()->escape.mFunc,
maxAddr,
FtrL3IACoherency))
.Times(1)
@ -535,7 +544,7 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) {
}
TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) {
wddm->adapter = static_cast<D3DKMT_HANDLE>(0);
wddm->hwDeviceId = std::make_unique<HwDeviceId>(0, LUID{}, std::make_unique<Gdi>());
EXPECT_CALL(*gmmMem,
configureDeviceAddressSpace(static_cast<D3DKMT_HANDLE>(0), ::testing::_, ::testing::_, ::testing::_, ::testing::_))
.Times(0);
@ -555,7 +564,7 @@ TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) {
}
TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoEscFunc) {
wddm->gdi->escape = static_cast<PFND3DKMT_ESCAPE>(nullptr);
wddm->getGdi()->escape = static_cast<PFND3DKMT_ESCAPE>(nullptr);
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_, ::testing::_, static_cast<PFND3DKMT_ESCAPE>(nullptr), ::testing::_,
::testing::_))
.Times(0);
@ -622,9 +631,9 @@ TEST_F(Wddm20Tests, whenCreateHwQueueIsCalledThenAlwaysReturnFalse) {
}
TEST_F(Wddm20Tests, whenWddmIsInitializedThenGdiDoesntHaveHwQueueDDIs) {
EXPECT_EQ(nullptr, wddm->gdi->createHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->gdi->destroyHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->gdi->submitCommandToHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->getGdi()->createHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->getGdi()->destroyHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->getGdi()->submitCommandToHwQueue.mFunc);
}
TEST(DebugFlagTest, givenDebugManagerWhenGetForUseNoRingFlushesKmdModeIsCalledThenTrueIsReturned) {
@ -1232,3 +1241,30 @@ HWTEST_F(Wddm20WithMockGdiDllTests, givenNonGen12LPPlatformWhenConfigureDeviceAd
EXPECT_EQ(NEO::windowsMinAddress, wddm->getWddmMinAddress());
}
struct GdiWithMockedCloseFunc : public Gdi {
GdiWithMockedCloseFunc() : Gdi() {
closeAdapter = mockCloseAdapter;
GdiWithMockedCloseFunc::closeAdapterCalled = 0u;
GdiWithMockedCloseFunc::closeAdapterCalledArgPassed = 0u;
}
static NTSTATUS __stdcall mockCloseAdapter(IN CONST D3DKMT_CLOSEADAPTER *adapter) {
closeAdapterCalled++;
closeAdapterCalledArgPassed = adapter->hAdapter;
return STATUS_SUCCESS;
}
static uint32_t closeAdapterCalled;
static D3DKMT_HANDLE closeAdapterCalledArgPassed;
};
uint32_t GdiWithMockedCloseFunc::closeAdapterCalled;
D3DKMT_HANDLE GdiWithMockedCloseFunc::closeAdapterCalledArgPassed;
TEST(HwDeviceId, whenHwDeviceIdIsDestroyedThenAdapterIsClosed) {
D3DKMT_HANDLE adapter = 0x1234;
{
HwDeviceId hwDeviceId{adapter, {}, std::make_unique<GdiWithMockedCloseFunc>()};
}
EXPECT_EQ(1u, GdiWithMockedCloseFunc::closeAdapterCalled);
EXPECT_EQ(adapter, GdiWithMockedCloseFunc::closeAdapterCalledArgPassed);
}

View File

@ -171,16 +171,16 @@ TEST_F(Wddm23Tests, givenDestructionOsContextWinWhenCallingDestroyMonitorFenceTh
}
TEST_F(Wddm23TestsWithoutWddmInit, whenInitCalledThenInitializeNewGdiDDIsAndCallToCreateHwQueue) {
EXPECT_EQ(nullptr, wddm->gdi->createHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->gdi->destroyHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->gdi->submitCommandToHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->getGdi()->createHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->getGdi()->destroyHwQueue.mFunc);
EXPECT_EQ(nullptr, wddm->getGdi()->submitCommandToHwQueue.mFunc);
init();
EXPECT_EQ(1u, wddmMockInterface->createHwQueueCalled);
EXPECT_NE(nullptr, wddm->gdi->createHwQueue.mFunc);
EXPECT_NE(nullptr, wddm->gdi->destroyHwQueue.mFunc);
EXPECT_NE(nullptr, wddm->gdi->submitCommandToHwQueue.mFunc);
EXPECT_NE(nullptr, wddm->getGdi()->createHwQueue.mFunc);
EXPECT_NE(nullptr, wddm->getGdi()->destroyHwQueue.mFunc);
EXPECT_NE(nullptr, wddm->getGdi()->submitCommandToHwQueue.mFunc);
}
TEST_F(Wddm23TestsWithoutWddmInit, whenCreateHwQueueFailedThenReturnFalseFromInit) {
@ -196,7 +196,7 @@ TEST_F(Wddm23TestsWithoutWddmInit, givenFailureOnGdiInitializationWhenCreatingHw
}
};
auto myMockGdi = new MyMockGdi();
wddm->gdi.reset(myMockGdi);
wddm->resetGdi(myMockGdi);
init();
EXPECT_FALSE(osContext->isInitialized());
EXPECT_EQ(1u, wddmMockInterface->createHwQueueCalled);

View File

@ -36,7 +36,7 @@ struct WddmFixture : ::testing::Test {
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
osInterface = executionEnvironment->rootDeviceEnvironments[0]->osInterface.get();
gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);

View File

@ -24,11 +24,15 @@ using namespace NEO;
class WddmWithKmDafMock : public Wddm {
public:
using Wddm::featureTable;
using Wddm::gdi;
using Wddm::mapGpuVirtualAddress;
WddmWithKmDafMock(RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(rootDeviceEnvironment) {
WddmWithKmDafMock(RootDeviceEnvironment &rootDeviceEnvironment, Gdi *mockGdi) : Wddm(rootDeviceEnvironment) {
kmDafListener.reset(new KmDafListenerMock);
this->hwDeviceId = std::make_unique<HwDeviceId>(ADAPTER_HANDLE, LUID{}, std::unique_ptr<Gdi>(mockGdi));
}
bool openAdapter() override {
return true;
}
KmDafListenerMock &getKmDafListenerMock() {
@ -40,8 +44,7 @@ class WddmKmDafListenerTest : public ::testing::Test {
public:
void SetUp() {
executionEnvironment = platform()->peekExecutionEnvironment();
wddmWithKmDafMock.reset(new WddmWithKmDafMock(*executionEnvironment->rootDeviceEnvironments[0].get()));
wddmWithKmDafMock->gdi.reset(new MockGdi());
wddmWithKmDafMock.reset(new WddmWithKmDafMock(*executionEnvironment->rootDeviceEnvironments[0].get(), new MockGdi()));
auto hwInfo = *executionEnvironment->getHardwareInfo();
wddmWithKmDafMock->init(hwInfo);
wddmWithKmDafMock->featureTable->ftrKmdDaf = true;

View File

@ -1235,7 +1235,7 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati
struct WddmMemoryManagerWithAsyncDeleterTest : public MockWddmMemoryManagerTest {
void SetUp() {
MockWddmMemoryManagerTest::SetUp();
wddm->gdi.reset(new MockGdi());
wddm->resetGdi(new MockGdi());
wddm->callBaseDestroyAllocations = false;
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);

View File

@ -49,7 +49,7 @@ class MockWddmMemoryManagerFixture {
gdi = new MockGdi();
wddm = static_cast<WddmMock *>(Wddm::createWddm(*executionEnvironment->rootDeviceEnvironments[0].get()));
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000;
wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1);
auto hwInfo = *platformDevices[0];

View File

@ -91,7 +91,7 @@ struct WddmResidencyControllerWithGdiTest : ::testing::Test {
rootDeviceEnvironment = std::make_unique<RootDeviceEnvironment>(*executionEnvironment);
wddm = std::unique_ptr<WddmMock>(static_cast<WddmMock *>(Wddm::createWddm(*rootDeviceEnvironment)));
gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
@ -114,7 +114,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
executionEnvironment = platform()->peekExecutionEnvironment();
wddm = new ::testing::NiceMock<GmockWddm>(*executionEnvironment->rootDeviceEnvironments[0].get());
wddm->gdi = std::make_unique<MockGdi>();
wddm->resetGdi(new MockGdi());
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
@ -150,7 +150,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test {
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
gdi = new MockGdi();
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm);
@ -183,7 +183,7 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenItIsConstructedThe
executionEnvironment.prepareRootDeviceEnvironments(1);
auto gdi = new MockGdi();
auto wddm = std::unique_ptr<WddmMock>{static_cast<WddmMock *>(Wddm::createWddm(*executionEnvironment.rootDeviceEnvironments[0].get()))};
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
@ -203,7 +203,7 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenRegisterCallbackTh
executionEnvironment.prepareRootDeviceEnvironments(1);
auto gdi = new MockGdi();
auto wddm = std::unique_ptr<WddmMock>{static_cast<WddmMock *>(Wddm::createWddm(*executionEnvironment.rootDeviceEnvironments[0].get()))};
wddm->gdi.reset(gdi);
wddm->resetGdi(gdi);
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);