1 /*
2 * Copyright (c) 2023, 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     mos_gpucontext_specific_next_xe.h
24 //! \brief    Container class for the linux/Android specfic gpu context
25 //!
26 
27 #ifndef __GPU_CONTEXT_SPECIFIC_NEXT_XE_H__
28 #define __GPU_CONTEXT_SPECIFIC_NEXT_XE_H__
29 
30 #include "mos_bufmgr_xe.h"
31 #include "mos_gpucontext_specific_next.h"
32 
33 //!
34 //! \class  GpuContextSpecific
35 //! \brief  Linux/Android specific gpu context
36 //!
37 class GpuContextSpecificNextXe : public GpuContextSpecificNext
38 {
39 public:
40     //!
41     //! \brief  Constructor
42     //!
GpuContextSpecificNextXe(const MOS_GPU_NODE gpuNode,CmdBufMgrNext * cmdBufMgr,GpuContextNext * reusedContext)43     GpuContextSpecificNextXe(
44         const MOS_GPU_NODE gpuNode,
45         CmdBufMgrNext      *cmdBufMgr,
46         GpuContextNext    *reusedContext) : GpuContextSpecificNext(gpuNode, cmdBufMgr, reusedContext){}
47 
48     //!
49     //! \brief  Destructor
50     //!
51     ~GpuContextSpecificNextXe();
52 
53     virtual void Clear(void) override;
54 
55     virtual MOS_STATUS SubmitCommandBuffer(
56         MOS_STREAM_HANDLE   streamState,
57         PMOS_COMMAND_BUFFER cmdBuffer,
58         bool                nullRendering) override;
59 
60     //!
61     //! \brief  Set the Gpu priority for workload scheduling.
62     //! \param [in] priority
63     //!             priority to set for current workload.
64     //! \return void
65     //!
66     virtual void UpdatePriority(int32_t priority) override;
67 
68     //!
69     //! \brief    Allocate gpu status buffer for gpu sync
70     //! \return   MOS_STATUS
71     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
72     //!
73     //MOS_STATUS AllocateGPUStatusBuf();
74 
75 protected:
76     virtual MOS_STATUS ReportEngineInfo(
77         void *engine_map,
78         int engineNum, bool engineSelectEnable = false) override;
79 
80     virtual MOS_STATUS Init3DCtx(PMOS_CONTEXT osParameters,
81                 PMOS_GPUCTX_CREATOPTIONS createOption,
82                 unsigned int *nengine,
83                 void *engine_map) override;
84 
85     virtual MOS_STATUS InitComputeCtx(PMOS_CONTEXT osParameters,
86                 unsigned int *nengine,
87                 void *engine_map,
88                 MOS_GPU_NODE gpuNode,
89                 bool *isEngineSelectEnable) override;
90 
91     virtual MOS_STATUS InitVdVeCtx(PMOS_CONTEXT osParameters,
92                 MOS_STREAM_HANDLE streamState,
93                 PMOS_GPUCTX_CREATOPTIONS createOption,
94                 unsigned int *nengine,
95                 void *engine_map,
96                 MOS_GPU_NODE gpuNode,
97                 bool *isEngineSelectEnable) override;
98 
99     virtual MOS_STATUS InitBltCtx(PMOS_CONTEXT osParameters,
100                 unsigned int *nengine,
101                 void *engine_map) override;
102 
103     virtual int32_t ParallelSubmitCommands(std::map<uint32_t, PMOS_COMMAND_BUFFER> secondaryCmdBufs,
104                                    PMOS_CONTEXT osContext,
105                                    uint32_t execFlag,
106                                    int32_t dr4) override;
107 
108     virtual MOS_STATUS PatchCommandBuffer(MOS_STREAM_HANDLE   streamState,
109                 PMOS_COMMAND_BUFFER cmdBuffer);
110 
111     virtual MOS_STATUS EndSubmitCommandBuffer(MOS_STREAM_HANDLE   streamState,
112                 PMOS_COMMAND_BUFFER cmdBuffer,
113                 bool                cmdBufMapIsReused);
114 
115 private:
116     void ClearSecondaryCmdBuffer(bool cmdBufMapIsReused);
117 
118 MEDIA_CLASS_DEFINE_END(GpuContextSpecificNextXe)
119 };
120 #endif  // __GPU_CONTEXT_SPECIFIC_NEXT_XE_H__
121