|
8 | 8 | #include "shared/source/helpers/timestamp_packet.h"
|
9 | 9 | #include "shared/source/memory_manager/surface.h"
|
10 | 10 | #include "shared/source/os_interface/os_context.h"
|
| 11 | +#include "shared/test/common/cmd_parse/hw_parse.h" |
11 | 12 | #include "shared/test/common/mocks/mock_csr.h"
|
12 | 13 | #include "shared/test/common/mocks/mock_execution_environment.h"
|
13 | 14 | #include "shared/test/common/mocks/mock_graphics_allocation.h"
|
| 15 | +#include "shared/test/common/mocks/mock_logical_state_helper.h" |
14 | 16 | #include "shared/test/common/mocks/mock_timestamp_container.h"
|
15 | 17 | #include "shared/test/common/test_macros/test.h"
|
16 | 18 | #include "shared/test/common/test_macros/test_checks_shared.h"
|
@@ -60,6 +62,66 @@ HWTEST_F(EnqueueHandlerTest, GivenCommandStreamWithoutKernelWhenCommandEnqueuedT
|
60 | 62 | EXPECT_EQ(allocation->getTaskCount(mockCmdQ->getGpgpuCommandStreamReceiver().getOsContext().getContextId()), 1u);
|
61 | 63 | }
|
62 | 64 |
|
| 65 | +HWTEST_F(EnqueueHandlerTest, givenLogicalStateHelperWhenDispatchingCommandsThenAddLastCommand) { |
| 66 | + using MI_NOOP = typename FamilyType::MI_NOOP; |
| 67 | + |
| 68 | + auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pClDevice, nullptr); |
| 69 | + auto logicalStateHelper = new LogicalStateHelperMock<FamilyType>(); |
| 70 | + |
| 71 | + auto &ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> &>(mockCmdQ->getGpgpuCommandStreamReceiver()); |
| 72 | + ultCsr.logicalStateHelper.reset(logicalStateHelper); |
| 73 | + |
| 74 | + auto surface = std::make_unique<NullSurface>(); |
| 75 | + EventsRequest eventsRequest(0, nullptr, nullptr); |
| 76 | + EventBuilder eventBuilder; |
| 77 | + Surface *surfaces[] = {surface.get()}; |
| 78 | + bool blocking = true; |
| 79 | + |
| 80 | + TimestampPacketDependencies timestampPacketDependencies; |
| 81 | + |
| 82 | + CsrDependencies csrDeps; |
| 83 | + EnqueueProperties enqueueProperties(false, false, false, true, false, nullptr); |
| 84 | + |
| 85 | + EXPECT_EQ(0u, logicalStateHelper->writeStreamInlineCalledCounter); |
| 86 | + |
| 87 | + mockCmdQ->enqueueCommandWithoutKernel(surfaces, 1, &mockCmdQ->getCS(0), 0, blocking, enqueueProperties, timestampPacketDependencies, |
| 88 | + eventsRequest, eventBuilder, 0, csrDeps, nullptr); |
| 89 | + |
| 90 | + EXPECT_EQ(1u, logicalStateHelper->writeStreamInlineCalledCounter); |
| 91 | + |
| 92 | + HardwareParse cmdParser; |
| 93 | + cmdParser.parseCommands<FamilyType>(ultCsr.commandStream); |
| 94 | + |
| 95 | + auto miNoop = find<MI_NOOP *>(cmdParser.cmdList.begin(), cmdParser.cmdList.end()); |
| 96 | + bool miNoopFound = false; |
| 97 | + uint32_t cmdsAfterNoop = 0; |
| 98 | + |
| 99 | + while (miNoop != cmdParser.cmdList.end()) { |
| 100 | + auto miNoopCmd = genCmdCast<MI_NOOP *>(*miNoop); |
| 101 | + if (miNoopCmd->getIdentificationNumber() == 0x123) { |
| 102 | + miNoopFound = true; |
| 103 | + break; |
| 104 | + } |
| 105 | + |
| 106 | + miNoop = find<MI_NOOP *>(++miNoop, cmdParser.cmdList.end()); |
| 107 | + } |
| 108 | + |
| 109 | + miNoop++; |
| 110 | + |
| 111 | + while (miNoop != cmdParser.cmdList.end()) { |
| 112 | + auto miNoopCmd = genCmdCast<MI_NOOP *>(*miNoop); |
| 113 | + |
| 114 | + if (miNoopCmd == nullptr) { |
| 115 | + cmdsAfterNoop++; |
| 116 | + } |
| 117 | + |
| 118 | + miNoop++; |
| 119 | + } |
| 120 | + |
| 121 | + EXPECT_TRUE(miNoopFound); |
| 122 | + EXPECT_EQ(1u, cmdsAfterNoop); |
| 123 | +} |
| 124 | + |
63 | 125 | template <bool enabled>
|
64 | 126 | struct EnqueueHandlerTimestampTest : public EnqueueHandlerTest {
|
65 | 127 | void SetUp() override {
|
|
0 commit comments