xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/gl/RendererGL.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2015 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker 
7*8975f5c5SAndroid Build Coastguard Worker // RendererGL.cpp: Implements the class methods for RendererGL.
8*8975f5c5SAndroid Build Coastguard Worker 
9*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/RendererGL.h"
10*8975f5c5SAndroid Build Coastguard Worker 
11*8975f5c5SAndroid Build Coastguard Worker #include <EGL/eglext.h>
12*8975f5c5SAndroid Build Coastguard Worker #include <thread>
13*8975f5c5SAndroid Build Coastguard Worker 
14*8975f5c5SAndroid Build Coastguard Worker #include "common/debug.h"
15*8975f5c5SAndroid Build Coastguard Worker #include "common/system_utils.h"
16*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/AttributeMap.h"
17*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Context.h"
18*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Display.h"
19*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/State.h"
20*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Surface.h"
21*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/BlitGL.h"
22*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/BufferGL.h"
23*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/ClearMultiviewGL.h"
24*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/CompilerGL.h"
25*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/ContextGL.h"
26*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/DisplayGL.h"
27*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/FenceNVGL.h"
28*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/FramebufferGL.h"
29*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/FunctionsGL.h"
30*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/ProgramGL.h"
31*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/QueryGL.h"
32*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/RenderbufferGL.h"
33*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/SamplerGL.h"
34*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/ShaderGL.h"
35*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/StateManagerGL.h"
36*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/SurfaceGL.h"
37*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/SyncGL.h"
38*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/TextureGL.h"
39*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/TransformFeedbackGL.h"
40*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/VertexArrayGL.h"
41*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/gl/renderergl_utils.h"
42*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/renderer_utils.h"
43*8975f5c5SAndroid Build Coastguard Worker 
44*8975f5c5SAndroid Build Coastguard Worker namespace
45*8975f5c5SAndroid Build Coastguard Worker {
46*8975f5c5SAndroid Build Coastguard Worker 
SetMaxShaderCompilerThreads(const rx::FunctionsGL * functions,GLuint count)47*8975f5c5SAndroid Build Coastguard Worker void SetMaxShaderCompilerThreads(const rx::FunctionsGL *functions, GLuint count)
48*8975f5c5SAndroid Build Coastguard Worker {
49*8975f5c5SAndroid Build Coastguard Worker     if (functions->maxShaderCompilerThreadsKHR != nullptr)
50*8975f5c5SAndroid Build Coastguard Worker     {
51*8975f5c5SAndroid Build Coastguard Worker         functions->maxShaderCompilerThreadsKHR(count);
52*8975f5c5SAndroid Build Coastguard Worker     }
53*8975f5c5SAndroid Build Coastguard Worker     else
54*8975f5c5SAndroid Build Coastguard Worker     {
55*8975f5c5SAndroid Build Coastguard Worker         ASSERT(functions->maxShaderCompilerThreadsARB != nullptr);
56*8975f5c5SAndroid Build Coastguard Worker         functions->maxShaderCompilerThreadsARB(count);
57*8975f5c5SAndroid Build Coastguard Worker     }
58*8975f5c5SAndroid Build Coastguard Worker }
59*8975f5c5SAndroid Build Coastguard Worker 
60*8975f5c5SAndroid Build Coastguard Worker #if defined(ANGLE_PLATFORM_ANDROID)
61*8975f5c5SAndroid Build Coastguard Worker const char *kIgnoredErrors[] = {
62*8975f5c5SAndroid Build Coastguard Worker     // Wrong error message on Android Q Pixel 2. http://anglebug.com/42262155
63*8975f5c5SAndroid Build Coastguard Worker     "FreeAllocationOnTimestamp - Reference to buffer created from "
64*8975f5c5SAndroid Build Coastguard Worker     "different context without a share list. Application failed to pass "
65*8975f5c5SAndroid Build Coastguard Worker     "share_context to eglCreateContext. Results are undefined.",
66*8975f5c5SAndroid Build Coastguard Worker     // http://crbug.com/1348684
67*8975f5c5SAndroid Build Coastguard Worker     "UpdateTimestamp - Reference to buffer created from different context without a share list. "
68*8975f5c5SAndroid Build Coastguard Worker     "Application failed to pass share_context to eglCreateContext. Results are undefined.",
69*8975f5c5SAndroid Build Coastguard Worker     "Attempt to use resource over contexts without enabling context sharing. App must pass a "
70*8975f5c5SAndroid Build Coastguard Worker     "share_context to eglCreateContext() to share resources.",
71*8975f5c5SAndroid Build Coastguard Worker };
72*8975f5c5SAndroid Build Coastguard Worker #endif  // defined(ANGLE_PLATFORM_ANDROID)
73*8975f5c5SAndroid Build Coastguard Worker 
74*8975f5c5SAndroid Build Coastguard Worker const char *kIgnoredWarnings[] = {
75*8975f5c5SAndroid Build Coastguard Worker     // We always request GL_ARB_gpu_shader5 and GL_EXT_gpu_shader5 when compiling shaders but some
76*8975f5c5SAndroid Build Coastguard Worker     // drivers warn when it is not present. This ends up spamming the console on every shader
77*8975f5c5SAndroid Build Coastguard Worker     // compile.
78*8975f5c5SAndroid Build Coastguard Worker     "extension `GL_ARB_gpu_shader5' unsupported in",
79*8975f5c5SAndroid Build Coastguard Worker     "extension `GL_EXT_gpu_shader5' unsupported in",
80*8975f5c5SAndroid Build Coastguard Worker };
81*8975f5c5SAndroid Build Coastguard Worker 
82*8975f5c5SAndroid Build Coastguard Worker }  // namespace
83*8975f5c5SAndroid Build Coastguard Worker 
LogGLDebugMessage(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar * message,const void * userParam)84*8975f5c5SAndroid Build Coastguard Worker static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source,
85*8975f5c5SAndroid Build Coastguard Worker                                                    GLenum type,
86*8975f5c5SAndroid Build Coastguard Worker                                                    GLuint id,
87*8975f5c5SAndroid Build Coastguard Worker                                                    GLenum severity,
88*8975f5c5SAndroid Build Coastguard Worker                                                    GLsizei length,
89*8975f5c5SAndroid Build Coastguard Worker                                                    const GLchar *message,
90*8975f5c5SAndroid Build Coastguard Worker                                                    const void *userParam)
91*8975f5c5SAndroid Build Coastguard Worker {
92*8975f5c5SAndroid Build Coastguard Worker     std::string sourceText   = gl::GetDebugMessageSourceString(source);
93*8975f5c5SAndroid Build Coastguard Worker     std::string typeText     = gl::GetDebugMessageTypeString(type);
94*8975f5c5SAndroid Build Coastguard Worker     std::string severityText = gl::GetDebugMessageSeverityString(severity);
95*8975f5c5SAndroid Build Coastguard Worker 
96*8975f5c5SAndroid Build Coastguard Worker #if defined(ANGLE_PLATFORM_ANDROID)
97*8975f5c5SAndroid Build Coastguard Worker     if (type == GL_DEBUG_TYPE_ERROR)
98*8975f5c5SAndroid Build Coastguard Worker     {
99*8975f5c5SAndroid Build Coastguard Worker         for (const char *&err : kIgnoredErrors)
100*8975f5c5SAndroid Build Coastguard Worker         {
101*8975f5c5SAndroid Build Coastguard Worker             if (strncmp(err, message, length) == 0)
102*8975f5c5SAndroid Build Coastguard Worker             {
103*8975f5c5SAndroid Build Coastguard Worker                 // There is only one ignored message right now and it is quite spammy, around 3MB
104*8975f5c5SAndroid Build Coastguard Worker                 // for a complete end2end tests run, so don't print it even as a warning.
105*8975f5c5SAndroid Build Coastguard Worker                 return;
106*8975f5c5SAndroid Build Coastguard Worker             }
107*8975f5c5SAndroid Build Coastguard Worker         }
108*8975f5c5SAndroid Build Coastguard Worker     }
109*8975f5c5SAndroid Build Coastguard Worker #endif  // defined(ANGLE_PLATFORM_ANDROID)
110*8975f5c5SAndroid Build Coastguard Worker 
111*8975f5c5SAndroid Build Coastguard Worker     if (type == GL_DEBUG_TYPE_ERROR)
112*8975f5c5SAndroid Build Coastguard Worker     {
113*8975f5c5SAndroid Build Coastguard Worker         ERR() << std::endl
114*8975f5c5SAndroid Build Coastguard Worker               << "\tSource: " << sourceText << std::endl
115*8975f5c5SAndroid Build Coastguard Worker               << "\tType: " << typeText << std::endl
116*8975f5c5SAndroid Build Coastguard Worker               << "\tID: " << gl::FmtHex(id) << std::endl
117*8975f5c5SAndroid Build Coastguard Worker               << "\tSeverity: " << severityText << std::endl
118*8975f5c5SAndroid Build Coastguard Worker               << "\tMessage: " << message;
119*8975f5c5SAndroid Build Coastguard Worker     }
120*8975f5c5SAndroid Build Coastguard Worker     else if (type != GL_DEBUG_TYPE_PERFORMANCE)
121*8975f5c5SAndroid Build Coastguard Worker     {
122*8975f5c5SAndroid Build Coastguard Worker         // Don't print performance warnings. They tend to be very spammy in the dEQP test suite and
123*8975f5c5SAndroid Build Coastguard Worker         // there is very little we can do about them.
124*8975f5c5SAndroid Build Coastguard Worker 
125*8975f5c5SAndroid Build Coastguard Worker         for (const char *&warn : kIgnoredWarnings)
126*8975f5c5SAndroid Build Coastguard Worker         {
127*8975f5c5SAndroid Build Coastguard Worker             if (strstr(message, warn) != nullptr)
128*8975f5c5SAndroid Build Coastguard Worker             {
129*8975f5c5SAndroid Build Coastguard Worker                 return;
130*8975f5c5SAndroid Build Coastguard Worker             }
131*8975f5c5SAndroid Build Coastguard Worker         }
132*8975f5c5SAndroid Build Coastguard Worker 
133*8975f5c5SAndroid Build Coastguard Worker         // TODO(ynovikov): filter into WARN and INFO if INFO is ever implemented
134*8975f5c5SAndroid Build Coastguard Worker         WARN() << std::endl
135*8975f5c5SAndroid Build Coastguard Worker                << "\tSource: " << sourceText << std::endl
136*8975f5c5SAndroid Build Coastguard Worker                << "\tType: " << typeText << std::endl
137*8975f5c5SAndroid Build Coastguard Worker                << "\tID: " << gl::FmtHex(id) << std::endl
138*8975f5c5SAndroid Build Coastguard Worker                << "\tSeverity: " << severityText << std::endl
139*8975f5c5SAndroid Build Coastguard Worker                << "\tMessage: " << message;
140*8975f5c5SAndroid Build Coastguard Worker     }
141*8975f5c5SAndroid Build Coastguard Worker }
142*8975f5c5SAndroid Build Coastguard Worker 
143*8975f5c5SAndroid Build Coastguard Worker namespace rx
144*8975f5c5SAndroid Build Coastguard Worker {
145*8975f5c5SAndroid Build Coastguard Worker 
RendererGL(std::unique_ptr<FunctionsGL> functions,const egl::AttributeMap & attribMap,DisplayGL * display)146*8975f5c5SAndroid Build Coastguard Worker RendererGL::RendererGL(std::unique_ptr<FunctionsGL> functions,
147*8975f5c5SAndroid Build Coastguard Worker                        const egl::AttributeMap &attribMap,
148*8975f5c5SAndroid Build Coastguard Worker                        DisplayGL *display)
149*8975f5c5SAndroid Build Coastguard Worker     : mMaxSupportedESVersion(0, 0),
150*8975f5c5SAndroid Build Coastguard Worker       mFunctions(std::move(functions)),
151*8975f5c5SAndroid Build Coastguard Worker       mStateManager(nullptr),
152*8975f5c5SAndroid Build Coastguard Worker       mBlitter(nullptr),
153*8975f5c5SAndroid Build Coastguard Worker       mMultiviewClearer(nullptr),
154*8975f5c5SAndroid Build Coastguard Worker       mUseDebugOutput(false),
155*8975f5c5SAndroid Build Coastguard Worker       mCapsInitialized(false),
156*8975f5c5SAndroid Build Coastguard Worker       mMultiviewImplementationType(MultiviewImplementationTypeGL::UNSPECIFIED),
157*8975f5c5SAndroid Build Coastguard Worker       mNativeParallelCompileEnabled(false),
158*8975f5c5SAndroid Build Coastguard Worker       mNeedsFlushBeforeDeleteTextures(false)
159*8975f5c5SAndroid Build Coastguard Worker {
160*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mFunctions);
161*8975f5c5SAndroid Build Coastguard Worker     ApplyFeatureOverrides(&mFeatures, display->getState().featureOverrides);
162*8975f5c5SAndroid Build Coastguard Worker     if (!display->getState().featureOverrides.allDisabled)
163*8975f5c5SAndroid Build Coastguard Worker     {
164*8975f5c5SAndroid Build Coastguard Worker         nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures);
165*8975f5c5SAndroid Build Coastguard Worker     }
166*8975f5c5SAndroid Build Coastguard Worker     mStateManager =
167*8975f5c5SAndroid Build Coastguard Worker         new StateManagerGL(mFunctions.get(), getNativeCaps(), getNativeExtensions(), mFeatures);
168*8975f5c5SAndroid Build Coastguard Worker     mBlitter          = new BlitGL(mFunctions.get(), mFeatures, mStateManager);
169*8975f5c5SAndroid Build Coastguard Worker     mMultiviewClearer = new ClearMultiviewGL(mFunctions.get(), mStateManager);
170*8975f5c5SAndroid Build Coastguard Worker 
171*8975f5c5SAndroid Build Coastguard Worker     bool hasDebugOutput = mFunctions->isAtLeastGL(gl::Version(4, 3)) ||
172*8975f5c5SAndroid Build Coastguard Worker                           mFunctions->hasGLExtension("GL_KHR_debug") ||
173*8975f5c5SAndroid Build Coastguard Worker                           mFunctions->isAtLeastGLES(gl::Version(3, 2)) ||
174*8975f5c5SAndroid Build Coastguard Worker                           mFunctions->hasGLESExtension("GL_KHR_debug");
175*8975f5c5SAndroid Build Coastguard Worker 
176*8975f5c5SAndroid Build Coastguard Worker     mUseDebugOutput = hasDebugOutput && ShouldUseDebugLayers(attribMap);
177*8975f5c5SAndroid Build Coastguard Worker 
178*8975f5c5SAndroid Build Coastguard Worker     if (mUseDebugOutput)
179*8975f5c5SAndroid Build Coastguard Worker     {
180*8975f5c5SAndroid Build Coastguard Worker         mFunctions->enable(GL_DEBUG_OUTPUT);
181*8975f5c5SAndroid Build Coastguard Worker         mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
182*8975f5c5SAndroid Build Coastguard Worker         mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0,
183*8975f5c5SAndroid Build Coastguard Worker                                         nullptr, GL_TRUE);
184*8975f5c5SAndroid Build Coastguard Worker         mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0,
185*8975f5c5SAndroid Build Coastguard Worker                                         nullptr, GL_TRUE);
186*8975f5c5SAndroid Build Coastguard Worker         mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, 0,
187*8975f5c5SAndroid Build Coastguard Worker                                         nullptr, GL_FALSE);
188*8975f5c5SAndroid Build Coastguard Worker         mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION,
189*8975f5c5SAndroid Build Coastguard Worker                                         0, nullptr, GL_FALSE);
190*8975f5c5SAndroid Build Coastguard Worker         mFunctions->debugMessageCallback(&LogGLDebugMessage, nullptr);
191*8975f5c5SAndroid Build Coastguard Worker     }
192*8975f5c5SAndroid Build Coastguard Worker 
193*8975f5c5SAndroid Build Coastguard Worker     if (mFeatures.initializeCurrentVertexAttributes.enabled)
194*8975f5c5SAndroid Build Coastguard Worker     {
195*8975f5c5SAndroid Build Coastguard Worker         GLint maxVertexAttribs = 0;
196*8975f5c5SAndroid Build Coastguard Worker         mFunctions->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
197*8975f5c5SAndroid Build Coastguard Worker 
198*8975f5c5SAndroid Build Coastguard Worker         for (GLint i = 0; i < maxVertexAttribs; ++i)
199*8975f5c5SAndroid Build Coastguard Worker         {
200*8975f5c5SAndroid Build Coastguard Worker             mFunctions->vertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 1.0f);
201*8975f5c5SAndroid Build Coastguard Worker         }
202*8975f5c5SAndroid Build Coastguard Worker     }
203*8975f5c5SAndroid Build Coastguard Worker 
204*8975f5c5SAndroid Build Coastguard Worker     if (hasNativeParallelCompile() && !mNativeParallelCompileEnabled)
205*8975f5c5SAndroid Build Coastguard Worker     {
206*8975f5c5SAndroid Build Coastguard Worker         SetMaxShaderCompilerThreads(mFunctions.get(), 0xffffffff);
207*8975f5c5SAndroid Build Coastguard Worker         mNativeParallelCompileEnabled = true;
208*8975f5c5SAndroid Build Coastguard Worker     }
209*8975f5c5SAndroid Build Coastguard Worker }
210*8975f5c5SAndroid Build Coastguard Worker 
~RendererGL()211*8975f5c5SAndroid Build Coastguard Worker RendererGL::~RendererGL()
212*8975f5c5SAndroid Build Coastguard Worker {
213*8975f5c5SAndroid Build Coastguard Worker     SafeDelete(mBlitter);
214*8975f5c5SAndroid Build Coastguard Worker     SafeDelete(mMultiviewClearer);
215*8975f5c5SAndroid Build Coastguard Worker     SafeDelete(mStateManager);
216*8975f5c5SAndroid Build Coastguard Worker }
217*8975f5c5SAndroid Build Coastguard Worker 
flush()218*8975f5c5SAndroid Build Coastguard Worker angle::Result RendererGL::flush()
219*8975f5c5SAndroid Build Coastguard Worker {
220*8975f5c5SAndroid Build Coastguard Worker     if (!mWorkDoneSinceLastFlush && !mNeedsFlushBeforeDeleteTextures)
221*8975f5c5SAndroid Build Coastguard Worker     {
222*8975f5c5SAndroid Build Coastguard Worker         return angle::Result::Continue;
223*8975f5c5SAndroid Build Coastguard Worker     }
224*8975f5c5SAndroid Build Coastguard Worker 
225*8975f5c5SAndroid Build Coastguard Worker     mFunctions->flush();
226*8975f5c5SAndroid Build Coastguard Worker     mNeedsFlushBeforeDeleteTextures = false;
227*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush         = false;
228*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
229*8975f5c5SAndroid Build Coastguard Worker }
230*8975f5c5SAndroid Build Coastguard Worker 
finish()231*8975f5c5SAndroid Build Coastguard Worker angle::Result RendererGL::finish()
232*8975f5c5SAndroid Build Coastguard Worker {
233*8975f5c5SAndroid Build Coastguard Worker     if (mFeatures.finishDoesNotCauseQueriesToBeAvailable.enabled && mUseDebugOutput)
234*8975f5c5SAndroid Build Coastguard Worker     {
235*8975f5c5SAndroid Build Coastguard Worker         mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
236*8975f5c5SAndroid Build Coastguard Worker     }
237*8975f5c5SAndroid Build Coastguard Worker 
238*8975f5c5SAndroid Build Coastguard Worker     mFunctions->finish();
239*8975f5c5SAndroid Build Coastguard Worker     mNeedsFlushBeforeDeleteTextures = false;
240*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush         = false;
241*8975f5c5SAndroid Build Coastguard Worker 
242*8975f5c5SAndroid Build Coastguard Worker     if (mFeatures.finishDoesNotCauseQueriesToBeAvailable.enabled && mUseDebugOutput)
243*8975f5c5SAndroid Build Coastguard Worker     {
244*8975f5c5SAndroid Build Coastguard Worker         mFunctions->disable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
245*8975f5c5SAndroid Build Coastguard Worker     }
246*8975f5c5SAndroid Build Coastguard Worker 
247*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
248*8975f5c5SAndroid Build Coastguard Worker }
249*8975f5c5SAndroid Build Coastguard Worker 
getResetStatus()250*8975f5c5SAndroid Build Coastguard Worker gl::GraphicsResetStatus RendererGL::getResetStatus()
251*8975f5c5SAndroid Build Coastguard Worker {
252*8975f5c5SAndroid Build Coastguard Worker     return gl::FromGLenum<gl::GraphicsResetStatus>(mFunctions->getGraphicsResetStatus());
253*8975f5c5SAndroid Build Coastguard Worker }
254*8975f5c5SAndroid Build Coastguard Worker 
insertEventMarker(GLsizei length,const char * marker)255*8975f5c5SAndroid Build Coastguard Worker void RendererGL::insertEventMarker(GLsizei length, const char *marker) {}
256*8975f5c5SAndroid Build Coastguard Worker 
pushGroupMarker(GLsizei length,const char * marker)257*8975f5c5SAndroid Build Coastguard Worker void RendererGL::pushGroupMarker(GLsizei length, const char *marker) {}
258*8975f5c5SAndroid Build Coastguard Worker 
popGroupMarker()259*8975f5c5SAndroid Build Coastguard Worker void RendererGL::popGroupMarker() {}
260*8975f5c5SAndroid Build Coastguard Worker 
pushDebugGroup(GLenum source,GLuint id,const std::string & message)261*8975f5c5SAndroid Build Coastguard Worker void RendererGL::pushDebugGroup(GLenum source, GLuint id, const std::string &message) {}
262*8975f5c5SAndroid Build Coastguard Worker 
popDebugGroup()263*8975f5c5SAndroid Build Coastguard Worker void RendererGL::popDebugGroup() {}
264*8975f5c5SAndroid Build Coastguard Worker 
getMaxSupportedESVersion() const265*8975f5c5SAndroid Build Coastguard Worker const gl::Version &RendererGL::getMaxSupportedESVersion() const
266*8975f5c5SAndroid Build Coastguard Worker {
267*8975f5c5SAndroid Build Coastguard Worker     // Force generation of caps
268*8975f5c5SAndroid Build Coastguard Worker     getNativeCaps();
269*8975f5c5SAndroid Build Coastguard Worker 
270*8975f5c5SAndroid Build Coastguard Worker     return mMaxSupportedESVersion;
271*8975f5c5SAndroid Build Coastguard Worker }
272*8975f5c5SAndroid Build Coastguard Worker 
generateCaps(gl::Caps * outCaps,gl::TextureCapsMap * outTextureCaps,gl::Extensions * outExtensions,gl::Limitations * outLimitations) const273*8975f5c5SAndroid Build Coastguard Worker void RendererGL::generateCaps(gl::Caps *outCaps,
274*8975f5c5SAndroid Build Coastguard Worker                               gl::TextureCapsMap *outTextureCaps,
275*8975f5c5SAndroid Build Coastguard Worker                               gl::Extensions *outExtensions,
276*8975f5c5SAndroid Build Coastguard Worker                               gl::Limitations *outLimitations) const
277*8975f5c5SAndroid Build Coastguard Worker {
278*8975f5c5SAndroid Build Coastguard Worker     nativegl_gl::GenerateCaps(mFunctions.get(), mFeatures, outCaps, outTextureCaps, outExtensions,
279*8975f5c5SAndroid Build Coastguard Worker                               outLimitations, &mMaxSupportedESVersion,
280*8975f5c5SAndroid Build Coastguard Worker                               &mMultiviewImplementationType, &mNativePLSOptions);
281*8975f5c5SAndroid Build Coastguard Worker }
282*8975f5c5SAndroid Build Coastguard Worker 
getGPUDisjoint()283*8975f5c5SAndroid Build Coastguard Worker GLint RendererGL::getGPUDisjoint()
284*8975f5c5SAndroid Build Coastguard Worker {
285*8975f5c5SAndroid Build Coastguard Worker     // TODO(ewell): On GLES backends we should find a way to reliably query disjoint events
286*8975f5c5SAndroid Build Coastguard Worker     return 0;
287*8975f5c5SAndroid Build Coastguard Worker }
288*8975f5c5SAndroid Build Coastguard Worker 
getTimestamp()289*8975f5c5SAndroid Build Coastguard Worker GLint64 RendererGL::getTimestamp()
290*8975f5c5SAndroid Build Coastguard Worker {
291*8975f5c5SAndroid Build Coastguard Worker     GLint64 result = 0;
292*8975f5c5SAndroid Build Coastguard Worker     mFunctions->getInteger64v(GL_TIMESTAMP, &result);
293*8975f5c5SAndroid Build Coastguard Worker     return result;
294*8975f5c5SAndroid Build Coastguard Worker }
295*8975f5c5SAndroid Build Coastguard Worker 
ensureCapsInitialized() const296*8975f5c5SAndroid Build Coastguard Worker void RendererGL::ensureCapsInitialized() const
297*8975f5c5SAndroid Build Coastguard Worker {
298*8975f5c5SAndroid Build Coastguard Worker     if (!mCapsInitialized)
299*8975f5c5SAndroid Build Coastguard Worker     {
300*8975f5c5SAndroid Build Coastguard Worker         generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations);
301*8975f5c5SAndroid Build Coastguard Worker         mCapsInitialized = true;
302*8975f5c5SAndroid Build Coastguard Worker     }
303*8975f5c5SAndroid Build Coastguard Worker }
304*8975f5c5SAndroid Build Coastguard Worker 
getNativeCaps() const305*8975f5c5SAndroid Build Coastguard Worker const gl::Caps &RendererGL::getNativeCaps() const
306*8975f5c5SAndroid Build Coastguard Worker {
307*8975f5c5SAndroid Build Coastguard Worker     ensureCapsInitialized();
308*8975f5c5SAndroid Build Coastguard Worker     return mNativeCaps;
309*8975f5c5SAndroid Build Coastguard Worker }
310*8975f5c5SAndroid Build Coastguard Worker 
getNativeTextureCaps() const311*8975f5c5SAndroid Build Coastguard Worker const gl::TextureCapsMap &RendererGL::getNativeTextureCaps() const
312*8975f5c5SAndroid Build Coastguard Worker {
313*8975f5c5SAndroid Build Coastguard Worker     ensureCapsInitialized();
314*8975f5c5SAndroid Build Coastguard Worker     return mNativeTextureCaps;
315*8975f5c5SAndroid Build Coastguard Worker }
316*8975f5c5SAndroid Build Coastguard Worker 
getNativeExtensions() const317*8975f5c5SAndroid Build Coastguard Worker const gl::Extensions &RendererGL::getNativeExtensions() const
318*8975f5c5SAndroid Build Coastguard Worker {
319*8975f5c5SAndroid Build Coastguard Worker     ensureCapsInitialized();
320*8975f5c5SAndroid Build Coastguard Worker     return mNativeExtensions;
321*8975f5c5SAndroid Build Coastguard Worker }
322*8975f5c5SAndroid Build Coastguard Worker 
getNativeLimitations() const323*8975f5c5SAndroid Build Coastguard Worker const gl::Limitations &RendererGL::getNativeLimitations() const
324*8975f5c5SAndroid Build Coastguard Worker {
325*8975f5c5SAndroid Build Coastguard Worker     ensureCapsInitialized();
326*8975f5c5SAndroid Build Coastguard Worker     return mNativeLimitations;
327*8975f5c5SAndroid Build Coastguard Worker }
328*8975f5c5SAndroid Build Coastguard Worker 
getNativePixelLocalStorageOptions() const329*8975f5c5SAndroid Build Coastguard Worker const ShPixelLocalStorageOptions &RendererGL::getNativePixelLocalStorageOptions() const
330*8975f5c5SAndroid Build Coastguard Worker {
331*8975f5c5SAndroid Build Coastguard Worker     return mNativePLSOptions;
332*8975f5c5SAndroid Build Coastguard Worker }
333*8975f5c5SAndroid Build Coastguard Worker 
getMultiviewImplementationType() const334*8975f5c5SAndroid Build Coastguard Worker MultiviewImplementationTypeGL RendererGL::getMultiviewImplementationType() const
335*8975f5c5SAndroid Build Coastguard Worker {
336*8975f5c5SAndroid Build Coastguard Worker     ensureCapsInitialized();
337*8975f5c5SAndroid Build Coastguard Worker     return mMultiviewImplementationType;
338*8975f5c5SAndroid Build Coastguard Worker }
339*8975f5c5SAndroid Build Coastguard Worker 
initializeFrontendFeatures(angle::FrontendFeatures * features) const340*8975f5c5SAndroid Build Coastguard Worker void RendererGL::initializeFrontendFeatures(angle::FrontendFeatures *features) const
341*8975f5c5SAndroid Build Coastguard Worker {
342*8975f5c5SAndroid Build Coastguard Worker     ensureCapsInitialized();
343*8975f5c5SAndroid Build Coastguard Worker     nativegl_gl::InitializeFrontendFeatures(mFunctions.get(), features);
344*8975f5c5SAndroid Build Coastguard Worker }
345*8975f5c5SAndroid Build Coastguard Worker 
dispatchCompute(const gl::Context * context,GLuint numGroupsX,GLuint numGroupsY,GLuint numGroupsZ)346*8975f5c5SAndroid Build Coastguard Worker angle::Result RendererGL::dispatchCompute(const gl::Context *context,
347*8975f5c5SAndroid Build Coastguard Worker                                           GLuint numGroupsX,
348*8975f5c5SAndroid Build Coastguard Worker                                           GLuint numGroupsY,
349*8975f5c5SAndroid Build Coastguard Worker                                           GLuint numGroupsZ)
350*8975f5c5SAndroid Build Coastguard Worker {
351*8975f5c5SAndroid Build Coastguard Worker     mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
352*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush = true;
353*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
354*8975f5c5SAndroid Build Coastguard Worker }
355*8975f5c5SAndroid Build Coastguard Worker 
dispatchComputeIndirect(const gl::Context * context,GLintptr indirect)356*8975f5c5SAndroid Build Coastguard Worker angle::Result RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
357*8975f5c5SAndroid Build Coastguard Worker {
358*8975f5c5SAndroid Build Coastguard Worker     mFunctions->dispatchComputeIndirect(indirect);
359*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush = true;
360*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
361*8975f5c5SAndroid Build Coastguard Worker }
362*8975f5c5SAndroid Build Coastguard Worker 
memoryBarrier(GLbitfield barriers)363*8975f5c5SAndroid Build Coastguard Worker angle::Result RendererGL::memoryBarrier(GLbitfield barriers)
364*8975f5c5SAndroid Build Coastguard Worker {
365*8975f5c5SAndroid Build Coastguard Worker     mFunctions->memoryBarrier(barriers);
366*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush = true;
367*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
368*8975f5c5SAndroid Build Coastguard Worker }
memoryBarrierByRegion(GLbitfield barriers)369*8975f5c5SAndroid Build Coastguard Worker angle::Result RendererGL::memoryBarrierByRegion(GLbitfield barriers)
370*8975f5c5SAndroid Build Coastguard Worker {
371*8975f5c5SAndroid Build Coastguard Worker     mFunctions->memoryBarrierByRegion(barriers);
372*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush = true;
373*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
374*8975f5c5SAndroid Build Coastguard Worker }
375*8975f5c5SAndroid Build Coastguard Worker 
framebufferFetchBarrier()376*8975f5c5SAndroid Build Coastguard Worker void RendererGL::framebufferFetchBarrier()
377*8975f5c5SAndroid Build Coastguard Worker {
378*8975f5c5SAndroid Build Coastguard Worker     mFunctions->framebufferFetchBarrierEXT();
379*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush = true;
380*8975f5c5SAndroid Build Coastguard Worker }
381*8975f5c5SAndroid Build Coastguard Worker 
hasNativeParallelCompile()382*8975f5c5SAndroid Build Coastguard Worker bool RendererGL::hasNativeParallelCompile()
383*8975f5c5SAndroid Build Coastguard Worker {
384*8975f5c5SAndroid Build Coastguard Worker     if (mFeatures.disableNativeParallelCompile.enabled)
385*8975f5c5SAndroid Build Coastguard Worker     {
386*8975f5c5SAndroid Build Coastguard Worker         return false;
387*8975f5c5SAndroid Build Coastguard Worker     }
388*8975f5c5SAndroid Build Coastguard Worker     return mFunctions->maxShaderCompilerThreadsKHR != nullptr ||
389*8975f5c5SAndroid Build Coastguard Worker            mFunctions->maxShaderCompilerThreadsARB != nullptr;
390*8975f5c5SAndroid Build Coastguard Worker }
391*8975f5c5SAndroid Build Coastguard Worker 
setMaxShaderCompilerThreads(GLuint count)392*8975f5c5SAndroid Build Coastguard Worker void RendererGL::setMaxShaderCompilerThreads(GLuint count)
393*8975f5c5SAndroid Build Coastguard Worker {
394*8975f5c5SAndroid Build Coastguard Worker     if (hasNativeParallelCompile())
395*8975f5c5SAndroid Build Coastguard Worker     {
396*8975f5c5SAndroid Build Coastguard Worker         SetMaxShaderCompilerThreads(mFunctions.get(), count);
397*8975f5c5SAndroid Build Coastguard Worker     }
398*8975f5c5SAndroid Build Coastguard Worker }
399*8975f5c5SAndroid Build Coastguard Worker 
setNeedsFlushBeforeDeleteTextures()400*8975f5c5SAndroid Build Coastguard Worker void RendererGL::setNeedsFlushBeforeDeleteTextures()
401*8975f5c5SAndroid Build Coastguard Worker {
402*8975f5c5SAndroid Build Coastguard Worker     mNeedsFlushBeforeDeleteTextures = true;
403*8975f5c5SAndroid Build Coastguard Worker }
404*8975f5c5SAndroid Build Coastguard Worker 
markWorkSubmitted()405*8975f5c5SAndroid Build Coastguard Worker void RendererGL::markWorkSubmitted()
406*8975f5c5SAndroid Build Coastguard Worker {
407*8975f5c5SAndroid Build Coastguard Worker     mWorkDoneSinceLastFlush = true;
408*8975f5c5SAndroid Build Coastguard Worker }
409*8975f5c5SAndroid Build Coastguard Worker 
flushIfNecessaryBeforeDeleteTextures()410*8975f5c5SAndroid Build Coastguard Worker void RendererGL::flushIfNecessaryBeforeDeleteTextures()
411*8975f5c5SAndroid Build Coastguard Worker {
412*8975f5c5SAndroid Build Coastguard Worker     if (mNeedsFlushBeforeDeleteTextures)
413*8975f5c5SAndroid Build Coastguard Worker     {
414*8975f5c5SAndroid Build Coastguard Worker         (void)flush();
415*8975f5c5SAndroid Build Coastguard Worker     }
416*8975f5c5SAndroid Build Coastguard Worker }
417*8975f5c5SAndroid Build Coastguard Worker 
handleGPUSwitch()418*8975f5c5SAndroid Build Coastguard Worker void RendererGL::handleGPUSwitch()
419*8975f5c5SAndroid Build Coastguard Worker {
420*8975f5c5SAndroid Build Coastguard Worker     nativegl_gl::ReInitializeFeaturesAtGPUSwitch(mFunctions.get(), &mFeatures);
421*8975f5c5SAndroid Build Coastguard Worker }
422*8975f5c5SAndroid Build Coastguard Worker 
423*8975f5c5SAndroid Build Coastguard Worker }  // namespace rx
424