mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Cleanup in WDDM files
Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
165194bf85
commit
a77d2b1dde
@@ -71,6 +71,7 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/read_preemption_regkey.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/um_km_data_translator.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/um_km_data_translator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm${BRANCH_DIR_SUFFIX}/create_um_km_data_translator.cpp
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/driver_info.h"
|
||||
#include "shared/source/utilities/debug_settings_reader.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -15,8 +16,6 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class SettingsReader;
|
||||
|
||||
bool isCompatibleDriverStore(std::string &&deviceRegistryPath);
|
||||
|
||||
class DriverInfoWindows : public DriverInfo {
|
||||
|
||||
@@ -7,13 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
#include "shared/source/os_interface/windows/d3dkmthk_wrapper.h"
|
||||
#include "shared/source/os_interface/windows/os_inc.h"
|
||||
#include "shared/source/os_interface/windows/thk_wrapper.h"
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
|
||||
#include <d3d9types.h>
|
||||
|
||||
#include <d3dkmthk.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,6 +9,21 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
unsigned int getPid() {
|
||||
return GetCurrentProcessId();
|
||||
}
|
||||
|
||||
bool isShutdownInProgress() {
|
||||
auto handle = GetModuleHandleA("ntdll.dll");
|
||||
|
||||
if (!handle) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto RtlDllShutdownInProgress = reinterpret_cast<BOOLEAN(WINAPI *)()>(GetProcAddress(handle, "RtlDllShutdownInProgress"));
|
||||
return RtlDllShutdownInProgress();
|
||||
}
|
||||
|
||||
namespace SysCalls {
|
||||
|
||||
HANDLE createEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) {
|
||||
|
||||
@@ -7,11 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/options.h"
|
||||
#include "shared/source/os_interface/windows/d3dkmthk_wrapper.h"
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
#include "shared/source/utilities/api_intercept.h"
|
||||
|
||||
#include <d3dkmthk.h>
|
||||
|
||||
namespace NEO {
|
||||
// Default template for GetID( ) for Thk function, causing compilation error !!
|
||||
// Returns ID for specific ThkWrapper type
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define INITGUID
|
||||
#include "shared/source/os_interface/windows/wddm/adapter_factory_dxcore.h"
|
||||
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/windows/debug_registry_reader.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
unsigned int readEnablePreemptionRegKey() {
|
||||
auto registryReader = std::make_unique<RegistryReader>(false, "System\\CurrentControlSet\\Control\\GraphicsDrivers\\Scheduler");
|
||||
return static_cast<unsigned int>(registryReader->getSetting("EnablePreemption", 1));
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/helpers/windows/gmm_callbacks.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/source/os_interface/windows/debug_registry_reader.h"
|
||||
#include "shared/source/os_interface/windows/driver_info_windows.h"
|
||||
#include "shared/source/os_interface/windows/dxcore_wrapper.h"
|
||||
#include "shared/source/os_interface/windows/gdi_interface.h"
|
||||
#include "shared/source/os_interface/windows/kmdaf_listener.h"
|
||||
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||
@@ -41,12 +41,6 @@
|
||||
#include "gmm_client_context.h"
|
||||
#include "gmm_memory.h"
|
||||
|
||||
// clang-format off
|
||||
#include <initguid.h>
|
||||
#include <dxcore.h>
|
||||
#include <dxgi.h>
|
||||
// clang-format on
|
||||
|
||||
namespace NEO {
|
||||
extern Wddm::CreateDXGIFactoryFcn getCreateDxgiFactory();
|
||||
extern Wddm::DXCoreCreateAdapterFactoryFcn getDXCoreCreateAdapterFactory();
|
||||
@@ -69,7 +63,7 @@ Wddm::Wddm(std::unique_ptr<HwDeviceIdWddm> hwDeviceIdIn, RootDeviceEnvironment &
|
||||
gfxPlatform.reset(new PLATFORM);
|
||||
memset(gtSystemInfo.get(), 0, sizeof(*gtSystemInfo));
|
||||
memset(gfxPlatform.get(), 0, sizeof(*gfxPlatform));
|
||||
this->registryReader.reset(new RegistryReader(false, "System\\CurrentControlSet\\Control\\GraphicsDrivers\\Scheduler"));
|
||||
this->enablePreemptionRegValue = NEO::readEnablePreemptionRegKey();
|
||||
kmDafListener = std::unique_ptr<KmDafListener>(new KmDafListener);
|
||||
temporaryResources = std::make_unique<WddmResidentAllocationsContainer>(this);
|
||||
}
|
||||
@@ -222,7 +216,7 @@ bool Wddm::createDevice(PreemptionMode preemptionMode) {
|
||||
CreateDevice.hAdapter = getAdapter();
|
||||
CreateDevice.Flags.LegacyMode = FALSE;
|
||||
if (preemptionMode >= PreemptionMode::MidBatch) {
|
||||
CreateDevice.Flags.DisableGpuTimeout = readEnablePreemptionRegKey();
|
||||
CreateDevice.Flags.DisableGpuTimeout = getEnablePreemptionRegValue();
|
||||
}
|
||||
|
||||
status = getGdi()->createDevice(&CreateDevice);
|
||||
@@ -663,6 +657,9 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
|
||||
}
|
||||
|
||||
bool Wddm::destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) {
|
||||
if ((0U == allocationCount) && (0U == resourceHandle)) {
|
||||
return true;
|
||||
}
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DKMT_DESTROYALLOCATION2 DestroyAllocation = {0};
|
||||
DEBUG_BREAK_IF(!(allocationCount <= 1 || resourceHandle == 0));
|
||||
@@ -700,14 +697,14 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
|
||||
std::unique_ptr<char[]> allocPrivateData(new char[QueryResourceInfo.TotalPrivateDriverDataSize]);
|
||||
std::unique_ptr<char[]> resPrivateData(new char[QueryResourceInfo.ResourcePrivateDriverDataSize]);
|
||||
std::unique_ptr<char[]> resPrivateRuntimeData(new char[QueryResourceInfo.PrivateRuntimeDataSize]);
|
||||
std::unique_ptr<D3DDDI_OPENALLOCATIONINFO[]> allocationInfo(new D3DDDI_OPENALLOCATIONINFO[QueryResourceInfo.NumAllocations]);
|
||||
std::unique_ptr<D3DDDI_OPENALLOCATIONINFO2[]> allocationInfo(new D3DDDI_OPENALLOCATIONINFO2[QueryResourceInfo.NumAllocations]);
|
||||
|
||||
D3DKMT_OPENRESOURCE OpenResource = {0};
|
||||
|
||||
OpenResource.hDevice = device;
|
||||
OpenResource.hGlobalShare = handle;
|
||||
OpenResource.NumAllocations = QueryResourceInfo.NumAllocations;
|
||||
OpenResource.pOpenAllocationInfo = allocationInfo.get();
|
||||
OpenResource.pOpenAllocationInfo2 = allocationInfo.get();
|
||||
OpenResource.pTotalPrivateDriverDataBuffer = allocPrivateData.get();
|
||||
OpenResource.TotalPrivateDriverDataBufferSize = QueryResourceInfo.TotalPrivateDriverDataSize;
|
||||
OpenResource.pResourcePrivateDriverData = resPrivateData.get();
|
||||
@@ -815,7 +812,7 @@ bool Wddm::createContext(OsContextWin &osContext) {
|
||||
|
||||
PrivateData.IsProtectedProcess = FALSE;
|
||||
PrivateData.IsDwm = FALSE;
|
||||
PrivateData.ProcessID = GetCurrentProcessId();
|
||||
PrivateData.ProcessID = NEO::getPid();
|
||||
PrivateData.GpuVAContext = TRUE;
|
||||
PrivateData.pHwContextId = &hwContextId;
|
||||
PrivateData.IsMediaUsage = false;
|
||||
@@ -828,7 +825,7 @@ bool Wddm::createContext(OsContextWin &osContext) {
|
||||
CreateContext.Flags.HwQueueSupported = wddmInterface->hwQueuesSupported();
|
||||
|
||||
if (osContext.getPreemptionMode() >= PreemptionMode::MidBatch) {
|
||||
CreateContext.Flags.DisableGpuTimeout = readEnablePreemptionRegKey();
|
||||
CreateContext.Flags.DisableGpuTimeout = getEnablePreemptionRegValue();
|
||||
}
|
||||
|
||||
UmKmDataTempStorage<CREATECONTEXT_PVTDATA> internalRepresentation;
|
||||
@@ -903,8 +900,8 @@ void Wddm::getDeviceState() {
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int Wddm::readEnablePreemptionRegKey() {
|
||||
return static_cast<unsigned int>(registryReader->getSetting("EnablePreemption", 1));
|
||||
unsigned int Wddm::getEnablePreemptionRegValue() {
|
||||
return enablePreemptionRegValue;
|
||||
}
|
||||
|
||||
bool Wddm::waitOnGPU(D3DKMT_HANDLE context) {
|
||||
@@ -1003,14 +1000,7 @@ LUID Wddm::getAdapterLuid() const {
|
||||
}
|
||||
|
||||
bool Wddm::isShutdownInProgress() {
|
||||
auto handle = GetModuleHandleA("ntdll.dll");
|
||||
|
||||
if (!handle) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto RtlDllShutdownInProgress = reinterpret_cast<BOOLEAN(WINAPI *)()>(GetProcAddress(handle, "RtlDllShutdownInProgress"));
|
||||
return RtlDllShutdownInProgress();
|
||||
return NEO::isShutdownInProgress();
|
||||
}
|
||||
|
||||
void Wddm::releaseReservedAddress(void *reservedAddress) {
|
||||
|
||||
@@ -52,6 +52,10 @@ struct OsHandleStorage;
|
||||
|
||||
enum class HeapIndex : uint32_t;
|
||||
|
||||
unsigned int readEnablePreemptionRegKey();
|
||||
unsigned int getPid();
|
||||
bool isShutdownInProgress();
|
||||
|
||||
class Wddm : public DriverModel {
|
||||
public:
|
||||
static constexpr DriverModelType driverModelType = DriverModelType::WDDM;
|
||||
@@ -146,8 +150,6 @@ class Wddm : public DriverModel {
|
||||
return static_cast<uint32_t>(hwContextId);
|
||||
}
|
||||
|
||||
std::unique_ptr<SettingsReader> registryReader;
|
||||
|
||||
uintptr_t getWddmMinAddress() const {
|
||||
return this->minAddress;
|
||||
}
|
||||
@@ -155,7 +157,7 @@ class Wddm : public DriverModel {
|
||||
return wddmInterface.get();
|
||||
}
|
||||
|
||||
unsigned int readEnablePreemptionRegKey();
|
||||
unsigned int getEnablePreemptionRegValue();
|
||||
MOCKABLE_VIRTUAL uint64_t *getPagingFenceAddress() {
|
||||
return pagingFenceAddress;
|
||||
}
|
||||
@@ -209,6 +211,7 @@ class Wddm : public DriverModel {
|
||||
bool instrumentationEnabled = false;
|
||||
std::string deviceRegistryPath;
|
||||
RootDeviceEnvironment &rootDeviceEnvironment;
|
||||
unsigned int enablePreemptionRegValue = 1;
|
||||
|
||||
unsigned long hwContextId = 0;
|
||||
uintptr_t maximumApplicationAddress = 0;
|
||||
|
||||
@@ -105,7 +105,7 @@ bool WddmInterface23::createHwQueue(OsContextWin &osContext) {
|
||||
|
||||
createHwQueue.hHwContext = osContext.getWddmContextHandle();
|
||||
if (osContext.getPreemptionMode() >= PreemptionMode::MidBatch) {
|
||||
createHwQueue.Flags.DisableGpuTimeout = wddm.readEnablePreemptionRegKey();
|
||||
createHwQueue.Flags.DisableGpuTimeout = wddm.getEnablePreemptionRegValue();
|
||||
}
|
||||
|
||||
auto status = wddm.getGdi()->createHwQueue(&createHwQueue);
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
|
||||
#include <d3dkmthk.h>
|
||||
#include "shared/source/os_interface/windows/d3dkmthk_wrapper.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
@@ -36,9 +36,7 @@ class WddmPreemptionTests : public Test<WddmFixtureWithMockGdiDll> {
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
||||
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
||||
osInterface = executionEnvironment->rootDeviceEnvironments[0]->osInterface.get();
|
||||
auto regReader = new RegistryReaderMock();
|
||||
wddm->registryReader.reset(regReader);
|
||||
regReader->forceRetValue = forceReturnPreemptionRegKeyValue;
|
||||
wddm->enablePreemptionRegValue = forceReturnPreemptionRegKeyValue;
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfoTest);
|
||||
wddm->init();
|
||||
hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
|
||||
Reference in New Issue
Block a user