|
10 | 10 | #include "shared/source/debug_settings/debug_settings_manager.h" |
11 | 11 | #include "shared/source/direct_submission/dispatchers/render_dispatcher.h" |
12 | 12 | #include "shared/source/helpers/flush_stamp.h" |
| 13 | +#include "shared/source/utilities/cpuintrinsics.h" |
13 | 14 | #include "shared/test/common/cmd_parse/hw_parse.h" |
14 | 15 | #include "shared/test/common/fixtures/direct_submission_fixture.h" |
15 | 16 | #include "shared/test/common/helpers/debug_manager_state_restore.h" |
|
23 | 24 | #include "shared/test/common/mocks/mock_io_functions.h" |
24 | 25 | #include "shared/test/common/test_macros/test.h" |
25 | 26 |
|
| 27 | +namespace CpuIntrinsicsTests { |
| 28 | +extern std::atomic<uint32_t> sfenceCounter; |
| 29 | +} // namespace CpuIntrinsicsTests |
| 30 | + |
26 | 31 | using DirectSubmissionTest = Test<DirectSubmissionFixture>; |
27 | 32 |
|
28 | 33 | using DirectSubmissionDispatchBufferTest = Test<DirectSubmissionDispatchBufferFixture>; |
@@ -699,3 +704,27 @@ HWTEST_F(DirectSubmissionDispatchBufferTest, |
699 | 704 | auto expectedValue = reinterpret_cast<uint32_t *>(directSubmission.ringCommandStream.getSpace(0))[0]; |
700 | 705 | EXPECT_EQ(expectedValue, directSubmission.reserved); |
701 | 706 | } |
| 707 | + |
| 708 | +HWTEST_F(DirectSubmissionDispatchBufferTest, givenDebugFlagSetWhenDispatchingWorkloadThenProgramSfenceInstruction) { |
| 709 | + DebugManagerStateRestore restorer{}; |
| 710 | + |
| 711 | + DebugManager.flags.DirectSubmissionInsertSfenceInstructionPriorToSubmission.set(1); |
| 712 | + using Dispatcher = BlitterDispatcher<FamilyType>; |
| 713 | + |
| 714 | + FlushStampTracker flushStamp(true); |
| 715 | + |
| 716 | + MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice, *osContext.get()); |
| 717 | + EXPECT_TRUE(directSubmission.initialize(true, true)); |
| 718 | + |
| 719 | + auto initialCounterValue = CpuIntrinsicsTests::sfenceCounter.load(); |
| 720 | + |
| 721 | + EXPECT_TRUE(directSubmission.dispatchCommandBuffer(batchBuffer, flushStamp)); |
| 722 | + |
| 723 | + EXPECT_EQ(initialCounterValue + 1, CpuIntrinsicsTests::sfenceCounter); |
| 724 | + |
| 725 | + DebugManager.flags.DirectSubmissionInsertSfenceInstructionPriorToSubmission.set(2); |
| 726 | + |
| 727 | + EXPECT_TRUE(directSubmission.dispatchCommandBuffer(batchBuffer, flushStamp)); |
| 728 | + |
| 729 | + EXPECT_EQ(initialCounterValue + 3, CpuIntrinsicsTests::sfenceCounter); |
| 730 | +} |
0 commit comments