Debian Codegraph @

media_softlet/agnostic/common/renderhal/hal_oca_interface_next.h

raw
1 /*
2 * Copyright (c) 2021, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file hal_oca_interface_next.h
24 //! \brief Implementation of functions for HAL OCA Interface
25 //!
26
27 #ifndef __HAL_OCA_INTERFACE_NEXT_H__
28 #define __HAL_OCA_INTERFACE_NEXT_H__
29
30 #include "mhw_mi.h"
31 #include "mos_os_hw.h"
32 #include "mhw_mi_itf.h"
33 #include "media_defs.h"
34 /****************************************************************************************************/
35 /* HalOcaInterface */
36 /****************************************************************************************************/
37
38 class HalOcaInterfaceNext
39 {
40 public:
41 //!
42 //! \brief Oca operation which should be called at the beginning of 1st level batch buffer start.
43 //! \param [in/out] cmdBuffer
44 //! Command buffer for current BB. hOcaBuf in cmdBuffer will be updated.
45 //! \param [in] mosContext
46 //! Reference to MOS_CONTEXT.
47 //! \param [in] gpuContextHandle
48 //! Gpu context handle
49 //! \param [in] miItf
50 //! Reference to Mhw MiItf.
51 //! \param [in] mmioRegisters
52 //! mmio registers for current engine.
53 //! \param [in] offsetOf1stLevelBB
54 //! Offset for current BB in cmdBuffer.
55 //! \param [in] bUseSizeOfCmdBuf
56 //! If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB.
57 //! \param [in] sizeOf1stLevelBB
58 //! Size of BB. Ignore if bUseSizeOfResource == true.
59 //! \return void
60 //! No return value. Handle all exception inside the function.
61 //!
62 static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext,
63 uint32_t gpuContextHandle, std::shared_ptr<mhw::mi::Itf> miItf, MHW_MI_MMIOREGISTERS &mmioRegisters,
64 uint32_t offsetOf1stLevelBB = 0, bool bUseSizeOfCmdBuf = true, uint32_t sizeOf1stLevelBB = 0);
65
66 //!
67 //! \brief Oca operation which should be called at the beginning of 1st level batch buffer start.
68 //! \param [in/out] cmdBuffer
69 //! Command buffer for current BB. hOcaBuf in cmdBuffer will be updated.
70 //! \param [in] mosContext
71 //! Reference to MOS_CONTEXT.
72 //! \param [in] gpuContextHandle
73 //! Gpu context handle
74 //! \param [in] miItf
75 //! Reference to Mhw MiItf.
76 //! \param [in] mmioRegisters
77 //! mmio registers for current engine.
78 //! \param [in] offsetOf1stLevelBB
79 //! Offset for current BB in cmdBuffer.
80 //! \param [in] bUseSizeOfCmdBuf
81 //! If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB.
82 //! \param [in] sizeOf1stLevelBB
83 //! Size of BB. Ignore if bUseSizeOfResource == true.
84 //! \return void
85 //! No return value. Handle all exception inside the function.
86 //!
87 static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext,
88 uint32_t gpuContextHandle, std::shared_ptr<mhw::mi::Itf> miItf, MmioRegistersMfx &mmioRegisters,
89 uint32_t offsetOf1stLevelBB = 0, bool bUseSizeOfCmdBuf = true, uint32_t sizeOf1stLevelBB = 0);
90
91 //!
92 //! \brief Oca operation which should be called before adding batch buffer end command for 1st
93 //! level batch buffer.
94 //! \param [in/out] cmdBuffer
95 //! Command buffer for current BB. hOcaBuf in cmdBuffer will be updated.
96 //! \param [in] osInterface
97 //! Reference to MOS_INTERFACE.
98 //! \return void
99 //! No return value. Handle all exception inside the function.
100 //!
101 static void On1stLevelBBEnd(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface);
102
103 //!
104 //! \brief Oca operation which should be called before sending start sub level batch buffer command.
105 //! \param [in] cmdBuffer
106 //! Command buffer for current BB.
107 //! \param [in] mosContext
108 //! Reference to MOS_CONTEXT.
109 //! \param [in] pMosResource
110 //! Pointer to the MOS_RESOURCE.
111 //! \param [in] offsetOfSubLevelBB
112 //! Offset for current BB in pMosResource.
113 //! \param [in] bUseSizeOfResource
114 //! If true, use size of pMosResource for batch buffer, else use sizeOfIndirectState.
115 //! \param [in] sizeOfSubLevelBB
116 //! Size of BB. Ignore if bUseSizeOfResource == true.
117 //! \return void
118 //! No return value. Handle all exception inside the function.
119 //!
120 static void OnSubLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pMosResource, uint32_t offsetOfSubLevelBB, bool bUseSizeOfResource, uint32_t sizeOfSubLevelBB);
121
122 //!
123 //! \brief Oca operation which should be called when indirect states being added.
124 //! \param [in] cmdBuffer
125 //! Command buffer for current BB.
126 //! \param [in] mosContext
127 //! Reference to MOS_CONTEXT.
128 //! \param [in] pMosResource
129 //! Pointer to the MOS_RESOURCE.
130 //! \param [in] offsetOfIndirectState
131 //! Offset for current state in pMosResource.
132 //! \param [in] bUseSizeOfResource
133 //! If true, use size of pMosResource for indirect state, else use sizeOfIndirectState.
134 //! \param [in] sizeOfIndirectState
135 //! Size of indirect state. Ignore if bUseSizeOfResource == true.
136 //! \return void
137 //! No return value. Handle all exception inside the function.
138 //!
139 static void OnIndirectState(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pMosResource, uint32_t offsetOfIndirectState, bool bUseSizeOfResource, uint32_t sizeOfIndirectState);
140
141 //!
142 //! \brief Oca operation which should be called before adding dispatch states,
143 //! e.g. VEB_DI_IECP_STATE and MEDIA_OBJECT_WALKER.
144 //! \param [in] cmdBuffer
145 //! Command buffer for current BB.
146 //! \param [in] mosContext
147 //! Reference to MOS_CONTEXT.
148 //! \param [in] miItf
149 //! Reference to Mhw MiItf.
150 //! \param [in] mmioRegisters
151 //! mmio registers for current engine.
152 //! \return void
153 //! No return value. Handle all exception inside the function.
154 //!
155 static void OnDispatch(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface, std::shared_ptr<mhw::mi::Itf> miItf, MHW_MI_MMIOREGISTERS &mmioRegisters);
156
157 //!
158 //! \brief Add string to oca log section
159 //! \param [in] cmdBuffer
160 //! Command buffer for current BB.
161 //! \param [in] mosContext
162 //! Reference to MOS_CONTEXT.
163 //! \param [in] str
164 //! string to be added.
165 //! \param [in] maxCount
166 //! size of the buffer pointed by str.
167 //! \return void
168 //! No return value. Handle all exception inside the function.
169 //!
170 static void TraceMessage(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, const char *str, uint32_t maxCount);
171
172 //!
173 //! \brief Add vp kernel info to oca log section.
174 //! \param [in] cmdBuffer
175 //! Command buffer for current BB.
176 //! \param [in] osInterface
177 //! Reference to MOS_INTERFACE.
178 //! \param [in] res
179 //! Reference to MOS_RESOURCE.
180 //! \param [in] hwCmdType
181 //! Hw command type.
182 //! \param [in] locationInCmd
183 //! Location in command.
184 //! \param [in] offsetInRes
185 //! Offset in resource.
186 //! \return void
187 //! No return value. Handle all exception inside the function.
188 //!
189 static void DumpResourceInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface, MOS_RESOURCE &res, MOS_HW_COMMAND hwCmdType, uint32_t locationInCmd, uint32_t offsetInRes);
190
191 //!
192 //! \brief Insert bindless/stateless resource state heap into OcaBufferHandlerMap
193 //! \param [in] key
194 //! The base address of resource state heap
195 //! \param [in] osInterface
196 //! Reference to PMOS_INTERFACE.
197 //! \param [in] cmdBuffer
198 //! Command buffer for current BB.
199 //! \return void
200 //! No return value. Handle all exception inside the function.
201 //!
202 static void InsertResourceHeapToCurrentCmdBufferOcaBufferHandle(uint32_t *key, PMOS_INTERFACE osInterface, PMOS_COMMAND_BUFFER _cmdBuffer);
203
204 //!
205 //! \brief Trace OCA Sku Value.
206 //! \param [in] cmdBuffer
207 //! Command buffer for current BB.
208 //! \param [in] osInterface
209 //! Reference to MOS_INTERFACE.
210 //! \return void
211 //! No return value. Handle all exception inside the function.
212 //!
213 static void TraceOcaSkuValue(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface);
214
215 //!
216 //! \brief Add vp kernel info to oca log section.
217 //! \param [in] cmdBuffer
218 //! Command buffer for current BB.
219 //! \param [in] mosContext
220 //! Reference to MOS_CONTEXT.
221 //! \param [in] vpKernelID
222 //! Value of enum VpKernelID.
223 //! \param [in] fcKernelCount
224 //! If vpKernelID == kernelCombinedFc, fcKernelCount is the kernel count for fc, otherwise, it's not used.
225 //! \param [in] fcKernelList
226 //! If vpKernelID == kernelCombinedFc, fcKernelList is the kernel list for fc, otherwise, it's not used.
227 //! \return void
228 //! No return value. Handle all exception inside the function.
229 //!
230 static void DumpVpKernelInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, int vpKernelID, int fcKernelCount, int *fcKernelList, int aiKernelFeatureType = 0);
231
232 //!
233 //! \brief Add vp kernel info to oca log section.
234 //! \param [in] cmdBuffer
235 //! Command buffer for current BB.
236 //! \param [in] mosContext
237 //! Reference to MOS_CONTEXT.
238 //! \param [in] pControlValues
239 //! Value of user features.
240 //! \return void
241 //! No return value. Handle all exception inside the function.
242 //!
243 static void DumpVpUserFeautreControlInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, PMOS_OCA_LOG_USER_FEATURE_CONTROL_INFO pControlValues);
244
245 //!
246 //! \brief Add vphal parameters to oca log section.
247 //! \param [in] cmdBuffer
248 //! Command buffer for current BB.
249 //! \param [in] mosContext
250 //! Reference to MOS_CONTEXT.
251 //! \param [in] pVphalDumper
252 //! Pointer to vphal dumper object.
253 //! \return void
254 //! No return value. Handle all exception inside the function.
255 //!
256 static void DumpVphalParam(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pVphalDumper);
257
258 //!
259 //! \brief Add codechal parameters to oca log section.
260 //! \param [in] cmdBuffer
261 //! Command buffer for current BB.
262 //! \param [in] mosContext
263 //! Reference to MOS_CONTEXT.
264 //! \param [in] pCodechalDumper
265 //! Pointer to codechal dumper object.
266 //! \return void
267 //! No return value. Handle all exception inside the function.
268 //!
269 static void DumpCodechalParam(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pCodechalDumper, CODECHAL_STANDARD codec);
270
271 //!
272 //! \brief Get large resource dump support state
273 //! \return bool
274 //! Return true when support large reource dump
275 //!
276 static bool IsLargeResouceDumpSupported();
277
278 //!
279 //! \brief Add cp IO Message to oca log section.
280 //! \param [in] ocaInterface
281 //! Reference to MosOcaInterface.
282 //! \param [in] hOcaBuf
283 //! Reference to MOS_OCA_BUFFER_HANDLE.
284 //! \param [in] mosCtx
285 //! DDI device context.
286 //! \param [in] pCpDumper
287 //! Pointer to cp dumper object.
288 //! \param [in] type
289 //! Cp message type.
290 //! \return void
291 //! No return value. Handle all exception inside the function.
292 //!
293 static void DumpCpIoMsg(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pCpDumper, int type);
294
295 protected:
296 static MOS_STATUS MhwMiLoadRegisterImmCmd(
297 std::shared_ptr<mhw::mi::Itf> miItf,
298 PMOS_COMMAND_BUFFER pCmdBuffer,
299 MHW_MI_LOAD_REGISTER_IMM_PARAMS *params);
300
301 //!
302 //! \brief Error handle function.
303 //! \param [in] mosCtx
304 //! the ddi device context.
305 //! \param [in] status
306 //! The MOS_STATUS for current error.
307 //! \param [in] funcName
308 //! The failure function name.
309 //! \param [in] lineNumber
310 //! The line number where OnOcaError being called in failure function.
311 //! \return void
312 //! No return value. Handle all exception inside the function.
313 //!
314 static void OnOcaError(MOS_CONTEXT_HANDLE mosContext, MOS_STATUS status, const char *functionName, uint32_t lineNumber);
315 //!
316 //! \brief Get OCA buffer handle from pool.
317 //! \param [in] cmdBuffer
318 //! Command buffer for current BB.
319 //! \param [in] mosContext
320 //! Reference to MOS_CONTEXT.
321 //! \return MOS_OCA_BUFFER_HANDLE
322 //! MOS_OCA_BUFFER_HANDLE.
323 //!
324 static MOS_OCA_BUFFER_HANDLE GetOcaBufferHandle(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext);
325
326 //!
327 //! \brief Remove OCA buffer handle from pool.
328 //! \param [in] cmdBuffer
329 //! Command buffer for current BB.
330 //! \param [in] mosContext
331 //! Reference to MOS_CONTEXT.
332 //! \return void
333 //! No return value. Handle all exception inside the function.
334 //!
335 static void RemoveOcaBufferHandle(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext);
336
337 //!
338 //! \brief Add cp parameters to oca log section.
339 //! \param [in] ocaInterface
340 //! Reference to MosOcaInterface.
341 //! \param [in] hOcaBuf
342 //! Reference to MOS_OCA_BUFFER_HANDLE.
343 //! \param [in] mosCtx
344 //! DDI device context.
345 //! \param [in] pCpDumper
346 //! Pointer to cp dumper object.
347 //! \return void
348 //! No return value. Handle all exception inside the function.
349 //!
350 static void DumpCpParam(MosOcaInterface &ocaInterface, MOS_OCA_BUFFER_HANDLE &hOcaBuf, PMOS_CONTEXT mosCtx, void *pCpDumper);
351
352 //!
353 //! \brief Oca operation which should be called at the beginning of 1st level batch buffer start.
354 //! \param [in/out] cmdBuffer
355 //! Command buffer for current BB. ocaBufHandle in cmdBuffer will be updated.
356 //! \param [in] mosContext
357 //! Reference to MOS_CONTEXT.
358 //! \param [in] gpuContextHandle
359 //! Gpu context handle
360 //! \return void
361 //! No return value. Handle all exception inside the function.
362 //!
363 static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext, uint32_t gpuContextHandle);
364
365 static void AddRTLogReource(MOS_COMMAND_BUFFER &cmdBuffer,
366 MOS_CONTEXT_HANDLE mosContext,
367 MOS_INTERFACE &osInterface);
368
369 // Private functions to ensure class singleton.
370 HalOcaInterfaceNext();
371 HalOcaInterfaceNext(HalOcaInterfaceNext &);
372 HalOcaInterfaceNext& operator= (HalOcaInterfaceNext &);
373
374 MEDIA_CLASS_DEFINE_END(HalOcaInterfaceNext)
375 };
376
377
378 #endif // __RHAL_OCA_INTERFACE_H__