From f17b46bc22fa25fab24f0f50f4e3fbaa23e8ed03 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Wed, 27 Jul 2022 01:00:20 +0000 Subject: [PATCH] Reposition members of wddm classes Signed-off-by: Zbigniew Zdanowicz --- .../windows/debug_registry_reader.h | 8 ++- .../os_interface/windows/gdi_interface.h | 2 +- .../os_interface/windows/hw_device_id.h | 6 +- .../os_interface/windows/hw_device_id_win.cpp | 6 +- .../os_interface/windows/os_context_win.cpp | 5 +- .../os_interface/windows/os_context_win.h | 4 +- .../source/os_interface/windows/wddm/wddm.h | 67 ++++++++++--------- .../windows/wddm_residency_controller.h | 15 +++-- 8 files changed, 64 insertions(+), 49 deletions(-) diff --git a/shared/source/os_interface/windows/debug_registry_reader.h b/shared/source/os_interface/windows/debug_registry_reader.h index 35592ed4b8..f28c334f4f 100644 --- a/shared/source/os_interface/windows/debug_registry_reader.h +++ b/shared/source/os_interface/windows/debug_registry_reader.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -26,9 +26,11 @@ class RegistryReader : public SettingsReader { const char *appSpecificLocation(const std::string &name) override; protected: - HKEY hkeyType; - std::string registryReadRootKey; void setUpProcessName(); + + std::string registryReadRootKey; std::string processName; + + HKEY hkeyType; }; } // namespace NEO diff --git a/shared/source/os_interface/windows/gdi_interface.h b/shared/source/os_interface/windows/gdi_interface.h index 103a773b02..3e2668accf 100644 --- a/shared/source/os_interface/windows/gdi_interface.h +++ b/shared/source/os_interface/windows/gdi_interface.h @@ -80,7 +80,7 @@ class Gdi { protected: MOCKABLE_VIRTUAL bool getAllProcAddresses(); - bool initialized = false; std::unique_ptr gdiDll; + bool initialized = false; }; } // namespace NEO diff --git a/shared/source/os_interface/windows/hw_device_id.h b/shared/source/os_interface/windows/hw_device_id.h index e18b712d52..6d7534f759 100644 --- a/shared/source/os_interface/windows/hw_device_id.h +++ b/shared/source/os_interface/windows/hw_device_id.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -36,9 +36,9 @@ class HwDeviceIdWddm : public HwDeviceId { } protected: - const D3DKMT_HANDLE adapter; const LUID adapterLuid; - OsEnvironment *osEnvironment; std::unique_ptr umKmDataTranslator; + OsEnvironment *osEnvironment; + const D3DKMT_HANDLE adapter; }; } // namespace NEO diff --git a/shared/source/os_interface/windows/hw_device_id_win.cpp b/shared/source/os_interface/windows/hw_device_id_win.cpp index dbeccff4d4..be442de653 100644 --- a/shared/source/os_interface/windows/hw_device_id_win.cpp +++ b/shared/source/os_interface/windows/hw_device_id_win.cpp @@ -21,8 +21,10 @@ HwDeviceIdWddm::~HwDeviceIdWddm() { HwDeviceIdWddm::HwDeviceIdWddm(D3DKMT_HANDLE adapterIn, LUID adapterLuidIn, OsEnvironment *osEnvironmentIn, std::unique_ptr umKmDataTranslator) : HwDeviceId(DriverModelType::WDDM), - adapter(adapterIn), adapterLuid(adapterLuidIn), osEnvironment(osEnvironmentIn), - umKmDataTranslator(std::move(umKmDataTranslator)) {} + adapterLuid(adapterLuidIn), umKmDataTranslator(std::move(umKmDataTranslator)), + osEnvironment(osEnvironmentIn), adapter(adapterIn) { +} + Gdi *HwDeviceIdWddm::getGdi() const { return static_cast(osEnvironment)->gdi.get(); }; diff --git a/shared/source/os_interface/windows/os_context_win.cpp b/shared/source/os_interface/windows/os_context_win.cpp index 0454dcca86..26f83de2d3 100644 --- a/shared/source/os_interface/windows/os_context_win.cpp +++ b/shared/source/os_interface/windows/os_context_win.cpp @@ -24,8 +24,9 @@ OsContext *OsContextWin::create(OSInterface *osInterface, uint32_t contextId, co OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, const EngineDescriptor &engineDescriptor) : OsContext(contextId, engineDescriptor), - wddm(wddm), - residencyController(wddm, contextId) {} + residencyController(wddm, contextId), + wddm(wddm) { +} void OsContextWin::initializeContext() { diff --git a/shared/source/os_interface/windows/os_context_win.h b/shared/source/os_interface/windows/os_context_win.h index 4fac6f0a94..41d2331ca9 100644 --- a/shared/source/os_interface/windows/os_context_win.h +++ b/shared/source/os_interface/windows/os_context_win.h @@ -40,10 +40,10 @@ class OsContextWin : public OsContext { protected: void initializeContext() override; - D3DKMT_HANDLE wddmContextHandle = 0; + WddmResidencyController residencyController; HardwareQueue hardwareQueue; Wddm &wddm; - WddmResidencyController residencyController; + D3DKMT_HANDLE wddmContextHandle = 0; bool debuggableContext = false; }; } // namespace NEO diff --git a/shared/source/os_interface/windows/wddm/wddm.h b/shared/source/os_interface/windows/wddm/wddm.h index 53eb7307fe..4e7c11c088 100644 --- a/shared/source/os_interface/windows/wddm/wddm.h +++ b/shared/source/os_interface/windows/wddm/wddm.h @@ -208,35 +208,6 @@ class Wddm : public DriverModel { PhyicalDevicePciSpeedInfo getPciSpeedInfo() const override; protected: - std::unique_ptr hwDeviceId; - D3DKMT_HANDLE device = 0; - D3DKMT_HANDLE pagingQueue = 0; - D3DKMT_HANDLE pagingQueueSyncObject = 0; - - uint64_t *pagingFenceAddress = nullptr; - std::atomic currentPagingFenceValue{0}; - - // Adapter information - std::unique_ptr gfxPlatform; - std::unique_ptr gtSystemInfo; - std::unique_ptr featureTable; - std::unique_ptr workaroundTable; - GMM_GFX_PARTITIONING gfxPartition{}; - ADAPTER_BDF adapterBDF{}; - uint64_t systemSharedMemory = 0; - uint64_t dedicatedVideoMemory = 0; - uint32_t maxRenderFrequency = 0; - uint32_t timestampFrequency = 0u; - bool instrumentationEnabled = false; - std::string deviceRegistryPath; - RootDeviceEnvironment &rootDeviceEnvironment; - unsigned int enablePreemptionRegValue = 1; - - unsigned long hwContextId = 0; - uintptr_t maximumApplicationAddress = 0; - std::unique_ptr gmmMemory; - uintptr_t minAddress = 0; - Wddm(std::unique_ptr &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment); MOCKABLE_VIRTUAL bool waitOnGPU(D3DKMT_HANDLE context); bool createDevice(PreemptionMode preemptionMode); @@ -254,14 +225,50 @@ class Wddm : public DriverModel { } void setPlatformSupportEvictWhenNecessaryFlag(const HwInfoConfig &hwInfoConfig); - static GetSystemInfoFcn getSystemInfo; + GMM_GFX_PARTITIONING gfxPartition{}; + ADAPTER_BDF adapterBDF{}; + std::string deviceRegistryPath; + + std::atomic currentPagingFenceValue{0}; + + uint64_t systemSharedMemory = 0; + uint64_t dedicatedVideoMemory = 0; + + // Adapter information + std::unique_ptr gfxPlatform; + std::unique_ptr gtSystemInfo; + std::unique_ptr featureTable; + std::unique_ptr workaroundTable; + + std::unique_ptr hwDeviceId; + std::unique_ptr gmmMemory; std::unique_ptr kmDafListener; std::unique_ptr wddmInterface; std::unique_ptr temporaryResources; std::unique_ptr residencyLogger; std::unique_ptr osMemory; + static GetSystemInfoFcn getSystemInfo; + RootDeviceEnvironment &rootDeviceEnvironment; + + uint64_t *pagingFenceAddress = nullptr; + + uintptr_t maximumApplicationAddress = 0; + uintptr_t minAddress = 0; + + unsigned long hwContextId = 0; + + D3DKMT_HANDLE device = 0; + D3DKMT_HANDLE pagingQueue = 0; + D3DKMT_HANDLE pagingQueueSyncObject = 0; + + uint32_t maxRenderFrequency = 0; + uint32_t timestampFrequency = 0u; + + unsigned int enablePreemptionRegValue = 1; + bool platformSupportsEvictWhenNecessary = false; + bool instrumentationEnabled = false; }; } // namespace NEO diff --git a/shared/source/os_interface/windows/wddm_residency_controller.h b/shared/source/os_interface/windows/wddm_residency_controller.h index 4018a88497..17f5cc164d 100644 --- a/shared/source/os_interface/windows/wddm_residency_controller.h +++ b/shared/source/os_interface/windows/wddm_residency_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -66,18 +66,21 @@ class WddmResidencyController { bool isInitialized() const; protected: - Wddm &wddm; - uint32_t osContextId; MonitoredFence monitoredFence = {}; + ResidencyContainer trimCandidateList; + SpinLock lock; SpinLock trimCallbackLock; - bool memoryBudgetExhausted = false; uint64_t lastTrimFenceValue = 0u; - ResidencyContainer trimCandidateList; + + Wddm &wddm; + VOID *trimCallbackHandle = nullptr; + + uint32_t osContextId; uint32_t trimCandidatesCount = 0; - VOID *trimCallbackHandle = nullptr; + bool memoryBudgetExhausted = false; }; } // namespace NEO