Skip to content

Commit 12e650a

Browse files
chuanli1intel-mediadev
authored andcommitted
[Decode] Support multi-context for NullHW proxy test packet
Changed data store buffer from single instance to per-GPU-context map to support multiple GPU contexts. Added GetCurrentDataStoreBuf() method to retrieve context-specific buffer. Updated Init() to create buffers per context and Destroy() to clean up all mapped buffers. Modified Pack2ndLevelCmds() and AddNullHwProxyCmd() to accept osInterface parameter for context lookup. This ensures proper buffer isolation when decode operations run on different GPU contexts.
1 parent 2c21642 commit 12e650a

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

media_softlet/agnostic/common/codec/hal/dec/shared/nullhwproxy/decode_nullhw_proxy_test_packet.cpp

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ namespace decode
5353
__MEDIA_USER_FEATURE_VALUE_NULLHW_PROXY_REPEAT_COUNT,
5454
MediaUserSetting::Group::Device);
5555

56-
if (m_dataStoreBuf == nullptr)
56+
MOS_GPU_CONTEXT gpuContext = osInterface->pfnGetGpuContext(osInterface);
57+
if (m_dataStoreBufMap.find(gpuContext) == m_dataStoreBufMap.end())
5758
{
58-
m_dataStoreBuf = m_allocator->AllocateBuffer(2 * sizeof(uint32_t), "Store data buffer", resourceInternalReadWriteCache, notLockableVideoMem, true, 0);
59-
DECODE_CHK_NULL(m_dataStoreBuf);
59+
MOS_BUFFER* dataStoreBuf = m_allocator->AllocateBuffer(2 * sizeof(uint32_t), "Store data buffer", resourceInternalReadWriteCache, notLockableVideoMem, true, 0);
60+
DECODE_CHK_NULL(dataStoreBuf);
61+
m_dataStoreBufMap[gpuContext] = dataStoreBuf;
6062
}
6163
if (m_secondLevelBBArray == nullptr)
6264
{
@@ -75,12 +77,32 @@ namespace decode
7577
MOS_STATUS DecodeNullHWProxyTestPkt::Destory()
7678
{
7779
DECODE_CHK_NULL(m_allocator);
78-
DECODE_CHK_STATUS(m_allocator->Destroy(m_dataStoreBuf));
80+
for (auto& pair : m_dataStoreBufMap)
81+
{
82+
DECODE_CHK_STATUS(m_allocator->Destroy(pair.second));
83+
}
84+
m_dataStoreBufMap.clear();
7985
DECODE_CHK_STATUS(m_allocator->Destroy(m_secondLevelBBArray));
8086

8187
return MOS_STATUS_SUCCESS;
8288
}
8389

90+
MOS_BUFFER* DecodeNullHWProxyTestPkt::GetCurrentDataStoreBuf(MOS_INTERFACE *osInterface)
91+
{
92+
DECODE_FUNC_CALL();
93+
if (osInterface == nullptr)
94+
{
95+
return nullptr;
96+
}
97+
MOS_GPU_CONTEXT gpuContext = osInterface->pfnGetGpuContext(osInterface);
98+
auto it = m_dataStoreBufMap.find(gpuContext);
99+
if (it != m_dataStoreBufMap.end())
100+
{
101+
return it->second;
102+
}
103+
return nullptr;
104+
}
105+
84106
MOS_STATUS DecodeNullHWProxyTestPkt::Init2ndLevelCmdBuffer(MHW_BATCH_BUFFER& batchBuffer, uint8_t* batchBufBase)
85107
{
86108
DECODE_FUNC_CALL();
@@ -158,14 +180,17 @@ namespace decode
158180
return eStatus;
159181
}
160182

161-
MOS_STATUS DecodeNullHWProxyTestPkt::Pack2ndLevelCmds(DecodePipeline* pipeline, MOS_COMMAND_BUFFER& cmdBuffer)
183+
MOS_STATUS DecodeNullHWProxyTestPkt::Pack2ndLevelCmds(DecodePipeline* pipeline, MOS_INTERFACE *osInterface, MOS_COMMAND_BUFFER& cmdBuffer)
162184
{
163185
DECODE_FUNC_CALL();
164186

187+
MOS_BUFFER* dataStoreBuf = GetCurrentDataStoreBuf(osInterface);
188+
DECODE_CHK_NULL(dataStoreBuf);
189+
165190
// MI_ATOMIC: ADD 1 TO ORIGINAL DATA
166191
auto &par = m_miItf->GETPAR_MI_ATOMIC();
167192
par = {};
168-
par.pOsResource = &m_dataStoreBuf->OsResource;
193+
par.pOsResource = &dataStoreBuf->OsResource;
169194
par.dwResourceOffset = sizeof(uint32_t);
170195
par.dwDataSize = sizeof(uint32_t);
171196
par.Operation = mhw::mi::MHW_MI_ATOMIC_INC;
@@ -176,7 +201,7 @@ namespace decode
176201
uint32_t compData = m_repeatCount;
177202

178203
DECODE_CHK_STATUS(SendCondBbEndCmd(
179-
&m_dataStoreBuf->OsResource, 0, compData, false, true, compareOperation, &cmdBuffer));
204+
&dataStoreBuf->OsResource, 0, compData, false, true, compareOperation, &cmdBuffer));
180205

181206
// Chained BB loop
182207
auto &chainedBBStartPar = m_miItf->GETPAR_MI_BATCH_BUFFER_START();
@@ -201,10 +226,13 @@ namespace decode
201226
DECODE_CHK_NULL(osInterface);
202227
DECODE_CHK_NULL(m_miItf);
203228

229+
MOS_BUFFER* dataStoreBuf = GetCurrentDataStoreBuf(osInterface);
230+
DECODE_CHK_NULL(dataStoreBuf);
231+
204232
// add 2nd level BB before start status reporting
205233
auto &par = m_miItf->MHW_GETPAR_F(MI_STORE_DATA_IMM)();
206234
par = {};
207-
par.pOsResource = &m_dataStoreBuf->OsResource;
235+
par.pOsResource = &dataStoreBuf->OsResource;
208236
par.dwResourceOffset = 0;
209237
par.dwValue = 0xFFFFFF;
210238

@@ -224,7 +252,7 @@ namespace decode
224252
DECODE_CHK_NULL(batchBufBase);
225253
DECODE_CHK_STATUS(Init2ndLevelCmdBuffer(*m_batchBuf, batchBufBase));
226254
m_statusCheckCmdBuffer.cmdBuf1stLvl = cmdBuffer;
227-
DECODE_CHK_STATUS(Pack2ndLevelCmds(pipeline, m_statusCheckCmdBuffer));
255+
DECODE_CHK_STATUS(Pack2ndLevelCmds(pipeline, osInterface, m_statusCheckCmdBuffer));
228256
if (!osInterface->pfnIsMismatchOrderProgrammingSupported())
229257
{
230258
DECODE_CHK_STATUS(m_miItf->AddMiBatchBufferEnd(&m_statusCheckCmdBuffer, nullptr));

media_softlet/agnostic/common/codec/hal/dec/shared/nullhwproxy/decode_nullhw_proxy_test_packet.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DecodeNullHWProxyTestPkt
3535
{
3636
private:
3737
DecodeNullHWProxyTestPkt() {}
38-
MOS_BUFFER *m_dataStoreBuf = nullptr;
38+
std::map<MOS_GPU_CONTEXT, MOS_BUFFER*> m_dataStoreBufMap;
3939
BatchBufferArray *m_secondLevelBBArray = nullptr;
4040
PMHW_BATCH_BUFFER m_batchBuf = nullptr;
4141
DecodeAllocator *m_allocator = nullptr;
@@ -59,7 +59,8 @@ class DecodeNullHWProxyTestPkt
5959
MOS_STATUS Init(DecodePipeline* pipeline, MOS_INTERFACE *osInterface);
6060
MOS_STATUS Destory();
6161
MOS_STATUS Init2ndLevelCmdBuffer(MHW_BATCH_BUFFER &batchBuffer, uint8_t *batchBufBase);
62-
MOS_STATUS Pack2ndLevelCmds(DecodePipeline *pipeline, MOS_COMMAND_BUFFER &cmdBuffer);
62+
MOS_STATUS Pack2ndLevelCmds(DecodePipeline *pipeline, MOS_INTERFACE *osInterface, MOS_COMMAND_BUFFER &cmdBuffer);
63+
MOS_BUFFER* GetCurrentDataStoreBuf(MOS_INTERFACE *osInterface);
6364
MOS_STATUS AddNullHwProxyCmd(DecodePipeline *pipeline, MOS_INTERFACE *osInterface, PMOS_COMMAND_BUFFER cmdBuffer);
6465
MOS_STATUS SendCondBbEndCmd(
6566
PMOS_RESOURCE resource,
@@ -69,6 +70,7 @@ class DecodeNullHWProxyTestPkt
6970
bool enableEndCurrentBatchBuffLevel,
7071
uint32_t compareOperation,
7172
PMOS_COMMAND_BUFFER cmdBuffer);
73+
MEDIA_CLASS_DEFINE_END(decode__DecodeNullHWProxyTestPkt)
7274
};
7375
#endif
7476
}

0 commit comments

Comments
 (0)