| 1 | /* |
| 2 | * Copyright (c) 2020, 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 render_copy_next.h |
| 24 | //! \brief header file of render copy base functions |
| 25 | //! \details define render copy basic API |
| 26 | //! |
| 27 | #ifndef __MEDIA_RENDER_COPY_NEXT_H__ |
| 28 | #define __MEDIA_RENDER_COPY_NEXT_H__ |
| 29 | |
| 30 | #include "media_copy.h" |
| 31 | #include "media_copy_common.h" |
| 32 | #include "renderhal.h" |
| 33 | #include "hal_kerneldll_next.h" |
| 34 | |
| 35 | // Kernel Params --------------------------------------------------------------- |
| 36 | const RENDERHAL_KERNEL_PARAM g_rendercopy_KernelParam[RENDER_COPY_NUM] = |
| 37 | { |
| 38 | ///* GRF_Count |
| 39 | // | BT_Count |
| 40 | // | | Sampler_Count |
| 41 | // | | | Thread_Count |
| 42 | // | | | | GRF_Start_Register |
| 43 | // | | | | | CURBE_Length |
| 44 | // | | | | | | block_width |
| 45 | // | | | | | | | block_height |
| 46 | // | | | | | | | | blocks_x |
| 47 | // | | | | | | | | | blocks_y |
| 48 | // | | | | | | | | | |*/ |
| 49 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_1D_to_2D_NV12 |
| 50 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_2D_to_1D_NV12 |
| 51 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_2D_to_2D_NV12 |
| 52 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_1D_to_2D_Planar |
| 53 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_2D_to_1D_Planar |
| 54 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_2D_to_2D_Planar |
| 55 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_1D_to_2D_Packed |
| 56 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_2D_to_1D_Packed |
| 57 | {4, 34, 0, RENDER_COPY_THREADS_MAX, 0, 0, 64, 8, 1, 1}, // CopyKernel_2D_to_2D_Packed |
| 58 | }; |
| 59 | |
| 60 | typedef struct _RENDER_COPY_CACHE_CNTL |
| 61 | { |
| 62 | bool bL3CachingEnabled; |
| 63 | uint32_t SourceSurfMemObjCtl; |
| 64 | uint32_t TargetSurfMemObjCtl; |
| 65 | |
| 66 | }RENDER_COPY_CACHE_CNTL, *PRENDER_COPY_CACHE_CNTL; |
| 67 | |
| 68 | typedef struct _MEDIACOPY_RENDER_DATA |
| 69 | { |
| 70 | int32_t iBlocksX; |
| 71 | int32_t iBlocksY; |
| 72 | int32_t iBindingTable; |
| 73 | int32_t iMediaID;; |
| 74 | PRENDERHAL_MEDIA_STATE pMediaState; |
| 75 | |
| 76 | // Kernel Information |
| 77 | PRENDERHAL_KERNEL_PARAM pKernelParam; //!< Kernel Parameter |
| 78 | Kdll_CacheEntry KernelEntry; //!< Kernel Entry |
| 79 | int32_t iCurbeLength; |
| 80 | int32_t iInlineLength; |
| 81 | |
| 82 | // Perf |
| 83 | VPHAL_PERFTAG PerfTag; |
| 84 | RENDER_COPY_CACHE_CNTL SurfMemObjCtl; |
| 85 | |
| 86 | // Debug parameters |
| 87 | char* pKernelName; //!< Kernel Used for current rendering |
| 88 | int32_t iCurbeOffset; //!< The offset of curbe data |
| 89 | } MEDIACOPY_RENDER_DATA, *PMEDIACOPY_RENDER_DATA; |
| 90 | |
| 91 | class MhwInterfacesNext; |
| 92 | class RenderCopyStateNext |
| 93 | { |
| 94 | public: |
| 95 | RenderCopyStateNext(PMOS_INTERFACE osInterface, MhwInterfacesNext *mhwInterfaces); |
| 96 | |
| 97 | virtual ~RenderCopyStateNext(); |
| 98 | |
| 99 | //! |
| 100 | //! \brief RenderCopyStateNext initialize |
| 101 | //! \details Initialize the RenderCopyStateNext, create BLT context. |
| 102 | //! \return MOS_STATUS |
| 103 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 104 | //! |
| 105 | virtual MOS_STATUS Initialize(); |
| 106 | |
| 107 | //! |
| 108 | //! \brief GetBytesPerPixel |
| 109 | //! \details Get Bytes Per each pixel for different format |
| 110 | //! \param Formate |
| 111 | //! [in] Surface's Format |
| 112 | //! \return int32_t |
| 113 | //! Return the numb for Byte |
| 114 | //! |
| 115 | int32_t GetBytesPerPixelPerPlane(MOS_FORMAT Format); |
| 116 | |
| 117 | //! |
| 118 | //! \brief Get kernel ID |
| 119 | //! \details choose the kernel ID for each loop. |
| 120 | //! \return MOS_STATUS |
| 121 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 122 | //! |
| 123 | MOS_STATUS GetCurentKernelID(); |
| 124 | |
| 125 | //! |
| 126 | //! \brief Render copy omputer walker setup |
| 127 | //! \details Computer walker setup for render copy |
| 128 | //! \param PMHW_WALKER_PARAMS pWalkerParams |
| 129 | //! [in/out] Pointer to Walker params |
| 130 | //! \return MOS_STATUS |
| 131 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 132 | //! |
| 133 | MOS_STATUS RenderCopyComputerWalker( |
| 134 | PMHW_GPGPU_WALKER_PARAMS pWalkerParams); |
| 135 | |
| 136 | //! |
| 137 | //! \brief setup surface states |
| 138 | //! \details Setup surface states for fast 1toN |
| 139 | |
| 140 | //! \return MOS_STATUS |
| 141 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 142 | //! |
| 143 | MOS_STATUS SetupSurfaceStates(); |
| 144 | |
| 145 | MOS_STATUS LoadStaticData(int32_t *piCurbeOffset); |
| 146 | |
| 147 | //! |
| 148 | //! \brief Copy input surface to Output surface |
| 149 | //! \details Copy 2D surface to 2D surface |
| 150 | //! \param src |
| 151 | //! [in] Pointer to source resource |
| 152 | //! \param dst |
| 153 | //! [in] Pointer to destination resource |
| 154 | //! \return MOS_STATUS |
| 155 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 156 | //! |
| 157 | virtual MOS_STATUS CopySurface( |
| 158 | PMOS_RESOURCE src, |
| 159 | PMOS_RESOURCE dst); |
| 160 | protected: |
| 161 | |
| 162 | //! |
| 163 | //! \brief Submit command |
| 164 | //! \details Submit render command |
| 165 | //! \return MOS_STATUS |
| 166 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 167 | //! |
| 168 | virtual MOS_STATUS SubmitCMD( ); |
| 169 | MOS_STATUS SetupKernel(int32_t iKDTIndex); |
| 170 | |
| 171 | public: |
| 172 | PMOS_INTERFACE m_osInterface = nullptr; |
| 173 | MhwInterfacesNext *m_mhwInterfaces = nullptr; |
| 174 | RENDERHAL_INTERFACE *m_renderHal = nullptr; |
| 175 | MhwCpInterface *m_cpInterface = nullptr; |
| 176 | void *m_pKernelBin = nullptr; |
| 177 | Kdll_State *m_pKernelDllState = nullptr;//!< Kernel DLL state |
| 178 | |
| 179 | RENDERCOPY_KERNELID m_currKernelId = KERNEL_CopyKernel_1D_to_2D_NV12; |
| 180 | MEDIACOPY_RENDER_DATA m_RenderData = {}; |
| 181 | MOS_SURFACE m_Source = {}; |
| 182 | MOS_SURFACE m_Target = {}; |
| 183 | bool m_bNullHwRenderCopy = false; |
| 184 | |
| 185 | uint32_t m_WalkerWidthBlockSize = 128; |
| 186 | uint32_t m_WalkerHeightBlockSize = 8; |
| 187 | const void* m_KernelBin = nullptr; |
| 188 | uint32_t m_KernelBinSize = 0; |
| 189 | MEDIA_CLASS_DEFINE_END(RenderCopyStateNext) |
| 190 | }; |
| 191 | |
| 192 | #endif // __MEDIA_RENDER_COPY_NEXT_H__ |