1 /*===================== begin_copyright_notice ==================================
2
3 # Copyright (c) 2021, 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 vphal_xe_hpm.cpp
26 //! \brief Vphal Interface Definition
27 //! \details Vphal Interface Definition Including:
28 //! const and function
29 //!
30 #include "vphal_xe_hpm.h"
31 #include "vphal_renderer_xe_hpm.h"
32
33
34 //!
35 //! \brief Allocate VPHAL Resources
36 //! \details Allocate VPHAL Resources
37 //! - Allocate and initialize HW states
38 //! - Allocate and initialize renderer states
39 //! \param [in] pVpHalSettings
40 //! Pointer to VPHAL Settings
41 //! \return MOS_STATUS
42 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
43 //!
Allocate(const VphalSettings * pVpHalSettings)44 MOS_STATUS VphalStateXe_Hpm::Allocate(
45 const VphalSettings *pVpHalSettings)
46 {
47 MOS_STATUS eStatus;
48
49 VPHAL_PUBLIC_CHK_NULL(m_osInterface);
50 VPHAL_PUBLIC_CHK_NULL(pVpHalSettings);
51 VPHAL_PUBLIC_CHK_NULL(m_renderHal);
52
53 Mos_SetVirtualEngineSupported(m_osInterface, true);
54 m_osInterface->pfnVirtualEngineSupported(m_osInterface, true, true);
55
56 VPHAL_PUBLIC_CHK_STATUS(VphalState::Allocate(pVpHalSettings));
57
58 // Update MOCS
59 if (m_renderHal->pOsInterface && m_renderHal->pOsInterface->pfnCachePolicyGetMemoryObject && m_renderHal->pOsInterface->pfnGetGmmClientContext)
60 {
61 MHW_STATE_BASE_ADDR_PARAMS *pStateBaseParams = &m_renderHal->StateBaseAddressParams;
62 MEMORY_OBJECT_CONTROL_STATE StateMocs = m_renderHal->pOsInterface->pfnCachePolicyGetMemoryObject(MOS_MP_RESOURCE_USAGE_SurfaceState,
63 m_renderHal->pOsInterface->pfnGetGmmClientContext(m_renderHal->pOsInterface));
64
65 //update MOCS for Instruction Cache
66 pStateBaseParams->mocs4InstructionCache = StateMocs.DwordValue;
67 //update MOCS for General state
68 pStateBaseParams->mocs4GeneralState = StateMocs.DwordValue;
69 //update MOCS for Dynamic state
70 pStateBaseParams->mocs4DynamicState = StateMocs.DwordValue;
71 //update MOCS for Surface state
72 pStateBaseParams->mocs4SurfaceState = StateMocs.DwordValue;
73 //update MOCS for Indirect Object
74 pStateBaseParams->mocs4IndirectObjectBuffer = StateMocs.DwordValue;
75 //update MOCS for Stateless Dataport access
76 pStateBaseParams->mocs4StatelessDataport = StateMocs.DwordValue;
77 }
78
79 finish:
80 return eStatus;
81 }
82
83 //!
84 //! \brief Create instance of VphalRenderer
85 //! \details Create instance of VphalRenderer
86 //! \return MOS_STATUS
87 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
88 //!
CreateRenderer()89 MOS_STATUS VphalStateXe_Hpm::CreateRenderer()
90 {
91 MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
92
93 // Setup rendering interface functions
94 m_renderer = MOS_New(
95 VphalRendererXe_Hpm,
96 m_renderHal,
97 &eStatus);
98
99 if (m_renderer == nullptr)
100 {
101 return MOS_STATUS_NULL_POINTER;
102 }
103 else
104 {
105 if (eStatus != MOS_STATUS_SUCCESS)
106 {
107 MOS_Delete(m_renderer);
108 m_renderer = nullptr;
109 return eStatus;
110 }
111 else
112 {
113 m_renderer->SetStatusReportTable(&m_statusTable);
114 }
115 }
116
117 eStatus = m_renderer->InitKdllParam();
118 if (eStatus != MOS_STATUS_SUCCESS)
119 {
120 MOS_Delete(m_renderer);
121 m_renderer = nullptr;
122 return eStatus;
123 }
124
125 eStatus = m_renderer->AllocateRenderComponents(
126 m_veboxInterface,
127 m_sfcInterface);
128
129 return eStatus;
130 }
131