fix: Flush monitor fence only to context where needed

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2024-12-09 14:05:54 +00:00
committed by Compute-Runtime-Automation
parent 51c0e80299
commit c2093990d4
2 changed files with 10 additions and 3 deletions

View File

@@ -1183,9 +1183,12 @@ bool Wddm::waitFromCpu(uint64_t lastFenceValue, const MonitoredFence &monitoredF
if (!skipResourceCleanup() && lastFenceValue > *monitoredFence.cpuAddress) {
if (lastFenceValue > monitoredFence.lastSubmittedFence) {
this->forEachContextWithinWddm([](const EngineControl &engine) {
auto lock = engine.commandStreamReceiver->obtainUniqueOwnership();
engine.commandStreamReceiver->flushMonitorFence();
this->forEachContextWithinWddm([&monitoredFence](const EngineControl &engine) {
auto &contextMonitoredFence = static_cast<OsContextWin *>(engine.osContext)->getResidencyController().getMonitoredFence();
if (contextMonitoredFence.cpuAddress == monitoredFence.cpuAddress) {
auto lock = engine.commandStreamReceiver->obtainUniqueOwnership();
engine.commandStreamReceiver->flushMonitorFence();
}
});
}

View File

@@ -1215,9 +1215,13 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenLastSubmittedFenceLowerTha
wddm->callBaseWaitFromCpu = true;
EXPECT_EQ(directSubmission->flushMonitorFenceCalled, 0u);
D3DKMT_HANDLE handle = 1;
uint64_t value = 0u;
NEO::MonitoredFence monitorFence = {};
monitorFence.cpuAddress = &value;
auto gpuVa = castToUint64(&value);
static_cast<OsContextWin *>(device->getDefaultEngine().osContext)->getResidencyController().resetMonitoredFenceParams(handle, &value, gpuVa);
wddm->waitFromCpu(1, monitorFence, false);
EXPECT_EQ(directSubmission->flushMonitorFenceCalled, 1u);