xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/gl/RendererGL.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2015 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // RendererGL.h: Defines the class interface for RendererGL.
8 
9 #ifndef LIBANGLE_RENDERER_GL_RENDERERGL_H_
10 #define LIBANGLE_RENDERER_GL_RENDERERGL_H_
11 
12 #include <list>
13 #include <mutex>
14 
15 #include "libANGLE/Caps.h"
16 #include "libANGLE/Error.h"
17 #include "libANGLE/Version.h"
18 #include "libANGLE/renderer/gl/renderergl_utils.h"
19 #include "platform/autogen/FeaturesGL_autogen.h"
20 
21 namespace angle
22 {
23 struct FrontendFeatures;
24 }  // namespace angle
25 
26 namespace gl
27 {
28 struct IndexRange;
29 class Path;
30 class State;
31 }  // namespace gl
32 
33 namespace egl
34 {
35 class AttributeMap;
36 }  // namespace egl
37 
38 namespace sh
39 {
40 struct BlockMemberInfo;
41 }  // namespace sh
42 
43 namespace rx
44 {
45 class BlitGL;
46 class ClearMultiviewGL;
47 class ContextImpl;
48 class DisplayGL;
49 class FunctionsGL;
50 class RendererGL;
51 class StateManagerGL;
52 
53 class RendererGL : angle::NonCopyable
54 {
55   public:
56     RendererGL(std::unique_ptr<FunctionsGL> functions,
57                const egl::AttributeMap &attribMap,
58                DisplayGL *display);
59     virtual ~RendererGL();
60 
61     angle::Result flush();
62     angle::Result finish();
63 
64     gl::GraphicsResetStatus getResetStatus();
65 
66     // EXT_debug_marker
67     void insertEventMarker(GLsizei length, const char *marker);
68     void pushGroupMarker(GLsizei length, const char *marker);
69     void popGroupMarker();
70 
71     // KHR_debug
72     void pushDebugGroup(GLenum source, GLuint id, const std::string &message);
73     void popDebugGroup();
74 
75     GLint getGPUDisjoint();
76     GLint64 getTimestamp();
77 
78     const gl::Version &getMaxSupportedESVersion() const;
getFunctions()79     const FunctionsGL *getFunctions() const { return mFunctions.get(); }
getStateManager()80     StateManagerGL *getStateManager() const { return mStateManager; }
getFeatures()81     const angle::FeaturesGL &getFeatures() const { return mFeatures; }
getBlitter()82     BlitGL *getBlitter() const { return mBlitter; }
getMultiviewClearer()83     ClearMultiviewGL *getMultiviewClearer() const { return mMultiviewClearer; }
84 
85     MultiviewImplementationTypeGL getMultiviewImplementationType() const;
86     const gl::Caps &getNativeCaps() const;
87     const gl::TextureCapsMap &getNativeTextureCaps() const;
88     const gl::Extensions &getNativeExtensions() const;
89     const gl::Limitations &getNativeLimitations() const;
90     const ShPixelLocalStorageOptions &getNativePixelLocalStorageOptions() const;
91     void initializeFrontendFeatures(angle::FrontendFeatures *features) const;
92 
93     angle::Result dispatchCompute(const gl::Context *context,
94                                   GLuint numGroupsX,
95                                   GLuint numGroupsY,
96                                   GLuint numGroupsZ);
97     angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect);
98 
99     angle::Result memoryBarrier(GLbitfield barriers);
100     angle::Result memoryBarrierByRegion(GLbitfield barriers);
101 
102     void framebufferFetchBarrier();
103 
104     // Checks if the driver has the KHR_parallel_shader_compile or ARB_parallel_shader_compile
105     // extension.
106     bool hasNativeParallelCompile();
107     void setMaxShaderCompilerThreads(GLuint count);
108 
109     void setNeedsFlushBeforeDeleteTextures();
110     void flushIfNecessaryBeforeDeleteTextures();
111 
112     void markWorkSubmitted();
113 
114     void handleGPUSwitch();
115 
116   private:
117     void ensureCapsInitialized() const;
118     void generateCaps(gl::Caps *outCaps,
119                       gl::TextureCapsMap *outTextureCaps,
120                       gl::Extensions *outExtensions,
121                       gl::Limitations *outLimitations) const;
122 
123     mutable gl::Version mMaxSupportedESVersion;
124 
125     std::unique_ptr<FunctionsGL> mFunctions;
126     StateManagerGL *mStateManager;
127 
128     BlitGL *mBlitter;
129     ClearMultiviewGL *mMultiviewClearer;
130 
131     bool mUseDebugOutput;
132 
133     mutable bool mCapsInitialized;
134     mutable gl::Caps mNativeCaps;
135     mutable gl::TextureCapsMap mNativeTextureCaps;
136     mutable gl::Extensions mNativeExtensions;
137     mutable gl::Limitations mNativeLimitations;
138     mutable ShPixelLocalStorageOptions mNativePLSOptions;
139     mutable MultiviewImplementationTypeGL mMultiviewImplementationType;
140 
141     bool mWorkDoneSinceLastFlush = false;
142 
143     bool mNativeParallelCompileEnabled;
144 
145     angle::FeaturesGL mFeatures;
146 
147     // Workaround for anglebug.com/40644715
148     bool mNeedsFlushBeforeDeleteTextures;
149 };
150 
151 }  // namespace rx
152 
153 #endif  // LIBANGLE_RENDERER_GL_RENDERERGL_H_
154