1 /*
2 * Copyright (c) 2017-2018, 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_g11.cpp
24 //! \brief implementation of Gen11 hardware functions
25 //! \details Render functions
26 //!
27
28 #include "renderhal.h"
29 #include "renderhal_g11.h"
30
31 //!
32 //! \brief GSH settings for G11
33 //!
34 extern const RENDERHAL_STATE_HEAP_SETTINGS g_cRenderHal_State_Heap_Settings_g11 =
35 {
36 // Global GSH Allocation parameters
37 RENDERHAL_SYNC_SIZE, //!< iSyncSize
38
39 // Media State Allocation parameters
40 RENDERHAL_MEDIA_STATES, //!< iMediaStateHeaps - Set by Initialize
41 RENDERHAL_MEDIA_IDS, //!< iMediaIDs
42 RENDERHAL_CURBE_SIZE, //!< iCurbeSize
43 RENDERHAL_SAMPLERS, //!< iSamplers
44 RENDERHAL_SAMPLERS_AVS_G11, //!< iSamplersAVS
45 RENDERHAL_SAMPLERS_VA, //!< iSamplersVA
46 RENDERHAL_KERNEL_COUNT, //!< iKernelCount
47 RENDERHAL_KERNEL_HEAP, //!< iKernelHeapSize
48 RENDERHAL_KERNEL_BLOCK_SIZE, //!< iKernelBlockSize
49
50 // Media VFE/ID configuration, limits
51 0, //!< iPerThreadScratchSize
52 RENDERHAL_MAX_SIP_SIZE, //!< iSipSize
53
54 // Surface State Heap Settings
55 RENDERHAL_SSH_INSTANCES, //!< iSurfaceStateHeaps
56 RENDERHAL_SSH_BINDING_TABLES, //!< iBindingTables
57 RENDERHAL_SSH_SURFACE_STATES, //!< iSurfaceStates
58 RENDERHAL_SSH_SURFACES_PER_BT, //!< iSurfacesPerBT
59 RENDERHAL_SSH_BINDING_TABLE_ALIGN //!< iBTAlignment
60 };
61
62
63 const uint32_t g_cLookup_RotationMode_g11[8] =
64 {
65 ROTATION_IDENTITY, // 0 - MHW_ROTATION_IDENTITY
66 ROTATION_90, // 1 - MHW_ROTATION_90
67 ROTATION_180, // 2 - MHW_ROTATION_180
68 ROTATION_270, // 3 - MHW_ROTATION_270
69 ROTATION_IDENTITY, // 4 - MHW_MIRROR_HORIZONTAL
70 ROTATION_180, // 5 - MHW_MIRROR_VERTICAL
71 ROTATION_270, // 6 - MHW_ROTATE_90_MIRROR_VERTICAL
72 ROTATION_90 // 7 - MHW_ROTATE_90_MIRROR_HORIZONTAL
73 };
74
75 #define RENDERHAL_NS_PER_TICK_RENDER_G11 (83.333) // Assume it same as SKL, 83.333 nano seconds per tick in render engine
76
77 //!
78 //! DSH State Heap settings for G11
79 //!
80 const RENDERHAL_DYN_HEAP_SETTINGS g_cRenderHal_DSH_Settings_g11 =
81 {
82 0x0080000, // dwDshInitialSize = 512MB
83 0x0080000, // dwDshSizeIncrement = 512kB
84 0x8000000, // dwDshMaximumSize = 128MB (all heaps)
85 0x0100000, // dwIshInitialSize = 1M
86 0x0040000, // dwIshSizeIncrement = 256kB
87 0x0400000, // dwIshMaximumSize = 4MB
88 16, // iMinMediaStates
89 256, // iMaxMediaStates
90 16, // iMinKernels
91 2048 // iMaxKernels
92 };
93
94 //!
95 //! \brief Setup Surface State
96 //! \details Setup Surface State for Gen11
97 //! \param PRENDERHAL_INTERFACE pRenderHal
98 //! [in] Pointer to Hardware Interface Structure
99 //! \param PRENDERHAL_SURFACE pRenderHalSurface
100 //! [in] Pointer to Render Hal Surface
101 //! \param PRENDERHAL_SURFACE_STATE_PARAMS pParams
102 //! [in] Pointer to Surface State Params
103 //! \param int32_t *piNumEntries
104 //! [out] Pointer to Number of Surface State Entries (Num Planes)
105 //! \param PRENDERHAL_SURFACE_STATE_ENTRY * ppSurfaceEntries
106 //! [out] Array of Surface State Entries
107 //! \param PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride
108 //! [in] Ignored (not used in Gen11)
109 //! \return MOS_STATUS
110 //!
SetupSurfaceState(PRENDERHAL_INTERFACE pRenderHal,PRENDERHAL_SURFACE pRenderHalSurface,PRENDERHAL_SURFACE_STATE_PARAMS pParams,int32_t * piNumEntries,PRENDERHAL_SURFACE_STATE_ENTRY * ppSurfaceEntries,PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride)111 MOS_STATUS XRenderHal_Interface_g11::SetupSurfaceState (
112 PRENDERHAL_INTERFACE pRenderHal,
113 PRENDERHAL_SURFACE pRenderHalSurface,
114 PRENDERHAL_SURFACE_STATE_PARAMS pParams,
115 int32_t *piNumEntries,
116 PRENDERHAL_SURFACE_STATE_ENTRY *ppSurfaceEntries,
117 PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride)
118 {
119 PRENDERHAL_SURFACE_STATE_ENTRY pSurfaceEntry;
120 PMOS_PLANE_OFFSET pPlaneOffset;
121 MHW_SURFACE_STATE_PARAMS SurfStateParams;
122 PMOS_SURFACE pSurface;
123 int32_t i;
124 uint32_t dwPixelsPerSampleUV;
125 uint32_t dwSurfaceSize;
126 MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
127
128 //-----------------------------------------
129 MHW_RENDERHAL_UNUSED(pOffsetOverride);
130 MHW_RENDERHAL_CHK_NULL(pRenderHal);
131 MHW_RENDERHAL_CHK_NULL(pRenderHalSurface);
132 MHW_RENDERHAL_CHK_NULL(pParams);
133 MHW_RENDERHAL_CHK_NULL(ppSurfaceEntries);
134 MHW_RENDERHAL_CHK_NULL(pRenderHal->pStateHeap);
135 MHW_RENDERHAL_CHK_NULL(pRenderHal->pHwSizes);
136 MHW_RENDERHAL_CHK_NULL(pRenderHal->pMhwStateHeap);
137 MHW_RENDERHAL_ASSERT(pRenderHalSurface->Rotation >= 0 && pRenderHalSurface->Rotation < 8);
138 //-----------------------------------------
139
140 dwSurfaceSize = pRenderHal->pHwSizes->dwSizeSurfaceState;
141
142 MOS_ZeroMemory(&SurfStateParams, sizeof(SurfStateParams));
143
144 // Get the Surface State Entries
145 MHW_RENDERHAL_CHK_STATUS(pRenderHal->pfnGetSurfaceStateEntries(
146 pRenderHal,
147 pRenderHalSurface,
148 pParams,
149 piNumEntries,
150 ppSurfaceEntries));
151
152 for (i = 0; i < *piNumEntries; i++)
153 {
154 // Pointer to surface state entry for current plane
155 pSurfaceEntry = ppSurfaceEntries[i];
156
157 pSurface = pSurfaceEntry->pSurface;
158
159 // Set the Surface State Offset from base of SSH
160 pSurfaceEntry->dwSurfStateOffset = pRenderHal->pStateHeap->iSurfaceStateOffset + // Offset to Base Of Current Surface State Area
161 pSurfaceEntry->iSurfStateID * dwSurfaceSize; // Offset to Surface State within the area
162
163 // Obtain the Pointer to the Surface state from SSH Buffer
164 SurfStateParams.pSurfaceState = pSurfaceEntry->pSurfaceState;
165 SurfStateParams.bUseAdvState = pSurfaceEntry->bAVS;
166 SurfStateParams.dwWidth = pSurfaceEntry->dwWidth;
167 SurfStateParams.dwHeight = pSurfaceEntry->dwHeight;
168 SurfStateParams.dwFormat = pSurfaceEntry->dwFormat;
169 SurfStateParams.dwPitch = pSurfaceEntry->dwPitch;
170 SurfStateParams.dwQPitch = pSurfaceEntry->dwQPitch;
171 SurfStateParams.bTiledSurface = pSurfaceEntry->bTiledSurface;
172 SurfStateParams.bTileWalk = pSurfaceEntry->bTileWalk;
173 SurfStateParams.dwCacheabilityControl = pRenderHal->pfnGetSurfaceMemoryObjectControl(pRenderHal, pParams);
174 SurfStateParams.bCompressionEnabled = pSurface->bIsCompressed;
175 SurfStateParams.bCompressionMode = (pSurface->CompressionMode == MOS_MMC_VERTICAL) ? 1 : 0;
176 SurfStateParams.RotationMode = g_cLookup_RotationMode_g11[pRenderHalSurface->Rotation];
177
178 if (pSurfaceEntry->bAVS)
179 {
180 SurfStateParams.bHalfPitchChroma = pSurfaceEntry->bHalfPitchChroma;
181 SurfStateParams.bInterleaveChroma = pSurfaceEntry->bInterleaveChroma;
182 SurfStateParams.UVPixelOffsetUDirection = pSurfaceEntry->DirectionU;
183 SurfStateParams.UVPixelOffsetVDirection = pSurfaceEntry->DirectionV;
184
185 // On SNB+, when VDI Walker is enabled, Input surface width should be 16 pixel aligned
186 if (pParams->bWidth16Align)
187 {
188 SurfStateParams.dwWidth = MOS_ALIGN_CEIL(pSurfaceEntry->dwWidth, 16);
189 }
190
191 if (pSurfaceEntry->YUVPlane == MHW_U_PLANE) // AVS U plane
192 {
193 // Lockoffset is the offset from base address of Y plane to the origin of U/V plane.
194 // So, We can get XOffsetforU by Lockoffset % pSurface->dwPitch, and get YOffsetForU by Lockoffset / pSurface->dwPitch
195 SurfStateParams.dwXOffsetForU = (uint32_t)pSurface->UPlaneOffset.iLockSurfaceOffset % pSurface->dwPitch;
196 SurfStateParams.dwYOffsetForU = (uint32_t)pSurface->UPlaneOffset.iLockSurfaceOffset / pSurface->dwPitch;
197 SurfStateParams.dwXOffsetForV = 0;
198 SurfStateParams.dwYOffsetForV = 0;
199 SurfStateParams.iXOffset = pSurface->UPlaneOffset.iXOffset;
200 SurfStateParams.iYOffset = pSurface->UPlaneOffset.iYOffset;
201 }
202 else if (pSurfaceEntry->YUVPlane == MHW_V_PLANE) // AVS V plane
203 {
204 SurfStateParams.dwXOffsetForU = 0;
205 SurfStateParams.dwYOffsetForU = 0;
206 SurfStateParams.dwXOffsetForV = (uint32_t)pSurface->VPlaneOffset.iLockSurfaceOffset % pSurface->dwPitch;
207 SurfStateParams.dwYOffsetForV = (uint32_t)pSurface->VPlaneOffset.iLockSurfaceOffset / pSurface->dwPitch;
208 SurfStateParams.iXOffset = pSurface->VPlaneOffset.iXOffset;
209 SurfStateParams.iYOffset = pSurface->VPlaneOffset.iYOffset;
210 }
211 else // AVS/DNDI Y plane
212 {
213 SurfStateParams.dwXOffsetForU = pSurfaceEntry->wUXOffset;
214 SurfStateParams.dwYOffsetForU = pSurfaceEntry->wUYOffset;
215 SurfStateParams.dwXOffsetForV = pSurfaceEntry->wVXOffset;
216 SurfStateParams.dwYOffsetForV = pSurfaceEntry->wVYOffset;
217 SurfStateParams.iXOffset = 0;
218 SurfStateParams.iYOffset = pSurface->YPlaneOffset.iYOffset;
219 }
220 if (pRenderHalSurface->bInterlacedScaling)
221 {
222 SurfStateParams.bVerticalLineStrideOffset = pSurfaceEntry->bVertStrideOffs;
223 SurfStateParams.bVerticalLineStride = pSurfaceEntry->bVertStride;
224 }
225 }
226 else // 2D/3D Surface (non-AVS)
227 {
228 SurfStateParams.SurfaceType3D = (pSurface->dwDepth > 1) ?
229 GFX3DSTATE_SURFACETYPE_3D :
230 GFX3DSTATE_SURFACETYPE_2D;
231 SurfStateParams.dwDepth = MOS_MAX(1, pSurface->dwDepth);
232 SurfStateParams.bVerticalLineStrideOffset = pSurfaceEntry->bVertStrideOffs;
233 SurfStateParams.bVerticalLineStride = pSurfaceEntry->bVertStride;
234 SurfStateParams.bHalfPitchChroma = pSurfaceEntry->bHalfPitchChroma;
235
236 // Setup surface g9 surface state
237 if (pSurfaceEntry->YUVPlane == MHW_U_PLANE ||
238 pSurfaceEntry->YUVPlane == MHW_V_PLANE)
239 {
240 pPlaneOffset = (pSurfaceEntry->YUVPlane == MHW_U_PLANE) ?
241 &pSurface->UPlaneOffset : &pSurface->VPlaneOffset;
242
243 // Get Pixels Per Sample if we use dataport read
244 if(pParams->bWidthInDword_UV)
245 {
246 RenderHal_GetPixelsPerSample(pSurface->Format, &dwPixelsPerSampleUV);
247 }
248 else
249 {
250 // If the kernel uses sampler - do not change width (it affects coordinates)
251 dwPixelsPerSampleUV = 1;
252 }
253
254 if(dwPixelsPerSampleUV == 1)
255 {
256 SurfStateParams.iXOffset = pPlaneOffset->iXOffset;
257 }
258 else
259 {
260 SurfStateParams.iXOffset = pPlaneOffset->iXOffset/sizeof(uint32_t);
261 }
262
263 SurfStateParams.iYOffset = pPlaneOffset->iYOffset;
264 }
265 else // Y plane
266 {
267 pPlaneOffset = &pSurface->YPlaneOffset;
268
269 SurfStateParams.iXOffset = pPlaneOffset->iXOffset/sizeof(uint32_t);
270 SurfStateParams.iYOffset = pPlaneOffset->iYOffset;
271
272 if((pSurfaceEntry->YUVPlane == MHW_Y_PLANE) &&
273 (pSurfaceEntry->dwFormat == MHW_GFX3DSTATE_SURFACEFORMAT_PLANAR_420_8))
274 {
275 if (pSurface->Format == Format_YV12)
276 {
277 SurfStateParams.bSeperateUVPlane = true;
278 SurfStateParams.dwXOffsetForU = 0;
279 SurfStateParams.dwYOffsetForU = pSurface->dwHeight * 2 + pSurface->dwHeight / 2;
280 SurfStateParams.dwXOffsetForV = 0;
281 SurfStateParams.dwYOffsetForV = pSurface->dwHeight * 2;
282 }
283 else
284 {
285 SurfStateParams.bSeperateUVPlane = false;
286 SurfStateParams.dwXOffsetForU = 0;
287 SurfStateParams.dwYOffsetForU = (uint32_t)((pSurface->UPlaneOffset.iSurfaceOffset - pSurface->YPlaneOffset.iSurfaceOffset) / pSurface->dwPitch) + pSurface->UPlaneOffset.iYOffset;
288 SurfStateParams.dwXOffsetForV = 0;
289 SurfStateParams.dwYOffsetForV = 0;
290 }
291 }
292
293 if((pSurfaceEntry->YUVPlane == MHW_Y_PLANE) &&
294 (pSurfaceEntry->dwFormat == MHW_GFX3DSTATE_SURFACEFORMAT_PLANAR_420_16))
295 {
296 SurfStateParams.bSeperateUVPlane = false;
297 SurfStateParams.dwXOffsetForU = 0;
298 SurfStateParams.dwYOffsetForU = (uint32_t)((pSurface->UPlaneOffset.iSurfaceOffset - pSurface->YPlaneOffset.iSurfaceOffset) / pSurface->dwPitch) + pSurface->UPlaneOffset.iYOffset;
299 SurfStateParams.dwXOffsetForV = 0;
300 SurfStateParams.dwYOffsetForV = 0;
301 }
302 }
303 }
304
305 // Call MHW to setup the Surface State Heap entry
306 MHW_RENDERHAL_CHK_STATUS(pRenderHal->pMhwStateHeap->SetSurfaceStateEntry(&SurfStateParams));
307
308 // Setup OS specific states
309 MHW_RENDERHAL_CHK_STATUS(pRenderHal->pfnSetupSurfaceStatesOs(pRenderHal, pParams, pSurfaceEntry));
310 }
311
312 eStatus = MOS_STATUS_SUCCESS;
313
314 finish:
315 return eStatus;
316 }
317
318 //!
319 //! \brief Encode SLM Size for Interface Descriptor
320 //! \details Setup SLM size
321 //! \param uint32_t SLMSize
322 //! [in] SLM size in 1K
323 //! \return encoded output
324 //!
EncodeSLMSize(uint32_t SLMSize)325 uint32_t XRenderHal_Interface_g11::EncodeSLMSize(uint32_t SLMSize)
326 {
327 uint32_t EncodedValue;
328 if (SLMSize <= 2)
329 {
330 EncodedValue = SLMSize;
331 }
332 else
333 {
334 EncodedValue = 0;
335 do
336 {
337 SLMSize >>= 1;
338 EncodedValue++;
339 } while (SLMSize);
340 }
341 return EncodedValue;
342 }
343
344 //!
345 //! \brief Convert To Nano Seconds
346 //! \details Convert to Nano Seconds
347 //! \param PRENDERHAL_INTERFACE pRenderHal
348 //! [in] Pointer to Hardware Interface Structure
349 //! \param uint64_t iTicks
350 //! [in] Ticks
351 //! \param uint64_t *piNs
352 //! [in] Nano Seconds
353 //! \return void
354 //!
ConvertToNanoSeconds(PRENDERHAL_INTERFACE pRenderHal,uint64_t iTicks,uint64_t * piNs)355 void XRenderHal_Interface_g11::ConvertToNanoSeconds(
356 PRENDERHAL_INTERFACE pRenderHal,
357 uint64_t iTicks,
358 uint64_t *piNs)
359 {
360 //-----------------------------
361 MHW_RENDERHAL_UNUSED(pRenderHal);
362 MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal);
363 MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(piNs);
364 //-----------------------------
365 *piNs = (uint64_t)(iTicks * RENDERHAL_NS_PER_TICK_RENDER_G11);
366 }
367
368 //!
369 //! \brief Setup Chroma direction for Gen11
370 //! \details Setup Chroma direction
371 //! \param PRENDERHAL_INTERFACE pRenderHal
372 //! [in] Pointer to HW Interface
373 //! \param PRENDERHAL_SURFACE pSurface
374 //! [in] Pointer to surface
375 //! \return uint8_t
376 //!
SetChromaDirection(PRENDERHAL_INTERFACE pRenderHal,PRENDERHAL_SURFACE pRenderHalSurface)377 uint8_t XRenderHal_Interface_g11::SetChromaDirection(
378 PRENDERHAL_INTERFACE pRenderHal,
379 PRENDERHAL_SURFACE pRenderHalSurface)
380 {
381 uint8_t Direction;
382 MHW_RENDERHAL_UNUSED(pRenderHal);
383
384 MHW_RENDERHAL_ASSERT(pRenderHal);
385 MHW_RENDERHAL_ASSERT(pRenderHalSurface);
386
387 Direction = 0;
388
389 if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_HORZ_CENTER)
390 {
391 Direction = CHROMA_SITING_UDIRECTION_CENTER;
392 }
393 else
394 {
395 Direction = CHROMA_SITING_UDIRECTION_LEFT;
396 }
397
398 // Combined U/V direction together in one uint8_t, 1 bit for U direction, 3 bits for V direction.
399 Direction = Direction << 3;
400
401 if (pRenderHalSurface->pDeinterlaceParams || pRenderHalSurface->bQueryVariance)
402 {
403 if ((pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD) ||
404 (pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD))
405 {
406 if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_TOP)
407 {
408 Direction |= CHROMA_SITING_VDIRECTION_1_2;
409 }
410 else if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_BOTTOM)
411 {
412 Direction |= CHROMA_SITING_VDIRECTION_1;
413 }
414 else
415 {
416 Direction |= CHROMA_SITING_VDIRECTION_3_4;
417 }
418 }
419 else if ((pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD) ||
420 (pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD))
421 {
422 if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_TOP)
423 {
424 Direction |= CHROMA_SITING_VDIRECTION_0;
425 }
426 else if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_BOTTOM)
427 {
428 Direction |= CHROMA_SITING_VDIRECTION_1_2;
429 }
430 else
431 {
432 Direction |= CHROMA_SITING_VDIRECTION_1_4;
433 }
434 }
435 }
436 else
437 {
438 if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_TOP)
439 {
440 Direction |= CHROMA_SITING_VDIRECTION_0;
441 }
442 else if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_BOTTOM)
443 {
444 Direction |= CHROMA_SITING_VDIRECTION_1;
445 }
446 else
447 {
448 Direction |= CHROMA_SITING_VDIRECTION_1_2;
449 }
450 }
451
452 return Direction;
453 }
454
455 //!
456 //! \brief Initialize the State Heap Settings per platform
457 //! \param PRENDERHAL_STATE_HEAP_SETTINGS pSettings
458 //! [out] Pointer to PRENDERHAL_STATE_HEAP_SETTINGSStructure
459 //! \return void
460 //!
InitStateHeapSettings(PRENDERHAL_INTERFACE pRenderHal)461 void XRenderHal_Interface_g11::InitStateHeapSettings(
462 PRENDERHAL_INTERFACE pRenderHal)
463 {
464 MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal);
465 // Set State Heap settings for g11
466 pRenderHal->StateHeapSettings = g_cRenderHal_State_Heap_Settings_g11;
467 }
468
469 //!
470 //! \brief Initialize the default surface type and advanced surface type per platform
471 //! \param PRENDERHAL_INTERFACE pRenderHal
472 //! [out] Pointer to PRENDERHAL_INTERFACE
473 //! \return void
474 //!
InitSurfaceTypes(PRENDERHAL_INTERFACE pRenderHal)475 void XRenderHal_Interface_g11::InitSurfaceTypes(
476 PRENDERHAL_INTERFACE pRenderHal)
477 {
478 MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal);
479 // Set default / advanced surface types
480 pRenderHal->SurfaceTypeDefault = RENDERHAL_SURFACE_TYPE_G10;
481 pRenderHal->SurfaceTypeAdvanced = RENDERHAL_SURFACE_TYPE_ADV_G10;
482 }
483
484 //!
485 //! \brief Enables L3 cacheing flag and sets related registers/values
486 //! \param PRENDERHAL_INTERFACE pRenderHal
487 //! [in] Pointer to Hardware Interface
488 //! \param pCacheSettings
489 //! [in] L3 Cache Configurations
490 //! \return MOS_STATUS
491 //! MOS_STATUS_SUCCESS if success, else fail reason
492 //!
EnableL3Caching(PRENDERHAL_INTERFACE pRenderHal,PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings)493 MOS_STATUS XRenderHal_Interface_g11::EnableL3Caching(
494 PRENDERHAL_INTERFACE pRenderHal,
495 PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings)
496 {
497 MOS_STATUS eStatus;
498 MHW_RENDER_ENGINE_L3_CACHE_SETTINGS_G11 mHwL3CacheConfig = {};
499 PMHW_RENDER_ENGINE_L3_CACHE_SETTINGS pCacheConfig;
500 MhwRenderInterface *pMhwRender;
501
502 MHW_RENDERHAL_CHK_NULL(pRenderHal);
503 pMhwRender = pRenderHal->pMhwRenderInterface;
504 MHW_RENDERHAL_CHK_NULL(pMhwRender);
505
506 if (nullptr == pCacheSettings)
507 {
508 MHW_RENDERHAL_CHK_STATUS(pMhwRender->EnableL3Caching(nullptr));
509 goto finish;
510 }
511
512 // customize the cache config for renderhal and let mhw_render overwrite it
513 pCacheConfig = &mHwL3CacheConfig;
514
515 pCacheConfig->dwCntlReg = RENDERHAL_L3_CACHE_CONFIG_CNTLREG_VALUE_G11_RENDERHAL;
516
517 // Override L3 cache configuration
518 if (pCacheSettings->bOverride)
519 {
520 if (pCacheSettings->bCntlRegOverride)
521 {
522 pCacheConfig->dwCntlReg = pCacheSettings->dwCntlReg;
523 }
524 }
525 MHW_RENDERHAL_CHK_STATUS(pMhwRender->EnableL3Caching(pCacheConfig));
526
527 finish:
528 return eStatus;
529 }
530
531 //!
532 //! \brief Get offset and/or pointer to sampler state
533 //! \details Get offset and/or pointer to sampler state in General State Heap
534 //! \param PRENDERHAL_INTERFACE pRenderHal
535 //! [in] Pointer to RenderHal Interface
536 //! \param int32_t iMediaID
537 //! [in] Media ID associated with sampler
538 //! \param int32_t iSamplerID
539 //! [in] Sampler ID
540 //! \param uint32_t *pdwSamplerOffset
541 //! [out] optional; offset of sampler state from GSH base
542 //! \param void **ppSampler
543 //! [out] optional; pointer to sampler state in GSH
544 //! \return MOS_STATUS
545 //!
GetSamplerOffsetAndPtr_DSH(PRENDERHAL_INTERFACE pRenderHal,int32_t iMediaID,int32_t iSamplerID,PMHW_SAMPLER_STATE_PARAM pSamplerParams,uint32_t * pdwSamplerOffset,void ** ppSampler)546 MOS_STATUS XRenderHal_Interface_g11::GetSamplerOffsetAndPtr_DSH(
547 PRENDERHAL_INTERFACE pRenderHal,
548 int32_t iMediaID,
549 int32_t iSamplerID,
550 PMHW_SAMPLER_STATE_PARAM pSamplerParams,
551 uint32_t *pdwSamplerOffset,
552 void **ppSampler)
553 {
554 PRENDERHAL_STATE_HEAP pStateHeap;
555 PRENDERHAL_DYNAMIC_STATE pDynamicState;
556 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
557 uint32_t dwSamplerIndirect;
558 uint32_t dwOffset;
559 MHW_SAMPLER_TYPE SamplerType;
560
561 MHW_RENDERHAL_CHK_NULL(pRenderHal);
562 MHW_RENDERHAL_CHK_NULL(pRenderHal->pStateHeap);
563 MHW_RENDERHAL_CHK_NULL(pRenderHal->pStateHeap->pCurMediaState);
564 MHW_RENDERHAL_CHK_NULL(pRenderHal->pHwSizes);
565
566 pStateHeap = pRenderHal->pStateHeap;
567 pDynamicState = pStateHeap->pCurMediaState->pDynamicState;
568
569 MHW_RENDERHAL_CHK_NULL(pDynamicState);
570
571 MHW_RENDERHAL_ASSERT(iMediaID < pDynamicState->MediaID.iCount);
572
573 dwOffset = iMediaID * pDynamicState->dwSizeSamplers; // Go to Media ID sampler offset
574
575 SamplerType = (pSamplerParams) ? pSamplerParams->SamplerType : MHW_SAMPLER_TYPE_3D;
576
577 switch (SamplerType)
578 {
579 case MHW_SAMPLER_TYPE_AVS:
580 MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->SamplerAVS.iCount);
581 dwOffset += pDynamicState->SamplerAVS.dwOffset + // Go to AVS sampler area
582 iSamplerID * MHW_SAMPLER_STATE_AVS_INC_G9; // 16: size of one element, 128 elements for SKL
583 break;
584
585 case MHW_SAMPLER_TYPE_CONV:
586 MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->SamplerConv.iCount);
587 dwOffset = pDynamicState->SamplerConv.dwOffset; // Goto Conv sampler base
588 if ( pSamplerParams->Convolve.ui8ConvolveType == 0 && pSamplerParams->Convolve.skl_mode )
589 { // 2D convolve
590 dwOffset += iSamplerID * MHW_SAMPLER_STATE_CONV_INC_G9; // 16: size of one element, 128 elements for SKL
591 }
592 else if ( pSamplerParams->Convolve.ui8ConvolveType == 1 )
593 { // 1D convolve
594 dwOffset += iSamplerID * MHW_SAMPLER_STATE_CONV_1D_INC_G9; // 16: size of one element, 8 elements for SKL
595 }
596 else
597 { // 1P convolve (same as gen8) and 2D convolve BDW mode
598 dwOffset += iSamplerID * MHW_SAMPLER_STATE_CONV_INC_G8; // 16: size of one element, 32: 32 entry
599 }
600 break;
601
602 case MHW_SAMPLER_TYPE_MISC:
603 MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->SamplerMisc.iCount);
604 dwOffset += pDynamicState->Sampler3D.dwOffset + // Goto sampler base
605 iSamplerID * MHW_SAMPLER_STATE_VA_INC; // 16: size of one element, 2: 2 entries
606 break;
607
608 case MHW_SAMPLER_TYPE_3D:
609 case MHW_SAMPLER_TYPE_VME:
610 default:
611 MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->Sampler3D.iCount);
612 dwSamplerIndirect = dwOffset;
613 dwOffset += pDynamicState->Sampler3D.dwOffset + // Go 3D Sampler base
614 iSamplerID * pRenderHal->pHwSizes->dwSizeSamplerState; // Goto to "samplerID" sampler state
615
616 if (pSamplerParams)
617 {
618 dwSamplerIndirect += pDynamicState->SamplerInd.dwOffset + // offset to indirect sampler area
619 iSamplerID * pRenderHal->pHwSizes->dwSizeSamplerIndirectState; // Goto to "samplerID" indirect state
620 pSamplerParams->Unorm.IndirectStateOffset = dwSamplerIndirect;
621 }
622
623 break;
624 }
625
626 if (pdwSamplerOffset)
627 {
628 *pdwSamplerOffset = dwOffset;
629 }
630
631 finish:
632 return eStatus;
633 }
634
635 //!
636 //! \brief Initialize the DSH Settings
637 //! \details Initialize the structure DynamicHeapSettings in pRenderHal
638 //! \param PRENDERHAL_INTERFACE pRenderHal
639 //! [in] Pointer to HW interface
640 //! \return void
641 //!
InitDynamicHeapSettings(PRENDERHAL_INTERFACE pRenderHal)642 void XRenderHal_Interface_g11::InitDynamicHeapSettings(
643 PRENDERHAL_INTERFACE pRenderHal)
644 {
645 MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal);
646
647 // Additional Dynamic State Heap settings for g11
648 pRenderHal->DynamicHeapSettings = g_cRenderHal_DSH_Settings_g11;
649 }
650
651 //!
652 //! \brief Set Power Option Status
653 //! \param [in] pRenderHal
654 //! Pointer to Hardware Interface
655 //! \param [in/out] pCmdBuffer
656 //! Pointer to Command Buffer
657 //! \return MOS_STATUS
658 //! MOS_STATUS_SUCCESS if success, else fail reason
659 //!
SetPowerOptionStatus(PRENDERHAL_INTERFACE pRenderHal,PMOS_COMMAND_BUFFER pCmdBuffer)660 MOS_STATUS XRenderHal_Interface_g11::SetPowerOptionStatus(
661 PRENDERHAL_INTERFACE pRenderHal,
662 PMOS_COMMAND_BUFFER pCmdBuffer)
663 {
664 // deprecated after enabled per-context SSEU.
665 return MOS_STATUS_SUCCESS;
666 }
667
668 //!
669 //! \brief Set L3 cache override config parameters
670 //! \param [in] pRenderHal
671 //! Pointer to RenderHal Interface Structure
672 //! \param [in,out] pCacheSettings
673 //! Pointer to pCacheSettings
674 //! \param [in] bEnableSLM
675 //! Flag to enable SLM
676 //! \return MOS_STATUS
677 //! MOS_STATUS_SUCCESS if success. Error code otherwise
678 //!
SetCacheOverrideParams(PRENDERHAL_INTERFACE pRenderHal,PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings,bool bEnableSLM)679 MOS_STATUS XRenderHal_Interface_g11::SetCacheOverrideParams(
680 PRENDERHAL_INTERFACE pRenderHal,
681 PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings,
682 bool bEnableSLM)
683 {
684 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
685
686 MHW_RENDERHAL_CHK_NULL(pCacheSettings);
687
688 pCacheSettings->dwCntlReg = RENDERHAL_L3_CACHE_CONFIG_CNTLREG_VALUE_G11_RENDERHAL;
689 pCacheSettings->bCntlRegOverride = true;
690
691 finish:
692 return eStatus;
693 }
694
695 //!
696 //! \brief Check if Override is needed or not
697 //! \param [in] pRenderHal
698 //! Pointer to Hardware Interface
699 //! \param [in,out] pCmdBuffer
700 //! Pointer to Command Buffer
701 //! \param [in] pGenericPrologParam
702 //! Pointer to MHW generic prolog parameters
703 //! \return MOS_STATUS
704 //! MOS_STATUS_SUCCESS if success, else fail reason
705 //!
IsOvrdNeeded(PRENDERHAL_INTERFACE pRenderHal,PMOS_COMMAND_BUFFER pCmdBuffer,PRENDERHAL_GENERIC_PROLOG_PARAMS pGenericPrologParams)706 MOS_STATUS XRenderHal_Interface_g11::IsOvrdNeeded(
707 PRENDERHAL_INTERFACE pRenderHal,
708 PMOS_COMMAND_BUFFER pCmdBuffer,
709 PRENDERHAL_GENERIC_PROLOG_PARAMS pGenericPrologParams)
710 {
711 PMOS_INTERFACE pOsInterface;
712 MOS_STATUS eStatus;
713 PMOS_CMD_BUF_ATTRI_VE pAttriVe;
714 PRENDERHAL_GENERIC_PROLOG_PARAMS_G11 pGenericPrologParamsG11;
715
716 MHW_RENDERHAL_CHK_NULL(pRenderHal);
717 MHW_RENDERHAL_CHK_NULL(pCmdBuffer);
718 MHW_RENDERHAL_CHK_NULL(pRenderHal->pOsInterface);
719
720 eStatus = MOS_STATUS_SUCCESS;
721 pOsInterface = pRenderHal->pOsInterface;
722 pAttriVe = (PMOS_CMD_BUF_ATTRI_VE)(pCmdBuffer->Attributes.pAttriVe);
723 pGenericPrologParamsG11 = dynamic_cast<PRENDERHAL_GENERIC_PROLOG_PARAMS_G11>(pGenericPrologParams);
724
725 if (pAttriVe)
726 {
727 if (pGenericPrologParamsG11)
728 {
729 // Split Frame
730 if (pGenericPrologParamsG11->VEngineHintParams.BatchBufferCount == 2 && pOsInterface->VEEnable)
731 {
732 pAttriVe->bUseVirtualEngineHint = true;
733 pAttriVe->VEngineHintParams = pGenericPrologParamsG11->VEngineHintParams;
734 }
735 }
736
737 #if (_DEBUG || _RELEASE_INTERNAL)
738 if (pOsInterface->bEnableDbgOvrdInVE)
739 {
740 if (pOsInterface->bVeboxScalabilityMode)
741 {
742 pAttriVe->VEngineHintParams.DebugOverride = true;
743 pAttriVe->VEngineHintParams.BatchBufferCount = 2;
744 pAttriVe->VEngineHintParams.EngineInstance[0] = 0;
745 pAttriVe->VEngineHintParams.EngineInstance[1] = 1;
746 }
747 else if (pOsInterface->eForceVebox)
748 {
749 pAttriVe->VEngineHintParams.DebugOverride = true;
750 pAttriVe->VEngineHintParams.BatchBufferCount = 1;
751 pAttriVe->VEngineHintParams.EngineInstance[0] = pOsInterface->eForceVebox - 1;
752 }
753 }
754 #endif
755 }
756
757 finish:
758 return eStatus;
759 };
760
761 //! \brief Get the size of Render Surface State Command
762 //! \return size_t
763 //! the size of render surface state command
GetSurfaceStateCmdSize()764 size_t XRenderHal_Interface_g11::GetSurfaceStateCmdSize()
765 {
766 return MOS_ALIGN_CEIL( MOS_MAX(mhw_state_heap_g11_X::RENDER_SURFACE_STATE_CMD::byteSize,
767 mhw_state_heap_g11_X::MEDIA_SURFACE_STATE_CMD::byteSize), MHW_SURFACE_STATE_ALIGN);
768 }
769
770