From f374696f1dc03c997fe44f94903a5fbe11b6244c Mon Sep 17 00:00:00 2001 From: Maciej Dziuban Date: Mon, 22 Oct 2018 15:59:26 +0200 Subject: [PATCH] Move MonitoredFence to WddmResidencyController Change-Id: Iac99e7d730fda26d13feed56d5e4c50adf115e51 Signed-off-by: Maciej Dziuban --- .../os_interface/windows/os_context_win.cpp | 8 --- runtime/os_interface/windows/os_context_win.h | 5 -- runtime/os_interface/windows/wddm/wddm.cpp | 17 +++--- .../windows/wddm/wddm_interface.cpp | 10 ++-- .../windows/wddm_device_command_stream.inl | 2 +- .../windows/wddm_memory_manager.cpp | 8 +-- .../windows/wddm_residency_controller.cpp | 8 +++ .../windows/wddm_residency_controller.h | 6 ++ .../windows/device_command_stream_tests.cpp | 2 +- .../os_interface/windows/wddm20_tests.cpp | 10 ++-- .../os_interface/windows/wddm23_tests.cpp | 24 ++++---- .../windows/wddm_memory_manager_tests.cpp | 56 +++++++++---------- 12 files changed, 79 insertions(+), 77 deletions(-) diff --git a/runtime/os_interface/windows/os_context_win.cpp b/runtime/os_interface/windows/os_context_win.cpp index 4e1eb74f66..df835991d2 100644 --- a/runtime/os_interface/windows/os_context_win.cpp +++ b/runtime/os_interface/windows/os_context_win.cpp @@ -30,14 +30,6 @@ OsContextWin::~OsContextImpl() { wddm.destroyContext(context); } -void OsContextWin::resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress) { - monitoredFence.lastSubmittedFence = 0; - monitoredFence.currentFenceValue = 1; - monitoredFence.fenceHandle = handle; - monitoredFence.cpuAddress = cpuAddress; - monitoredFence.gpuAddress = gpuAddress; -} - OsContext::OsContext(OSInterface *osInterface, uint32_t contextId) : contextId(contextId) { if (osInterface) { osContextImpl = std::make_unique(*osInterface->get()->getWddm(), contextId); diff --git a/runtime/os_interface/windows/os_context_win.h b/runtime/os_interface/windows/os_context_win.h index a6276f75d9..882188bdc0 100644 --- a/runtime/os_interface/windows/os_context_win.h +++ b/runtime/os_interface/windows/os_context_win.h @@ -8,8 +8,6 @@ #pragma once #include "runtime/os_interface/os_context.h" #include "runtime/os_interface/windows/wddm_residency_controller.h" -#include "runtime/os_interface/windows/windows_wrapper.h" -#include "runtime/os_interface/windows/windows_defs.h" #include namespace OCLRT { @@ -33,8 +31,6 @@ class OsContext::OsContextImpl { bool isInitialized() const { return initialized; } - MonitoredFence &getMonitoredFence() { return monitoredFence; } - void resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress); Wddm *getWddm() const { return &wddm; } WddmResidencyController &getResidencyController() { return residencyController; } @@ -43,7 +39,6 @@ class OsContext::OsContextImpl { D3DKMT_HANDLE context = 0; D3DKMT_HANDLE hwQueueHandle = 0; Wddm &wddm; - MonitoredFence monitoredFence = {}; WddmResidencyController residencyController; }; } // namespace OCLRT diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index 27c7757b4e..93c0b55444 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -711,12 +711,12 @@ bool Wddm::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsCo if (currentPagingFenceValue > *pagingFenceAddress && !waitOnGPU(osContext.getContext())) { return false; } - DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", osContext.getMonitoredFence().currentFenceValue); + DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", osContext.getResidencyController().getMonitoredFence().currentFenceValue); status = wddmInterface->submit(commandBuffer, size, commandHeader, osContext); if (status) { - osContext.getMonitoredFence().lastSubmittedFence = osContext.getMonitoredFence().currentFenceValue; - osContext.getMonitoredFence().currentFenceValue++; + osContext.getResidencyController().getMonitoredFence().lastSubmittedFence = osContext.getResidencyController().getMonitoredFence().currentFenceValue; + osContext.getResidencyController().getMonitoredFence().currentFenceValue++; } getDeviceState(); UNRECOVERABLE_IF(!status); @@ -742,9 +742,10 @@ void Wddm::getDeviceState() { } void Wddm::handleCompletion(OsContextWin &osContext) { - if (osContext.getMonitoredFence().cpuAddress) { - auto *currentTag = osContext.getMonitoredFence().cpuAddress; - while (*currentTag < osContext.getMonitoredFence().currentFenceValue - 1) + auto &monitoredFence = osContext.getResidencyController().getMonitoredFence(); + if (monitoredFence.cpuAddress) { + auto *currentTag = monitoredFence.cpuAddress; + while (*currentTag < monitoredFence.currentFenceValue - 1) ; } } @@ -770,10 +771,10 @@ bool Wddm::waitOnGPU(D3DKMT_HANDLE context) { bool Wddm::waitFromCpu(uint64_t lastFenceValue, OsContextWin &osContext) { NTSTATUS status = STATUS_SUCCESS; - if (lastFenceValue > *osContext.getMonitoredFence().cpuAddress) { + if (lastFenceValue > *osContext.getResidencyController().getMonitoredFence().cpuAddress) { D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU waitFromCpu = {0}; waitFromCpu.ObjectCount = 1; - waitFromCpu.ObjectHandleArray = &osContext.getMonitoredFence().fenceHandle; + waitFromCpu.ObjectHandleArray = &osContext.getResidencyController().getMonitoredFence().fenceHandle; waitFromCpu.FenceValueArray = &lastFenceValue; waitFromCpu.hDevice = device; waitFromCpu.hAsyncEvent = NULL; diff --git a/runtime/os_interface/windows/wddm/wddm_interface.cpp b/runtime/os_interface/windows/wddm/wddm_interface.cpp index b323d3db02..a6d6b329e2 100644 --- a/runtime/os_interface/windows/wddm/wddm_interface.cpp +++ b/runtime/os_interface/windows/wddm/wddm_interface.cpp @@ -29,9 +29,9 @@ bool WddmInterface::createMonitoredFence(OsContextWin &osContext) { DEBUG_BREAK_IF(STATUS_SUCCESS != Status); - osContext.resetMonitoredFenceParams(CreateSynchronizationObject.hSyncObject, - reinterpret_cast(CreateSynchronizationObject.Info.MonitoredFence.FenceValueCPUVirtualAddress), - CreateSynchronizationObject.Info.MonitoredFence.FenceValueGPUVirtualAddress); + osContext.getResidencyController().resetMonitoredFenceParams(CreateSynchronizationObject.hSyncObject, + reinterpret_cast(CreateSynchronizationObject.Info.MonitoredFence.FenceValueCPUVirtualAddress), + CreateSynchronizationObject.Info.MonitoredFence.FenceValueGPUVirtualAddress); return Status == STATUS_SUCCESS; } @@ -44,7 +44,7 @@ bool WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *commandH D3DKMT_SUBMITCOMMAND SubmitCommand = {0}; NTSTATUS status = STATUS_SUCCESS; - auto monitoredFence = osContext.getMonitoredFence(); + auto monitoredFence = osContext.getResidencyController().getMonitoredFence(); SubmitCommand.Commands = commandBuffer; SubmitCommand.CommandLength = static_cast(size); SubmitCommand.BroadcastContextCount = 1; @@ -99,7 +99,7 @@ const bool WddmInterface23::hwQueuesSupported() { } bool WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) { - auto monitoredFence = osContext.getMonitoredFence(); + auto monitoredFence = osContext.getResidencyController().getMonitoredFence(); D3DKMT_SUBMITCOMMANDTOHWQUEUE submitCommand = {}; submitCommand.hHwQueue = osContext.getHwQueue(); diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index ce9a1a01e2..24de8aebf2 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -116,7 +116,7 @@ FlushStamp WddmCommandStreamReceiver::flush(BatchBuffer &batchBuffer, wddm->submit(commandStreamAddress, batchBuffer.usedSize - batchBuffer.startOffset, commandBufferHeader, *osContext.get()); - return osContext.get()->getMonitoredFence().lastSubmittedFence; + return osContext.get()->getResidencyController().getMonitoredFence().lastSubmittedFence; } template diff --git a/runtime/os_interface/windows/wddm_memory_manager.cpp b/runtime/os_interface/windows/wddm_memory_manager.cpp index d95cf01be5..b05be0267d 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -483,7 +483,7 @@ bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer &all osContext.get()->getResidencyController().acquireLock(); - DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", osContext.get()->getMonitoredFence().currentFenceValue); + DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", osContext.get()->getResidencyController().getMonitoredFence().currentFenceValue); for (uint32_t i = 0; i < residencyCount; i++) { WddmAllocation *allocation = reinterpret_cast(allocationsForResidency[i]); @@ -538,7 +538,7 @@ bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer &all for (uint32_t i = 0; i < residencyCount; i++) { WddmAllocation *allocation = reinterpret_cast(allocationsForResidency[i]); // Update fence value not to early destroy / evict allocation - auto currentFence = osContext.get()->getMonitoredFence().currentFenceValue; + auto currentFence = osContext.get()->getResidencyController().getMonitoredFence().currentFenceValue; allocation->getResidencyData().updateCompletionData(currentFence, osContext.getContextId()); allocation->getResidencyData().resident = true; @@ -636,7 +636,7 @@ void WddmMemoryManager::trimResidency(D3DDDI_TRIMRESIDENCYSET_FLAGS flags, uint6 } if (flags.PeriodicTrim || flags.RestartPeriodicTrim) { - const auto newPeriodicTrimFenceValue = *osContext.get()->getMonitoredFence().cpuAddress; + const auto newPeriodicTrimFenceValue = *osContext.get()->getResidencyController().getMonitoredFence().cpuAddress; osContext.get()->getResidencyController().setLastTrimFenceValue(newPeriodicTrimFenceValue); DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "updated lastPeriodicTrimFenceValue =", newPeriodicTrimFenceValue); } @@ -660,7 +660,7 @@ bool WddmMemoryManager::trimResidencyToBudget(uint64_t bytes) { } lastFence = wddmAllocation->getResidencyData().getFenceValueForContextId(0); - auto &monitoredFence = osContext.get()->getMonitoredFence(); + auto &monitoredFence = osContext.get()->getResidencyController().getMonitoredFence(); if (lastFence <= monitoredFence.lastSubmittedFence) { uint32_t fragmentsToEvict = 0; diff --git a/runtime/os_interface/windows/wddm_residency_controller.cpp b/runtime/os_interface/windows/wddm_residency_controller.cpp index 0427057988..3f3d87c196 100644 --- a/runtime/os_interface/windows/wddm_residency_controller.cpp +++ b/runtime/os_interface/windows/wddm_residency_controller.cpp @@ -163,4 +163,12 @@ void WddmResidencyController::compactTrimCandidateList() { checkTrimCandidateCount(); } +void WddmResidencyController::resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress) { + monitoredFence.lastSubmittedFence = 0; + monitoredFence.currentFenceValue = 1; + monitoredFence.fenceHandle = handle; + monitoredFence.cpuAddress = cpuAddress; + monitoredFence.gpuAddress = gpuAddress; +} + } // namespace OCLRT diff --git a/runtime/os_interface/windows/wddm_residency_controller.h b/runtime/os_interface/windows/wddm_residency_controller.h index 39a5a13aa4..aee60c2a6b 100644 --- a/runtime/os_interface/windows/wddm_residency_controller.h +++ b/runtime/os_interface/windows/wddm_residency_controller.h @@ -8,6 +8,8 @@ #pragma once #include "runtime/memory_manager/residency_container.h" +#include "runtime/os_interface/windows/windows_wrapper.h" +#include "runtime/os_interface/windows/windows_defs.h" #include @@ -40,6 +42,9 @@ class WddmResidencyController { const ResidencyContainer &peekTrimCandidateList() const { return trimCandidateList; } uint32_t peekTrimCandidatesCount() const { return trimCandidatesCount; } + MonitoredFence &getMonitoredFence() { return monitoredFence; } + void resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress); + protected: uint32_t osContextId; std::atomic lock = false; @@ -47,5 +52,6 @@ class WddmResidencyController { uint64_t lastTrimFenceValue = 0u; ResidencyContainer trimCandidateList; uint32_t trimCandidatesCount = 0; + MonitoredFence monitoredFence = {}; }; } // namespace OCLRT diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index be65f0a11d..747e3512bd 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -194,7 +194,7 @@ TEST_F(WddmCommandStreamTest, Flush) { EXPECT_EQ(1u, wddm->submitResult.called); EXPECT_TRUE(wddm->submitResult.success); - EXPECT_EQ(flushStamp, device->getOsContext()->get()->getMonitoredFence().lastSubmittedFence); + EXPECT_EQ(flushStamp, device->getOsContext()->get()->getResidencyController().getMonitoredFence().lastSubmittedFence); memoryManager->freeGraphicsMemory(commandBuffer); } diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index 49a17a51b8..b05e88f25c 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -383,7 +383,7 @@ TEST_F(Wddm20Tests, makeResidentNonResident) { error = wddm->evict(&allocation.handle, 1, sizeToTrim); EXPECT_TRUE(error); - auto monitoredFence = osContextWin->getMonitoredFence(); + auto monitoredFence = osContextWin->getResidencyController().getMonitoredFence(); UINT64 fenceValue = 100; monitoredFence.cpuAddress = &fenceValue; monitoredFence.currentFenceValue = 101; @@ -634,7 +634,7 @@ TEST_F(Wddm20Tests, givenDestroyAllocationWhenItIsCalledThenAllocationIsPassedTo allocation.getResidencyData().updateCompletionData(10, osContext.get()->getContextId()); allocation.handle = ALLOCATION_HANDLE; - *osContextWin->getMonitoredFence().cpuAddress = 10; + *osContextWin->getResidencyController().getMonitoredFence().cpuAddress = 10; D3DKMT_HANDLE handle = (D3DKMT_HANDLE)0x1234; @@ -662,7 +662,7 @@ TEST_F(Wddm20Tests, WhenLastFenceLessEqualThanMonitoredThenWaitFromCpuIsNotCalle allocation.getResidencyData().updateCompletionData(10, osContext.get()->getContextId()); allocation.handle = ALLOCATION_HANDLE; - *osContextWin->getMonitoredFence().cpuAddress = 10; + *osContextWin->getResidencyController().getMonitoredFence().cpuAddress = 10; gdi->getWaitFromCpuArg().FenceValueArray = nullptr; gdi->getWaitFromCpuArg().Flags.Value = 0; @@ -685,7 +685,7 @@ TEST_F(Wddm20Tests, WhenLastFenceGreaterThanMonitoredThenWaitFromCpuIsCalled) { allocation.getResidencyData().updateCompletionData(10, osContext.get()->getContextId()); allocation.handle = ALLOCATION_HANDLE; - *osContextWin->getMonitoredFence().cpuAddress = 10; + *osContextWin->getResidencyController().getMonitoredFence().cpuAddress = 10; gdi->getWaitFromCpuArg().FenceValueArray = nullptr; gdi->getWaitFromCpuArg().Flags.Value = 0; @@ -711,7 +711,7 @@ TEST_F(Wddm20Tests, createMonitoredFenceIsInitializedWithFenceValueZeroAndCurren wddm->wddmInterface->createMonitoredFence(*osContextWin); EXPECT_EQ(0u, gdi->getCreateSynchronizationObject2Arg().Info.MonitoredFence.InitialFenceValue); - EXPECT_EQ(1u, osContextWin->getMonitoredFence().currentFenceValue); + EXPECT_EQ(1u, osContextWin->getResidencyController().getMonitoredFence().currentFenceValue); } NTSTATUS APIENTRY queryResourceInfoMock(D3DKMT_QUERYRESOURCEINFO *pData) { diff --git a/unit_tests/os_interface/windows/wddm23_tests.cpp b/unit_tests/os_interface/windows/wddm23_tests.cpp index 8f511edef9..cbd1a4d9e1 100644 --- a/unit_tests/os_interface/windows/wddm23_tests.cpp +++ b/unit_tests/os_interface/windows/wddm23_tests.cpp @@ -99,32 +99,32 @@ TEST_F(Wddm23Tests, givenCmdBufferWhenSubmitCalledThenSetAllRequiredFiledsAndUpd auto hwQueue = osContextWin->getHwQueue(); COMMAND_BUFFER_HEADER cmdBufferHeader = {}; - EXPECT_EQ(1u, osContextWin->getMonitoredFence().currentFenceValue); - EXPECT_EQ(0u, osContextWin->getMonitoredFence().lastSubmittedFence); + EXPECT_EQ(1u, osContextWin->getResidencyController().getMonitoredFence().currentFenceValue); + EXPECT_EQ(0u, osContextWin->getResidencyController().getMonitoredFence().lastSubmittedFence); wddm->submit(cmdBufferAddress, cmdSize, &cmdBufferHeader, *osContextWin); EXPECT_EQ(cmdBufferAddress, getSubmitCommandToHwQueueDataFcn()->CommandBuffer); EXPECT_EQ(static_cast(cmdSize), getSubmitCommandToHwQueueDataFcn()->CommandLength); EXPECT_EQ(hwQueue, getSubmitCommandToHwQueueDataFcn()->hHwQueue); - EXPECT_EQ(osContextWin->getMonitoredFence().fenceHandle, getSubmitCommandToHwQueueDataFcn()->HwQueueProgressFenceId); + EXPECT_EQ(osContextWin->getResidencyController().getMonitoredFence().fenceHandle, getSubmitCommandToHwQueueDataFcn()->HwQueueProgressFenceId); EXPECT_EQ(&cmdBufferHeader, getSubmitCommandToHwQueueDataFcn()->pPrivateDriverData); EXPECT_EQ(static_cast(MemoryConstants::pageSize), getSubmitCommandToHwQueueDataFcn()->PrivateDriverDataSize); - EXPECT_EQ(osContextWin->getMonitoredFence().gpuAddress, cmdBufferHeader.MonitorFenceVA); - EXPECT_EQ(osContextWin->getMonitoredFence().lastSubmittedFence, cmdBufferHeader.MonitorFenceValue); - EXPECT_EQ(2u, osContextWin->getMonitoredFence().currentFenceValue); - EXPECT_EQ(1u, osContextWin->getMonitoredFence().lastSubmittedFence); + EXPECT_EQ(osContextWin->getResidencyController().getMonitoredFence().gpuAddress, cmdBufferHeader.MonitorFenceVA); + EXPECT_EQ(osContextWin->getResidencyController().getMonitoredFence().lastSubmittedFence, cmdBufferHeader.MonitorFenceValue); + EXPECT_EQ(2u, osContextWin->getResidencyController().getMonitoredFence().currentFenceValue); + EXPECT_EQ(1u, osContextWin->getResidencyController().getMonitoredFence().lastSubmittedFence); } TEST_F(Wddm23Tests, whenMonitoredFenceIsCreatedThenSetupAllRequiredFields) { wddm->wddmInterface->createMonitoredFence(*osContextWin); - EXPECT_NE(nullptr, osContextWin->getMonitoredFence().cpuAddress); - EXPECT_EQ(1u, osContextWin->getMonitoredFence().currentFenceValue); - EXPECT_NE(static_cast(0), osContextWin->getMonitoredFence().fenceHandle); - EXPECT_NE(static_cast(0), osContextWin->getMonitoredFence().gpuAddress); - EXPECT_EQ(0u, osContextWin->getMonitoredFence().lastSubmittedFence); + EXPECT_NE(nullptr, osContextWin->getResidencyController().getMonitoredFence().cpuAddress); + EXPECT_EQ(1u, osContextWin->getResidencyController().getMonitoredFence().currentFenceValue); + EXPECT_NE(static_cast(0), osContextWin->getResidencyController().getMonitoredFence().fenceHandle); + EXPECT_NE(static_cast(0), osContextWin->getResidencyController().getMonitoredFence().gpuAddress); + EXPECT_EQ(0u, osContextWin->getResidencyController().getMonitoredFence().lastSubmittedFence); } TEST_F(Wddm23Tests, givenCurrentPendingFenceValueGreaterThanPendingFenceValueWhenSubmitCalledThenCallWaitOnGpu) { diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index 30f4db5e8e..f340e3a1bd 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -894,7 +894,7 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsUpdatesLa MockWddmAllocation allocation1, allocation2, allocation3, allocation4; ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4}; - osContext->get()->getMonitoredFence().currentFenceValue = 20; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 20; memoryManager->makeResidentResidencyAllocations(residencyPack, *osContext); @@ -927,7 +927,7 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsSetsLastF WddmAllocation *allocationTriple = (WddmAllocation *)memoryManager->allocateGraphicsMemory(8196, reinterpret_cast(0x1500)); - osContext->get()->getMonitoredFence().currentFenceValue = 20; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 20; ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2}; memoryManager->makeResidentResidencyAllocations(residencyPack, *osContext); @@ -981,7 +981,7 @@ TEST_F(WddmMemoryManagerResidencyTest, givenNotUsedAllocationsFromPreviousPeriod osContext->get()->getResidencyController().setLastTrimFenceValue(10); osContext->get()->getResidencyController().setLastTrimFenceValue(10); // Set current fence value to greater value - osContext->get()->getMonitoredFence().currentFenceValue = 20; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 20; wddm->makeNonResidentResult.called = 0; @@ -1015,7 +1015,7 @@ TEST_F(WddmMemoryManagerResidencyTest, givenOneUsedAllocationFromPreviousPeriodi // Set last periodic fence value osContext->get()->getResidencyController().setLastTrimFenceValue(10); // Set current fence value to greater value - osContext->get()->getMonitoredFence().currentFenceValue = 20; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 20; wddm->makeNonResidentResult.called = 0; @@ -1059,7 +1059,7 @@ TEST_F(WddmMemoryManagerResidencyTest, givenTripleAllocationWithUsedAndUnusedFra // Set last periodic fence value osContext->get()->getResidencyController().setLastTrimFenceValue(10); // Set current fence value to greater value - osContext->get()->getMonitoredFence().currentFenceValue = 20; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 20; wddm->makeNonResidentResult.called = 0; @@ -1086,7 +1086,7 @@ TEST_F(WddmMemoryManagerResidencyTest, givenPeriodicTrimWhenTrimCallbackCalledTh // Set last periodic fence value osContext->get()->getResidencyController().setLastTrimFenceValue(10); // Set current fence value to greater value - *osContext->get()->getMonitoredFence().cpuAddress = 20; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 20; memoryManager->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim); @@ -1103,7 +1103,7 @@ TEST_F(WddmMemoryManagerResidencyTest, givenRestartPeriodicTrimWhenTrimCallbackC // Set last periodic fence value osContext->get()->getResidencyController().setLastTrimFenceValue(10); // Set current fence value to greater value - *osContext->get()->getMonitoredFence().cpuAddress = 20; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 20; memoryManager->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim); @@ -1130,9 +1130,9 @@ TEST_F(WddmMemoryManagerResidencyTest, trimToBudgetAllDoneAllocations) { allocation3.getResidencyData().updateCompletionData(2, osContext->getContextId()); allocation3.getResidencyData().resident = true; - *osContext->get()->getMonitoredFence().cpuAddress = 1; - osContext->get()->getMonitoredFence().lastSubmittedFence = 1; - osContext->get()->getMonitoredFence().currentFenceValue = 1; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 1; + osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence = 1; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 1; wddm->makeNonResidentResult.called = 0; @@ -1161,8 +1161,8 @@ TEST_F(WddmMemoryManagerResidencyTest, trimToBudgetReturnsFalseWhenNumBytesToTri allocation1.getResidencyData().resident = true; allocation1.getResidencyData().updateCompletionData(0, osContext->getContextId()); - *osContext->get()->getMonitoredFence().cpuAddress = 1; - osContext->get()->getMonitoredFence().lastSubmittedFence = 1; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 1; + osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence = 1; wddm->makeNonResidentResult.called = 0; @@ -1190,9 +1190,9 @@ TEST_F(WddmMemoryManagerResidencyTest, trimToBudgetStopsEvictingWhenNumBytesToTr allocation3.getResidencyData().updateCompletionData(2, osContext->getContextId()); allocation3.getResidencyData().resident = true; - *osContext->get()->getMonitoredFence().cpuAddress = 1; - osContext->get()->getMonitoredFence().lastSubmittedFence = 1; - osContext->get()->getMonitoredFence().currentFenceValue = 1; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 1; + osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence = 1; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 1; wddm->makeNonResidentResult.called = 0; @@ -1225,9 +1225,9 @@ TEST_F(WddmMemoryManagerResidencyTest, trimToBudgetMarksEvictedAllocationNonResi allocation3.getResidencyData().updateCompletionData(2, osContext->getContextId()); allocation3.getResidencyData().resident = true; - *osContext->get()->getMonitoredFence().cpuAddress = 1; - osContext->get()->getMonitoredFence().lastSubmittedFence = 1; - osContext->get()->getMonitoredFence().currentFenceValue = 1; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 1; + osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence = 1; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 1; wddm->makeNonResidentResult.called = 0; @@ -1250,9 +1250,9 @@ TEST_F(WddmMemoryManagerResidencyTest, trimToBudgetWaitsFromCpuWhenLastFenceIsGr allocation1.getResidencyData().resident = true; allocation1.getResidencyData().updateCompletionData(2, osContext->getContextId()); - *osContext->get()->getMonitoredFence().cpuAddress = 1; - osContext->get()->getMonitoredFence().lastSubmittedFence = 2; - osContext->get()->getMonitoredFence().currentFenceValue = 3; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 1; + osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence = 2; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 3; wddm->makeNonResidentResult.called = 0; wddm->waitFromCpuResult.called = 0; @@ -1301,9 +1301,9 @@ TEST_F(WddmMemoryManagerResidencyTest, trimToBudgetEvictsDoneFragmentsOnly) { osContext->get()->getResidencyController().addToTrimCandidateList(allocationTriple); osContext->get()->getResidencyController().addToTrimCandidateList(&allocation2); - *osContext->get()->getMonitoredFence().cpuAddress = 1; - osContext->get()->getMonitoredFence().lastSubmittedFence = 1; - osContext->get()->getMonitoredFence().currentFenceValue = 2; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 1; + osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence = 1; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 2; wddm->makeNonResidentResult.called = 0; @@ -1344,9 +1344,9 @@ TEST_F(WddmMemoryManagerResidencyTest, givenThreeAllocationsAlignedSizeBiggerTha allocation3.getResidencyData().updateCompletionData(1, osContext->getContextId()); allocation3.getResidencyData().resident = true; - *osContext->get()->getMonitoredFence().cpuAddress = 1; - osContext->get()->getMonitoredFence().lastSubmittedFence = 1; - osContext->get()->getMonitoredFence().currentFenceValue = 1; + *osContext->get()->getResidencyController().getMonitoredFence().cpuAddress = 1; + osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence = 1; + osContext->get()->getResidencyController().getMonitoredFence().currentFenceValue = 1; wddm->makeNonResidentResult.called = 0; @@ -1624,7 +1624,7 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsSucceedsWhenMakeR size_t allocationSize = 0x1000; WddmAllocation allocationToTrim(cpuPtr, allocationSize, cpuPtr, allocationSize, nullptr, MemoryPool::MemoryNull, memoryManager->getOsContextCount()); - allocationToTrim.getResidencyData().updateCompletionData(osContext->get()->getMonitoredFence().lastSubmittedFence, osContext->getContextId()); + allocationToTrim.getResidencyData().updateCompletionData(osContext->get()->getResidencyController().getMonitoredFence().lastSubmittedFence, osContext->getContextId()); auto makeResidentWithOutBytesToTrim = [allocationSize](D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { *numberOfBytesToTrim = allocationSize; return false; };