Debian Codegraph @

shared/test/unit_test/direct_submission/dispatchers/render_dispatcher_tests.cpp

raw
1 /*
2 * Copyright (C) 2020-2023 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/direct_submission/dispatchers/render_dispatcher.h"
9 #include "shared/source/helpers/gfx_core_helper.h"
10 #include "shared/test/common/cmd_parse/hw_parse.h"
11 #include "shared/test/common/helpers/unit_test_helper.h"
12 #include "shared/test/common/mocks/mock_device.h"
13 #include "shared/test/common/test_macros/hw_test.h"
14 #include "shared/test/common/test_macros/test.h"
15 #include "shared/test/unit_test/direct_submission/dispatchers/dispatcher_fixture.h"
16 #include "shared/test/unit_test/fixtures/preemption_fixture.h"
17
18 using RenderDispatcherTest = Test<DispatcherFixture>;
19
20 using namespace NEO;
21
22 HWTEST_F(RenderDispatcherTest, givenRenderWhenAskingForPreemptionCmdSizeThenReturnSetMmioCmdSize) {
23 using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
24
25 size_t expectedCmdSize = 0u;
26 if (getPreemptionTestHwDetails<FamilyType>().supportsPreemptionProgramming()) {
27 expectedCmdSize = sizeof(MI_LOAD_REGISTER_IMM);
28 }
29 EXPECT_EQ(expectedCmdSize, RenderDispatcher<FamilyType>::getSizePreemption());
30 }
31
32 HWTEST_F(RenderDispatcherTest, givenRenderWhenAddingPreemptionCmdThenExpectProperMmioAddress) {
33 using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
34
35 auto preemptionDetails = getPreemptionTestHwDetails<FamilyType>();
36
37 RenderDispatcher<FamilyType>::dispatchPreemption(cmdBuffer);
38
39 HardwareParse hwParse;
40 hwParse.parseCommands<FamilyType>(cmdBuffer);
41 MI_LOAD_REGISTER_IMM *immCmd = hwParse.getCommand<MI_LOAD_REGISTER_IMM>();
42 if (preemptionDetails.supportsPreemptionProgramming()) {
43 ASSERT_NE(nullptr, immCmd);
44 uint32_t expectedMmio = preemptionDetails.regAddress;
45 uint32_t expectedValue = preemptionDetails.modeToRegValueMap[PreemptionMode::MidBatch];
46
47 EXPECT_EQ(expectedMmio, immCmd->getRegisterOffset());
48 EXPECT_EQ(expectedValue, immCmd->getDataDword());
49
50 } else {
51 EXPECT_EQ(nullptr, immCmd);
52 }
53 }
54
55 HWTEST_F(RenderDispatcherTest, givenRenderWhenAskingForMonitorFenceCmdSizeThenReturnRequiredPipeControlCmdSize) {
56 size_t expectedSize = MemorySynchronizationCommands<FamilyType>::getSizeForBarrierWithPostSyncOperation(this->pDevice->getRootDeviceEnvironment(), false);
57
58 EXPECT_EQ(expectedSize, RenderDispatcher<FamilyType>::getSizeMonitorFence(this->pDevice->getRootDeviceEnvironment()));
59 }
60
61 HWTEST_F(RenderDispatcherTest, givenRenderWhenAddingMonitorFenceCmdThenExpectPipeControlWithProperAddressAndValue) {
62 using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
63 using POST_SYNC_OPERATION = typename FamilyType::PIPE_CONTROL::POST_SYNC_OPERATION;
64
65 uint64_t gpuVa = 0xFF00FF0000ull;
66 uint64_t value = 0x102030;
67
68 RenderDispatcher<FamilyType>::dispatchMonitorFence(cmdBuffer, gpuVa, value, this->pDevice->getRootDeviceEnvironment(), false, false, false);
69
70 HardwareParse hwParse;
71 hwParse.parseCommands<FamilyType>(cmdBuffer);
72
73 bool foundMonitorFence = false;
74 for (auto &it : hwParse.cmdList) {
75 PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(it);
76 if (pipeControl) {
77 foundMonitorFence =
78 (pipeControl->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) &&
79 (NEO::UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl) == gpuVa) &&
80 (pipeControl->getImmediateData() == value);
81 if (foundMonitorFence) {
82 break;
83 }
84 }
85 }
86 EXPECT_TRUE(foundMonitorFence);
87 }
88
89 HWTEST_F(RenderDispatcherTest, givenRenderWhenAskingForCacheFlushCmdSizeThenReturnSetRequiredPipeControls) {
90 size_t expectedSize = MemorySynchronizationCommands<FamilyType>::getSizeForFullCacheFlush();
91
92 size_t actualSize = RenderDispatcher<FamilyType>::getSizeCacheFlush(pDevice->getRootDeviceEnvironment());
93 EXPECT_EQ(expectedSize, actualSize);
94 }
95
96 HWTEST_F(RenderDispatcherTest, givenRenderWhenAddingCacheFlushCmdThenExpectPipeControlWithProperFields) {
97 using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
98
99 RenderDispatcher<FamilyType>::dispatchCacheFlush(cmdBuffer, pDevice->getRootDeviceEnvironment(), 0ull);
100
101 HardwareParse hwParse;
102 hwParse.parseCommands<FamilyType>(cmdBuffer);
103
104 bool foundCacheFlush = false;
105 for (auto &it : hwParse.cmdList) {
106 PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(it);
107 if (pipeControl) {
108 foundCacheFlush =
109 pipeControl->getRenderTargetCacheFlushEnable() &&
110 pipeControl->getInstructionCacheInvalidateEnable() &&
111 pipeControl->getTextureCacheInvalidationEnable() &&
112 pipeControl->getPipeControlFlushEnable() &&
113 pipeControl->getStateCacheInvalidationEnable();
114 if (foundCacheFlush) {
115 break;
116 }
117 }
118 }
119 EXPECT_TRUE(foundCacheFlush);
120 }
121
122 HWCMDTEST_F(IGFX_XE_HP_CORE, RenderDispatcherTest,
123 givenRenderDispatcherPartitionedWorkloadFlagTrueWhenAddingMonitorFenceCmdThenExpectPipeControlWithProperAddressAndValueAndPartitionParameter) {
124 using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
125 using POST_SYNC_OPERATION = typename FamilyType::PIPE_CONTROL::POST_SYNC_OPERATION;
126
127 uint64_t gpuVa = 0xBADA550000ull;
128 uint64_t value = 0x102030;
129
130 RenderDispatcher<FamilyType>::dispatchMonitorFence(cmdBuffer, gpuVa, value, this->pDevice->getRootDeviceEnvironment(), false, true, false);
131
132 HardwareParse hwParse;
133 hwParse.parsePipeControl = true;
134 hwParse.parseCommands<FamilyType>(cmdBuffer);
135 hwParse.findHardwareCommands<FamilyType>();
136
137 bool foundMonitorFence = false;
138 for (auto &it : hwParse.pipeControlList) {
139 PIPE_CONTROL *pipeControl = reinterpret_cast<PIPE_CONTROL *>(it);
140 if (pipeControl->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) {
141 foundMonitorFence = true;
142 EXPECT_EQ(gpuVa, NEO::UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl));
143 EXPECT_EQ(value, pipeControl->getImmediateData());
144 EXPECT_TRUE(pipeControl->getWorkloadPartitionIdOffsetEnable());
145 EXPECT_FALSE(pipeControl->getTlbInvalidate());
146 EXPECT_TRUE(pipeControl->getTextureCacheInvalidationEnable());
147 break;
148 }
149 }
150 EXPECT_TRUE(foundMonitorFence);
151 }
152
153 HWTEST_F(RenderDispatcherTest, givenRenderWhenCheckingForMultiTileSynchronizationSupportThenExpectTrue) {
154 EXPECT_TRUE(RenderDispatcher<FamilyType>::isMultiTileSynchronizationSupported());
155 }
156
157 HWCMDTEST_F(IGFX_XE_HP_CORE, RenderDispatcherTest,
158 givenRenderDispatcherNotifyFlagTrueWhenAddingMonitorFenceCmdThenExpectPipeControlWithProperAddressAndValueAndNotifyParameter) {
159 using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
160 using POST_SYNC_OPERATION = typename FamilyType::PIPE_CONTROL::POST_SYNC_OPERATION;
161
162 uint64_t gpuAddress = 0xADD35500ull;
163 uint64_t value = 0x102030;
164
165 RenderDispatcher<FamilyType>::dispatchMonitorFence(cmdBuffer, gpuAddress, value, this->pDevice->getRootDeviceEnvironment(), true, false, false);
166
167 HardwareParse hwParse;
168 hwParse.parsePipeControl = true;
169 hwParse.parseCommands<FamilyType>(cmdBuffer);
170 hwParse.findHardwareCommands<FamilyType>();
171
172 bool foundMonitorFence = false;
173 for (auto &it : hwParse.pipeControlList) {
174 PIPE_CONTROL *pipeControl = reinterpret_cast<PIPE_CONTROL *>(it);
175 if (pipeControl->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) {
176 foundMonitorFence = true;
177 EXPECT_EQ(gpuAddress, NEO::UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl));
178 EXPECT_EQ(value, pipeControl->getImmediateData());
179 EXPECT_TRUE(pipeControl->getNotifyEnable());
180 EXPECT_FALSE(pipeControl->getTlbInvalidate());
181 EXPECT_TRUE(pipeControl->getTextureCacheInvalidationEnable());
182 break;
183 }
184 }
185 EXPECT_TRUE(foundMonitorFence);
186 }
187
188 HWTEST_F(RenderDispatcherTest, givenRenderWithDcFlushFlagTrueWhenAddingMonitorFenceCmdThenExpectPipeControlWithProperAddressAndValueAndDcFlushParameter) {
189 using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
190 using POST_SYNC_OPERATION = typename FamilyType::PIPE_CONTROL::POST_SYNC_OPERATION;
191
192 uint64_t gpuVa = 0xFF00FF0000ull;
193 uint64_t value = 0x102030;
194
195 RenderDispatcher<FamilyType>::dispatchMonitorFence(cmdBuffer, gpuVa, value, this->pDevice->getRootDeviceEnvironment(), false, false, true);
196
197 HardwareParse hwParse;
198 hwParse.parseCommands<FamilyType>(cmdBuffer);
199
200 bool foundMonitorFence = false;
201 for (auto &it : hwParse.cmdList) {
202 PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(it);
203 if (pipeControl) {
204 foundMonitorFence =
205 (pipeControl->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA) &&
206 (NEO::UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl) == gpuVa) &&
207 (pipeControl->getImmediateData() == value);
208 if (foundMonitorFence) {
209 EXPECT_TRUE(pipeControl->getDcFlushEnable());
210 EXPECT_FALSE(pipeControl->getTlbInvalidate());
211 EXPECT_TRUE(pipeControl->getTextureCacheInvalidationEnable());
212 break;
213 }
214 }
215 }
216 EXPECT_TRUE(foundMonitorFence);
217 }