diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 4a89b7f6f4..6f5af5e65f 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -994,13 +994,15 @@ TaskCountType CommandQueue::peekBcsTaskCount(aub_stream::EngineType bcsEngineTyp } bool CommandQueue::isTextureCacheFlushNeeded(uint32_t commandType) const { + auto isDirectSubmissionEnabled = getGpgpuCommandStreamReceiver().isDirectSubmissionEnabled(); switch (commandType) { case CL_COMMAND_COPY_IMAGE: case CL_COMMAND_WRITE_IMAGE: case CL_COMMAND_FILL_IMAGE: + return isDirectSubmissionEnabled; case CL_COMMAND_READ_IMAGE: case CL_COMMAND_COPY_IMAGE_TO_BUFFER: - return getGpgpuCommandStreamReceiver().isDirectSubmissionEnabled(); + return isDirectSubmissionEnabled && getDevice().getGfxCoreHelper().isCacheFlushPriorImageReadRequired(); default: return false; } diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index 09cf6a99fb..c5bd446f0c 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -451,17 +451,24 @@ HWTEST_F(CommandQueueCommandStreamTest, WhenCheckIsTextureCacheFlushNeededThenRe std::set typesToFlush = {CL_COMMAND_COPY_IMAGE, CL_COMMAND_WRITE_IMAGE, CL_COMMAND_FILL_IMAGE, CL_COMMAND_READ_IMAGE, CL_COMMAND_COPY_IMAGE_TO_BUFFER}; - for (auto i = CL_COMMAND_NDRANGE_KERNEL; i < CL_COMMAND_SVM_MIGRATE_MEM; i++) { - if (typesToFlush.find(i) != typesToFlush.end()) { + for (auto operation = CL_COMMAND_NDRANGE_KERNEL; operation < CL_COMMAND_SVM_MIGRATE_MEM; operation++) { + if (typesToFlush.find(operation) != typesToFlush.end()) { commandStreamReceiver.directSubmissionAvailable = true; - EXPECT_TRUE(cmdQ.isTextureCacheFlushNeeded(i)); + + if (operation == CL_COMMAND_READ_IMAGE || operation == CL_COMMAND_COPY_IMAGE_TO_BUFFER) { + auto isCacheFlushPriorImageReadRequired = mockDevice->getGfxCoreHelper().isCacheFlushPriorImageReadRequired(); + EXPECT_EQ(isCacheFlushPriorImageReadRequired, cmdQ.isTextureCacheFlushNeeded(operation)); + } else { + EXPECT_TRUE(cmdQ.isTextureCacheFlushNeeded(operation)); + } + commandStreamReceiver.directSubmissionAvailable = false; - EXPECT_FALSE(cmdQ.isTextureCacheFlushNeeded(i)); + EXPECT_FALSE(cmdQ.isTextureCacheFlushNeeded(operation)); } else { commandStreamReceiver.directSubmissionAvailable = true; - EXPECT_FALSE(cmdQ.isTextureCacheFlushNeeded(i)); + EXPECT_FALSE(cmdQ.isTextureCacheFlushNeeded(operation)); commandStreamReceiver.directSubmissionAvailable = false; - EXPECT_FALSE(cmdQ.isTextureCacheFlushNeeded(i)); + EXPECT_FALSE(cmdQ.isTextureCacheFlushNeeded(operation)); } } } diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 97f6d824b5..21990305d7 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -203,6 +203,8 @@ class GfxCoreHelper { virtual bool getSipBinaryFromExternalLib() const = 0; virtual uint32_t getImplicitArgsVersion() const = 0; + virtual bool isCacheFlushPriorImageReadRequired() const = 0; + virtual ~GfxCoreHelper() = default; protected: @@ -450,6 +452,8 @@ class GfxCoreHelperHw : public GfxCoreHelper { bool getSipBinaryFromExternalLib() const override; + bool isCacheFlushPriorImageReadRequired() const override; + ~GfxCoreHelperHw() override = default; protected: diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index dd65ab0926..0cc3c4cdfc 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -848,4 +848,9 @@ uint32_t GfxCoreHelperHw::getImplicitArgsVersion() const { return 0; } +template +bool GfxCoreHelperHw::isCacheFlushPriorImageReadRequired() const { + return false; +} + } // namespace NEO diff --git a/shared/source/helpers/gfx_core_helper_xe2_and_later.inl b/shared/source/helpers/gfx_core_helper_xe2_and_later.inl index 2a6949913c..7c4c728f13 100644 --- a/shared/source/helpers/gfx_core_helper_xe2_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_xe2_and_later.inl @@ -91,4 +91,9 @@ bool GfxCoreHelperHw::usmCompressionSupported(const NEO::HardwareInfo &h return hwInfo.capabilityTable.ftrRenderCompressedBuffers; } +template <> +bool GfxCoreHelperHw::isCacheFlushPriorImageReadRequired() const { + return true; +} + } // namespace NEO diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp index 726b7b10be..754aa270c0 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp @@ -1932,3 +1932,8 @@ HWTEST_F(GfxCoreHelperTest, givenDebugFlagForceUseOnlyGlobalTimestampsSetWhenCal auto &gfxCoreHelper = getHelper(); EXPECT_TRUE(gfxCoreHelper.useOnlyGlobalTimestamps()); } + +HWTEST2_F(GfxCoreHelperTest, whenIsCacheFlushPriorImageReadRequiredCalledThenFalseIsReturned, IsBeforeXe2HpgCore) { + auto &helper = getHelper(); + EXPECT_FALSE(helper.isCacheFlushPriorImageReadRequired()); +} \ No newline at end of file diff --git a/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp b/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp index 93bfe55cb8..2c73d3ff0c 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp @@ -106,3 +106,9 @@ HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenEncodeAdditionalT EXPECT_EQ(storeRegMem->getRegisterAddress(), RegisterOffsets::globalTimestampUn); EXPECT_EQ(storeRegMem->getMemoryAddress(), sndAddress + sizeof(uint32_t)); } + +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenIsCacheFlushPriorImageReadRequiredThenTrueIsReturned, IsAtLeastXe2HpgCore) { + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + EXPECT_TRUE(gfxCoreHelper.isCacheFlushPriorImageReadRequired()); +} \ No newline at end of file