diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 703ff3015a..9a935b7bf5 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -179,7 +179,7 @@ void CommandStreamReceiver::processEviction() { void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) { if (gfxAllocation.isResident(osContext->getContextId())) { - if (gfxAllocation.peekEvictable()) { + if (gfxAllocation.peekEvictable() && !gfxAllocation.isAlwaysResident(osContext->getContextId())) { this->getEvictionAllocations().push_back(&gfxAllocation); } else { gfxAllocation.setEvictable(true); diff --git a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp index 4e4a2419a1..564ae30eba 100644 --- a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp @@ -676,6 +676,13 @@ TEST_F(WddmCommandStreamTest, WhenMakingNonResidentThenAllocationIsPlacedInEvict EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + csr->getEvictionAllocations().clear(); + + commandBuffer->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, csr->getOsContext().getContextId()); + csr->makeNonResident(*commandBuffer); + + EXPECT_EQ(0u, csr->getEvictionAllocations().size()); + memoryManager->freeGraphicsMemory(commandBuffer); }