Debian Codegraph @

media_driver/linux/ult/ult_app/ddi_test_decode.cpp

raw
1 /*
2 * Copyright (c) 2018, 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 #include "ddi_test_decode.h"
23
24 using namespace std;
25
26 TEST_F(MediaDecodeDdiTest, DecodeHEVCLong)
27 {
28 m_GpuCmdFactory = g_gpuCmdFactoryDecodeHEVCLong;
29 DecTestData *pDecData = m_decDataFactory.GetDecTestData("HEVC-Long");
30 ExectueDecodeTest(pDecData);
31 delete pDecData;
32 }
33
34 TEST_F(MediaDecodeDdiTest, DecodeAVCLong)
35 {
36 m_GpuCmdFactory = g_gpuCmdFactoryDecodeAVCLong;
37 DecTestData *pDecData = m_decDataFactory.GetDecTestData("AVC-Long");
38 ExectueDecodeTest(pDecData);
39 delete pDecData;
40 }
41
42 void MediaDecodeDdiTest::ExectueDecodeTest(DecTestData *pDecData)
43 {
44 vector<Platform_t> platforms = m_driverLoader.GetPlatforms();
45 for (int i = 0; i < m_driverLoader.GetPlatformNum(); i++)
46 {
47 if (m_decTestCfg.IsDecTestEnabled(DeviceConfigTable[platforms[i]],
48 pDecData->GetFeatureID()))
49 {
50 CmdValidator::GpuCmdsValidationInit(m_GpuCmdFactory, platforms[i]);
51 DecodeExecute(pDecData, platforms[i]);
52 }
53 }
54 }
55
56 void MediaDecodeDdiTest::DecodeExecute(DecTestData *pDecData, Platform_t platform)
57 {
58 VAConfigID config_id;
59 VAContextID context_id;
60 VASurfaceStatus surface_status;
61
62 // So far we still use DeviceConfigTable to find the platform, as the libdrm mock use this.
63 // If we want to use vector Platforms, we would use vector in libdrm too.
64 int ret = m_driverLoader.InitDriver(platform);
65 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
66 << ", Failed function = m_driverLoader.InitDriver" << endl;
67
68 // The attribute only use RCType and FEI function type in createconfig.
69 ret = m_driverLoader.m_ctx.vtable->vaCreateConfig(&m_driverLoader.m_ctx,
70 pDecData->GetFeatureID().profile, pDecData->GetFeatureID().entrypoint,
71 (VAConfigAttrib *)&(pDecData->GetConfAttrib()[0]), pDecData->GetConfAttrib().size(), &config_id);
72 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
73 << ", Failed function = m_driverLoader.m_ctx.vtable->vaCreateConfig" << endl;
74
75 vector<VASurfaceID> &resources = pDecData->GetResources();
76 ret = m_driverLoader.m_ctx.vtable->vaCreateSurfaces2(&m_driverLoader.m_ctx, VA_RT_FORMAT_YUV420,
77 pDecData->GetWidth(), pDecData->GetHeight(), &resources[0], resources.size(), nullptr, 0);
78 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
79 << ", Failed function = m_driverLoader.m_ctx.vtable->vaCreateSurfaces2" << endl;
80
81 ret = m_driverLoader.m_ctx.vtable->vaCreateContext(&m_driverLoader.m_ctx, config_id, pDecData->GetWidth(),
82 pDecData->GetHeight(),VA_PROGRESSIVE, &resources[0], resources.size(), &context_id);
83 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
84 << ", Failed function = m_driverLoader.m_ctx.vtable->vaCreateContext" << endl;
85
86 for (int i = 0; i < pDecData->m_num_frames; i++)
87 {
88 // As BeginPicture would reset some parameters, so it should be called before RenderPicture.
89 ret = m_driverLoader.m_ctx.vtable->vaBeginPicture(&m_driverLoader.m_ctx, context_id, resources[0]);
90 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
91 << ", Failed function = m_driverLoader.m_ctx.vtable->vaBeginPicture" << endl;
92
93 vector<vector<CompBufConif>> &compBufs = pDecData->GetCompBuffers();
94 for (int j = 0; j < compBufs[i].size(); j++)
95 {
96 ret = m_driverLoader.m_ctx.vtable->vaCreateBuffer(&m_driverLoader.m_ctx, context_id,
97 compBufs[i][j].bufType, compBufs[i][j].bufSize, 1, compBufs[i][j].pData, &compBufs[i][j].bufID);
98 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
99 << ", Failed function = m_driverLoader.m_ctx.vtable->vaCreateBuffer" << endl;
100 }
101
102 pDecData->UpdateCompBuffers(i);
103 for (int j = 0; j < compBufs[i].size(); j++)
104 {
105 // In RenderPicture, it suppose all needed buffer has been created already.
106 ret = m_driverLoader.m_ctx.vtable->vaRenderPicture(&m_driverLoader.m_ctx,
107 context_id, &compBufs[i][j].bufID, 1);
108 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
109 << ", Failed function = m_driverLoader.m_ctx.vtable->vaRenderPicture" << endl;
110 }
111
112 ret = m_driverLoader.m_ctx.vtable->vaEndPicture(&m_driverLoader.m_ctx, context_id);
113 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
114 << ", Failed function = m_driverLoader.m_ctx.vtable->vaEndPicture" << endl;
115
116 do
117 {
118 ret = m_driverLoader.m_ctx.vtable->vaQuerySurfaceStatus(
119 &m_driverLoader.m_ctx, resources[0], &surface_status);
120 } while (surface_status != VASurfaceReady);
121
122 for (int j = 0; j < compBufs[i].size(); j++)
123 {
124 ret = m_driverLoader.m_ctx.vtable->vaDestroyBuffer(&m_driverLoader.m_ctx, compBufs[i][j].bufID);
125 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
126 << ", Failed function = m_driverLoader.m_ctx.vtable->vaDestroyBuffer" << endl;
127 }
128 }
129
130 ret = m_driverLoader.m_ctx.vtable->vaDestroySurfaces(&m_driverLoader.m_ctx, &resources[0], resources.size());
131 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
132 << ", Failed function = m_driverLoader.m_ctx.vtable->vaDestroySurfaces" << endl;
133
134 ret = m_driverLoader.m_ctx.vtable->vaDestroyContext(&m_driverLoader.m_ctx, context_id);
135 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
136 << ", Failed function = m_driverLoader.m_ctx.vtable->vaDestroyContext" << endl;
137
138 ret = m_driverLoader.m_ctx.vtable->vaDestroyConfig(&m_driverLoader.m_ctx, config_id);
139 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
140 << ", Failed function = m_driverLoader.m_ctx.vtable->vaDestroyConfig" << endl;
141
142 ret = m_driverLoader.CloseDriver();
143 EXPECT_EQ(VA_STATUS_SUCCESS, ret) << "Platform = " << g_platformName[platform]
144 << ", Failed function = m_driverLoader.CloseDriver" << endl;
145 }
146
147 DecodeTestConfig::DecodeTestConfig()
148 {
149 m_mapPlatformFeatureID[DeviceConfigTable[igfxSKLAKE]] = {
150 TEST_Intel_Decode_HEVC,
151 TEST_Intel_Decode_AVC ,
152 };
153 m_mapPlatformFeatureID[DeviceConfigTable[igfxBROXTON]] = {
154 TEST_Intel_Decode_HEVC,
155 TEST_Intel_Decode_AVC ,
156 };
157 m_mapPlatformFeatureID[DeviceConfigTable[igfxBROADWELL]] = {
158 TEST_Intel_Decode_AVC ,
159 };
160 }
161
162 bool DecodeTestConfig::IsDecTestEnabled(DeviceConfig platform, FeatureID featureId)
163 {
164 const auto &featureIdArray = m_mapPlatformFeatureID[platform];
165 for (int i = 0; i < featureIdArray.size(); i++)
166 {
167 // In fact, we may need to call QueryEntroyPoint to make sure it does have this config.
168 // But we suppose this test is done in Caps test.
169 // Otherwise, here is need to call QueryEntroyPoint to check if it's supported.
170 if (featureId == featureIdArray[i])
171 {
172 return true;
173 }
174 }
175
176 return false;
177 }