• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef _LIB_OPENGL_RENDER_THREAD_INFO_H
17 #define _LIB_OPENGL_RENDER_THREAD_INFO_H
18 
19 #include <functional>
20 #include <memory>
21 #include <unordered_set>
22 
23 #include "aemu/base/files/Stream.h"
24 #include "renderControl_dec/renderControl_dec.h"
25 #include "RenderThreadInfoGl.h"
26 #include "RenderThreadInfoMagma.h"
27 #include "RenderThreadInfoVk.h"
28 
29 namespace gfxstream {
30 
31 // A class used to model the state of each RenderThread related
32 struct RenderThreadInfo {
33     // Create new instance. Only call this once per thread.
34     // Future callls to get() will return this instance until
35     // it is destroyed.
36     RenderThreadInfo();
37 
38     // Destructor.
39     ~RenderThreadInfo();
40 
41     // Return the current thread's instance, if any, or NULL.
42     static RenderThreadInfo* get();
43 
44     // Loop over all active render thread infos
45     static void forAllRenderThreadInfos(std::function<void(RenderThreadInfo*)>);
46 
47     void initGl();
48 
49     renderControl_decoder_context_t m_rcDec;
50 
51     // The unique id of owner guest process of this render thread
52     uint64_t                        m_puid = 0;
53     std::optional<std::string>      m_processName;
54 
55     std::optional<gl::RenderThreadInfoGl> m_glInfo;
56     std::optional<vk::RenderThreadInfoVk> m_vkInfo;
57     std::optional<RenderThreadInfoMagma> m_magmaInfo;
58 
59     // Whether this thread was used to perform composition.
60     bool m_isCompositionThread = false;
61 
62     // Functions to save / load a snapshot
63     // They must be called after Framebuffer snapshot
64     void onSave(android::base::Stream* stream);
65     bool onLoad(android::base::Stream* stream);
66 
67     // Sometimes we can load render thread info before
68     // FrameBuffer repopulates the contexts.
69     void postLoadRefreshCurrentContextSurfacePtrs();
70 };
71 
72 }  // namespace gfxstream
73 
74 #endif
75