Debian Codegraph @

media_driver/agnostic/common/cm/cm_surface.h

raw
1 /*
2 * Copyright (c) 2017, 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 cm_surface.h
24 //! \brief Contains Class CmSurface definitions
25 //!
26 #pragma once
27
28 #include "cm_def.h"
29 #include "cm_surface_manager.h"
30 #include "frame_tracker.h"
31
32 namespace CMRT_UMD
33 {
34
35 class CmSurfaceManager;
36 class CmEventRT;
37 class CSync;
38
39 class CmSurface
40 {
41 public:
42 static int32_t Destroy( CmSurface* &surface );
43 bool IsCmCreated( void ){ return m_isCmCreated; }
44 virtual CM_ENUM_CLASS_TYPE Type() const = 0;
45 int32_t TouchDeviceQueue();
46 virtual int32_t WaitForReferenceFree();
47 int32_t SetMemoryObjectControl(MEMORY_OBJECT_CONTROL memCtrl, MEMORY_TYPE memType, uint32_t age);
48 int32_t SetResourceUsage(MOS_HW_RESOURCE_DEF mosUsage);
49
50 std::string GetFormatString(CM_SURFACE_FORMAT format);
51 virtual void DumpContent(uint32_t kernelNumber, char *kernelName, int32_t taskId, uint32_t argIndex, uint32_t vectorIndex) { return; }
52 virtual void Log(std::ostringstream &oss) { return; }
53 inline void SetRenderTracker(uint32_t index, uint32_t tracker) {m_lastRenderTracker.Merge(index, tracker); }
54 inline void SetFastTracker(uint32_t index, uint32_t tracker) {m_lastFastTracker.Merge(index, tracker); }
55 inline void SetVeboxTracker(uint32_t tracker) {m_lastVeboxTracker = tracker; }
56 inline void DelayDestroy() { m_released = true; }
57 inline bool IsDelayDestroyed() {return m_released; }
58 inline bool AllReferenceCompleted() {
59 // not called in render, otherwise it finished execution in render
60 return (m_lastRenderTracker.IsExpired())
61 // not called in enqueuefast, otherwise it finished execution in enqueuefast
62 && (m_lastFastTracker.IsExpired())
63 // not called in vebox, otherwise it finished execution in vebox
64 && (m_lastVeboxTracker == 0 || ((int)(m_lastVeboxTracker - m_surfaceMgr->LatestVeboxTracker()) <= 0));
65 }
66 inline bool CanBeDestroyed() {
67 return m_released && AllReferenceCompleted();
68 }
69
70 inline CmSurface*& DelayDestroyPrev() {return m_delayDestroyPrev; }
71 inline CmSurface*& DelayDestroyNext() {return m_delayDestroyNext; }
72
73 inline uint8_t GetPropertyIndex() {return m_propertyIndex; }
74
75 protected:
76 CmSurface( CmSurfaceManager* surfMgr , bool isCmCreated );
77 virtual ~CmSurface( void );
78 int32_t Initialize( uint32_t index );
79
80 int32_t FlushDeviceQueue( CmEventRT* event );
81 bool MemoryObjectCtrlPolicyCheck(MEMORY_OBJECT_CONTROL memCtrl);
82
83 #if MDF_SURFACE_CONTENT_DUMP
84 MOS_CONTEXT* GetMosContext();
85 #endif // #if MDF_SURFACE_CONTENT_DUMP
86
87 SurfaceIndex* m_index;
88
89 CmSurfaceManager* m_surfaceMgr;
90
91 bool m_isCmCreated;
92
93 CM_SURFACE_MEM_OBJ_CTRL m_memObjCtrl;
94
95 FrameTrackerToken m_lastRenderTracker;
96
97 FrameTrackerToken m_lastFastTracker;
98
99 uint32_t m_lastVeboxTracker;
100
101 bool m_released; // if true, means it is been destroyed by app and added in the delaydestroy queue in surfmgr
102
103 CmSurface *m_delayDestroyPrev; // previous node in bi-directional list
104
105 CmSurface *m_delayDestroyNext; // next node in bi-directional list
106
107 uint8_t m_propertyIndex; // Index to the current surface properties
108
109 private:
110 CmSurface (const CmSurface& other);
111 CmSurface& operator= (const CmSurface& other);
112 };
113 }; //namespace