• 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 
25 #if GFXSTREAM_ENABLE_HOST_GLES
26 #include "renderControl_dec/renderControl_dec.h"
27 #include "RenderThreadInfoGl.h"
28 #endif
29 
30 #include "RenderThreadInfoVk.h"
31 
32 #if GFXSTREAM_ENABLE_HOST_MAGMA
33 #include "RenderThreadInfoMagma.h"
34 #endif
35 
36 namespace gfxstream {
37 
38 // A class used to model the state of each RenderThread related
39 struct RenderThreadInfo {
40     // Create new instance. Only call this once per thread.
41     // Future callls to get() will return this instance until
42     // it is destroyed.
43     RenderThreadInfo();
44 
45     // Destructor.
46     ~RenderThreadInfo();
47 
48     // Return the current thread's instance, if any, or NULL.
49     static RenderThreadInfo* get();
50 
51     // Loop over all active render thread infos
52     static void forAllRenderThreadInfos(std::function<void(RenderThreadInfo*)>);
53 
54 #if GFXSTREAM_ENABLE_HOST_GLES
55     void initGl();
56 #endif
57 
58     // The unique id of owner guest process of this render thread
59     uint64_t                        m_puid = 0;
60     std::optional<std::string>      m_processName;
61 
62 #if GFXSTREAM_ENABLE_HOST_GLES
63     renderControl_decoder_context_t m_rcDec;
64     std::optional<gl::RenderThreadInfoGl> m_glInfo;
65 #endif
66 
67     std::optional<vk::RenderThreadInfoVk> m_vkInfo;
68 
69 #if GFXSTREAM_ENABLE_HOST_MAGMA
70     std::optional<RenderThreadInfoMagma> m_magmaInfo;
71 #endif
72 
73     // Whether this thread was used to perform composition.
74     bool m_isCompositionThread = false;
75 
76     // Functions to save / load a snapshot
77     // They must be called after Framebuffer snapshot
78     void onSave(android::base::Stream* stream);
79     bool onLoad(android::base::Stream* stream);
80 
81     // Sometimes we can load render thread info before
82     // FrameBuffer repopulates the contexts.
83     void postLoadRefreshCurrentContextSurfacePtrs();
84 };
85 
86 }  // namespace gfxstream
87 
88 #endif
89