1 /*
2 * Copyright (c) 2017-2019, 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     codechal_encode_sw_scoreboard_g12.h
24 //! \brief    Gen12 class for SW socreboard init kernel.
25 //!
26 
27 #ifndef __CODECHAL_ENCODE_SW_SCOREBOARD_MDF_G12_H__
28 #define __CODECHAL_ENCODE_SW_SCOREBOARD_MDF_G12_H__
29 
30 #include "codechal_encode_sw_scoreboard_g12.h"
31 
32 class CodechalEncodeSwScoreboardMdfG12 : public CodechalEncodeSwScoreboardG12
33 {
34 public:
35     //!
36     //! \brief    Initialize SW scoreboard init kernel state
37     //!
38     //! \return   MOS_STATUS
39     //!           MOS_STATUS_SUCCESS if success, else fail reason
40     //!
41     MOS_STATUS InitKernelState()override;
42 
43     //!
44     //! \brief    SW scoreboard init kernel function
45     //!
46     //! \param    [in] params
47     //!           Pointer to KernelParams
48     //!
49     //! \return   MOS_STATUS
50     //!           MOS_STATUS_SUCCESS if success, else fail reason
51     //!
52     MOS_STATUS Execute(KernelParams *params)override;
53 
54     //!
55     //! \brief    Constructor
56     //!
CodechalEncodeSwScoreboardMdfG12(CodechalEncoderState * encoder)57     CodechalEncodeSwScoreboardMdfG12(CodechalEncoderState* encoder) :
58         CodechalEncodeSwScoreboardG12(encoder) {}
59 
60     //!
61     //! \brief    Destructor
62     //!
~CodechalEncodeSwScoreboardMdfG12()63     virtual ~CodechalEncodeSwScoreboardMdfG12() { ReleaseResources(); };
64 
65 protected:
66     //!
67     //! \brief    SW scoreboard init kernel Curbe data
68     //!
69     struct CurbeData
70     {
71         // DW0
72         union
73         {
74             struct
75             {
76                 uint32_t   scoreboardWidth    : MOS_BITFIELD_RANGE( 0, 15);
77                 uint32_t   scoreboardHeight   : MOS_BITFIELD_RANGE(16, 31);
78             };
79             struct
80             {
81                 uint32_t   value;
82             };
83         } DW0;
84 
85         // DW1
86         union
87         {
88             struct
89             {
90                 uint32_t   isHevc                   : MOS_BITFIELD_BIT  (     0);
91                 uint32_t   reserved                 : MOS_BITFIELD_RANGE( 1, 31);
92             };
93             struct
94             {
95                 uint32_t   value;
96             };
97         } DW1;
98 
99         // DW2
100         union
101         {
102             struct
103             {
104                 uint32_t   numberOfWaveFrontsSplits : MOS_BITFIELD_RANGE( 0,  7);
105                 uint32_t   numberofChildThreads     : MOS_BITFIELD_RANGE( 8, 15);
106                 uint32_t   reserved                 : MOS_BITFIELD_RANGE(16, 31);
107             };
108             struct
109             {
110                 uint32_t   value;
111             };
112         } DW2;
113 
114         // DW3
115         union
116         {
117             struct
118             {
119                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
120             };
121             struct
122             {
123                 uint32_t   value;
124             };
125         } DW3;
126 
127         // DW4
128         union
129         {
130             struct
131             {
132                 uint32_t   dependencyPattern  : MOS_BITFIELD_RANGE( 0, 15);
133                 uint32_t   reserved           : MOS_BITFIELD_RANGE(16, 31);
134             };
135             struct
136             {
137                 uint32_t   value;
138             };
139         } DW4;
140 
141         // DW5
142         union
143         {
144             struct
145             {
146                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
147             };
148             struct
149             {
150                 uint32_t   value;
151             };
152         } DW5;
153 
154         // DW6
155         union
156         {
157             struct
158             {
159                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
160             };
161             struct
162             {
163                 uint32_t   value;
164             };
165         } DW6;
166 
167         // DW7
168         union
169         {
170             struct
171             {
172                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
173             };
174             struct
175             {
176                 uint32_t   value;
177             };
178         } DW7;
179 
180         // DW8
181         union
182         {
183             struct
184             {
185                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
186             };
187             struct
188             {
189                 uint32_t   value;
190             };
191         } DW8;
192 
193         // DW9
194         union
195         {
196             struct
197             {
198                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
199             };
200             struct
201             {
202                 uint32_t   value;
203             };
204         } DW9;
205 
206         // DW10
207         union
208         {
209             struct
210             {
211                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
212             };
213             struct
214             {
215                 uint32_t   value;
216             };
217         } DW10;
218 
219         // DW11
220         union
221         {
222             struct
223             {
224                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
225             };
226             struct
227             {
228                 uint32_t   value;
229             };
230         } DW11;
231 
232         // DW12
233         union
234         {
235             struct
236             {
237                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
238             };
239             struct
240             {
241                 uint32_t   value;
242             };
243         } DW12;
244 
245         // DW13
246         union
247         {
248             struct
249             {
250                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
251             };
252             struct
253             {
254                 uint32_t   value;
255             };
256         } DW13;
257 
258         // DW14
259         union
260         {
261             struct
262             {
263                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
264             };
265             struct
266             {
267                 uint32_t   value;
268             };
269         } DW14;
270 
271         // DW15
272         union
273         {
274             struct
275             {
276                 uint32_t   reserved           : MOS_BITFIELD_RANGE( 0, 31);
277             };
278             struct
279             {
280                 uint32_t   value;
281             };
282         } DW15;
283     };
284     C_ASSERT(MOS_BYTES_TO_DWORDS(sizeof(CurbeData)) == 16);
285 
286     CmThreadSpace          *m_threadSpace = nullptr;
287     CmKernel               *m_cmKrn = nullptr;
288     CmProgram              *m_cmProgram = nullptr;
289     CmSurface2D            *m_scoreboardSurface = nullptr;
290     CmSurface2D            *m_lcuInfoSurface = nullptr;
291 
292     //!
293     //! \brief    Set Curbe (depends on Generation/implementation)
294     //!
295     //! \return   MOS_STATUS
296     //!           MOS_STATUS_SUCCESS if success, else fail reason
297     //!
298     virtual MOS_STATUS SetCurbe(CurbeData& curbe);
299 
300     MOS_STATUS SetupSurfaces();
301     MOS_STATUS SetupKernelArgs();
302     MOS_STATUS ReleaseResources();
303 };
304 
305 #endif  // __CODECHAL_ENCODE_SW_SCOREBOARD_G12_H__
306