1 /*
2 * Copyright (c) 2009-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_g10.h
24 //! \brief
25 //!
26 //!
27 //! \file       renderhal_g10.h
28 //! \brief      header file of Gen10 hardware functions
29 //! \details    Gen10 hardware functions declare
30 //!
31 #ifndef __RENDERHAL_G10_H__
32 #define __RENDERHAL_G10_H__
33 
34 #include "renderhal_platform_interface.h"
35 #include "mhw_render_hwcmd_g10_X.h"
36 #include "mhw_state_heap_hwcmd_g10_X.h"
37 
38 //! \brief      for CNL GT2 VP and MDF
39 //!              SLM     URB     DC      RO      Rest/L3 Client Pool
40 //!               0      64      0       0       192 (KB chunks based on GT2)
41 #define RENDERHAL_L3_CACHE_CONFIG_CNTLREG_VALUE_G10_RENDERHAL (0xC0000040)
42 #define RENDERHAL_L3_CACHE_SLM_CONFIG_CNTLREG_VALUE_G10_RENDERHAL (0xA0000021)
43 #define RENDERHAL_SAMPLERS_AVS_G10          6
44 
45 extern const RENDERHAL_STATE_HEAP_SETTINGS g_cRenderHal_State_Heap_Settings_g10;
46 
47 class XRenderHal_Interface_g10 : public XRenderHal_Platform_Interface
48 {
49 public:
XRenderHal_Interface_g10()50     XRenderHal_Interface_g10() {}
~XRenderHal_Interface_g10()51     virtual ~XRenderHal_Interface_g10() {}
52 
53     //!
54     //! \brief    Setup Surface State
55     //! \details  Setup Surface States for Gen10
56     //! \param    PRENDERHAL_INTERFACE pRenderHal
57     //!           [in] Pointer to Hardware Interface Structure
58     //! \param    PRENDERHAL_SURFACE pRenderHalSurface
59     //!           [in] Pointer to Render Hal Surface
60     //! \param    PRENDERHAL_SURFACE_STATE_PARAMS pParams
61     //!           [in] Pointer to Surface State Params
62     //! \param    int32_t *piNumEntries
63     //!           [out] Pointer to Number of Surface State Entries (Num Planes)
64     //! \param    PRENDERHAL_SURFACE_STATE_ENTRY * ppSurfaceEntries
65     //!           [out] Array of Surface State Entries
66     //! \param    PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride
67     //!           [in] If not nullptr, provides adjustments to Y, UV plane offsets,
68     //!           used for kernel WA in a few cases. nullptr is the most common usage.
69     //! \return   MOS_STATUS
70     //!
71     MOS_STATUS SetupSurfaceState(
72         PRENDERHAL_INTERFACE            pRenderHal,
73         PRENDERHAL_SURFACE              pRenderHalSurface,
74         PRENDERHAL_SURFACE_STATE_PARAMS pParams,
75         int32_t                         *piNumEntries,
76         PRENDERHAL_SURFACE_STATE_ENTRY  *ppSurfaceEntries,
77         PRENDERHAL_OFFSET_OVERRIDE      pOffsetOverride);
78 
79     //!
80     //! \brief    Check if Sampler128Elements is supported
81     //! \return   true of false
82     //!
IsSampler128ElementsSupported()83     virtual inline bool IsSampler128ElementsSupported() { return true; }
84 
85     //!
86     //! \brief      Checks how per thread scratch space size bits in VFE state are interpreted by HW
87     //! \details    For BDW GT1/2/3 A0 steppings, per thread scratch space size in VFE state
88     //!             is 11 bits indicating [2k bytes, 2 Mbytes]: 0=2k, 1=4k, 2=8k � 10=2M
89     //!             BDW+ excluding A0 step is 12 bits indicating [1k bytes, 2 Mbytes]: 0=1k, 1=2k, 2=4k, 3=8k � 11=2M
90     //! \param      PRENDERHAL_INTERFACE pRenderHal
91     //!             [in]    Pointer to RenderHal interface
92     //! \return     true if BDW A0 stepping, false otherwise
93     //!
PerThreadScratchSpaceStart2K(PRENDERHAL_INTERFACE pRenderHal)94     bool PerThreadScratchSpaceStart2K(PRENDERHAL_INTERFACE pRenderHal)
95     {
96         MOS_UNUSED(pRenderHal);
97         return true;
98     }
99 
100     //!
101     //! \brief    Encode SLM Size for Interface Descriptor
102     //! \details  Setup SLM size
103     //! \param    uint32_t SLMSize
104     //!           [in] SLM size in 1K
105     //! \return   encoded output
106     //!
107     uint32_t EncodeSLMSize(uint32_t SLMSize);
108 
109     //!
110     //! \brief    Set Chroma Direction
111     //! \details  Setup Chroma Direction for G10
112     //! \param    PRENDERHAL_INTERFACE pRenderHal
113     //!           [in]  Pointer to Hardware Interface
114     //! \param    PRENDERHAL_SURFACE pRenderHalSurface
115     //!           [in]  Pointer to Render Hal Surface
116     //! \return   uint8_t
117     //!
118     uint8_t SetChromaDirection(
119         PRENDERHAL_INTERFACE pRenderHal,
120         PRENDERHAL_SURFACE   pRenderHalSurface);
121 
122     //!
123     //! \brief    Convert To Nano Seconds
124     //! \details  Convert to Nano Seconds
125     //! \param    PRENDERHAL_INTERFACE pRenderHal
126     //!           [in] Pointer to Hardware Interface Structure
127     //! \param    uint64_t iTicks
128     //!           [in] Ticks
129     //! \param    uint64_t *piNs
130     //!           [in] Nano Seconds
131     //! \return   void
132     //!
133     void ConvertToNanoSeconds(
134         PRENDERHAL_INTERFACE    pRenderHal,
135         uint64_t                iTicks,
136         uint64_t                *piNs);
137 
138     //!
139     //! \brief    Initialize the State Heap Settings per platform
140     //! \param    PRENDERHAL_INTERFACE    pRenderHal
141     //!           [out] Pointer to PRENDERHAL_INTERFACE
142     //! \return   void
143     //!
144     void InitStateHeapSettings(
145         PRENDERHAL_INTERFACE    pRenderHal);
146 
147     //!
148     //! \brief    Initialize the default surface type and advanced surface type  per platform
149     //! \param    PRENDERHAL_INTERFACE    pRenderHal
150     //!           [out] Pointer to PRENDERHAL_INTERFACE
151     //! \return   void
152     //!
153     void InitSurfaceTypes(
154         PRENDERHAL_INTERFACE    pRenderHal);
155 
156     //!
157     //! \brief    Check if YV12 Single Pass is supported
158     //! \param    PRENDERHAL_INTERFACE    pRenderHal
159     //!           [in]  Pointer to Hardware Interface
160     //! \return   true of false
161     //!
IsEnableYV12SinglePass(PRENDERHAL_INTERFACE pRenderHal)162     inline bool IsEnableYV12SinglePass(
163         PRENDERHAL_INTERFACE    pRenderHal)
164     {
165         return MEDIA_IS_WA(pRenderHal->pWaTable, WaEnableYV12BugFixInHalfSliceChicken7);
166     }
167 
168     //!
169     //! \brief    Get the Size of AVS Sampler State
170     //! \param    PRENDERHAL_INTERFACE    pRenderHal
171     //!           [in]  Pointer to Hardware Interface
172     //! \return   size
173     //!
GetSizeSamplerStateAvs(PRENDERHAL_INTERFACE pRenderHal)174     inline uint32_t GetSizeSamplerStateAvs(
175         PRENDERHAL_INTERFACE    pRenderHal)
176     {
177         return 2 * pRenderHal->pHwSizes->dwSizeSamplerStateAvs; // Kernel using 1,3,5 sampler index for AVS sampler state.
178     }
179 
180     //!
181     //! \brief    Enables L3 cacheing flag and sets related registers/values
182     //! \param    PRENDERHAL_INTERFACE    pRenderHal
183     //!           [in]  Pointer to Hardware Interface
184     //! \param    pCacheSettings
185     //!           [in] L3 Cache Configurations
186     //! \return   MOS_STATUS
187     //!           MOS_STATUS_SUCCESS if success, else fail reason
188     //!
189     virtual MOS_STATUS EnableL3Caching(
190         PRENDERHAL_INTERFACE         pRenderHal,
191         PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings);
192 
193     //!
194     //! \brief    Get offset and/or pointer to sampler state
195     //! \details  Get offset and/or pointer to sampler state in General State Heap
196     //! \param    PRENDERHAL_INTERFACE pRenderHal
197     //!           [in] Pointer to RenderHal Interface
198     //! \param    int32_t iMediaID
199     //!           [in] Media ID associated with sampler
200     //! \param    int32_t iSamplerID
201     //!           [in] Sampler ID
202     //! \param    uint32_t *pdwSamplerOffset
203     //!           [out] optional; offset of sampler state from GSH base
204     //! \param    void  **ppSampler
205     //!           [out] optional; pointer to sampler state in GSH
206     //! \return   MOS_STATUS
207     //!
208     virtual MOS_STATUS GetSamplerOffsetAndPtr_DSH(
209         PRENDERHAL_INTERFACE     pRenderHal,
210         int32_t                  iMediaID,
211         int32_t                  iSamplerID,
212         PMHW_SAMPLER_STATE_PARAM pSamplerParams,
213         uint32_t                 *pdwSamplerOffset,
214         void                    **ppSampler);
215 
216     //!
217     //! \brief      Initialize the DSH Settings
218     //! \details    Initialize the structure DynamicHeapSettings in pRenderHal
219     //! \param      PRENDERHAL_INTERFACE pRenderHal
220     //!             [in]    Pointer to HW interface
221     //! \return     void
222     //!
223     virtual void InitDynamicHeapSettings(
224         PRENDERHAL_INTERFACE  pRenderHal);
225 
226     //!
227     //! \brief      Get the pointer to the MHW_VFE_PARAMS
228     //! \return     MHW_VFE_PARAMS*
229     //!             pointer to the MHW_VFE_PARAMS
230     //!
GetVfeStateParameters()231     virtual MHW_VFE_PARAMS* GetVfeStateParameters() { return &m_vfeStateParams; }
232 
233     //!
234     //! \brief    Set Power Option Status
235     //! \param    [in] pRenderHal
236     //!           Pointer to Hardware Interface
237     //! \param    [in,out] pCmdBuffer
238     //!           Pointer to Command Buffer
239     //! \return   MOS_STATUS
240     //!           MOS_STATUS_SUCCESS if success, else fail reason
241     //!
242     virtual MOS_STATUS SetPowerOptionStatus(
243         PRENDERHAL_INTERFACE         pRenderHal,
244         PMOS_COMMAND_BUFFER          pCmdBuffer);
245 
246     //!
247     //! \brief      Set L3 cache override config parameters
248     //! \param      [in] pRenderHal
249     //!             Pointer to RenderHal Interface Structure
250     //! \param      [in,out] pCacheSettings
251     //!             Pointer to pCacheSettings
252     //! \param      [in] bEnableSLM
253     //!             Flag to enable SLM
254     //! \return     MOS_STATUS
255     //!             MOS_STATUS_SUCCESS if success. Error code otherwise
256     //!
257     virtual MOS_STATUS SetCacheOverrideParams(
258         PRENDERHAL_INTERFACE            pRenderHal,
259         PRENDERHAL_L3_CACHE_SETTINGS    pCacheSettings,
260         bool                            bEnableSLM);
261 
262     //! \brief      Get the size of Render Surface State Command
263     //! \return     size_t
264     //!             the size of render surface state command
265     virtual size_t GetSurfaceStateCmdSize();
266 
267     //! \brief      Get the address of the ith Palette Data
268     //! \param      [in] i
269     //!             Index of the palette data
270     //! \return     void *
271     //!             address of the ith palette data table
GetPaletteDataAddress(int i)272     virtual void* GetPaletteDataAddress(int i) {return &m_paletteData[i];}
273 
274     //! \brief      Get the size of Binding Table State Command
275     //! \return     size_t
276     //!             the size of binding table state command
GetBTStateCmdSize()277     virtual size_t GetBTStateCmdSize() {return mhw_state_heap_g10_X::BINDING_TABLE_STATE_CMD::byteSize;}
278 
279     //! \brief    Check if compute context in use
280     //! \param    PRENDERHAL_INTERFACE    pRenderHal
281     //!           [in]  Pointer to Hardware Interface
282     //! \return   true of false
IsComputeContextInUse(PRENDERHAL_INTERFACE pRenderHal)283     virtual bool IsComputeContextInUse(PRENDERHAL_INTERFACE pRenderHal)
284     {
285         MOS_UNUSED(pRenderHal);
286         return false;
287     }
288 protected:
289     MHW_VFE_PARAMS               m_vfeStateParams;
290     mhw_render_g10_X::PALETTE_ENTRY_CMD
291                                  m_paletteData[RENDERHAL_PALETTE_MAX][RENDERHAL_PALETTE_ENTRIES_MAX];
292 };
293 
294 #endif // __RENDERHAL_G10_H__
295