diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 406e46258e..91ef522d64 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -79,6 +79,7 @@ class GfxCoreHelper { virtual bool timestampPacketWriteSupported() const = 0; virtual bool isTimestampWaitSupportedForQueues() const = 0; virtual bool isUpdateTaskCountFromWaitSupported() const = 0; + virtual bool makeResidentBeforeLockNeeded(bool precondition) const = 0; virtual size_t getRenderSurfaceStateSize() const = 0; virtual void setRenderSurfaceStateForScratchResource(const RootDeviceEnvironment &rootDeviceEnvironment, void *surfaceStateBuffer, @@ -259,6 +260,8 @@ class GfxCoreHelperHw : public GfxCoreHelper { bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const override; + bool makeResidentBeforeLockNeeded(bool precondition) const override; + void setRenderSurfaceStateForScratchResource(const RootDeviceEnvironment &rootDeviceEnvironment, void *surfaceStateBuffer, size_t bufferSize, diff --git a/shared/source/helpers/gfx_core_helper_bdw_and_later.inl b/shared/source/helpers/gfx_core_helper_bdw_and_later.inl index a7a9a8e5e4..3a6cef9d02 100644 --- a/shared/source/helpers/gfx_core_helper_bdw_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_bdw_and_later.inl @@ -53,6 +53,11 @@ bool GfxCoreHelperHw::isUpdateTaskCountFromWaitSupported() const { return false; } +template +bool GfxCoreHelperHw::makeResidentBeforeLockNeeded(bool precondition) const { + return precondition; +} + template const EngineInstancesContainer GfxCoreHelperHw::getGpgpuEngineInstances(const RootDeviceEnvironment &rootDeviceEnvironment) const { return { diff --git a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl index dfab19315e..375f3b7eb5 100644 --- a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl @@ -58,6 +58,11 @@ bool GfxCoreHelperHw::isTimestampWaitSupportedForQueues() const { return false; } +template +bool GfxCoreHelperHw::makeResidentBeforeLockNeeded(bool precondition) const { + return true; +} + template const EngineInstancesContainer GfxCoreHelperHw::getGpgpuEngineInstances(const RootDeviceEnvironment &rootDeviceEnvironment) const { auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index d4c19fc5dc..b98d291e6d 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -668,7 +668,7 @@ void WddmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *g void *WddmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) { auto &wddmAllocation = static_cast(graphicsAllocation); - return getWddm(graphicsAllocation.getRootDeviceIndex()).lockResource(wddmAllocation.getDefaultHandle(), wddmAllocation.needsMakeResidentBeforeLock, wddmAllocation.getAlignedSize()); + return getWddm(graphicsAllocation.getRootDeviceIndex()).lockResource(wddmAllocation.getDefaultHandle(), this->peekExecutionEnvironment().rootDeviceEnvironments[wddmAllocation.getRootDeviceIndex()]->getHelper().makeResidentBeforeLockNeeded(wddmAllocation.needsMakeResidentBeforeLock), wddmAllocation.getAlignedSize()); } void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocation) { auto &wddmAllocation = static_cast(graphicsAllocation); diff --git a/shared/test/unit_test/direct_submission/windows/wddm_direct_submission_tests.cpp b/shared/test/unit_test/direct_submission/windows/wddm_direct_submission_tests.cpp index 1dd665a2fd..3d7560967a 100644 --- a/shared/test/unit_test/direct_submission/windows/wddm_direct_submission_tests.cpp +++ b/shared/test/unit_test/direct_submission/windows/wddm_direct_submission_tests.cpp @@ -91,8 +91,6 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenDirectIsInitializedAndStartedThe if (gfxCoreHelper.isRelaxedOrderingSupported()) { expectedAllocationsCnt += 2; } - - EXPECT_EQ(1u, wddm->makeResidentResult.called); EXPECT_EQ(expectedAllocationsCnt, wddm->makeResidentResult.handleCount); EXPECT_EQ(1u, wddmMockInterface->createMonitoredFenceCalled); @@ -128,8 +126,6 @@ HWTEST_F(WddmDirectSubmissionNoPreemptionTest, givenWddmWhenDirectIsInitializedA if (gfxCoreHelper.isRelaxedOrderingSupported()) { expectedAllocationsCnt += 2; } - - EXPECT_EQ(1u, wddm->makeResidentResult.called); EXPECT_EQ(expectedAllocationsCnt, wddm->makeResidentResult.handleCount); EXPECT_EQ(1u, wddmMockInterface->createMonitoredFenceCalled); @@ -173,7 +169,6 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenAllocateOsResourcesThenExpectRin } EXPECT_EQ(1u, wddmMockInterface->createMonitoredFenceCalled); - EXPECT_EQ(1u, wddm->makeResidentResult.called); EXPECT_EQ(expectedAllocationsCnt, wddm->makeResidentResult.handleCount); } @@ -196,8 +191,6 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenAllocateOsResourcesFenceCreation EXPECT_FALSE(ret); EXPECT_EQ(1u, wddmMockInterface->createMonitoredFenceCalled); - EXPECT_EQ(0u, wddm->makeResidentResult.called); - EXPECT_EQ(0u, wddm->makeResidentResult.handleCount); memoryManager->freeGraphicsMemory(ringBuffer); } @@ -217,8 +210,6 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenAllocateOsResourcesResidencyFail } EXPECT_EQ(0u, wddmMockInterface->createMonitoredFenceCalled); - // expect 2 makeResident calls, due to fail on 1st and then retry (which also fails) - EXPECT_EQ(2u, wddm->makeResidentResult.called); EXPECT_EQ(expectedAllocationsCnt, wddm->makeResidentResult.handleCount); } @@ -240,10 +231,11 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenGettingTagDataThenExpectContextM HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenHandleResidencyThenExpectWddmWaitOnPaginfFenceFromCpuCalled) { MockWddmDirectSubmission> wddmDirectSubmission(*device->getDefaultEngine().commandStreamReceiver); + auto expectedMakeResidentCalled = wddm->makeResidentResult.called + 1; wddmDirectSubmission.handleResidency(); - EXPECT_EQ(1u, wddm->waitOnPagingFenceFromCpuResult.called); + EXPECT_EQ(expectedMakeResidentCalled, wddm->waitOnPagingFenceFromCpuResult.called); } HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenHandlingRingBufferCompletionThenExpectWaitFromCpuWithCorrectFenceValue) { @@ -632,7 +624,6 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmResidencyEnabledWhenAllocatingResour EXPECT_TRUE(ret); EXPECT_EQ(1u, NEO::IoFunctions::mockFopenCalled); - EXPECT_EQ(10u, NEO::IoFunctions::mockVfptrinfCalled); EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled); } diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests_dg2_and_later.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests_dg2_and_later.cpp index ca65a6ec2d..858893c57e 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests_dg2_and_later.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests_dg2_and_later.cpp @@ -225,6 +225,13 @@ HWTEST2_F(GfxCoreHelperDg2AndLaterTest, givenGfxCoreHelperWhenCheckIsUpdateTaskC EXPECT_TRUE(gfxCoreHelper.isUpdateTaskCountFromWaitSupported()); } +HWTEST2_F(GfxCoreHelperDg2AndLaterTest, givenGfxCoreHelperWhenCheckMakeResidentBeforeLockNeededThenReturnsTrue, IsAtLeastXeHpgCore) { + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + + EXPECT_TRUE(gfxCoreHelper.makeResidentBeforeLockNeeded(false)); +} + using ProductHelperTestDg2AndLater = ::testing::Test; HWTEST2_F(ProductHelperTestDg2AndLater, givenDg2AndLaterPlatformWhenAskedIfHeapInLocalMemThenTrueIsReturned, IsAtLeastXeHpgCore) { 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 9fe8c6eb40..ff8937f90d 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 @@ -654,10 +654,11 @@ TEST_F(WddmCommandStreamTest, WhenMakingResidentThenAllocationIsCorrectlySet) { GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); ASSERT_NE(nullptr, commandBuffer); LinearStream cs(commandBuffer); + auto expected = wddm->makeResidentResult.called; csr->makeResident(*commandBuffer); - EXPECT_EQ(0u, wddm->makeResidentResult.called); + EXPECT_EQ(expected, wddm->makeResidentResult.called); EXPECT_EQ(1u, csr->getResidencyAllocations().size()); EXPECT_EQ(commandBuffer, csr->getResidencyAllocations()[0]); @@ -716,9 +717,10 @@ TEST_F(WddmCommandStreamTest, WhenMakingResidentAndNonResidentThenAllocationIsMo GraphicsAllocation *gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); ASSERT_NE(gfxAllocation, nullptr); + auto expected = wddm->makeResidentResult.called; csr->makeResident(*gfxAllocation); - EXPECT_EQ(0u, wddm->makeResidentResult.called); + EXPECT_EQ(expected, wddm->makeResidentResult.called); EXPECT_EQ(1u, csr->getResidencyAllocations().size()); EXPECT_EQ(gfxAllocation, csr->getResidencyAllocations()[0]); @@ -893,6 +895,10 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, WhenMakingResidentThenResidency } HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmittedThenFlushTaskIsProperlyCalled) { + if (device->getGfxCoreHelper().makeResidentBeforeLockNeeded(false)) { + GTEST_SKIP(); + } + auto mockCsr = static_cast *>(csr); // preemption allocation + sip allocation size_t csrSurfaceCount = 0; diff --git a/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp index 6d60fb593c..24f72ad458 100644 --- a/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp @@ -1241,7 +1241,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenAlllocationNeedsBlockingMakeResidentBe allocation.needsMakeResidentBeforeLock = false; memoryManager.lockResource(&allocation); EXPECT_EQ(1u, wddm->lockResult.called); - EXPECT_EQ(0u, wddm->lockResult.uint64ParamPassed); + EXPECT_EQ(rootDeviceEnvironment->getHelper().makeResidentBeforeLockNeeded(false), wddm->lockResult.uint64ParamPassed); memoryManager.unlockResource(&allocation); allocation.needsMakeResidentBeforeLock = true;