1 /*
2 * Copyright (c) 2020-2021, 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 decode_filmgrain_gennoise_rp2_packet_g12.cpp
24 //! \brief film grain regress phase2 kernel render packet which used in by mediapipline.
25 //! \details film grain regress phase2 kernel render packet provide the structures and generate the cmd buffer which mediapipline will used.
26 //!
27
28 #include "decode_filmgrain_gennoise_rp2_packet_g12.h"
29 #include "decode_av1_filmgrain_feature_g12.h"
30 #include "decode_av1_feature_defs_g12.h"
31 #include "mos_defs.h"
32 #include "hal_oca_interface.h"
33 #include "codechal_utilities.h"
34
35 namespace decode
36 {
37
FilmGrainRp2Packet(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterface * hwInterface)38 FilmGrainRp2Packet::FilmGrainRp2Packet(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterface *hwInterface):
39 CmdPacket(task),
40 RenderCmdPacket(task, hwInterface->GetOsInterface(), hwInterface->GetRenderHalInterface())
41 {
42 if (pipeline != nullptr)
43 {
44 m_statusReport = pipeline->GetStatusReportInstance();
45 m_featureManager = pipeline->GetFeatureManager();
46 m_av1Pipeline = dynamic_cast<Av1PipelineG12_Base *>(pipeline);
47 }
48 if (hwInterface != nullptr)
49 {
50 m_hwInterface = hwInterface;
51 m_miInterface = hwInterface->GetMiInterface();
52 m_osInterface = hwInterface->GetOsInterface();
53 m_vdencInterface = hwInterface->GetVdencInterface();
54 m_renderHal = hwInterface->GetRenderHalInterface();
55 }
56 }
57
Init()58 MOS_STATUS FilmGrainRp2Packet::Init()
59 {
60 DECODE_FUNC_CALL();
61 DECODE_CHK_NULL(m_miInterface);
62 DECODE_CHK_NULL(m_statusReport);
63 DECODE_CHK_NULL(m_featureManager);
64 DECODE_CHK_NULL(m_av1Pipeline);
65 DECODE_CHK_NULL(m_osInterface);
66 DECODE_CHK_NULL(m_vdencInterface);
67
68 DECODE_CHK_STATUS(RenderCmdPacket::Init());
69
70 m_av1BasicFeature = dynamic_cast<Av1BasicFeatureG12 *>(m_featureManager->GetFeature(FeatureIDs::basicFeature));
71 DECODE_CHK_NULL(m_av1BasicFeature);
72
73 m_filmGrainFeature = dynamic_cast<Av1DecodeFilmGrainG12 *>(m_featureManager->GetFeature(Av1FeatureIDs::av1SwFilmGrain));
74 DECODE_CHK_NULL(m_filmGrainFeature);
75
76 m_allocator = m_av1Pipeline->GetDecodeAllocator();
77 DECODE_CHK_NULL(m_allocator);
78
79 DECODE_CHK_STATUS(Initilize());
80
81 return MOS_STATUS_SUCCESS;
82 }
83
Prepare()84 MOS_STATUS FilmGrainRp2Packet::Prepare()
85 {
86 DECODE_FUNC_CALL();
87
88 DECODE_CHK_NULL(m_hwInterface);
89
90 m_picParams = m_av1BasicFeature->m_av1PicParams;
91
92 ResetBindingTableEntry();
93
94 DECODE_CHK_STATUS(RenderEngineSetup());
95 DECODE_CHK_STATUS(KernelStateSetup());
96 DECODE_CHK_STATUS(SetUpSurfaceState());
97 DECODE_CHK_STATUS(SetCurbeRegressPhase2());
98 DECODE_CHK_STATUS(LoadKernel());
99
100 if (m_walkerType == WALKER_TYPE_MEDIA)
101 {
102 DECODE_CHK_STATUS(SetupMediaWalker());
103 }
104 else if (m_walkerType == WALKER_TYPE_COMPUTE)
105 {
106 m_renderData.walkerParam.alignedRect.left = 0;
107 m_renderData.walkerParam.alignedRect.top = 0;
108 m_renderData.walkerParam.alignedRect.right = m_av1BasicFeature->m_filmGrainProcParams->m_outputSurface->dwWidth;
109 m_renderData.walkerParam.alignedRect.bottom = m_av1BasicFeature->m_filmGrainProcParams->m_outputSurface->dwHeight;
110 m_renderData.walkerParam.iCurbeLength = m_renderData.iCurbeLength;
111 m_renderData.walkerParam.iCurbeOffset = m_renderData.iCurbeOffset;
112 m_renderData.walkerParam.iBindingTable = m_renderData.bindingTable;
113 m_renderData.walkerParam.iMediaID = m_renderData.mediaID;
114 m_renderData.walkerParam.iBlocksX = m_renderData.KernelParam.blocks_x;
115 m_renderData.walkerParam.iBlocksY = m_renderData.KernelParam.blocks_y;
116 DECODE_CHK_STATUS(PrepareComputeWalkerParams(m_renderData.walkerParam, m_gpgpuWalkerParams));
117 }
118 else
119 {
120 DECODE_ASSERTMESSAGE("Walker is disabled!");
121 return MOS_STATUS_UNKNOWN;
122 }
123
124 return MOS_STATUS_SUCCESS;
125 }
126
Submit(MOS_COMMAND_BUFFER * commandBuffer,uint8_t packetPhase)127 MOS_STATUS FilmGrainRp2Packet::Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase)
128 {
129 PMOS_INTERFACE pOsInterface = nullptr;
130 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
131 uint32_t dwSyncTag = 0;
132 int32_t i = 0, iRemaining = 0;
133 PMHW_MI_INTERFACE pMhwMiInterface = nullptr;
134 MhwRenderInterface * pMhwRender = nullptr;
135 MHW_MEDIA_STATE_FLUSH_PARAM FlushParam = {};
136 bool bEnableSLM = false;
137 RENDERHAL_GENERIC_PROLOG_PARAMS GenericPrologParams = {};
138 MOS_RESOURCE GpuStatusBuffer = {};
139 MediaPerfProfiler * pPerfProfiler = nullptr;
140 MOS_CONTEXT * pOsContext = nullptr;
141 PMHW_MI_MMIOREGISTERS pMmioRegisters = nullptr;
142 PRENDERHAL_INTERFACE_LEGACY pRenderHalLegacy = (PRENDERHAL_INTERFACE_LEGACY)m_renderHal;
143
144 RENDER_PACKET_CHK_NULL_RETURN(pRenderHalLegacy);
145 RENDER_PACKET_CHK_NULL_RETURN(pRenderHalLegacy->pMhwRenderInterface);
146 RENDER_PACKET_CHK_NULL_RETURN(pRenderHalLegacy->pMhwMiInterface);
147 RENDER_PACKET_CHK_NULL_RETURN(pRenderHalLegacy->pMhwRenderInterface->GetMmioRegisters());
148 RENDER_PACKET_CHK_NULL_RETURN(pRenderHalLegacy->pOsInterface);
149 RENDER_PACKET_CHK_NULL_RETURN(pRenderHalLegacy->pOsInterface->pOsContext);
150
151 eStatus = MOS_STATUS_UNKNOWN;
152 pOsInterface = pRenderHalLegacy->pOsInterface;
153 pMhwMiInterface = pRenderHalLegacy->pMhwMiInterface;
154 pMhwRender = pRenderHalLegacy->pMhwRenderInterface;
155 iRemaining = 0;
156 FlushParam = g_cRenderHal_InitMediaStateFlushParams;
157 pPerfProfiler = pRenderHalLegacy->pPerfProfiler;
158 pOsContext = pOsInterface->pOsContext;
159 pMmioRegisters = pMhwRender->GetMmioRegisters();
160
161 RENDER_PACKET_CHK_STATUS_RETURN(SetPowerMode(CODECHAl_MEDIA_STATE_AV1_FILM_GRAIN_RP2));
162
163 // Initialize command buffer and insert prolog
164 RENDER_PACKET_CHK_STATUS_RETURN(pRenderHalLegacy->pfnInitCommandBuffer(pRenderHalLegacy, commandBuffer, &GenericPrologParams));
165
166 HalOcaInterface::On1stLevelBBStart(*commandBuffer, *m_osInterface->pOsContext, m_osInterface->CurrentGpuContextHandle,
167 *m_hwInterface->GetMiInterface(), *m_hwInterface->GetMiInterface()->GetMmioRegisters());
168 HalOcaInterface::TraceMessage(*commandBuffer, (MOS_CONTEXT_HANDLE)m_osInterface->pOsContext, __FUNCTION__, sizeof(__FUNCTION__));
169
170 if(pOsInterface && !m_av1BasicFeature->m_singleKernelPerfFlag)
171 {
172 pOsInterface->pfnSetPerfTag(pOsInterface, ((PERFTAG_CALL_FILM_GRAIN_RP2_KERNEL << 8) | CODECHAL_DECODE_MODE_AV1VLD << 4 | m_av1BasicFeature->m_pictureCodingType));
173 RENDER_PACKET_CHK_STATUS_RETURN(pPerfProfiler->AddPerfCollectStartCmd((void *)pRenderHalLegacy, pOsInterface, pMhwMiInterface, commandBuffer));
174 }
175
176 // Write timing data for 3P budget
177 RENDER_PACKET_CHK_STATUS_RETURN(pRenderHalLegacy->pfnSendTimingData(pRenderHalLegacy, commandBuffer, true));
178
179 bEnableSLM = false; // Media walker first
180 RENDER_PACKET_CHK_STATUS_RETURN(pRenderHalLegacy->pfnSetCacheOverrideParams(
181 pRenderHalLegacy,
182 &pRenderHalLegacy->L3CacheSettings,
183 bEnableSLM));
184
185 // Flush media states
186 RENDER_PACKET_CHK_STATUS_RETURN(pRenderHalLegacy->pfnSendMediaStates(
187 pRenderHalLegacy,
188 commandBuffer,
189 m_walkerType == WALKER_TYPE_MEDIA ? &m_mediaWalkerParams : nullptr,
190 m_walkerType == WALKER_TYPE_MEDIA ? nullptr : &m_gpgpuWalkerParams));
191
192 // Write back GPU Status tag
193 if (!pOsInterface->bEnableKmdMediaFrameTracking)
194 {
195 RENDER_PACKET_CHK_STATUS_RETURN(pRenderHalLegacy->pfnSendRcsStatusTag(pRenderHalLegacy, commandBuffer));
196 }
197
198 if (!m_av1BasicFeature->m_singleKernelPerfFlag)
199 {
200 RENDER_PACKET_CHK_STATUS_RETURN(pPerfProfiler->AddPerfCollectEndCmd((void *)pRenderHalLegacy, pOsInterface, pMhwMiInterface, commandBuffer));
201 }
202
203 // Write timing data for 3P budget
204 RENDER_PACKET_CHK_STATUS_RETURN(pRenderHalLegacy->pfnSendTimingData(pRenderHalLegacy, commandBuffer, false));
205
206 MHW_PIPE_CONTROL_PARAMS PipeControlParams;
207
208 MOS_ZeroMemory(&PipeControlParams, sizeof(PipeControlParams));
209 PipeControlParams.dwFlushMode = MHW_FLUSH_WRITE_CACHE;
210 PipeControlParams.bGenericMediaStateClear = false;
211 PipeControlParams.bIndirectStatePointersDisable = true;
212 PipeControlParams.bDisableCSStall = false;
213 RENDER_PACKET_CHK_STATUS_RETURN(pMhwMiInterface->AddPipeControl(commandBuffer, nullptr, &PipeControlParams));
214
215 if (MEDIA_IS_WA(pRenderHalLegacy->pWaTable, WaSendDummyVFEafterPipelineSelect))
216 {
217 MHW_VFE_PARAMS VfeStateParams = {};
218 VfeStateParams.dwNumberofURBEntries = 1;
219 RENDER_PACKET_CHK_STATUS_RETURN(pMhwRender->AddMediaVfeCmd(commandBuffer, &VfeStateParams));
220 }
221
222 // Add media flush command in case HW not cleaning the media state
223 if (MEDIA_IS_WA(pRenderHalLegacy->pWaTable, WaMSFWithNoWatermarkTSGHang))
224 {
225 FlushParam.bFlushToGo = true;
226 if (m_walkerType == WALKER_TYPE_MEDIA)
227 {
228 FlushParam.ui8InterfaceDescriptorOffset = m_mediaWalkerParams.InterfaceDescriptorOffset;
229 }
230 else
231 {
232 RENDER_PACKET_ASSERTMESSAGE("ERROR, pWalkerParams is nullptr and cannot get InterfaceDescriptorOffset.");
233 }
234 RENDER_PACKET_CHK_STATUS_RETURN(pMhwMiInterface->AddMediaStateFlush(commandBuffer, nullptr, &FlushParam));
235 }
236 else if (MEDIA_IS_WA(pRenderHalLegacy->pWaTable, WaAddMediaStateFlushCmd))
237 {
238 RENDER_PACKET_CHK_STATUS_RETURN(pMhwMiInterface->AddMediaStateFlush(commandBuffer, nullptr, &FlushParam));
239 }
240
241 HalOcaInterface::On1stLevelBBEnd(*commandBuffer, *m_osInterface);
242
243 if (pBatchBuffer)
244 {
245 // Send Batch Buffer end command (HW/OS dependent)
246 RENDER_PACKET_CHK_STATUS_RETURN(pMhwMiInterface->AddMiBatchBufferEnd(commandBuffer, nullptr));
247 }
248 else if (IsMiBBEndNeeded(pOsInterface))
249 {
250 // Send Batch Buffer end command for 1st level Batch Buffer
251 RENDER_PACKET_CHK_STATUS_RETURN(pMhwMiInterface->AddMiBatchBufferEnd(commandBuffer, nullptr));
252 }
253 else if (pRenderHalLegacy->pOsInterface->bNoParsingAssistanceInKmd)
254 {
255 RENDER_PACKET_CHK_STATUS_RETURN(pMhwMiInterface->AddMiBatchBufferEnd(commandBuffer, nullptr));
256 }
257
258 // Return unused command buffer space to OS
259 pOsInterface->pfnReturnCommandBuffer(pOsInterface, commandBuffer, 0);
260
261 MOS_NULL_RENDERING_FLAGS NullRenderingFlags = pOsInterface->pfnGetNullHWRenderFlags(pOsInterface);
262
263 if ((NullRenderingFlags.VPLgca ||
264 NullRenderingFlags.VPGobal) == false)
265 {
266 dwSyncTag = pRenderHalLegacy->pStateHeap->dwNextTag++;
267
268 // Set media state and batch buffer as busy
269 pRenderHalLegacy->pStateHeap->pCurMediaState->bBusy = true;
270 if (pBatchBuffer)
271 {
272 pBatchBuffer->bBusy = true;
273 pBatchBuffer->dwSyncTag = dwSyncTag;
274 }
275 }
276
277 return MOS_STATUS_SUCCESS;
278 }
279
SetupMediaWalker()280 MOS_STATUS FilmGrainRp2Packet::SetupMediaWalker()
281 {
282 DECODE_FUNC_CALL();
283
284 DECODE_CHK_NULL(m_hwInterface);
285
286 // Current only add Media Walker Support in film Grain
287 m_walkerType = WALKER_TYPE_MEDIA;
288
289 CODECHAL_WALKER_CODEC_PARAMS walkerCodecParams;
290 memset(&walkerCodecParams, 0, sizeof(walkerCodecParams));
291 walkerCodecParams.WalkerMode = MHW_WALKER_MODE_DUAL;
292 walkerCodecParams.dwResolutionX = 1;
293 walkerCodecParams.dwResolutionY = 1;
294 walkerCodecParams.bNoDependency = true; // raster scan mode
295
296 DECODE_CHK_STATUS(CodecHalInitMediaObjectWalkerParams(m_hwInterface, &m_mediaWalkerParams, &walkerCodecParams));
297
298 return MOS_STATUS_SUCCESS;
299 }
300
Initilize()301 MOS_STATUS FilmGrainRp2Packet::Initilize()
302 {
303 m_kernelIndex = regressPhase2;
304
305 return MOS_STATUS_SUCCESS;
306 }
307
KernelStateSetup()308 MOS_STATUS FilmGrainRp2Packet::KernelStateSetup()
309 {
310 m_kernelCount = 1;
311 MHW_KERNEL_STATE *kernelState = &m_filmGrainFeature->m_kernelStates[m_kernelIndex];
312 uint32_t btCount = m_filmGrainFeature->m_filmGrainBindingTableCount[m_kernelIndex];
313 int32_t curbeLength = m_filmGrainFeature->m_filmGrainCurbeSize[m_kernelIndex];
314
315 PRENDERHAL_INTERFACE_LEGACY pRenderHalLegacy = (PRENDERHAL_INTERFACE_LEGACY)m_renderHal;
316 // Initialize States
317 MOS_ZeroMemory(m_filter, sizeof(Kdll_FilterEntry));
318 MOS_ZeroMemory(&m_renderData.KernelEntry, sizeof(Kdll_CacheEntry));
319
320 // Set Kernel Parameter
321 m_renderData.KernelParam.GRF_Count = 0;
322 m_renderData.KernelParam.BT_Count = btCount;
323 m_renderData.KernelParam.Sampler_Count = 0;
324 m_renderData.KernelParam.Thread_Count = pRenderHalLegacy->pMhwRenderInterface->GetHwCaps()->dwMaxThreads;
325 m_renderData.KernelParam.GRF_Start_Register = 0;
326 m_renderData.KernelParam.CURBE_Length = curbeLength;
327 m_renderData.KernelParam.block_width = CODECHAL_MACROBLOCK_WIDTH;
328 m_renderData.KernelParam.block_height = CODECHAL_MACROBLOCK_HEIGHT;
329 m_renderData.KernelParam.blocks_x = 1;
330 m_renderData.KernelParam.blocks_y = 1;
331
332 m_renderData.iCurbeOffset = pRenderHalLegacy->pMhwStateHeap->GetSizeofCmdInterfaceDescriptorData();
333
334 // Set Parameters for Kernel Entry
335 m_renderData.KernelEntry.iKUID = 0;
336 m_renderData.KernelEntry.iKCID = m_kernelIndex;
337 m_renderData.KernelEntry.iFilterSize = 2;
338 m_renderData.KernelEntry.pFilter = m_filter;
339 m_renderData.KernelEntry.iSize = kernelState->KernelParams.iSize;
340 m_renderData.KernelEntry.pBinary = kernelState->KernelParams.pBinary;
341
342 // set Curbe/Inline Data length
343 m_renderData.iInlineLength = 0;
344 m_renderData.iCurbeLength = 0;
345
346 return MOS_STATUS_SUCCESS;
347 }
348
SetUpSurfaceState()349 MOS_STATUS FilmGrainRp2Packet::SetUpSurfaceState()
350 {
351 DECODE_FUNC_CALL();
352
353 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
354
355 //Set Surface States
356 RENDERHAL_SURFACE_NEXT renderHalSurfaceNext;
357 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
358
359 //Y random values - input
360 bool isWritable = false;
361 RENDERHAL_SURFACE_STATE_PARAMS surfaceParams;
362 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
363 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
364 surfaceParams.isOutput = true;
365 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
366
367 m_bindingTableIndex[rp2InputYRandomValue] = SetSurfaceForHwAccess(
368 m_filmGrainFeature->m_yRandomValuesSurface,
369 &renderHalSurfaceNext,
370 &surfaceParams,
371 isWritable);
372 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Input Y Random values index: %d\n", rp2InputYRandomValue, m_bindingTableIndex[rp2InputYRandomValue]);
373
374 //U random values - input
375 isWritable = false;
376 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
377 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
378 surfaceParams.isOutput = true;
379 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
380 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
381 m_bindingTableIndex[rp2InputURandomValue] = SetSurfaceForHwAccess(
382 m_filmGrainFeature->m_uRandomValuesSurface,
383 &renderHalSurfaceNext,
384 &surfaceParams,
385 isWritable);
386 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Input U Random values BT index: %d\n", rp2InputURandomValue, m_bindingTableIndex[rp2InputURandomValue]);
387
388 //V random values - input
389 isWritable = false;
390 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
391 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
392 surfaceParams.isOutput = true;
393 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
394 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
395 m_bindingTableIndex[rp2InputVRandomValue] = SetSurfaceForHwAccess(
396 m_filmGrainFeature->m_vRandomValuesSurface,
397 &renderHalSurfaceNext,
398 &surfaceParams,
399 isWritable);
400 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Input V Random values BT index: %d\n", rp2InputVRandomValue, m_bindingTableIndex[rp2InputVRandomValue]);
401
402 //Y dithering surface - input
403 isWritable = true;
404 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
405 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
406 surfaceParams.isOutput = true;
407 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
408 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
409 m_bindingTableIndex[rp2InputYDithering] = SetSurfaceForHwAccess(
410 m_filmGrainFeature->m_yDitheringTempSurface,
411 &renderHalSurfaceNext,
412 &surfaceParams,
413 isWritable);
414 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Input Y dithering surface BT index: %d\n", rp2InputYDithering, m_bindingTableIndex[rp2InputYDithering]);
415
416 //Y dithering surface - output
417 isWritable = true;
418 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
419 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
420 surfaceParams.isOutput = true;
421 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
422 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
423 m_bindingTableIndex[rp2OutputYDithering] = SetSurfaceForHwAccess(
424 m_filmGrainFeature->m_yDitheringSurface,
425 &renderHalSurfaceNext,
426 &surfaceParams,
427 isWritable);
428 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Output Y dithering surface BT index: %d\n", rp2OutputYDithering, m_bindingTableIndex[rp2OutputYDithering]);
429
430 //U dithering surface - output
431 isWritable = true;
432 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
433 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
434 surfaceParams.isOutput = true;
435 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
436 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
437 m_bindingTableIndex[rp2OutputUDithering] = SetSurfaceForHwAccess(
438 m_filmGrainFeature->m_uDitheringSurface,
439 &renderHalSurfaceNext,
440 &surfaceParams,
441 isWritable);
442 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Output U dithering surface BT index: %d\n", rp2OutputUDithering, m_bindingTableIndex[rp2OutputUDithering]);
443
444 //V dithering surface - output
445 isWritable = true;
446 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
447 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
448 surfaceParams.isOutput = true;
449 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
450 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
451 m_bindingTableIndex[rp2OutputVDithering] = SetSurfaceForHwAccess(
452 m_filmGrainFeature->m_vDitheringSurface,
453 &renderHalSurfaceNext,
454 &surfaceParams,
455 isWritable);
456 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Output V dithering surface BT index: %d\n", rp2OutputVDithering, m_bindingTableIndex[rp2OutputVDithering]);
457
458 //Y coefficients - input
459 isWritable = false;
460 m_filmGrainFeature->m_yCoeffSurface->size = 32 * sizeof(short);
461 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
462 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
463 surfaceParams.isOutput = false;
464 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
465 surfaceParams.bBufferUse = true;
466 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
467 m_bindingTableIndex[rp2InputYCoeff] = SetBufferForHwAccess(
468 *m_filmGrainFeature->m_yCoeffSurface,
469 &renderHalSurfaceNext,
470 &surfaceParams,
471 isWritable);
472 DECODE_VERBOSEMESSAGE("RP2: surface[%d] Y coeff input surface BT index: %d\n", rp2InputYCoeff, m_bindingTableIndex[rp2InputYCoeff]);
473
474 //U coefficients - input
475 isWritable = false;
476 m_filmGrainFeature->m_uCoeffSurface->size = 32 * sizeof(short);
477 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
478 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
479 surfaceParams.isOutput = false;
480 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
481 surfaceParams.bBufferUse = true;
482 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
483 m_bindingTableIndex[rp2InputUCoeff] = SetBufferForHwAccess(
484 *m_filmGrainFeature->m_uCoeffSurface,
485 &renderHalSurfaceNext,
486 &surfaceParams,
487 isWritable);
488 DECODE_VERBOSEMESSAGE("RP2: surface[%d] U coeff input surface BT index: %d\n", rp2InputUCoeff, m_bindingTableIndex[rp2InputUCoeff]);
489
490 //V coefficients - input
491 isWritable = false;
492 m_filmGrainFeature->m_vCoeffSurface->size = 32 * sizeof(short);
493 MOS_ZeroMemory(&surfaceParams, sizeof(RENDERHAL_SURFACE_STATE_PARAMS));
494 surfaceParams.MemObjCtl = m_hwInterface->GetCacheabilitySettings()[MOS_CODEC_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3].Value;
495 surfaceParams.isOutput = false;
496 surfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
497 surfaceParams.bBufferUse = true;
498 MOS_ZeroMemory(&renderHalSurfaceNext, sizeof(RENDERHAL_SURFACE_NEXT));
499 m_bindingTableIndex[rp2InputVCoeff] = SetBufferForHwAccess(
500 *m_filmGrainFeature->m_vCoeffSurface,
501 &renderHalSurfaceNext,
502 &surfaceParams,
503 isWritable);
504 DECODE_VERBOSEMESSAGE("RP2: surface[%d] U coeff input surface BT index: %d\n", rp2InputVCoeff, m_bindingTableIndex[rp2InputVCoeff]);
505
506 return MOS_STATUS_SUCCESS;
507 }
508
SetCurbeRegressPhase2()509 MOS_STATUS FilmGrainRp2Packet::SetCurbeRegressPhase2()
510 {
511 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
512
513 DECODE_FUNC_CALL();
514
515 CodecAv1FilmGrainParams *filmGrainParams = (CodecAv1FilmGrainParams *)&m_picParams->m_filmGrainParams;
516
517 FilmGrainRegressPhase2Curbe curbe;
518 curbe.DW0.YRandomValuesSurfaceIndex = rp2InputYRandomValue;
519 curbe.DW1.URandomValuesSurfaceIndex = rp2InputURandomValue;
520 curbe.DW2.VRandomValuesSurfaceIndex = rp2InputVRandomValue;
521 curbe.DW3.YDitheringInputSurfaceIndex = rp2InputYDithering;
522 curbe.DW4.YDitheringSurfaceIndex = rp2OutputYDithering;
523 curbe.DW5.UDitheringSurfaceIndex = rp2OutputUDithering;
524 curbe.DW6.VDitheringSurfaceIndex = rp2OutputVDithering;
525 curbe.DW7.YCoeffSurfaceIndex = rp2InputYCoeff;
526 curbe.DW8.UCoeffSurfaceIndex = rp2InputUCoeff;
527 curbe.DW9.VCoeffSurfaceIndex = rp2InputVCoeff;
528 curbe.DW10.RegressionCoefficientShift = m_picParams->m_filmGrainParams.m_filmGrainInfoFlags.m_fields.m_arCoeffShiftMinus6 + 6;
529
530 DECODE_CHK_STATUS(SetupCurbe(
531 &curbe,
532 sizeof(FilmGrainRegressPhase2Curbe),
533 m_renderData.KernelParam.Thread_Count));
534
535 return eStatus;
536 }
537
538
CalculateCommandSize(uint32_t & commandBufferSize,uint32_t & requestedPatchListSize)539 MOS_STATUS FilmGrainRp2Packet::CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize)
540 {
541 DECODE_FUNC_CALL();
542
543 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
544
545 commandBufferSize = m_hwInterface->GetKernelLoadCommandSize(m_renderData.KernelParam.BT_Count);
546 requestedPatchListSize = 0;
547
548 return MOS_STATUS_SUCCESS;
549 }
550
551 }
552