| 1 |
/* |
| 2 |
* Copyright (c) 2014-2017, 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 |
//! \file mhw_render_legacy.c |
| 23 |
//! \brief MHW interface for constructing commands for the render engine |
| 24 |
//! \details Impelements the functionalities common across all platforms for MHW_RENDER |
| 25 |
//! |
| 26 |
|
| 27 |
#include "mhw_render_legacy.h" |
| 28 |
|
| 29 |
//! |
| 30 |
//! \brief Allocates the MHW render interface internal parameters |
| 31 |
//! \details Internal MHW function to allocate all parameters needed for the |
| 32 |
//! render interface including the state heap interface |
| 33 |
//! \param MHW_STATE_HEAP_SETTINGS stateHeapSettings |
| 34 |
//! [in] Setting used to initialize the state heap interface |
| 35 |
//! \return MOS_STATUS |
| 36 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 37 |
//! |
| 38 |
MOS_STATUS MhwRenderInterface::AllocateHeaps( |
| 39 |
MHW_STATE_HEAP_SETTINGS stateHeapSettings) |
| 40 |
{ |
| 41 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 42 |
|
| 43 |
MHW_FUNCTION_ENTER; |
| 44 |
|
| 45 |
MHW_MI_CHK_NULL(m_stateHeapInterface); |
| 46 |
|
| 47 |
if ((stateHeapSettings.dwIshSize > 0 || |
| 48 |
stateHeapSettings.dwDshSize > 0 ) && |
| 49 |
stateHeapSettings.dwNumSyncTags > 0) |
| 50 |
{ |
| 51 |
MHW_MI_CHK_STATUS(m_stateHeapInterface->pfnCreate( |
| 52 |
&m_stateHeapInterface, |
| 53 |
stateHeapSettings)); |
| 54 |
} |
| 55 |
|
| 56 |
return eStatus; |
| 57 |
} |
| 58 |
|
| 59 |
void MhwRenderInterface::InitPlatformCaps( |
| 60 |
MEDIA_SYSTEM_INFO *gtSystemInfo) |
| 61 |
{ |
| 62 |
if (gtSystemInfo == nullptr) |
| 63 |
{ |
| 64 |
MHW_ASSERTMESSAGE("Invalid input pointer provided"); |
| 65 |
return; |
| 66 |
} |
| 67 |
|
| 68 |
MOS_ZeroMemory(&m_hwCaps, sizeof(MHW_RENDER_ENGINE_CAPS)); |
| 69 |
|
| 70 |
m_hwCaps.dwMaxUnormSamplers = MHW_RENDER_ENGINE_SAMPLERS_MAX; |
| 71 |
m_hwCaps.dwMaxAVSSamplers = MHW_RENDER_ENGINE_SAMPLERS_AVS_MAX; |
| 72 |
m_hwCaps.dwMaxBTIndex = MHW_RENDER_ENGINE_SSH_SURFACES_PER_BT_MAX - 1; |
| 73 |
m_hwCaps.dwMaxThreads = gtSystemInfo->ThreadCount; |
| 74 |
m_hwCaps.dwMaxMediaPayloadSize = MHW_RENDER_ENGINE_MEDIA_PALOAD_SIZE_MAX; |
| 75 |
m_hwCaps.dwMaxURBSize = MHW_RENDER_ENGINE_URB_SIZE_MAX; |
| 76 |
m_hwCaps.dwMaxURBEntries = MHW_RENDER_ENGINE_URB_ENTRIES_MAX; |
| 77 |
m_hwCaps.dwMaxSubslice = gtSystemInfo->MaxSubSlicesSupported; |
| 78 |
m_hwCaps.dwMaxEUIndex = MHW_RENDER_ENGINE_EU_INDEX_MAX; |
| 79 |
m_hwCaps.dwNumThreadsPerEU = (gtSystemInfo->EUCount > 0) ? |
| 80 |
gtSystemInfo->ThreadCount / gtSystemInfo->EUCount : 0; |
| 81 |
m_hwCaps.dwSizeRegistersPerThread = MHW_RENDER_ENGINE_SIZE_REGISTERS_PER_THREAD; |
| 82 |
|
| 83 |
m_hwCaps.dwMaxInterfaceDescriptorEntries = MHW_RENDER_ENGINE_INTERFACE_DESCRIPTOR_ENTRIES_MAX; |
| 84 |
m_hwCaps.dwMaxURBEntryAllocationSize = |
| 85 |
m_hwCaps.dwMaxCURBEAllocationSize = |
| 86 |
m_hwCaps.dwMaxURBSize - m_hwCaps.dwMaxInterfaceDescriptorEntries; |
| 87 |
} |
| 88 |
|
| 89 |
void MhwRenderInterface::InitPreemption() |
| 90 |
{ |
| 91 |
auto m_skuTable = m_osInterface->pfnGetSkuTable(m_osInterface); |
| 92 |
auto waTable = m_osInterface->pfnGetWaTable(m_osInterface); |
| 93 |
|
| 94 |
if (m_skuTable == nullptr || waTable == nullptr) |
| 95 |
{ |
| 96 |
MHW_ASSERTMESSAGE("Invalid SKU or WA table acquired"); |
| 97 |
return; |
| 98 |
} |
| 99 |
|
| 100 |
if (MEDIA_IS_SKU(m_skuTable, FtrMediaThreadGroupLevelPreempt) || |
| 101 |
MEDIA_IS_SKU(m_skuTable, FtrMediaMidBatchPreempt)) |
| 102 |
{ |
| 103 |
m_preemptionEnabled = true; |
| 104 |
|
| 105 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 106 |
MOS_USER_FEATURE_VALUE_DATA UserFeatureData; |
| 107 |
MOS_ZeroMemory(&UserFeatureData, sizeof(UserFeatureData)); |
| 108 |
MOS_UserFeature_ReadValue_ID( |
| 109 |
nullptr, |
| 110 |
__MEDIA_USER_FEATURE_VALUE_MEDIA_PREEMPTION_ENABLE_ID, |
| 111 |
&UserFeatureData, |
| 112 |
m_osInterface->pOsContext); |
| 113 |
m_preemptionEnabled = (UserFeatureData.i32Data) ? true : false; |
| 114 |
#endif |
| 115 |
} |
| 116 |
|
| 117 |
if (MEDIA_IS_SKU(m_skuTable, FtrPerCtxtPreemptionGranularityControl)) |
| 118 |
{ |
| 119 |
m_preemptionCntlRegisterOffset = MHW_RENDER_ENGINE_PREEMPTION_CONTROL_OFFSET; |
| 120 |
|
| 121 |
if (MEDIA_IS_SKU(m_skuTable, FtrMediaMidThreadLevelPreempt)) |
| 122 |
{ |
| 123 |
m_preemptionCntlRegisterValue = MHW_RENDER_ENGINE_MID_THREAD_PREEMPT_VALUE; |
| 124 |
} |
| 125 |
else if (MEDIA_IS_SKU(m_skuTable, FtrMediaThreadGroupLevelPreempt)) |
| 126 |
{ |
| 127 |
m_preemptionCntlRegisterValue = MHW_RENDER_ENGINE_THREAD_GROUP_PREEMPT_VALUE; |
| 128 |
} |
| 129 |
else if (MEDIA_IS_SKU(m_skuTable, FtrMediaMidBatchPreempt)) |
| 130 |
{ |
| 131 |
m_preemptionCntlRegisterValue = MHW_RENDER_ENGINE_MID_BATCH_PREEMPT_VALUE; |
| 132 |
} |
| 133 |
|
| 134 |
// Set it to Mid Batch Pre-emption level (command level) to avoid render engine hang after preemption is turned on in ring buffer |
| 135 |
if (MEDIA_IS_WA(waTable, WaMidBatchPreemption)) |
| 136 |
{ |
| 137 |
m_preemptionCntlRegisterValue = MHW_RENDER_ENGINE_MID_BATCH_PREEMPT_VALUE; |
| 138 |
} |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
MOS_STATUS MhwRenderInterface::EnablePreemption( |
| 143 |
PMOS_COMMAND_BUFFER cmdBuffer) |
| 144 |
{ |
| 145 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 146 |
|
| 147 |
MHW_MI_CHK_NULL(cmdBuffer); |
| 148 |
MHW_MI_CHK_NULL(m_osInterface); |
| 149 |
MHW_MI_CHK_NULL(m_miInterface); |
| 150 |
|
| 151 |
MEDIA_FEATURE_TABLE *m_skuTable = m_osInterface->pfnGetSkuTable(m_osInterface); |
| 152 |
MHW_MI_CHK_NULL(m_skuTable); |
| 153 |
|
| 154 |
if (MEDIA_IS_SKU(m_skuTable, FtrPerCtxtPreemptionGranularityControl)) |
| 155 |
{ |
| 156 |
MHW_MI_LOAD_REGISTER_IMM_PARAMS loadRegisterParams; |
| 157 |
MOS_ZeroMemory(&loadRegisterParams, sizeof(loadRegisterParams)); |
| 158 |
loadRegisterParams.dwRegister = m_preemptionCntlRegisterOffset; |
| 159 |
loadRegisterParams.dwData = m_preemptionCntlRegisterValue; |
| 160 |
MHW_MI_CHK_STATUS(m_miInterface->AddMiLoadRegisterImmCmd(cmdBuffer, &loadRegisterParams)); |
| 161 |
} |
| 162 |
|
| 163 |
return eStatus; |
| 164 |
} |