1 /*===================== begin_copyright_notice ==================================
2
3 * Copyright (c) 2024, Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22
23 ======================= end_copyright_notice ==================================*/
24 //!
25 //! \file renderhal_xe2_hpg_next.cpp
26 //! \brief implementation of Gen12_9 hardware functions
27 //! \details Render functions
28 //!
29
30 #include "renderhal.h"
31 #include "renderhal_xe2_hpg_next.h"
32 #include "vp_utils.h"
33 #include "media_feature.h"
34 #include "media_packet.h"
35
36 //!
37 //! \brief GSH settings for Xe2_hpg
38 //!
39 #define RENDERHAL_SAMPLERS_AVS_XE2_HPG 0
40 #define RENDERHAL_SSH_SURFACES_PER_BT_XE2_HPG 80
41 #define ENLARGE_KERNEL_COUNT_XE2_HPG RENDERHAL_KERNEL_COUNT * 3
42 #define ENLARGE_KERNEL_HEAP_XE2_HPG RENDERHAL_KERNEL_HEAP * 3
43 #define ENLARGE_CURBE_SIZE_XE2_HPG RENDERHAL_CURBE_SIZE * 16
44
45 extern const RENDERHAL_STATE_HEAP_SETTINGS g_cRenderHal_State_Heap_Settings_xe2_hpg =
46 {
47 // Global GSH Allocation parameters
48 RENDERHAL_SYNC_SIZE, //!< iSyncSize
49
50 // Media State Allocation parameters
51 RENDERHAL_MEDIA_STATES, //!< iMediaStateHeaps - Set by Initialize
52 RENDERHAL_MEDIA_IDS, //!< iMediaIDs
53 RENDERHAL_CURBE_SIZE, //!< iCurbeSize
54 RENDERHAL_SAMPLERS, //!< iSamplers
55 RENDERHAL_SAMPLERS_AVS_XE2_HPG, //!< iSamplersAVS
56 RENDERHAL_SAMPLERS_VA, //!< iSamplersVA
57 RENDERHAL_KERNEL_COUNT, //!< iKernelCount
58 RENDERHAL_KERNEL_HEAP, //!< iKernelHeapSize
59 RENDERHAL_KERNEL_BLOCK_SIZE, //!< iKernelBlockSize
60
61 // Media VFE/ID configuration, limits
62 0, //!< iPerThreadScratchSize
63 RENDERHAL_MAX_SIP_SIZE, //!< iSipSize
64
65 // Surface State Heap Settings
66 RENDERHAL_SSH_INSTANCES, //!< iSurfaceStateHeaps
67 RENDERHAL_SSH_BINDING_TABLES, //!< iBindingTables
68 RENDERHAL_SSH_SURFACE_STATES, //!< iSurfaceStates
69 RENDERHAL_SSH_SURFACES_PER_BT, //!< iSurfacesPerBT
70 RENDERHAL_SSH_BINDING_TABLE_ALIGN, //!< iBTAlignment
71 MOS_CODEC_RESOURCE_USAGE_BEGIN_CODEC //!< heapUsageType
72 };
73
74 extern const RENDERHAL_ENLARGE_PARAMS g_cRenderHal_Enlarge_State_Heap_Settings_Adv_xe2_hpg =
75 {
76 RENDERHAL_SSH_BINDING_TABLES_MAX, //!< iBindingTables
77 RENDERHAL_SSH_SURFACE_STATES_MAX, //!< iSurfaceStates
78 RENDERHAL_SSH_SURFACES_PER_BT_XE2_HPG, //!< iSurfacesPerBT
79 ENLARGE_KERNEL_COUNT_XE2_HPG, //!< iKernelCount
80 ENLARGE_KERNEL_HEAP_XE2_HPG, //!< iKernelHeapSize
81 ENLARGE_CURBE_SIZE_XE2_HPG //!< iCurbeSize
82 };
83
IsRenderHalMMCEnabled(PRENDERHAL_INTERFACE pRenderHal)84 MOS_STATUS XRenderHal_Interface_Xe2_Hpg_Next::IsRenderHalMMCEnabled(
85 PRENDERHAL_INTERFACE pRenderHal)
86 {
87 VP_FUNC_CALL();
88
89 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
90 bool isMMCEnabled = false;
91
92 MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal);
93
94 // Read user feature key to set MMC for Fast Composition surfaces
95 #if defined(LINUX) && (!defined(WDDM_LINUX))
96 isMMCEnabled = !MEDIA_IS_WA(pRenderHal->pWaTable, WaDisableVPMmc) || !MEDIA_IS_WA(pRenderHal->pWaTable, WaDisableCodecMmc);
97 #else
98 isMMCEnabled = true; // turn on MMC
99 #endif
100
101 #if (_DEBUG || _RELEASE_INTERNAL)
102 if (pRenderHal->userSettingPtr != nullptr)
103 {
104 // Read reg key to set MMC for Fast Composition surfaces
105 ReadUserSettingForDebug(
106 pRenderHal->userSettingPtr,
107 isMMCEnabled,
108 __MEDIA_USER_FEATURE_ENABLE_RENDER_ENGINE_MMC,
109 MediaUserSetting::Group::Device,
110 isMMCEnabled,
111 true);
112 }
113 #endif
114 m_renderHalMMCEnabled = isMMCEnabled && MEDIA_IS_SKU(pRenderHal->pSkuTable, FtrE2ECompression);
115 pRenderHal->isMMCEnabled = m_renderHalMMCEnabled;
116
117 return eStatus;
118 }
119
120 //! \brief Send To 3DState Binding Table Pool Alloc
121 //! \details Send To 3DState Binding Table Pool Alloc
122 //! \param PRENDERHAL_INTERFACE pRenderHal
123 //! [in] Pointer to RenderHal Interface Structure
124 //! \param PMOS_COMMAND_BUFFER pCmdBuffer
125 //! [in] Pointer to Command Buffer
126 //! \return MOS_STATUS
SendTo3DStateBindingTablePoolAlloc(PRENDERHAL_INTERFACE pRenderHal,PMOS_COMMAND_BUFFER pCmdBuffer)127 MOS_STATUS XRenderHal_Interface_Xe2_Hpg_Next::SendTo3DStateBindingTablePoolAlloc(
128 PRENDERHAL_INTERFACE pRenderHal,
129 PMOS_COMMAND_BUFFER pCmdBuffer)
130 {
131 VP_FUNC_CALL();
132
133 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
134
135 MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal);
136 MHW_RENDERHAL_CHK_NULL_RETURN(pCmdBuffer);
137 MHW_RENDERHAL_CHK_NULL_RETURN(m_renderItf);
138
139 auto &computerModeParams = m_renderItf->MHW_GETPAR_F(STATE_COMPUTE_MODE)();
140 computerModeParams = {};
141 computerModeParams.enableLargeGrf = true;
142 computerModeParams.forceEuThreadSchedulingMode = pRenderHal->euThreadSchedulingMode;
143 m_renderItf->MHW_ADDCMD_F(STATE_COMPUTE_MODE)(pCmdBuffer);
144
145 SETPAR_AND_ADDCMD(_3DSTATE_BINDING_TABLE_POOL_ALLOC, m_renderItf, pCmdBuffer);
146
147 return eStatus;
148 }
149
150 //!
151 //! \brief Initialize the State Heap Settings per platform
152 //! \param PRENDERHAL_STATE_HEAP_SETTINGS pSettings
153 //! [out] Pointer to PRENDERHAL_STATE_HEAP_SETTINGSStructure
154 //! \return void
155 //!
InitStateHeapSettings(PRENDERHAL_INTERFACE pRenderHal)156 void XRenderHal_Interface_Xe2_Hpg_Next::InitStateHeapSettings(
157 PRENDERHAL_INTERFACE pRenderHal)
158 {
159 MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal);
160 // Set State Heap settings for hpg_base
161 pRenderHal->StateHeapSettings = g_cRenderHal_State_Heap_Settings_xe2_hpg;
162 pRenderHal->enlargeStateHeapSettingsForAdv = g_cRenderHal_Enlarge_State_Heap_Settings_Adv_xe2_hpg;
163 }