| 1 |
/* |
| 2 |
* Copyright (c) 2008-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 |
//! |
| 23 |
//! \file hal_kerneldll_g8.c |
| 24 |
//! \brief Kernel Dynamic Linking/Loading routines for Gen8 |
| 25 |
//! |
| 26 |
|
| 27 |
#include "hal_kerneldll.h" |
| 28 |
#include "vphal.h" |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" { |
| 32 |
#endif // __cplusplus |
| 33 |
|
| 34 |
//--------------------------------------------------------------------------------------- |
| 35 |
// KernelDll_StartKernelSearch_g8 - Starts kernel search |
| 36 |
// |
| 37 |
// Parameters: |
| 38 |
// Kdll_State *pState - [in] Dynamic Linking State |
| 39 |
// Kdll_FilterEntry *pFilter - [in] Search filter (array of search entries) |
| 40 |
// int iFilterSize - [in] Search filter size |
| 41 |
// Kdll_SearchState *pSearchState - [in/out] Kernel search state |
| 42 |
// |
| 43 |
// Output: none |
| 44 |
//--------------------------------------------------------------------------------------- |
| 45 |
void KernelDll_StartKernelSearch_g8( |
| 46 |
Kdll_State *pState, |
| 47 |
Kdll_SearchState *pSearchState, |
| 48 |
Kdll_FilterEntry *pFilter, |
| 49 |
int32_t iFilterSize, |
| 50 |
uint32_t uiIs64BInstrEnabled) |
| 51 |
{ |
| 52 |
int32_t nLayer; |
| 53 |
bool AtLeastOneSample8x8Layer = false; |
| 54 |
bool AtLeastOneSampleNormLayer = false; |
| 55 |
|
| 56 |
VPHAL_RENDER_FUNCTION_ENTER; |
| 57 |
|
| 58 |
// Reset all states |
| 59 |
MOS_ZeroMemory(pSearchState, sizeof(Kdll_SearchState)); |
| 60 |
|
| 61 |
// Setup KDLL state |
| 62 |
pSearchState->pKdllState = pState; // KDLL state |
| 63 |
|
| 64 |
// Cleanup kernel table |
| 65 |
pSearchState->KernelCount = 0; // # of kernels |
| 66 |
|
| 67 |
// Cleanup patch data |
| 68 |
memset(pSearchState->Patches , 0, sizeof(pSearchState->Patches)); |
| 69 |
memset(pSearchState->PatchID , -1, sizeof(pSearchState->PatchID)); |
| 70 |
pSearchState->PatchCount = 0; |
| 71 |
|
| 72 |
// Copy original filter; filter will be modified as part of the search |
| 73 |
if (pFilter && iFilterSize > 0) |
| 74 |
{ |
| 75 |
MOS_SecureMemcpy(pSearchState->Filter, iFilterSize * sizeof(Kdll_FilterEntry), pFilter, iFilterSize * sizeof(Kdll_FilterEntry)); |
| 76 |
pSearchState->pFilter = pSearchState->Filter; |
| 77 |
pSearchState->iFilterSize = iFilterSize; |
| 78 |
|
| 79 |
// Set Procamp |
| 80 |
if (pFilter->procamp == DL_PROCAMP_DISABLED) |
| 81 |
{ |
| 82 |
pSearchState->bProcamp = false; |
| 83 |
} |
| 84 |
else |
| 85 |
{ |
| 86 |
pSearchState->bProcamp = true; |
| 87 |
} |
| 88 |
|
| 89 |
// Copy the render target format |
| 90 |
pSearchState->target_format = pSearchState->pFilter[iFilterSize - 1].format; |
| 91 |
|
| 92 |
// Copy the render target tile type |
| 93 |
pSearchState->target_tiletype = pSearchState->pFilter[iFilterSize - 1].tiletype; |
| 94 |
|
| 95 |
// PreComp L0 Rotation Optimization |
| 96 |
// In Multilayer case, if L0 is the only layer that rotates, then do preComp Rotation of L0 |
| 97 |
// ie Rotate L0 after Scaling and DONT rotate the RT after Composition. This makes it possible to |
| 98 |
// perform rotation and Composition in single phase. |
| 99 |
pSearchState->bRTRotate = true; |
| 100 |
|
| 101 |
// PreComp rotation is possible only if there are more than 2 filters/layers. |
| 102 |
// Otherwise RT rotation is done |
| 103 |
if (iFilterSize > 2) |
| 104 |
{ |
| 105 |
for (nLayer = 1; nLayer < iFilterSize - 1; nLayer++) |
| 106 |
{ |
| 107 |
if (pSearchState->pFilter[nLayer].rotation == MEDIA_ROTATION(VPHAL_ROTATION_IDENTITY)) |
| 108 |
{ |
| 109 |
// If any layer except L0 needs rotation then rotate RT and skip preComp L0 Rotation |
| 110 |
pSearchState->bRTRotate = false; |
| 111 |
pSearchState->pFilter[iFilterSize - 1].rotation = MEDIA_ROTATION(VPHAL_ROTATION_IDENTITY); |
| 112 |
break; |
| 113 |
} |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
// Gen8 requires shuffling the data returned by Sample_8x8 to match the |
| 118 |
// data layout of other sampler messages. |
| 119 |
// If at least one layer uses 8x8 sampling and one layer does not, |
| 120 |
// all layers that use 8x8 sampling needs their output shuffled. |
| 121 |
// If all layers use 8x8 sampling, only shuffle the RenderTarget layer |
| 122 |
// to save extra work in shuffling all layers. |
| 123 |
|
| 124 |
// Go through all layers except RenderTarget |
| 125 |
for (nLayer = 0; nLayer < iFilterSize - 1; nLayer++) |
| 126 |
{ |
| 127 |
if (pSearchState->pFilter[nLayer].sampler >= Sample_Scaling_AVS) |
| 128 |
{ |
| 129 |
AtLeastOneSample8x8Layer = true; |
| 130 |
} |
| 131 |
else |
| 132 |
{ |
| 133 |
AtLeastOneSampleNormLayer = true; |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
// All layers are sample 8x8 messages. Adjust the data in Render Target Layer. |
| 138 |
// If preComp rotation is applied to layer0 then RenderTarget does not rotate (bRTRotate=FALSE). |
| 139 |
// layer0 needs to be shuffled before it can be rotated. |
| 140 |
// So if layer0 shuffles then all layers need shuffling (Shuffle_All_8x8_Layer) |
| 141 |
// When PreComp rotation is NOT applied to layer0 then bRTRotate=TRUE |
| 142 |
// indicating only RenderTarget is rotated in which case only RenderTarget is shuffled(Shuffle_RenderTarget). |
| 143 |
if (AtLeastOneSample8x8Layer && !AtLeastOneSampleNormLayer && pSearchState->bRTRotate == true) |
| 144 |
{ |
| 145 |
for (nLayer = 0; nLayer < iFilterSize - 1; nLayer++) |
| 146 |
{ |
| 147 |
if (pSearchState->pFilter[nLayer].format == Format_NV12 && pSearchState->pFilter[nLayer].sampler == Sample_iScaling_AVS) |
| 148 |
{ |
| 149 |
pSearchState->ShuffleSamplerData = Shuffle_None; |
| 150 |
} |
| 151 |
else |
| 152 |
{ |
| 153 |
pSearchState->ShuffleSamplerData = Shuffle_RenderTarget; |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
// There are mix of sampler message types. Adjust the data in all sample 8x8 layer. |
| 158 |
else if (AtLeastOneSample8x8Layer && AtLeastOneSampleNormLayer) |
| 159 |
{ |
| 160 |
pSearchState->ShuffleSamplerData = Shuffle_All_8x8_Layer; |
| 161 |
} |
| 162 |
else |
| 163 |
{ |
| 164 |
pSearchState->ShuffleSamplerData = Shuffle_None; |
| 165 |
} |
| 166 |
|
| 167 |
// Indicate whether to use 64B save kernel for render target surface |
| 168 |
if (uiIs64BInstrEnabled && |
| 169 |
((pSearchState->target_tiletype == MOS_TILE_X) || |
| 170 |
(pSearchState->target_tiletype == MOS_TILE_LINEAR))) |
| 171 |
{ |
| 172 |
pSearchState->b64BSaveEnabled = true; |
| 173 |
} |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
#ifdef __cplusplus |
| 178 |
} |
| 179 |
#endif // __cplusplus |
| 180 |
|
| 181 |
void KernelDll_ModifyFunctionPointers_g8(Kdll_State *pState) |
| 182 |
{ |
| 183 |
pState->pfnStartKernelSearch = KernelDll_StartKernelSearch_g8; |
| 184 |
} |