@@ -115,3 +115,78 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCs
115115 alignedFree (buffer);
116116 }
117117}
118+
119+ HWCMDTEST_F (IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndWhenFlushTaskIsCalledThenAlwaysProgramStateBaseAddressAndSip) {
120+ using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
121+ using STATE_SIP = typename FamilyType::STATE_SIP;
122+
123+ auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr ));
124+
125+ if (device->getHardwareInfo ().capabilityTable .defaultPreemptionMode == PreemptionMode::MidThread) {
126+ device->setSourceLevelDebuggerActive (true );
127+ device->allocatePreemptionAllocationIfNotPresent ();
128+ auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0 ], *device->executionEnvironment );
129+
130+ device->resetCommandStreamReceiver (mockCsr);
131+
132+ mockCsr->overrideDispatchPolicy (DispatchMode::ImmediateDispatch);
133+
134+ CommandQueueHw<FamilyType> commandQueue (nullptr , device.get (), 0 );
135+ auto &commandStream = commandQueue.getCS (4096u );
136+ auto &preambleStream = mockCsr->getCS (0 );
137+
138+ DispatchFlags dispatchFlags;
139+ dispatchFlags.preemptionMode = PreemptionMode::Disabled;
140+
141+ void *buffer = alignedMalloc (MemoryConstants::pageSize, MemoryConstants::pageSize64k);
142+
143+ std::unique_ptr<MockGraphicsAllocation> allocation (new MockGraphicsAllocation (buffer, MemoryConstants::pageSize));
144+ std::unique_ptr<IndirectHeap> heap (new IndirectHeap (allocation.get ()));
145+
146+ mockCsr->flushTask (commandStream,
147+ 0 ,
148+ *heap.get (),
149+ *heap.get (),
150+ *heap.get (),
151+ 0 ,
152+ dispatchFlags,
153+ *device);
154+
155+ mockCsr->flushBatchedSubmissions ();
156+
157+ mockCsr->flushTask (commandStream,
158+ 0 ,
159+ *heap.get (),
160+ *heap.get (),
161+ *heap.get (),
162+ 0 ,
163+ dispatchFlags,
164+ *device);
165+
166+ auto sipType = SipKernel::getSipKernelType (device->getHardwareInfo ().pPlatform ->eRenderCoreFamily , true );
167+ auto sipAllocation = device->getExecutionEnvironment ()->getBuiltIns ()->getSipKernel (sipType, *device.get ()).getSipAllocation ();
168+
169+ HardwareParse hwParser;
170+ hwParser.parseCommands <FamilyType>(preambleStream);
171+ auto itorStateBaseAddr = find<STATE_BASE_ADDRESS *>(hwParser.cmdList .begin (), hwParser.cmdList .end ());
172+ auto itorStateSip = find<STATE_SIP *>(hwParser.cmdList .begin (), hwParser.cmdList .end ());
173+
174+ ASSERT_NE (hwParser.cmdList .end (), itorStateBaseAddr);
175+ ASSERT_NE (hwParser.cmdList .end (), itorStateSip);
176+
177+ auto itorStateBaseAddr2 = find<STATE_BASE_ADDRESS *>(std::next (itorStateBaseAddr), hwParser.cmdList .end ());
178+ auto itorStateSip2 = find<STATE_SIP *>(std::next (itorStateSip), hwParser.cmdList .end ());
179+
180+ ASSERT_NE (hwParser.cmdList .end (), itorStateBaseAddr2);
181+ ASSERT_NE (hwParser.cmdList .end (), itorStateSip2);
182+
183+ STATE_BASE_ADDRESS *sba = (STATE_BASE_ADDRESS *)*itorStateBaseAddr2;
184+ STATE_SIP *stateSipCmd = (STATE_SIP *)*itorStateSip2;
185+ EXPECT_LT (reinterpret_cast <void *>(sba), reinterpret_cast <void *>(stateSipCmd));
186+
187+ auto sipAddress = stateSipCmd->getSystemInstructionPointer ();
188+
189+ EXPECT_EQ (sipAllocation->getGpuAddressToPatch (), sipAddress);
190+ alignedFree (buffer);
191+ }
192+ }
0 commit comments