Debian Codegraph @

media_softlet/agnostic/common/renderhal/renderhal_platform_interface_next.h

raw
1 /*
2 * Copyright (c) 2021-2023, 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 renderhal_platform_interface_next.h
24 //! \brief abstract the platfrom specific APIs into one class
25 //!
26 //!
27 //! \file renderhal.h
28 //! \brief Render Engine Interfaces shared across platforms
29 //! \details Platform Independent Hardware Interfaces
30 //!
31 #ifndef __RENDERHAL_PLATFORM_INTERFACE_NEXT_H__
32 #define __RENDERHAL_PLATFORM_INTERFACE_NEXT_H__
33
34 #include <memory>
35 #include "media_class_trace.h"
36 #include "mhw_mi.h"
37 #include "mhw_mmio.h"
38 #include "mhw_render.h"
39 #include "mhw_state_heap.h"
40 #include "mhw_utilities_next.h"
41 #include "mos_defs.h"
42 #include "mos_os_specific.h"
43 #include "vp_common.h"
44 #include "renderhal_platform_interface.h"
45 #include "mhw_render_itf.h"
46 class MediaFeatureManager;
47 namespace mhw { namespace mi { class Itf; } }
48
49 typedef struct _RENDERHAL_GENERIC_PROLOG_PARAMS_NEXT : _RENDERHAL_GENERIC_PROLOG_PARAMS
50 {
51 MOS_VIRTUALENGINE_HINT_PARAMS VEngineHintParams = {{0}, 0, {{0}, {0}, {0}, {0}}, {0, 0, 0, 0}};
52 } RENDERHAL_GENERIC_PROLOG_PARAMS_NEXT, *PRENDERHAL_GENERIC_PROLOG_PARAMS_NEXT;
53
54 class XRenderHal_Platform_Interface_Next : public XRenderHal_Platform_Interface, public mhw::render::Itf::ParSetting
55 {
56 public:
57 XRenderHal_Platform_Interface_Next();
58 virtual ~XRenderHal_Platform_Interface_Next() {}
59
60 MOS_STATUS AddPipelineSelectCmd(
61 PRENDERHAL_INTERFACE pRenderHal,
62 PMOS_COMMAND_BUFFER pCmdBuffer,
63 bool gpGpuPipe);
64
65 MOS_STATUS SendStateBaseAddress(
66 PRENDERHAL_INTERFACE pRenderHal,
67 PMOS_COMMAND_BUFFER pCmdBuffer);
68
69 MOS_STATUS AddSipStateCmd(
70 PRENDERHAL_INTERFACE pRenderHal,
71 PMOS_COMMAND_BUFFER pCmdBuffer);
72
73 MOS_STATUS AddCfeStateCmd(
74 PRENDERHAL_INTERFACE pRenderHal,
75 PMOS_COMMAND_BUFFER pCmdBuffer,
76 PMHW_VFE_PARAMS params);
77
78 MOS_STATUS SendChromaKey(
79 PRENDERHAL_INTERFACE pRenderHal,
80 PMOS_COMMAND_BUFFER pCmdBuffer,
81 PMHW_CHROMAKEY_PARAMS pChromaKeyParams);
82
83 MOS_STATUS SendPalette(
84 PRENDERHAL_INTERFACE pRenderHal,
85 PMOS_COMMAND_BUFFER pCmdBuffer,
86 PMHW_PALETTE_PARAMS pPaletteLoadParams);
87
88 MOS_STATUS SetL3Cache(
89 PRENDERHAL_INTERFACE pRenderHal,
90 PMOS_COMMAND_BUFFER pCmdBuffer);
91
92 //!
93 //! \brief Get the size of render hal media state
94 //! \return size_t
95 //! The size of render hal media state
96 //!
97 size_t GetRenderHalMediaStateSize();
98
99 //!
100 //! \brief Get the size of render hal state heap
101 //! \return size_t
102 //! The size of render hal state heap
103 //!
104 size_t GetRenderHalStateHeapSize();
105
106 PMHW_MI_MMIOREGISTERS GetMmioRegisters(
107 PRENDERHAL_INTERFACE pRenderHal);
108
109 MOS_STATUS EnablePreemption(
110 PRENDERHAL_INTERFACE pRenderHal,
111 PMOS_COMMAND_BUFFER pCmdBuffer);
112
113 MOS_STATUS SendPredicationCommand(
114 PRENDERHAL_INTERFACE pRenderHal,
115 PMOS_COMMAND_BUFFER pCmdBuffer);
116
117 //! \brief Adds marker attributes in command buffer
118 //! \param PRENDERHAL_INTERFACE pRenderHal
119 //! [in] Pointer to RenderHal Interface Structure
120 //! \param PMOS_COMMAND_BUFFER pcmdBuffer
121 //! [in] Pointer to Command Buffer
122 //! \param bool isRender
123 //! [in] Flag of Render Engine
124 //! \return MOS_STATUS
125 MOS_STATUS SendMarkerCommand(
126 PRENDERHAL_INTERFACE pRenderHal,
127 PMOS_COMMAND_BUFFER cmdBuffer,
128 bool isRender);
129
130 MOS_STATUS AddMiPipeControl(
131 PRENDERHAL_INTERFACE pRenderHal,
132 PMOS_COMMAND_BUFFER pCmdBuffer,
133 MHW_PIPE_CONTROL_PARAMS* params);
134
135 //!
136 //! \brief Adds MI_LOAD_REGISTER_IMM to the command buffer
137 //! \param PRENDERHAL_INTERFACE pRenderHal
138 //! [in] Pointer to RenderHal Interface Structure
139 //! \param [in] pCmdBuffer
140 //! Command buffer to which requested command is added
141 //! \param [in] params
142 //! Parameters used to populate the requested command
143 //! \return MOS_STATUS
144 //! MOS_STATUS_SUCCESS if success, else fail reason
145 //!
146 MOS_STATUS AddMiLoadRegisterImmCmd(
147 PRENDERHAL_INTERFACE pRenderHal,
148 PMOS_COMMAND_BUFFER pCmdBuffer,
149 PMHW_MI_LOAD_REGISTER_IMM_PARAMS params);
150
151 MOS_STATUS SendGenericPrologCmd(
152 PRENDERHAL_INTERFACE pRenderHal,
153 PMOS_COMMAND_BUFFER pCmdBuffer,
154 PMHW_GENERIC_PROLOG_PARAMS pParams,
155 MHW_MI_MMIOREGISTERS* pMmioReg = nullptr);
156
157 MOS_STATUS CreateMhwInterfaces(
158 PRENDERHAL_INTERFACE pRenderHal,
159 PMOS_INTERFACE pOsInterface);
160
161 MOS_STATUS On1stLevelBBStart(
162 PRENDERHAL_INTERFACE pRenderHal,
163 PMOS_COMMAND_BUFFER pCmdBuffer,
164 PMOS_CONTEXT pOsContext,
165 uint32_t gpuContextHandle,
166 MHW_MI_MMIOREGISTERS *pMmioReg);
167
168 MOS_STATUS OnDispatch(
169 PRENDERHAL_INTERFACE pRenderHal,
170 PMOS_COMMAND_BUFFER pCmdBuffer,
171 PMOS_INTERFACE pOsInterface,
172 MHW_MI_MMIOREGISTERS *pMmioReg);
173
174 MOS_STATUS CreatePerfProfiler(
175 PRENDERHAL_INTERFACE pRenderHal);
176
177 MOS_STATUS DestroyPerfProfiler(
178 PRENDERHAL_INTERFACE pRenderHal);
179
180 MOS_STATUS AddPerfCollectStartCmd(
181 PRENDERHAL_INTERFACE pRenderHal,
182 MOS_INTERFACE *osInterface,
183 MOS_COMMAND_BUFFER *cmdBuffer);
184
185 MOS_STATUS StartPredicate(
186 PRENDERHAL_INTERFACE pRenderHal,
187 PMOS_COMMAND_BUFFER cmdBuffer);
188
189 MOS_STATUS StopPredicate(
190 PRENDERHAL_INTERFACE pRenderHal,
191 PMOS_COMMAND_BUFFER cmdBuffer);
192
193 MOS_STATUS AddPerfCollectEndCmd(
194 PRENDERHAL_INTERFACE pRenderHal,
195 PMOS_INTERFACE pOsInterface,
196 MOS_COMMAND_BUFFER *cmdBuffer);
197
198 MOS_STATUS AddMediaVfeCmd(
199 PRENDERHAL_INTERFACE pRenderHal,
200 PMOS_COMMAND_BUFFER pCmdBuffer,
201 MHW_VFE_PARAMS *params);
202
203 MOS_STATUS AddMediaStateFlush(
204 PRENDERHAL_INTERFACE pRenderHal,
205 PMOS_COMMAND_BUFFER pCmdBuffer,
206 MHW_MEDIA_STATE_FLUSH_PARAM *params);
207
208 MOS_STATUS AddMiBatchBufferEnd(
209 PRENDERHAL_INTERFACE pRenderHal,
210 PMOS_COMMAND_BUFFER pCmdBuffer,
211 PMHW_BATCH_BUFFER batchBuffer);
212
213 MOS_STATUS AddMediaObjectWalkerCmd(
214 PRENDERHAL_INTERFACE pRenderHal,
215 PMOS_COMMAND_BUFFER pCmdBuffer,
216 PMHW_WALKER_PARAMS params);
217
218 MOS_STATUS AddGpGpuWalkerStateCmd(
219 PRENDERHAL_INTERFACE pRenderHal,
220 PMOS_COMMAND_BUFFER pCmdBuffer,
221 PMHW_GPGPU_WALKER_PARAMS params);
222
223 MOS_STATUS AllocateHeaps(
224 PRENDERHAL_INTERFACE pRenderHal,
225 MHW_STATE_HEAP_SETTINGS MhwStateHeapSettings);
226
227 PMHW_STATE_HEAP_INTERFACE GetStateHeapInterface(
228 PRENDERHAL_INTERFACE pRenderHal);
229
230 MOS_STATUS DestoryMhwInterface(
231 PRENDERHAL_INTERFACE pRenderHal);
232
233 MOS_STATUS AddMediaCurbeLoadCmd(
234 PRENDERHAL_INTERFACE pRenderHal,
235 PMOS_COMMAND_BUFFER pCmdBuffer,
236 PMHW_CURBE_LOAD_PARAMS params);
237
238 MOS_STATUS AddMediaIDLoadCmd(
239 PRENDERHAL_INTERFACE pRenderHal,
240 PMOS_COMMAND_BUFFER pCmdBuffer,
241 PMHW_ID_LOAD_PARAMS params);
242
243 bool IsPreemptionEnabled(
244 PRENDERHAL_INTERFACE pRenderHal);
245
246 void GetSamplerResolutionAlignUnit(
247 PRENDERHAL_INTERFACE pRenderHal,
248 bool isAVSSampler,
249 uint32_t &widthAlignUnit,
250 uint32_t &heightAlignUnit);
251
252 PMHW_RENDER_ENGINE_CAPS GetHwCaps(
253 PRENDERHAL_INTERFACE pRenderHal);
254
255 bool IsComputeContextInUse(
256 PRENDERHAL_INTERFACE pRenderHal) override;
257
258 //!
259 //! \brief Check if Sampler128Elements is supported
260 //! \return true of false
261 //!
262 bool IsSampler128ElementsSupported() override;
263
264 //!
265 //! \brief Checks how per thread scratch space size bits in VFE state are interpreted by HW
266 //! \details For BDW GT1/2/3 A0 steppings, per thread scratch space size in VFE state
267 //! is 11 bits indicating [2k bytes, 2 Mbytes]: 0=2k, 1=4k, 2=8k ... 10=2M
268 //! BDW+ excluding A0 step is 12 bits indicating [1k bytes, 2 Mbytes]: 0=1k, 1=2k, 2=4k, 3=8k ... 11=2M
269 //! \param PRENDERHAL_INTERFACE pRenderHal
270 //! [in] Pointer to RenderHal interface
271 //! \return true if BDW A0 stepping, false otherwise
272 //!
273 bool PerThreadScratchSpaceStart2K(PRENDERHAL_INTERFACE pRenderHal) override;
274
275 //!
276 //! \brief Checks how per thread scratch space size bits in VFE state are interpreted by HW.
277 //! \details per thread scratch space size can be 2^n (n >= 6) bytes.
278 //! \param PRENDERHAL_INTERFACE pRenderHal
279 //! [in] Pointer to RenderHal interface
280 //! \return bool.
281 //!
282 bool PerThreadScratchSpaceStart64Byte(RENDERHAL_INTERFACE *renderHal) override;
283
284 //!
285 //! \brief Encode SLM Size for Interface Descriptor
286 //! \details Setup SLM size
287 //! \param uint32_t SLMSize
288 //! [in] SLM size
289 //! \return encoded output
290 //!
291 uint32_t EncodeSLMSize(uint32_t SLMSize) override;
292
293 //!
294 //! \brief Calculate Preferred Slm Allocation Size for Interface Descriptor
295 //! \details Setup Preferred Slm Allocation Size size
296 //! \param PRENDERHAL_INTERFACE pRenderHal
297 //! [in] Pointer to RenderHal interface
298 //! \param uint32_t SLMSize
299 //! [in] SLM size
300 //! \return Preferred Slm Allocation Size
301 //!
302 virtual MOS_STATUS CalculatePreferredSlmAllocationSizeFromSlmSize(
303 RENDERHAL_INTERFACE *renderHal,
304 uint32_t slmSize,
305 uint32_t numberOfThreadsPerThreadGroup,
306 uint32_t &perferedSlmAllocationSize);
307
308 //!
309 //! \brief Set Chroma Direction
310 //! \details Setup Chroma Direction for hpg_base
311 //! \param PRENDERHAL_INTERFACE pRenderHal
312 //! [in] Pointer to Hardware Interface
313 //! \param PRENDERHAL_SURFACE pRenderHalSurface
314 //! [in] Pointer to Render Hal Surface
315 //! \return uint8_t
316 //!
317 uint8_t SetChromaDirection(
318 PRENDERHAL_INTERFACE pRenderHal,
319 PRENDERHAL_SURFACE pRenderHalSurface) override;
320
321 //!
322 //! \brief Initialize the default surface type and advanced surface type per platform
323 //! \param PRENDERHAL_INTERFACE pRenderHal
324 //! [out] Pointer to PRENDERHAL_INTERFACE
325 //! \return void
326 //!
327 void InitSurfaceTypes(PRENDERHAL_INTERFACE pRenderHal) override;
328
329 //!
330 //! \brief Check if YV12 Single Pass is supported
331 //! \param PRENDERHAL_INTERFACE pRenderHal
332 //! [in] Pointer to Hardware Interface
333 //! \return true of false
334 //!
335 bool IsEnableYV12SinglePass(PRENDERHAL_INTERFACE pRenderHal) override;
336
337 //!
338 //! \brief Get the Size of AVS Sampler State
339 //! \param PRENDERHAL_INTERFACE pRenderHal
340 //! [in] Pointer to Hardware Interface
341 //! \return size
342 //!
343 uint32_t GetSizeSamplerStateAvs(PRENDERHAL_INTERFACE pRenderHal) override;
344
345 //!
346 //! \brief Set Power Option Status
347 //! \param [in] pRenderHal
348 //! Pointer to Hardware Interface
349 //! \param [in,out] pCmdBuffer
350 //! Pointer to Command Buffer
351 //! \return MOS_STATUS
352 //! MOS_STATUS_SUCCESS if success, else fail reason
353 //!
354 MOS_STATUS SetPowerOptionStatus(
355 PRENDERHAL_INTERFACE pRenderHal,
356 PMOS_COMMAND_BUFFER pCmdBuffer) override;
357
358 //!
359 //! \brief Set Composite Prolog CMD
360 //! \param [in] pRenderHal
361 //! Pointer to Hardware Interface
362 //! \param [in,out] pCmdBuffer
363 //! Pointer to Command Buffer
364 //! \return MOS_STATUS
365 //! MOS_STATUS_SUCCESS if success, else fail reason
366 //!
367 MOS_STATUS SetCompositePrologCmd(
368 PRENDERHAL_INTERFACE pRenderHal,
369 PMOS_COMMAND_BUFFER pCmdBuffer) override;
370
371 //!
372 //! \brief Send Compute Walker
373 //! \details Send Compute Walker
374 //! \param PRENDERHAL_INTERFACE pRenderHal
375 //! [in] Pointer to Hardware Interface Structure
376 //! \param PMOS_COMMAND_BUFFER pCmdBuffer
377 //! [in] Pointer to Command Buffer
378 //! \param PRENDERHAL_GPGPU_WALKER_PARAMS pGpGpuWalkerParams
379 //! [in] Pointer to GPGPU walker parameters
380 //! \return MOS_STATUS
381 //!
382 MOS_STATUS SendComputeWalker(
383 PRENDERHAL_INTERFACE pRenderHal,
384 PMOS_COMMAND_BUFFER pCmdBuffer,
385 PMHW_GPGPU_WALKER_PARAMS pGpGpuWalkerParams) override;
386
387 //!
388 //! \brief Send To 3DState Binding Table Pool Alloc
389 //! \details Send To 3DState Binding Table Pool Alloc
390 //! \param PRENDERHAL_INTERFACE pRenderHal
391 //! [in] Pointer to RenderHal Interface Structure
392 //! \param PMOS_COMMAND_BUFFER pCmdBuffer
393 //! [in] Pointer to Command Buffer
394 //! \return MOS_STATUS
395 //!
396 MOS_STATUS SendTo3DStateBindingTablePoolAlloc(
397 PRENDERHAL_INTERFACE pRenderHal,
398 PMOS_COMMAND_BUFFER pCmdBuffer) override;
399
400 //!
401 //! \brief Get Render Engine MMC Enable/Disable Flag
402 //! \param [in] pRenderHal
403 //! Pointer to Hardware Interface
404 //! \return MOS_STATUS
405 //! MOS_STATUS_SUCCESS if success, else fail reason
406 //!
407 MOS_STATUS IsRenderHalMMCEnabled(
408 PRENDERHAL_INTERFACE pRenderHal) override;
409
410 //!
411 //! \brief Check if Over ride is needed or not
412 //! \param [in] pRenderHal
413 //! Pointer to Hardware Interface
414 //! \param [in,out] pCmdBuffer
415 //! Pointer to Command Buffer
416 //! \param [in] pGenericPrologParam
417 //! Pointer to MHW generic prolog parameters
418 //! \return MOS_STATUS
419 //! MOS_STATUS_SUCCESS if success, else fail reason
420 //!
421 MOS_STATUS IsOvrdNeeded(
422 PRENDERHAL_INTERFACE pRenderHal,
423 PMOS_COMMAND_BUFFER pCmdBuffer,
424 PRENDERHAL_GENERIC_PROLOG_PARAMS pGenericPrologParams) override;
425
426 //!
427 //! \brief Allocates scratch space buffer.
428 //! \details A single scratch space buffer is allocated and used for all threads.
429 //! \param [in] perThreadScratchSpace
430 //! scratch space
431 //! \param [in] renderHal
432 //! Pointer to Hardware Interface
433 //! \return MOS_STATUS
434 //! MOS_STATUS_SUCCESS if success, else fail reason
435 //!
436 MOS_STATUS AllocateScratchSpaceBuffer(
437 uint32_t perThreadScratchSpace,
438 RENDERHAL_INTERFACE *renderHal) override;
439
440 //!
441 //! \brief Frees scratch space buffer.
442 //! \details A single scratch space buffer is allocated and used for all threads.
443 //! \param [in] renderHal
444 //! Pointer to Hardware Interface
445 //! \return MOS_STATUS
446 //! MOS_STATUS_SUCCESS if success, else fail reason
447 //!
448 MOS_STATUS FreeScratchSpaceBuffer(
449 RENDERHAL_INTERFACE *renderHal) override;
450
451 //!
452 //! \brief Get Surface Compression support caps
453 //! \param [in] format
454 //! surface format
455 //! \return bool
456 //! true or false
457 //!
458 virtual bool IsFormatMMCSupported(MOS_FORMAT format);
459
460 //!
461 //! \brief Is L8 format support
462 //! \return bool
463 //! true or false
464 //!
465 virtual bool IsL8FormatSupported();
466
467 std::shared_ptr<mhw::mi::Itf> GetMhwMiItf();
468
469 MHW_SETPAR_DECL_HDR(STATE_BASE_ADDRESS);
470
471 MHW_SETPAR_DECL_HDR(_3DSTATE_CHROMA_KEY);
472
473 MHW_SETPAR_DECL_HDR(STATE_SIP);
474
475 MHW_SETPAR_DECL_HDR(COMPUTE_WALKER);
476
477 MHW_SETPAR_DECL_HDR(_3DSTATE_BINDING_TABLE_POOL_ALLOC);
478
479 protected:
480
481 PRENDERHAL_INTERFACE m_renderHal = nullptr;
482 MediaFeatureManager *m_featureManager = nullptr;
483 PMHW_GPGPU_WALKER_PARAMS m_gpgpuWalkerParams = nullptr;
484 PMHW_ID_ENTRY_PARAMS m_interfaceDescriptorParams = nullptr;
485 bool m_renderHalMMCEnabled = false;
486 MOS_RESOURCE m_scratchSpaceResource;
487 std::shared_ptr<mhw::render::Itf> m_renderItf = nullptr;
488 std::shared_ptr<mhw::mi::Itf> m_miItf = nullptr;
489
490 MEDIA_CLASS_DEFINE_END(XRenderHal_Platform_Interface_Next)
491 };
492
493 #endif // __RENDERHAL_PLATFORM_INTERFACE_NEXT_H__