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 PLSProgramCache; 51 class RendererGL; 52 class StateManagerGL; 53 54 class RendererGL : angle::NonCopyable 55 { 56 public: 57 RendererGL(std::unique_ptr<FunctionsGL> functions, 58 const egl::AttributeMap &attribMap, 59 DisplayGL *display); 60 virtual ~RendererGL(); 61 62 angle::Result flush(); 63 angle::Result finish(); 64 65 gl::GraphicsResetStatus getResetStatus(); 66 67 // EXT_debug_marker 68 void insertEventMarker(GLsizei length, const char *marker); 69 void pushGroupMarker(GLsizei length, const char *marker); 70 void popGroupMarker(); 71 72 // KHR_debug 73 void pushDebugGroup(GLenum source, GLuint id, const std::string &message); 74 void popDebugGroup(); 75 76 GLint getGPUDisjoint(); 77 GLint64 getTimestamp(); 78 79 const gl::Version &getMaxSupportedESVersion() const; getFunctions()80 const FunctionsGL *getFunctions() const { return mFunctions.get(); } getStateManager()81 StateManagerGL *getStateManager() const { return mStateManager; } getFeatures()82 const angle::FeaturesGL &getFeatures() const { return mFeatures; } getBlitter()83 BlitGL *getBlitter() const { return mBlitter; } getMultiviewClearer()84 ClearMultiviewGL *getMultiviewClearer() const { return mMultiviewClearer; } 85 PLSProgramCache *getPLSProgramCache(); 86 87 MultiviewImplementationTypeGL getMultiviewImplementationType() const; 88 const gl::Caps &getNativeCaps() const; 89 const gl::TextureCapsMap &getNativeTextureCaps() const; 90 const gl::Extensions &getNativeExtensions() const; 91 const gl::Limitations &getNativeLimitations() const; 92 const ShPixelLocalStorageOptions &getNativePixelLocalStorageOptions() const; 93 void initializeFrontendFeatures(angle::FrontendFeatures *features) const; 94 95 angle::Result dispatchCompute(const gl::Context *context, 96 GLuint numGroupsX, 97 GLuint numGroupsY, 98 GLuint numGroupsZ); 99 angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect); 100 101 angle::Result memoryBarrier(GLbitfield barriers); 102 angle::Result memoryBarrierByRegion(GLbitfield barriers); 103 104 void framebufferFetchBarrier(); 105 106 // Checks if the driver has the KHR_parallel_shader_compile or ARB_parallel_shader_compile 107 // extension. 108 bool hasNativeParallelCompile(); 109 void setMaxShaderCompilerThreads(GLuint count); 110 111 void setNeedsFlushBeforeDeleteTextures(); 112 void flushIfNecessaryBeforeDeleteTextures(); 113 114 void markWorkSubmitted(); 115 116 void handleGPUSwitch(); 117 118 private: 119 void ensureCapsInitialized() const; 120 void generateCaps(gl::Caps *outCaps, 121 gl::TextureCapsMap *outTextureCaps, 122 gl::Extensions *outExtensions, 123 gl::Limitations *outLimitations) const; 124 125 mutable gl::Version mMaxSupportedESVersion; 126 127 std::unique_ptr<FunctionsGL> mFunctions; 128 StateManagerGL *mStateManager; 129 130 BlitGL *mBlitter; 131 ClearMultiviewGL *mMultiviewClearer; 132 133 // Load/store programs for EXT_shader_pixel_local_storage. 134 PLSProgramCache *mPLSProgramCache = nullptr; 135 136 bool mUseDebugOutput; 137 138 mutable bool mCapsInitialized; 139 mutable gl::Caps mNativeCaps; 140 mutable gl::TextureCapsMap mNativeTextureCaps; 141 mutable gl::Extensions mNativeExtensions; 142 mutable gl::Limitations mNativeLimitations; 143 mutable ShPixelLocalStorageOptions mNativePLSOptions; 144 mutable MultiviewImplementationTypeGL mMultiviewImplementationType; 145 146 bool mWorkDoneSinceLastFlush = false; 147 148 bool mNativeParallelCompileEnabled; 149 150 angle::FeaturesGL mFeatures; 151 152 // Workaround for anglebug.com/4267 153 bool mNeedsFlushBeforeDeleteTextures; 154 }; 155 156 } // namespace rx 157 158 #endif // LIBANGLE_RENDERER_GL_RENDERERGL_H_ 159