xref: /aosp_15_r20/external/angle/src/libANGLE/Context.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2002 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 // Context.cpp: Implements the gl::Context class, managing all GL state and performing
8*8975f5c5SAndroid Build Coastguard Worker // rendering operations. It is the GLES2 specific implementation of EGLContext.
9*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Context.inl.h"
10*8975f5c5SAndroid Build Coastguard Worker 
11*8975f5c5SAndroid Build Coastguard Worker #include <stdarg.h>
12*8975f5c5SAndroid Build Coastguard Worker #include <stdio.h>
13*8975f5c5SAndroid Build Coastguard Worker #include <string.h>
14*8975f5c5SAndroid Build Coastguard Worker 
15*8975f5c5SAndroid Build Coastguard Worker #include <iterator>
16*8975f5c5SAndroid Build Coastguard Worker #include <sstream>
17*8975f5c5SAndroid Build Coastguard Worker #include <vector>
18*8975f5c5SAndroid Build Coastguard Worker 
19*8975f5c5SAndroid Build Coastguard Worker #include "common/PackedEnums.h"
20*8975f5c5SAndroid Build Coastguard Worker #include "common/angle_version_info.h"
21*8975f5c5SAndroid Build Coastguard Worker #include "common/hash_utils.h"
22*8975f5c5SAndroid Build Coastguard Worker #include "common/matrix_utils.h"
23*8975f5c5SAndroid Build Coastguard Worker #include "common/platform.h"
24*8975f5c5SAndroid Build Coastguard Worker #include "common/string_utils.h"
25*8975f5c5SAndroid Build Coastguard Worker #include "common/system_utils.h"
26*8975f5c5SAndroid Build Coastguard Worker #include "common/tls.h"
27*8975f5c5SAndroid Build Coastguard Worker #include "common/utilities.h"
28*8975f5c5SAndroid Build Coastguard Worker #include "image_util/loadimage.h"
29*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Buffer.h"
30*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Compiler.h"
31*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Display.h"
32*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Fence.h"
33*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/FramebufferAttachment.h"
34*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/MemoryObject.h"
35*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/PixelLocalStorage.h"
36*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Program.h"
37*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/ProgramPipeline.h"
38*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Query.h"
39*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Renderbuffer.h"
40*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/ResourceManager.h"
41*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Sampler.h"
42*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Semaphore.h"
43*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Surface.h"
44*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Texture.h"
45*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/TransformFeedback.h"
46*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/VertexArray.h"
47*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/capture/FrameCapture.h"
48*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/capture/serialize.h"
49*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/context_private_call_autogen.h"
50*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/formatutils.h"
51*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/queryconversions.h"
52*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/queryutils.h"
53*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/DisplayImpl.h"
54*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/Format.h"
55*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/trace.h"
56*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/validationES.h"
57*8975f5c5SAndroid Build Coastguard Worker 
58*8975f5c5SAndroid Build Coastguard Worker #if defined(ANGLE_PLATFORM_APPLE)
59*8975f5c5SAndroid Build Coastguard Worker #    include <dispatch/dispatch.h>
60*8975f5c5SAndroid Build Coastguard Worker #    include "common/tls.h"
61*8975f5c5SAndroid Build Coastguard Worker #endif
62*8975f5c5SAndroid Build Coastguard Worker 
63*8975f5c5SAndroid Build Coastguard Worker namespace gl
64*8975f5c5SAndroid Build Coastguard Worker {
65*8975f5c5SAndroid Build Coastguard Worker namespace
66*8975f5c5SAndroid Build Coastguard Worker {
67*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kDrawDirtyObjectsBase{
68*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_ACTIVE_TEXTURES,
69*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_DRAW_FRAMEBUFFER,
70*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_VERTEX_ARRAY,
71*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_TEXTURES,
72*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_PROGRAM_PIPELINE_OBJECT,
73*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_SAMPLERS,
74*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_IMAGES,
75*8975f5c5SAndroid Build Coastguard Worker };
76*8975f5c5SAndroid Build Coastguard Worker 
77*8975f5c5SAndroid Build Coastguard Worker // TexImage uses the unpack state
78*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kTexImageDirtyBits{
79*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_UNPACK_STATE,
80*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_UNPACK_BUFFER_BINDING,
81*8975f5c5SAndroid Build Coastguard Worker };
82*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kTexImageExtendedDirtyBits{};
83*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kTexImageDirtyObjects{};
84*8975f5c5SAndroid Build Coastguard Worker 
85*8975f5c5SAndroid Build Coastguard Worker // Readpixels uses the pack state and read FBO
86*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kReadPixelsDirtyBits{
87*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_PACK_STATE,
88*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_PACK_BUFFER_BINDING,
89*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_READ_FRAMEBUFFER_BINDING,
90*8975f5c5SAndroid Build Coastguard Worker };
91*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kReadPixelsExtendedDirtyBits{};
92*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kReadPixelsDirtyObjectsBase{state::DIRTY_OBJECT_READ_FRAMEBUFFER};
93*8975f5c5SAndroid Build Coastguard Worker 
94*8975f5c5SAndroid Build Coastguard Worker // We sync the draw Framebuffer manually in prepareForClear to allow the clear calls to do
95*8975f5c5SAndroid Build Coastguard Worker // more custom handling for robust resource init.
96*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kClearDirtyBits{
97*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED,
98*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_SCISSOR_TEST_ENABLED,
99*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_SCISSOR,
100*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_VIEWPORT,
101*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_CLEAR_COLOR,
102*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_CLEAR_DEPTH,
103*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_CLEAR_STENCIL,
104*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_COLOR_MASK,
105*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_DEPTH_MASK,
106*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_STENCIL_WRITEMASK_FRONT,
107*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_STENCIL_WRITEMASK_BACK,
108*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING,
109*8975f5c5SAndroid Build Coastguard Worker };
110*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kClearExtendedDirtyBits{};
111*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kClearDirtyObjects{state::DIRTY_OBJECT_DRAW_FRAMEBUFFER};
112*8975f5c5SAndroid Build Coastguard Worker 
113*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kBlitDirtyBits{
114*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_SCISSOR_TEST_ENABLED,
115*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_SCISSOR,
116*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_FRAMEBUFFER_SRGB_WRITE_CONTROL_MODE,
117*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_READ_FRAMEBUFFER_BINDING,
118*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING,
119*8975f5c5SAndroid Build Coastguard Worker };
120*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kBlitExtendedDirtyBits{};
121*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kBlitDirtyObjectsBase{
122*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_READ_FRAMEBUFFER,
123*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_DRAW_FRAMEBUFFER,
124*8975f5c5SAndroid Build Coastguard Worker };
125*8975f5c5SAndroid Build Coastguard Worker 
126*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kComputeDirtyBits{
127*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING,
128*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS,
129*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING,
130*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_PROGRAM_BINDING,
131*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_PROGRAM_EXECUTABLE,
132*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_TEXTURE_BINDINGS,
133*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_SAMPLER_BINDINGS,
134*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_IMAGE_BINDINGS,
135*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING,
136*8975f5c5SAndroid Build Coastguard Worker };
137*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kComputeExtendedDirtyBits{};
138*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kComputeDirtyObjectsBase{
139*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_ACTIVE_TEXTURES,
140*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_TEXTURES,
141*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_PROGRAM_PIPELINE_OBJECT,
142*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_IMAGES,
143*8975f5c5SAndroid Build Coastguard Worker     state::DIRTY_OBJECT_SAMPLERS,
144*8975f5c5SAndroid Build Coastguard Worker };
145*8975f5c5SAndroid Build Coastguard Worker 
146*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kCopyImageDirtyBitsBase{state::DIRTY_BIT_READ_FRAMEBUFFER_BINDING};
147*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kCopyImageExtendedDirtyBits{};
148*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kCopyImageDirtyObjectsBase{state::DIRTY_OBJECT_READ_FRAMEBUFFER};
149*8975f5c5SAndroid Build Coastguard Worker 
150*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kReadInvalidateDirtyBits{state::DIRTY_BIT_READ_FRAMEBUFFER_BINDING};
151*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kReadInvalidateExtendedDirtyBits{};
152*8975f5c5SAndroid Build Coastguard Worker 
153*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kDrawInvalidateDirtyBits{state::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING};
154*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kDrawInvalidateExtendedDirtyBits{};
155*8975f5c5SAndroid Build Coastguard Worker 
156*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyBits kTilingDirtyBits{state::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING};
157*8975f5c5SAndroid Build Coastguard Worker constexpr state::ExtendedDirtyBits kTilingExtendedDirtyBits{};
158*8975f5c5SAndroid Build Coastguard Worker constexpr state::DirtyObjects kTilingDirtyObjects{state::DIRTY_OBJECT_DRAW_FRAMEBUFFER};
159*8975f5c5SAndroid Build Coastguard Worker 
160*8975f5c5SAndroid Build Coastguard Worker constexpr bool kEnableAEPRequirementLogging = false;
161*8975f5c5SAndroid Build Coastguard Worker 
AllocateOrGetShareGroup(egl::Display * display,const gl::Context * shareContext)162*8975f5c5SAndroid Build Coastguard Worker egl::ShareGroup *AllocateOrGetShareGroup(egl::Display *display, const gl::Context *shareContext)
163*8975f5c5SAndroid Build Coastguard Worker {
164*8975f5c5SAndroid Build Coastguard Worker     if (shareContext)
165*8975f5c5SAndroid Build Coastguard Worker     {
166*8975f5c5SAndroid Build Coastguard Worker         egl::ShareGroup *shareGroup = shareContext->getState().getShareGroup();
167*8975f5c5SAndroid Build Coastguard Worker         shareGroup->addRef();
168*8975f5c5SAndroid Build Coastguard Worker         return shareGroup;
169*8975f5c5SAndroid Build Coastguard Worker     }
170*8975f5c5SAndroid Build Coastguard Worker     else
171*8975f5c5SAndroid Build Coastguard Worker     {
172*8975f5c5SAndroid Build Coastguard Worker         return new egl::ShareGroup(display->getImplementation());
173*8975f5c5SAndroid Build Coastguard Worker     }
174*8975f5c5SAndroid Build Coastguard Worker }
175*8975f5c5SAndroid Build Coastguard Worker 
AllocateOrUseContextMutex(egl::ContextMutex * sharedContextMutex)176*8975f5c5SAndroid Build Coastguard Worker egl::ContextMutex *AllocateOrUseContextMutex(egl::ContextMutex *sharedContextMutex)
177*8975f5c5SAndroid Build Coastguard Worker {
178*8975f5c5SAndroid Build Coastguard Worker     if (sharedContextMutex != nullptr)
179*8975f5c5SAndroid Build Coastguard Worker     {
180*8975f5c5SAndroid Build Coastguard Worker         ASSERT(egl::kIsContextMutexEnabled);
181*8975f5c5SAndroid Build Coastguard Worker         ASSERT(sharedContextMutex->isReferenced());
182*8975f5c5SAndroid Build Coastguard Worker         return sharedContextMutex;
183*8975f5c5SAndroid Build Coastguard Worker     }
184*8975f5c5SAndroid Build Coastguard Worker     return new egl::ContextMutex();
185*8975f5c5SAndroid Build Coastguard Worker }
186*8975f5c5SAndroid Build Coastguard Worker 
187*8975f5c5SAndroid Build Coastguard Worker template <typename T>
GetQueryObjectParameter(const Context * context,Query * query,GLenum pname,T * params)188*8975f5c5SAndroid Build Coastguard Worker angle::Result GetQueryObjectParameter(const Context *context, Query *query, GLenum pname, T *params)
189*8975f5c5SAndroid Build Coastguard Worker {
190*8975f5c5SAndroid Build Coastguard Worker     if (!query)
191*8975f5c5SAndroid Build Coastguard Worker     {
192*8975f5c5SAndroid Build Coastguard Worker         // Some applications call into glGetQueryObjectuiv(...) prior to calling glBeginQuery(...)
193*8975f5c5SAndroid Build Coastguard Worker         // This wouldn't be an issue since the validation layer will handle such a usecases but when
194*8975f5c5SAndroid Build Coastguard Worker         // the app enables EGL_KHR_create_context_no_error extension, we skip the validation layer.
195*8975f5c5SAndroid Build Coastguard Worker         switch (pname)
196*8975f5c5SAndroid Build Coastguard Worker         {
197*8975f5c5SAndroid Build Coastguard Worker             case GL_QUERY_RESULT_EXT:
198*8975f5c5SAndroid Build Coastguard Worker                 *params = 0;
199*8975f5c5SAndroid Build Coastguard Worker                 break;
200*8975f5c5SAndroid Build Coastguard Worker             case GL_QUERY_RESULT_AVAILABLE_EXT:
201*8975f5c5SAndroid Build Coastguard Worker                 *params = GL_FALSE;
202*8975f5c5SAndroid Build Coastguard Worker                 break;
203*8975f5c5SAndroid Build Coastguard Worker             default:
204*8975f5c5SAndroid Build Coastguard Worker                 UNREACHABLE();
205*8975f5c5SAndroid Build Coastguard Worker                 return angle::Result::Stop;
206*8975f5c5SAndroid Build Coastguard Worker         }
207*8975f5c5SAndroid Build Coastguard Worker         return angle::Result::Continue;
208*8975f5c5SAndroid Build Coastguard Worker     }
209*8975f5c5SAndroid Build Coastguard Worker 
210*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
211*8975f5c5SAndroid Build Coastguard Worker     {
212*8975f5c5SAndroid Build Coastguard Worker         case GL_QUERY_RESULT_EXT:
213*8975f5c5SAndroid Build Coastguard Worker             return query->getResult(context, params);
214*8975f5c5SAndroid Build Coastguard Worker         case GL_QUERY_RESULT_AVAILABLE_EXT:
215*8975f5c5SAndroid Build Coastguard Worker         {
216*8975f5c5SAndroid Build Coastguard Worker             bool available = false;
217*8975f5c5SAndroid Build Coastguard Worker             if (context->isContextLost())
218*8975f5c5SAndroid Build Coastguard Worker             {
219*8975f5c5SAndroid Build Coastguard Worker                 available = true;
220*8975f5c5SAndroid Build Coastguard Worker             }
221*8975f5c5SAndroid Build Coastguard Worker             else
222*8975f5c5SAndroid Build Coastguard Worker             {
223*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_TRY(query->isResultAvailable(context, &available));
224*8975f5c5SAndroid Build Coastguard Worker             }
225*8975f5c5SAndroid Build Coastguard Worker             *params = CastFromStateValue<T>(pname, static_cast<GLuint>(available));
226*8975f5c5SAndroid Build Coastguard Worker             return angle::Result::Continue;
227*8975f5c5SAndroid Build Coastguard Worker         }
228*8975f5c5SAndroid Build Coastguard Worker         default:
229*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
230*8975f5c5SAndroid Build Coastguard Worker             return angle::Result::Stop;
231*8975f5c5SAndroid Build Coastguard Worker     }
232*8975f5c5SAndroid Build Coastguard Worker }
233*8975f5c5SAndroid Build Coastguard Worker 
234*8975f5c5SAndroid Build Coastguard Worker // Attribute map queries.
GetClientMajorVersion(const egl::AttributeMap & attribs)235*8975f5c5SAndroid Build Coastguard Worker EGLint GetClientMajorVersion(const egl::AttributeMap &attribs)
236*8975f5c5SAndroid Build Coastguard Worker {
237*8975f5c5SAndroid Build Coastguard Worker     return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1));
238*8975f5c5SAndroid Build Coastguard Worker }
239*8975f5c5SAndroid Build Coastguard Worker 
GetClientMinorVersion(const egl::AttributeMap & attribs)240*8975f5c5SAndroid Build Coastguard Worker EGLint GetClientMinorVersion(const egl::AttributeMap &attribs)
241*8975f5c5SAndroid Build Coastguard Worker {
242*8975f5c5SAndroid Build Coastguard Worker     return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0));
243*8975f5c5SAndroid Build Coastguard Worker }
244*8975f5c5SAndroid Build Coastguard Worker 
GetBackwardCompatibleContext(const egl::AttributeMap & attribs)245*8975f5c5SAndroid Build Coastguard Worker bool GetBackwardCompatibleContext(const egl::AttributeMap &attribs)
246*8975f5c5SAndroid Build Coastguard Worker {
247*8975f5c5SAndroid Build Coastguard Worker     return attribs.get(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE, EGL_TRUE) == EGL_TRUE;
248*8975f5c5SAndroid Build Coastguard Worker }
249*8975f5c5SAndroid Build Coastguard Worker 
GetWebGLContext(const egl::AttributeMap & attribs)250*8975f5c5SAndroid Build Coastguard Worker bool GetWebGLContext(const egl::AttributeMap &attribs)
251*8975f5c5SAndroid Build Coastguard Worker {
252*8975f5c5SAndroid Build Coastguard Worker     return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE);
253*8975f5c5SAndroid Build Coastguard Worker }
254*8975f5c5SAndroid Build Coastguard Worker 
GetClientVersion(egl::Display * display,const egl::AttributeMap & attribs)255*8975f5c5SAndroid Build Coastguard Worker Version GetClientVersion(egl::Display *display, const egl::AttributeMap &attribs)
256*8975f5c5SAndroid Build Coastguard Worker {
257*8975f5c5SAndroid Build Coastguard Worker     Version requestedVersion =
258*8975f5c5SAndroid Build Coastguard Worker         Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs));
259*8975f5c5SAndroid Build Coastguard Worker     if (GetBackwardCompatibleContext(attribs))
260*8975f5c5SAndroid Build Coastguard Worker     {
261*8975f5c5SAndroid Build Coastguard Worker         if (requestedVersion.major == 1)
262*8975f5c5SAndroid Build Coastguard Worker         {
263*8975f5c5SAndroid Build Coastguard Worker             // If the user requests an ES1 context, we cannot return an ES 2+ context.
264*8975f5c5SAndroid Build Coastguard Worker             return Version(1, 1);
265*8975f5c5SAndroid Build Coastguard Worker         }
266*8975f5c5SAndroid Build Coastguard Worker         else
267*8975f5c5SAndroid Build Coastguard Worker         {
268*8975f5c5SAndroid Build Coastguard Worker             // Always up the version to at least the max conformant version this display supports.
269*8975f5c5SAndroid Build Coastguard Worker             // Only return a higher client version if requested.
270*8975f5c5SAndroid Build Coastguard Worker             const Version conformantVersion = std::max(
271*8975f5c5SAndroid Build Coastguard Worker                 display->getImplementation()->getMaxConformantESVersion(), requestedVersion);
272*8975f5c5SAndroid Build Coastguard Worker             // Limit the WebGL context to at most version 3.1
273*8975f5c5SAndroid Build Coastguard Worker             const bool isWebGL = GetWebGLContext(attribs);
274*8975f5c5SAndroid Build Coastguard Worker             return isWebGL ? std::min(conformantVersion, Version(3, 1)) : conformantVersion;
275*8975f5c5SAndroid Build Coastguard Worker         }
276*8975f5c5SAndroid Build Coastguard Worker     }
277*8975f5c5SAndroid Build Coastguard Worker     else
278*8975f5c5SAndroid Build Coastguard Worker     {
279*8975f5c5SAndroid Build Coastguard Worker         return requestedVersion;
280*8975f5c5SAndroid Build Coastguard Worker     }
281*8975f5c5SAndroid Build Coastguard Worker }
282*8975f5c5SAndroid Build Coastguard Worker 
GetResetStrategy(const egl::AttributeMap & attribs)283*8975f5c5SAndroid Build Coastguard Worker GLenum GetResetStrategy(const egl::AttributeMap &attribs)
284*8975f5c5SAndroid Build Coastguard Worker {
285*8975f5c5SAndroid Build Coastguard Worker     EGLAttrib resetStrategyExt =
286*8975f5c5SAndroid Build Coastguard Worker         attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION);
287*8975f5c5SAndroid Build Coastguard Worker     EGLAttrib resetStrategyCore =
288*8975f5c5SAndroid Build Coastguard Worker         attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY, resetStrategyExt);
289*8975f5c5SAndroid Build Coastguard Worker 
290*8975f5c5SAndroid Build Coastguard Worker     switch (resetStrategyCore)
291*8975f5c5SAndroid Build Coastguard Worker     {
292*8975f5c5SAndroid Build Coastguard Worker         case EGL_NO_RESET_NOTIFICATION:
293*8975f5c5SAndroid Build Coastguard Worker             return GL_NO_RESET_NOTIFICATION_EXT;
294*8975f5c5SAndroid Build Coastguard Worker         case EGL_LOSE_CONTEXT_ON_RESET:
295*8975f5c5SAndroid Build Coastguard Worker             return GL_LOSE_CONTEXT_ON_RESET_EXT;
296*8975f5c5SAndroid Build Coastguard Worker         default:
297*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
298*8975f5c5SAndroid Build Coastguard Worker             return GL_NONE;
299*8975f5c5SAndroid Build Coastguard Worker     }
300*8975f5c5SAndroid Build Coastguard Worker }
301*8975f5c5SAndroid Build Coastguard Worker 
GetRobustAccess(const egl::AttributeMap & attribs)302*8975f5c5SAndroid Build Coastguard Worker bool GetRobustAccess(const egl::AttributeMap &attribs)
303*8975f5c5SAndroid Build Coastguard Worker {
304*8975f5c5SAndroid Build Coastguard Worker     EGLAttrib robustAccessExt  = attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE);
305*8975f5c5SAndroid Build Coastguard Worker     EGLAttrib robustAccessCore = attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS, robustAccessExt);
306*8975f5c5SAndroid Build Coastguard Worker 
307*8975f5c5SAndroid Build Coastguard Worker     bool attribRobustAccess = (robustAccessCore == EGL_TRUE);
308*8975f5c5SAndroid Build Coastguard Worker     bool contextFlagsRobustAccess =
309*8975f5c5SAndroid Build Coastguard Worker         ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != 0);
310*8975f5c5SAndroid Build Coastguard Worker 
311*8975f5c5SAndroid Build Coastguard Worker     return (attribRobustAccess || contextFlagsRobustAccess);
312*8975f5c5SAndroid Build Coastguard Worker }
313*8975f5c5SAndroid Build Coastguard Worker 
GetDebug(const egl::AttributeMap & attribs)314*8975f5c5SAndroid Build Coastguard Worker bool GetDebug(const egl::AttributeMap &attribs)
315*8975f5c5SAndroid Build Coastguard Worker {
316*8975f5c5SAndroid Build Coastguard Worker     return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) ||
317*8975f5c5SAndroid Build Coastguard Worker            ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) != 0);
318*8975f5c5SAndroid Build Coastguard Worker }
319*8975f5c5SAndroid Build Coastguard Worker 
GetNoError(const egl::AttributeMap & attribs)320*8975f5c5SAndroid Build Coastguard Worker bool GetNoError(const egl::AttributeMap &attribs)
321*8975f5c5SAndroid Build Coastguard Worker {
322*8975f5c5SAndroid Build Coastguard Worker     return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE);
323*8975f5c5SAndroid Build Coastguard Worker }
324*8975f5c5SAndroid Build Coastguard Worker 
GetExtensionsEnabled(const egl::AttributeMap & attribs,bool webGLContext)325*8975f5c5SAndroid Build Coastguard Worker bool GetExtensionsEnabled(const egl::AttributeMap &attribs, bool webGLContext)
326*8975f5c5SAndroid Build Coastguard Worker {
327*8975f5c5SAndroid Build Coastguard Worker     // If the context is WebGL, extensions are disabled by default
328*8975f5c5SAndroid Build Coastguard Worker     EGLAttrib defaultValue = webGLContext ? EGL_FALSE : EGL_TRUE;
329*8975f5c5SAndroid Build Coastguard Worker     return (attribs.get(EGL_EXTENSIONS_ENABLED_ANGLE, defaultValue) == EGL_TRUE);
330*8975f5c5SAndroid Build Coastguard Worker }
331*8975f5c5SAndroid Build Coastguard Worker 
GetBindGeneratesResource(const egl::AttributeMap & attribs)332*8975f5c5SAndroid Build Coastguard Worker bool GetBindGeneratesResource(const egl::AttributeMap &attribs)
333*8975f5c5SAndroid Build Coastguard Worker {
334*8975f5c5SAndroid Build Coastguard Worker     return (attribs.get(EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM, EGL_TRUE) == EGL_TRUE);
335*8975f5c5SAndroid Build Coastguard Worker }
336*8975f5c5SAndroid Build Coastguard Worker 
GetClientArraysEnabled(const egl::AttributeMap & attribs)337*8975f5c5SAndroid Build Coastguard Worker bool GetClientArraysEnabled(const egl::AttributeMap &attribs)
338*8975f5c5SAndroid Build Coastguard Worker {
339*8975f5c5SAndroid Build Coastguard Worker     return (attribs.get(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE, EGL_TRUE) == EGL_TRUE);
340*8975f5c5SAndroid Build Coastguard Worker }
341*8975f5c5SAndroid Build Coastguard Worker 
GetRobustResourceInit(egl::Display * display,const egl::AttributeMap & attribs)342*8975f5c5SAndroid Build Coastguard Worker bool GetRobustResourceInit(egl::Display *display, const egl::AttributeMap &attribs)
343*8975f5c5SAndroid Build Coastguard Worker {
344*8975f5c5SAndroid Build Coastguard Worker     const angle::FrontendFeatures &frontendFeatures = display->getFrontendFeatures();
345*8975f5c5SAndroid Build Coastguard Worker     return (frontendFeatures.forceRobustResourceInit.enabled ||
346*8975f5c5SAndroid Build Coastguard Worker             attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE);
347*8975f5c5SAndroid Build Coastguard Worker }
348*8975f5c5SAndroid Build Coastguard Worker 
GetContextPriority(const egl::AttributeMap & attribs)349*8975f5c5SAndroid Build Coastguard Worker EGLenum GetContextPriority(const egl::AttributeMap &attribs)
350*8975f5c5SAndroid Build Coastguard Worker {
351*8975f5c5SAndroid Build Coastguard Worker     return static_cast<EGLenum>(
352*8975f5c5SAndroid Build Coastguard Worker         attribs.getAsInt(EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_MEDIUM_IMG));
353*8975f5c5SAndroid Build Coastguard Worker }
354*8975f5c5SAndroid Build Coastguard Worker 
GetProtectedContent(const egl::AttributeMap & attribs)355*8975f5c5SAndroid Build Coastguard Worker bool GetProtectedContent(const egl::AttributeMap &attribs)
356*8975f5c5SAndroid Build Coastguard Worker {
357*8975f5c5SAndroid Build Coastguard Worker     return static_cast<bool>(attribs.getAsInt(EGL_PROTECTED_CONTENT_EXT, EGL_FALSE));
358*8975f5c5SAndroid Build Coastguard Worker }
359*8975f5c5SAndroid Build Coastguard Worker 
GetObjectLabelFromPointer(GLsizei length,const GLchar * label)360*8975f5c5SAndroid Build Coastguard Worker std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label)
361*8975f5c5SAndroid Build Coastguard Worker {
362*8975f5c5SAndroid Build Coastguard Worker     std::string labelName;
363*8975f5c5SAndroid Build Coastguard Worker     if (label != nullptr)
364*8975f5c5SAndroid Build Coastguard Worker     {
365*8975f5c5SAndroid Build Coastguard Worker         size_t labelLength = length < 0 ? strlen(label) : length;
366*8975f5c5SAndroid Build Coastguard Worker         labelName          = std::string(label, labelLength);
367*8975f5c5SAndroid Build Coastguard Worker     }
368*8975f5c5SAndroid Build Coastguard Worker     return labelName;
369*8975f5c5SAndroid Build Coastguard Worker }
370*8975f5c5SAndroid Build Coastguard Worker 
GetObjectLabelBase(const std::string & objectLabel,GLsizei bufSize,GLsizei * length,GLchar * label)371*8975f5c5SAndroid Build Coastguard Worker void GetObjectLabelBase(const std::string &objectLabel,
372*8975f5c5SAndroid Build Coastguard Worker                         GLsizei bufSize,
373*8975f5c5SAndroid Build Coastguard Worker                         GLsizei *length,
374*8975f5c5SAndroid Build Coastguard Worker                         GLchar *label)
375*8975f5c5SAndroid Build Coastguard Worker {
376*8975f5c5SAndroid Build Coastguard Worker     size_t writeLength = objectLabel.length();
377*8975f5c5SAndroid Build Coastguard Worker     if (label != nullptr && bufSize > 0)
378*8975f5c5SAndroid Build Coastguard Worker     {
379*8975f5c5SAndroid Build Coastguard Worker         writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length());
380*8975f5c5SAndroid Build Coastguard Worker         std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label);
381*8975f5c5SAndroid Build Coastguard Worker         label[writeLength] = '\0';
382*8975f5c5SAndroid Build Coastguard Worker     }
383*8975f5c5SAndroid Build Coastguard Worker 
384*8975f5c5SAndroid Build Coastguard Worker     if (length != nullptr)
385*8975f5c5SAndroid Build Coastguard Worker     {
386*8975f5c5SAndroid Build Coastguard Worker         *length = static_cast<GLsizei>(writeLength);
387*8975f5c5SAndroid Build Coastguard Worker     }
388*8975f5c5SAndroid Build Coastguard Worker }
389*8975f5c5SAndroid Build Coastguard Worker 
390*8975f5c5SAndroid Build Coastguard Worker enum SubjectIndexes : angle::SubjectIndex
391*8975f5c5SAndroid Build Coastguard Worker {
392*8975f5c5SAndroid Build Coastguard Worker     kTexture0SubjectIndex       = 0,
393*8975f5c5SAndroid Build Coastguard Worker     kTextureMaxSubjectIndex     = kTexture0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
394*8975f5c5SAndroid Build Coastguard Worker     kImage0SubjectIndex         = kTextureMaxSubjectIndex,
395*8975f5c5SAndroid Build Coastguard Worker     kImageMaxSubjectIndex       = kImage0SubjectIndex + IMPLEMENTATION_MAX_IMAGE_UNITS,
396*8975f5c5SAndroid Build Coastguard Worker     kUniformBuffer0SubjectIndex = kImageMaxSubjectIndex,
397*8975f5c5SAndroid Build Coastguard Worker     kUniformBufferMaxSubjectIndex =
398*8975f5c5SAndroid Build Coastguard Worker         kUniformBuffer0SubjectIndex + IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS,
399*8975f5c5SAndroid Build Coastguard Worker     kAtomicCounterBuffer0SubjectIndex = kUniformBufferMaxSubjectIndex,
400*8975f5c5SAndroid Build Coastguard Worker     kAtomicCounterBufferMaxSubjectIndex =
401*8975f5c5SAndroid Build Coastguard Worker         kAtomicCounterBuffer0SubjectIndex + IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS,
402*8975f5c5SAndroid Build Coastguard Worker     kShaderStorageBuffer0SubjectIndex = kAtomicCounterBufferMaxSubjectIndex,
403*8975f5c5SAndroid Build Coastguard Worker     kShaderStorageBufferMaxSubjectIndex =
404*8975f5c5SAndroid Build Coastguard Worker         kShaderStorageBuffer0SubjectIndex + IMPLEMENTATION_MAX_SHADER_STORAGE_BUFFER_BINDINGS,
405*8975f5c5SAndroid Build Coastguard Worker     kSampler0SubjectIndex    = kShaderStorageBufferMaxSubjectIndex,
406*8975f5c5SAndroid Build Coastguard Worker     kSamplerMaxSubjectIndex  = kSampler0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
407*8975f5c5SAndroid Build Coastguard Worker     kVertexArraySubjectIndex = kSamplerMaxSubjectIndex,
408*8975f5c5SAndroid Build Coastguard Worker     kReadFramebufferSubjectIndex,
409*8975f5c5SAndroid Build Coastguard Worker     kDrawFramebufferSubjectIndex,
410*8975f5c5SAndroid Build Coastguard Worker     kProgramSubjectIndex,
411*8975f5c5SAndroid Build Coastguard Worker     kProgramPipelineSubjectIndex,
412*8975f5c5SAndroid Build Coastguard Worker };
413*8975f5c5SAndroid Build Coastguard Worker 
IsClearBufferEnabled(const FramebufferState & fbState,GLenum buffer,GLint drawbuffer)414*8975f5c5SAndroid Build Coastguard Worker bool IsClearBufferEnabled(const FramebufferState &fbState, GLenum buffer, GLint drawbuffer)
415*8975f5c5SAndroid Build Coastguard Worker {
416*8975f5c5SAndroid Build Coastguard Worker     return buffer != GL_COLOR || fbState.getEnabledDrawBuffers()[drawbuffer];
417*8975f5c5SAndroid Build Coastguard Worker }
418*8975f5c5SAndroid Build Coastguard Worker 
IsColorMaskedOut(const BlendStateExt & blendStateExt,const GLint drawbuffer)419*8975f5c5SAndroid Build Coastguard Worker bool IsColorMaskedOut(const BlendStateExt &blendStateExt, const GLint drawbuffer)
420*8975f5c5SAndroid Build Coastguard Worker {
421*8975f5c5SAndroid Build Coastguard Worker     ASSERT(static_cast<size_t>(drawbuffer) < blendStateExt.getDrawBufferCount());
422*8975f5c5SAndroid Build Coastguard Worker     return blendStateExt.getColorMaskIndexed(static_cast<size_t>(drawbuffer)) == 0;
423*8975f5c5SAndroid Build Coastguard Worker }
424*8975f5c5SAndroid Build Coastguard Worker 
GetIsExternal(const egl::AttributeMap & attribs)425*8975f5c5SAndroid Build Coastguard Worker bool GetIsExternal(const egl::AttributeMap &attribs)
426*8975f5c5SAndroid Build Coastguard Worker {
427*8975f5c5SAndroid Build Coastguard Worker     return (attribs.get(EGL_EXTERNAL_CONTEXT_ANGLE, EGL_FALSE) == EGL_TRUE);
428*8975f5c5SAndroid Build Coastguard Worker }
429*8975f5c5SAndroid Build Coastguard Worker 
GetPerfMonitorString(const std::string & name,GLsizei bufSize,GLsizei * length,GLchar * stringOut)430*8975f5c5SAndroid Build Coastguard Worker void GetPerfMonitorString(const std::string &name,
431*8975f5c5SAndroid Build Coastguard Worker                           GLsizei bufSize,
432*8975f5c5SAndroid Build Coastguard Worker                           GLsizei *length,
433*8975f5c5SAndroid Build Coastguard Worker                           GLchar *stringOut)
434*8975f5c5SAndroid Build Coastguard Worker {
435*8975f5c5SAndroid Build Coastguard Worker     GLsizei numCharsWritten = std::min(bufSize, static_cast<GLsizei>(name.size()));
436*8975f5c5SAndroid Build Coastguard Worker 
437*8975f5c5SAndroid Build Coastguard Worker     if (length)
438*8975f5c5SAndroid Build Coastguard Worker     {
439*8975f5c5SAndroid Build Coastguard Worker         if (bufSize == 0)
440*8975f5c5SAndroid Build Coastguard Worker         {
441*8975f5c5SAndroid Build Coastguard Worker             *length = static_cast<GLsizei>(name.size());
442*8975f5c5SAndroid Build Coastguard Worker         }
443*8975f5c5SAndroid Build Coastguard Worker         else
444*8975f5c5SAndroid Build Coastguard Worker         {
445*8975f5c5SAndroid Build Coastguard Worker             // Excludes null terminator.
446*8975f5c5SAndroid Build Coastguard Worker             ASSERT(numCharsWritten > 0);
447*8975f5c5SAndroid Build Coastguard Worker             *length = numCharsWritten - 1;
448*8975f5c5SAndroid Build Coastguard Worker         }
449*8975f5c5SAndroid Build Coastguard Worker     }
450*8975f5c5SAndroid Build Coastguard Worker 
451*8975f5c5SAndroid Build Coastguard Worker     if (stringOut)
452*8975f5c5SAndroid Build Coastguard Worker     {
453*8975f5c5SAndroid Build Coastguard Worker         memcpy(stringOut, name.c_str(), numCharsWritten);
454*8975f5c5SAndroid Build Coastguard Worker     }
455*8975f5c5SAndroid Build Coastguard Worker }
456*8975f5c5SAndroid Build Coastguard Worker 
CanSupportAEP(const gl::Version & version,const gl::Extensions & extensions)457*8975f5c5SAndroid Build Coastguard Worker bool CanSupportAEP(const gl::Version &version, const gl::Extensions &extensions)
458*8975f5c5SAndroid Build Coastguard Worker {
459*8975f5c5SAndroid Build Coastguard Worker     // From the GL_ANDROID_extension_pack_es31a extension spec:
460*8975f5c5SAndroid Build Coastguard Worker     // OpenGL ES 3.1 and GLSL ES 3.10 are required.
461*8975f5c5SAndroid Build Coastguard Worker     // The following extensions are required:
462*8975f5c5SAndroid Build Coastguard Worker     // * KHR_debug
463*8975f5c5SAndroid Build Coastguard Worker     // * KHR_texture_compression_astc_ldr
464*8975f5c5SAndroid Build Coastguard Worker     // * KHR_blend_equation_advanced
465*8975f5c5SAndroid Build Coastguard Worker     // * OES_sample_shading
466*8975f5c5SAndroid Build Coastguard Worker     // * OES_sample_variables
467*8975f5c5SAndroid Build Coastguard Worker     // * OES_shader_image_atomic
468*8975f5c5SAndroid Build Coastguard Worker     // * OES_shader_multisample_interpolation
469*8975f5c5SAndroid Build Coastguard Worker     // * OES_texture_stencil8
470*8975f5c5SAndroid Build Coastguard Worker     // * OES_texture_storage_multisample_2d_array
471*8975f5c5SAndroid Build Coastguard Worker     // * EXT_copy_image
472*8975f5c5SAndroid Build Coastguard Worker     // * EXT_draw_buffers_indexed
473*8975f5c5SAndroid Build Coastguard Worker     // * EXT_geometry_shader
474*8975f5c5SAndroid Build Coastguard Worker     // * EXT_gpu_shader5
475*8975f5c5SAndroid Build Coastguard Worker     // * EXT_primitive_bounding_box
476*8975f5c5SAndroid Build Coastguard Worker     // * EXT_shader_io_blocks
477*8975f5c5SAndroid Build Coastguard Worker     // * EXT_tessellation_shader
478*8975f5c5SAndroid Build Coastguard Worker     // * EXT_texture_border_clamp
479*8975f5c5SAndroid Build Coastguard Worker     // * EXT_texture_buffer
480*8975f5c5SAndroid Build Coastguard Worker     // * EXT_texture_cube_map_array
481*8975f5c5SAndroid Build Coastguard Worker     // * EXT_texture_sRGB_decode
482*8975f5c5SAndroid Build Coastguard Worker     std::pair<const char *, bool> requirements[] = {
483*8975f5c5SAndroid Build Coastguard Worker         {"version >= ES_3_1", version >= ES_3_1},
484*8975f5c5SAndroid Build Coastguard Worker         {"extensions.debugKHR", extensions.debugKHR},
485*8975f5c5SAndroid Build Coastguard Worker         {"extensions.textureCompressionAstcLdrKHR", extensions.textureCompressionAstcLdrKHR},
486*8975f5c5SAndroid Build Coastguard Worker         {"extensions.blendEquationAdvancedKHR", extensions.blendEquationAdvancedKHR},
487*8975f5c5SAndroid Build Coastguard Worker         {"extensions.sampleShadingOES", extensions.sampleShadingOES},
488*8975f5c5SAndroid Build Coastguard Worker         {"extensions.sampleVariablesOES", extensions.sampleVariablesOES},
489*8975f5c5SAndroid Build Coastguard Worker         {"extensions.shaderImageAtomicOES", extensions.shaderImageAtomicOES},
490*8975f5c5SAndroid Build Coastguard Worker         {"extensions.shaderMultisampleInterpolationOES",
491*8975f5c5SAndroid Build Coastguard Worker          extensions.shaderMultisampleInterpolationOES},
492*8975f5c5SAndroid Build Coastguard Worker         {"extensions.textureStencil8OES", extensions.textureStencil8OES},
493*8975f5c5SAndroid Build Coastguard Worker         {"extensions.textureStorageMultisample2dArrayOES",
494*8975f5c5SAndroid Build Coastguard Worker          extensions.textureStorageMultisample2dArrayOES},
495*8975f5c5SAndroid Build Coastguard Worker         {"extensions.copyImageEXT", extensions.copyImageEXT},
496*8975f5c5SAndroid Build Coastguard Worker         {"extensions.drawBuffersIndexedEXT", extensions.drawBuffersIndexedEXT},
497*8975f5c5SAndroid Build Coastguard Worker         {"extensions.geometryShaderEXT", extensions.geometryShaderEXT},
498*8975f5c5SAndroid Build Coastguard Worker         {"extensions.gpuShader5EXT", extensions.gpuShader5EXT},
499*8975f5c5SAndroid Build Coastguard Worker         {"extensions.primitiveBoundingBoxEXT", extensions.primitiveBoundingBoxEXT},
500*8975f5c5SAndroid Build Coastguard Worker         {"extensions.shaderIoBlocksEXT", extensions.shaderIoBlocksEXT},
501*8975f5c5SAndroid Build Coastguard Worker         {"extensions.tessellationShaderEXT", extensions.tessellationShaderEXT},
502*8975f5c5SAndroid Build Coastguard Worker         {"extensions.textureBorderClampEXT", extensions.textureBorderClampEXT},
503*8975f5c5SAndroid Build Coastguard Worker         {"extensions.textureBufferEXT", extensions.textureBufferEXT},
504*8975f5c5SAndroid Build Coastguard Worker         {"extensions.textureCubeMapArrayEXT", extensions.textureCubeMapArrayEXT},
505*8975f5c5SAndroid Build Coastguard Worker         {"extensions.textureSRGBDecodeEXT", extensions.textureSRGBDecodeEXT},
506*8975f5c5SAndroid Build Coastguard Worker     };
507*8975f5c5SAndroid Build Coastguard Worker 
508*8975f5c5SAndroid Build Coastguard Worker     bool result = true;
509*8975f5c5SAndroid Build Coastguard Worker     for (const auto &req : requirements)
510*8975f5c5SAndroid Build Coastguard Worker     {
511*8975f5c5SAndroid Build Coastguard Worker         result = result && req.second;
512*8975f5c5SAndroid Build Coastguard Worker     }
513*8975f5c5SAndroid Build Coastguard Worker 
514*8975f5c5SAndroid Build Coastguard Worker     if (kEnableAEPRequirementLogging && !result)
515*8975f5c5SAndroid Build Coastguard Worker     {
516*8975f5c5SAndroid Build Coastguard Worker         INFO() << "CanSupportAEP() check failed for missing the following requirements:\n";
517*8975f5c5SAndroid Build Coastguard Worker         for (const auto &req : requirements)
518*8975f5c5SAndroid Build Coastguard Worker         {
519*8975f5c5SAndroid Build Coastguard Worker             if (!req.second)
520*8975f5c5SAndroid Build Coastguard Worker             {
521*8975f5c5SAndroid Build Coastguard Worker                 INFO() << "- " << req.first << "\n";
522*8975f5c5SAndroid Build Coastguard Worker             }
523*8975f5c5SAndroid Build Coastguard Worker         }
524*8975f5c5SAndroid Build Coastguard Worker     }
525*8975f5c5SAndroid Build Coastguard Worker 
526*8975f5c5SAndroid Build Coastguard Worker     return result;
527*8975f5c5SAndroid Build Coastguard Worker }
528*8975f5c5SAndroid Build Coastguard Worker }  // anonymous namespace
529*8975f5c5SAndroid Build Coastguard Worker 
530*8975f5c5SAndroid Build Coastguard Worker #if defined(ANGLE_PLATFORM_APPLE)
531*8975f5c5SAndroid Build Coastguard Worker // TODO(angleproject:6479): Due to a bug in Apple's dyld loader, `thread_local` will cause
532*8975f5c5SAndroid Build Coastguard Worker // excessive memory use. Temporarily avoid it by using pthread's thread
533*8975f5c5SAndroid Build Coastguard Worker // local storage instead.
GetCurrentValidContextTLSIndex()534*8975f5c5SAndroid Build Coastguard Worker static angle::TLSIndex GetCurrentValidContextTLSIndex()
535*8975f5c5SAndroid Build Coastguard Worker {
536*8975f5c5SAndroid Build Coastguard Worker     static angle::TLSIndex CurrentValidContextIndex = TLS_INVALID_INDEX;
537*8975f5c5SAndroid Build Coastguard Worker     static dispatch_once_t once;
538*8975f5c5SAndroid Build Coastguard Worker     dispatch_once(&once, ^{
539*8975f5c5SAndroid Build Coastguard Worker       ASSERT(CurrentValidContextIndex == TLS_INVALID_INDEX);
540*8975f5c5SAndroid Build Coastguard Worker       CurrentValidContextIndex = angle::CreateTLSIndex(nullptr);
541*8975f5c5SAndroid Build Coastguard Worker     });
542*8975f5c5SAndroid Build Coastguard Worker     return CurrentValidContextIndex;
543*8975f5c5SAndroid Build Coastguard Worker }
GetCurrentValidContextTLS()544*8975f5c5SAndroid Build Coastguard Worker Context *GetCurrentValidContextTLS()
545*8975f5c5SAndroid Build Coastguard Worker {
546*8975f5c5SAndroid Build Coastguard Worker     angle::TLSIndex CurrentValidContextIndex = GetCurrentValidContextTLSIndex();
547*8975f5c5SAndroid Build Coastguard Worker     ASSERT(CurrentValidContextIndex != TLS_INVALID_INDEX);
548*8975f5c5SAndroid Build Coastguard Worker     return static_cast<Context *>(angle::GetTLSValue(CurrentValidContextIndex));
549*8975f5c5SAndroid Build Coastguard Worker }
SetCurrentValidContextTLS(Context * context)550*8975f5c5SAndroid Build Coastguard Worker void SetCurrentValidContextTLS(Context *context)
551*8975f5c5SAndroid Build Coastguard Worker {
552*8975f5c5SAndroid Build Coastguard Worker     angle::TLSIndex CurrentValidContextIndex = GetCurrentValidContextTLSIndex();
553*8975f5c5SAndroid Build Coastguard Worker     ASSERT(CurrentValidContextIndex != TLS_INVALID_INDEX);
554*8975f5c5SAndroid Build Coastguard Worker     angle::SetTLSValue(CurrentValidContextIndex, context);
555*8975f5c5SAndroid Build Coastguard Worker }
556*8975f5c5SAndroid Build Coastguard Worker #elif defined(ANGLE_USE_STATIC_THREAD_LOCAL_VARIABLES)
557*8975f5c5SAndroid Build Coastguard Worker static thread_local Context *gCurrentValidContext = nullptr;
GetCurrentValidContextTLS()558*8975f5c5SAndroid Build Coastguard Worker Context *GetCurrentValidContextTLS()
559*8975f5c5SAndroid Build Coastguard Worker {
560*8975f5c5SAndroid Build Coastguard Worker     return gCurrentValidContext;
561*8975f5c5SAndroid Build Coastguard Worker }
SetCurrentValidContextTLS(Context * context)562*8975f5c5SAndroid Build Coastguard Worker void SetCurrentValidContextTLS(Context *context)
563*8975f5c5SAndroid Build Coastguard Worker {
564*8975f5c5SAndroid Build Coastguard Worker     gCurrentValidContext = context;
565*8975f5c5SAndroid Build Coastguard Worker }
566*8975f5c5SAndroid Build Coastguard Worker #else
567*8975f5c5SAndroid Build Coastguard Worker thread_local Context *gCurrentValidContext = nullptr;
568*8975f5c5SAndroid Build Coastguard Worker #endif
569*8975f5c5SAndroid Build Coastguard Worker 
570*8975f5c5SAndroid Build Coastguard Worker // Handle setting the current context in TLS on different platforms
SetCurrentValidContext(Context * context)571*8975f5c5SAndroid Build Coastguard Worker extern void SetCurrentValidContext(Context *context)
572*8975f5c5SAndroid Build Coastguard Worker {
573*8975f5c5SAndroid Build Coastguard Worker #if defined(ANGLE_USE_ANDROID_TLS_SLOT)
574*8975f5c5SAndroid Build Coastguard Worker     if (angle::gUseAndroidOpenGLTlsSlot)
575*8975f5c5SAndroid Build Coastguard Worker     {
576*8975f5c5SAndroid Build Coastguard Worker         ANGLE_ANDROID_GET_GL_TLS()[angle::kAndroidOpenGLTlsSlot] = static_cast<void *>(context);
577*8975f5c5SAndroid Build Coastguard Worker         return;
578*8975f5c5SAndroid Build Coastguard Worker     }
579*8975f5c5SAndroid Build Coastguard Worker #endif
580*8975f5c5SAndroid Build Coastguard Worker 
581*8975f5c5SAndroid Build Coastguard Worker #if defined(ANGLE_PLATFORM_APPLE) || defined(ANGLE_USE_STATIC_THREAD_LOCAL_VARIABLES)
582*8975f5c5SAndroid Build Coastguard Worker     SetCurrentValidContextTLS(context);
583*8975f5c5SAndroid Build Coastguard Worker #else
584*8975f5c5SAndroid Build Coastguard Worker     gCurrentValidContext = context;
585*8975f5c5SAndroid Build Coastguard Worker #endif
586*8975f5c5SAndroid Build Coastguard Worker }
587*8975f5c5SAndroid Build Coastguard Worker 
Context(egl::Display * display,const egl::Config * config,const Context * shareContext,TextureManager * shareTextures,SemaphoreManager * shareSemaphores,egl::ContextMutex * sharedContextMutex,MemoryProgramCache * memoryProgramCache,MemoryShaderCache * memoryShaderCache,const egl::AttributeMap & attribs,const egl::DisplayExtensions & displayExtensions,const egl::ClientExtensions & clientExtensions)588*8975f5c5SAndroid Build Coastguard Worker Context::Context(egl::Display *display,
589*8975f5c5SAndroid Build Coastguard Worker                  const egl::Config *config,
590*8975f5c5SAndroid Build Coastguard Worker                  const Context *shareContext,
591*8975f5c5SAndroid Build Coastguard Worker                  TextureManager *shareTextures,
592*8975f5c5SAndroid Build Coastguard Worker                  SemaphoreManager *shareSemaphores,
593*8975f5c5SAndroid Build Coastguard Worker                  egl::ContextMutex *sharedContextMutex,
594*8975f5c5SAndroid Build Coastguard Worker                  MemoryProgramCache *memoryProgramCache,
595*8975f5c5SAndroid Build Coastguard Worker                  MemoryShaderCache *memoryShaderCache,
596*8975f5c5SAndroid Build Coastguard Worker                  const egl::AttributeMap &attribs,
597*8975f5c5SAndroid Build Coastguard Worker                  const egl::DisplayExtensions &displayExtensions,
598*8975f5c5SAndroid Build Coastguard Worker                  const egl::ClientExtensions &clientExtensions)
599*8975f5c5SAndroid Build Coastguard Worker     : mState(shareContext ? &shareContext->mState : nullptr,
600*8975f5c5SAndroid Build Coastguard Worker              AllocateOrGetShareGroup(display, shareContext),
601*8975f5c5SAndroid Build Coastguard Worker              shareTextures,
602*8975f5c5SAndroid Build Coastguard Worker              shareSemaphores,
603*8975f5c5SAndroid Build Coastguard Worker              AllocateOrUseContextMutex(sharedContextMutex),
604*8975f5c5SAndroid Build Coastguard Worker              &mOverlay,
605*8975f5c5SAndroid Build Coastguard Worker              GetClientVersion(display, attribs),
606*8975f5c5SAndroid Build Coastguard Worker              GetDebug(attribs),
607*8975f5c5SAndroid Build Coastguard Worker              GetBindGeneratesResource(attribs),
608*8975f5c5SAndroid Build Coastguard Worker              GetClientArraysEnabled(attribs),
609*8975f5c5SAndroid Build Coastguard Worker              GetRobustResourceInit(display, attribs),
610*8975f5c5SAndroid Build Coastguard Worker              memoryProgramCache != nullptr,
611*8975f5c5SAndroid Build Coastguard Worker              GetContextPriority(attribs),
612*8975f5c5SAndroid Build Coastguard Worker              GetRobustAccess(attribs),
613*8975f5c5SAndroid Build Coastguard Worker              GetProtectedContent(attribs),
614*8975f5c5SAndroid Build Coastguard Worker              GetIsExternal(attribs)),
615*8975f5c5SAndroid Build Coastguard Worker       mShared(shareContext != nullptr || shareTextures != nullptr || shareSemaphores != nullptr),
616*8975f5c5SAndroid Build Coastguard Worker       mDisplayTextureShareGroup(shareTextures != nullptr),
617*8975f5c5SAndroid Build Coastguard Worker       mDisplaySemaphoreShareGroup(shareSemaphores != nullptr),
618*8975f5c5SAndroid Build Coastguard Worker       mErrors(&mState.getDebug(), display->getFrontendFeatures(), attribs),
619*8975f5c5SAndroid Build Coastguard Worker       mImplementation(display->getImplementation()
620*8975f5c5SAndroid Build Coastguard Worker                           ->createContext(mState, &mErrors, config, shareContext, attribs)),
621*8975f5c5SAndroid Build Coastguard Worker       mLabel(nullptr),
622*8975f5c5SAndroid Build Coastguard Worker       mCompiler(),
623*8975f5c5SAndroid Build Coastguard Worker       mConfig(config),
624*8975f5c5SAndroid Build Coastguard Worker       mHasBeenCurrent(false),
625*8975f5c5SAndroid Build Coastguard Worker       mSurfacelessSupported(displayExtensions.surfacelessContext),
626*8975f5c5SAndroid Build Coastguard Worker       mCurrentDrawSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)),
627*8975f5c5SAndroid Build Coastguard Worker       mCurrentReadSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)),
628*8975f5c5SAndroid Build Coastguard Worker       mDisplay(display),
629*8975f5c5SAndroid Build Coastguard Worker       mWebGLContext(GetWebGLContext(attribs)),
630*8975f5c5SAndroid Build Coastguard Worker       mBufferAccessValidationEnabled(false),
631*8975f5c5SAndroid Build Coastguard Worker       mExtensionsEnabled(GetExtensionsEnabled(attribs, mWebGLContext)),
632*8975f5c5SAndroid Build Coastguard Worker       mMemoryProgramCache(memoryProgramCache),
633*8975f5c5SAndroid Build Coastguard Worker       mMemoryShaderCache(memoryShaderCache),
634*8975f5c5SAndroid Build Coastguard Worker       mVertexArrayObserverBinding(this, kVertexArraySubjectIndex),
635*8975f5c5SAndroid Build Coastguard Worker       mDrawFramebufferObserverBinding(this, kDrawFramebufferSubjectIndex),
636*8975f5c5SAndroid Build Coastguard Worker       mReadFramebufferObserverBinding(this, kReadFramebufferSubjectIndex),
637*8975f5c5SAndroid Build Coastguard Worker       mProgramObserverBinding(this, kProgramSubjectIndex),
638*8975f5c5SAndroid Build Coastguard Worker       mProgramPipelineObserverBinding(this, kProgramPipelineSubjectIndex),
639*8975f5c5SAndroid Build Coastguard Worker       mFrameCapture(new angle::FrameCapture),
640*8975f5c5SAndroid Build Coastguard Worker       mRefCount(0),
641*8975f5c5SAndroid Build Coastguard Worker       mOverlay(mImplementation.get()),
642*8975f5c5SAndroid Build Coastguard Worker       mIsDestroyed(false)
643*8975f5c5SAndroid Build Coastguard Worker {
644*8975f5c5SAndroid Build Coastguard Worker     for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex;
645*8975f5c5SAndroid Build Coastguard Worker          uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex)
646*8975f5c5SAndroid Build Coastguard Worker     {
647*8975f5c5SAndroid Build Coastguard Worker         mUniformBufferObserverBindings.emplace_back(this, uboIndex);
648*8975f5c5SAndroid Build Coastguard Worker     }
649*8975f5c5SAndroid Build Coastguard Worker 
650*8975f5c5SAndroid Build Coastguard Worker     for (angle::SubjectIndex acbIndex = kAtomicCounterBuffer0SubjectIndex;
651*8975f5c5SAndroid Build Coastguard Worker          acbIndex < kAtomicCounterBufferMaxSubjectIndex; ++acbIndex)
652*8975f5c5SAndroid Build Coastguard Worker     {
653*8975f5c5SAndroid Build Coastguard Worker         mAtomicCounterBufferObserverBindings.emplace_back(this, acbIndex);
654*8975f5c5SAndroid Build Coastguard Worker     }
655*8975f5c5SAndroid Build Coastguard Worker 
656*8975f5c5SAndroid Build Coastguard Worker     for (angle::SubjectIndex ssboIndex = kShaderStorageBuffer0SubjectIndex;
657*8975f5c5SAndroid Build Coastguard Worker          ssboIndex < kShaderStorageBufferMaxSubjectIndex; ++ssboIndex)
658*8975f5c5SAndroid Build Coastguard Worker     {
659*8975f5c5SAndroid Build Coastguard Worker         mShaderStorageBufferObserverBindings.emplace_back(this, ssboIndex);
660*8975f5c5SAndroid Build Coastguard Worker     }
661*8975f5c5SAndroid Build Coastguard Worker 
662*8975f5c5SAndroid Build Coastguard Worker     for (angle::SubjectIndex samplerIndex = kSampler0SubjectIndex;
663*8975f5c5SAndroid Build Coastguard Worker          samplerIndex < kSamplerMaxSubjectIndex; ++samplerIndex)
664*8975f5c5SAndroid Build Coastguard Worker     {
665*8975f5c5SAndroid Build Coastguard Worker         mSamplerObserverBindings.emplace_back(this, samplerIndex);
666*8975f5c5SAndroid Build Coastguard Worker     }
667*8975f5c5SAndroid Build Coastguard Worker 
668*8975f5c5SAndroid Build Coastguard Worker     for (angle::SubjectIndex imageIndex = kImage0SubjectIndex; imageIndex < kImageMaxSubjectIndex;
669*8975f5c5SAndroid Build Coastguard Worker          ++imageIndex)
670*8975f5c5SAndroid Build Coastguard Worker     {
671*8975f5c5SAndroid Build Coastguard Worker         mImageObserverBindings.emplace_back(this, imageIndex);
672*8975f5c5SAndroid Build Coastguard Worker     }
673*8975f5c5SAndroid Build Coastguard Worker 
674*8975f5c5SAndroid Build Coastguard Worker     // Implementations now require the display to be set at context creation.
675*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mDisplay);
676*8975f5c5SAndroid Build Coastguard Worker }
677*8975f5c5SAndroid Build Coastguard Worker 
initialize()678*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::initialize()
679*8975f5c5SAndroid Build Coastguard Worker {
680*8975f5c5SAndroid Build Coastguard Worker     if (!mImplementation)
681*8975f5c5SAndroid Build Coastguard Worker     {
682*8975f5c5SAndroid Build Coastguard Worker         return egl::Error(EGL_NOT_INITIALIZED, "native context creation failed");
683*8975f5c5SAndroid Build Coastguard Worker     }
684*8975f5c5SAndroid Build Coastguard Worker 
685*8975f5c5SAndroid Build Coastguard Worker     // If the final context version created (with backwards compatibility possibly added in),
686*8975f5c5SAndroid Build Coastguard Worker     // generate an error if it's higher than the maximum supported version for the display. This
687*8975f5c5SAndroid Build Coastguard Worker     // validation is always done even with EGL validation disabled because it's not possible to
688*8975f5c5SAndroid Build Coastguard Worker     // detect ahead of time if an ES 3.1 context is supported (no ES_31_BIT) or if
689*8975f5c5SAndroid Build Coastguard Worker     // KHR_no_config_context is used.
690*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() > getDisplay()->getMaxSupportedESVersion())
691*8975f5c5SAndroid Build Coastguard Worker     {
692*8975f5c5SAndroid Build Coastguard Worker         return egl::Error(EGL_BAD_ATTRIBUTE, "Requested version is not supported");
693*8975f5c5SAndroid Build Coastguard Worker     }
694*8975f5c5SAndroid Build Coastguard Worker 
695*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
696*8975f5c5SAndroid Build Coastguard Worker }
697*8975f5c5SAndroid Build Coastguard Worker 
initializeDefaultResources()698*8975f5c5SAndroid Build Coastguard Worker void Context::initializeDefaultResources()
699*8975f5c5SAndroid Build Coastguard Worker {
700*8975f5c5SAndroid Build Coastguard Worker     mImplementation->setMemoryProgramCache(mMemoryProgramCache);
701*8975f5c5SAndroid Build Coastguard Worker 
702*8975f5c5SAndroid Build Coastguard Worker     initCaps();
703*8975f5c5SAndroid Build Coastguard Worker 
704*8975f5c5SAndroid Build Coastguard Worker     mState.initialize(this);
705*8975f5c5SAndroid Build Coastguard Worker 
706*8975f5c5SAndroid Build Coastguard Worker     mDefaultFramebuffer = std::make_unique<Framebuffer>(this, mImplementation.get());
707*8975f5c5SAndroid Build Coastguard Worker 
708*8975f5c5SAndroid Build Coastguard Worker     mFenceNVHandleAllocator.setBaseHandle(0);
709*8975f5c5SAndroid Build Coastguard Worker 
710*8975f5c5SAndroid Build Coastguard Worker     // [OpenGL ES 2.0.24] section 3.7 page 83:
711*8975f5c5SAndroid Build Coastguard Worker     // In the initial state, TEXTURE_2D and TEXTURE_CUBE_MAP have two-dimensional
712*8975f5c5SAndroid Build Coastguard Worker     // and cube map texture state vectors respectively associated with them.
713*8975f5c5SAndroid Build Coastguard Worker     // In order that access to these initial textures not be lost, they are treated as texture
714*8975f5c5SAndroid Build Coastguard Worker     // objects all of whose names are 0.
715*8975f5c5SAndroid Build Coastguard Worker 
716*8975f5c5SAndroid Build Coastguard Worker     Texture *zeroTexture2D = new Texture(mImplementation.get(), {0}, TextureType::_2D);
717*8975f5c5SAndroid Build Coastguard Worker     mZeroTextures[TextureType::_2D].set(this, zeroTexture2D);
718*8975f5c5SAndroid Build Coastguard Worker 
719*8975f5c5SAndroid Build Coastguard Worker     Texture *zeroTextureCube = new Texture(mImplementation.get(), {0}, TextureType::CubeMap);
720*8975f5c5SAndroid Build Coastguard Worker     mZeroTextures[TextureType::CubeMap].set(this, zeroTextureCube);
721*8975f5c5SAndroid Build Coastguard Worker 
722*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 0) || mSupportedExtensions.texture3DOES)
723*8975f5c5SAndroid Build Coastguard Worker     {
724*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTexture3D = new Texture(mImplementation.get(), {0}, TextureType::_3D);
725*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::_3D].set(this, zeroTexture3D);
726*8975f5c5SAndroid Build Coastguard Worker     }
727*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 0))
728*8975f5c5SAndroid Build Coastguard Worker     {
729*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTexture2DArray =
730*8975f5c5SAndroid Build Coastguard Worker             new Texture(mImplementation.get(), {0}, TextureType::_2DArray);
731*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::_2DArray].set(this, zeroTexture2DArray);
732*8975f5c5SAndroid Build Coastguard Worker     }
733*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 1) || mSupportedExtensions.textureMultisampleANGLE)
734*8975f5c5SAndroid Build Coastguard Worker     {
735*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTexture2DMultisample =
736*8975f5c5SAndroid Build Coastguard Worker             new Texture(mImplementation.get(), {0}, TextureType::_2DMultisample);
737*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::_2DMultisample].set(this, zeroTexture2DMultisample);
738*8975f5c5SAndroid Build Coastguard Worker     }
739*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 2) ||
740*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureStorageMultisample2dArrayOES)
741*8975f5c5SAndroid Build Coastguard Worker     {
742*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTexture2DMultisampleArray =
743*8975f5c5SAndroid Build Coastguard Worker             new Texture(mImplementation.get(), {0}, TextureType::_2DMultisampleArray);
744*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::_2DMultisampleArray].set(this, zeroTexture2DMultisampleArray);
745*8975f5c5SAndroid Build Coastguard Worker     }
746*8975f5c5SAndroid Build Coastguard Worker 
747*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 1))
748*8975f5c5SAndroid Build Coastguard Worker     {
749*8975f5c5SAndroid Build Coastguard Worker         for (int i = 0; i < mState.getCaps().maxAtomicCounterBufferBindings; i++)
750*8975f5c5SAndroid Build Coastguard Worker         {
751*8975f5c5SAndroid Build Coastguard Worker             bindBufferRange(BufferBinding::AtomicCounter, i, {0}, 0, 0);
752*8975f5c5SAndroid Build Coastguard Worker         }
753*8975f5c5SAndroid Build Coastguard Worker 
754*8975f5c5SAndroid Build Coastguard Worker         for (int i = 0; i < mState.getCaps().maxShaderStorageBufferBindings; i++)
755*8975f5c5SAndroid Build Coastguard Worker         {
756*8975f5c5SAndroid Build Coastguard Worker             bindBufferRange(BufferBinding::ShaderStorage, i, {0}, 0, 0);
757*8975f5c5SAndroid Build Coastguard Worker         }
758*8975f5c5SAndroid Build Coastguard Worker     }
759*8975f5c5SAndroid Build Coastguard Worker 
760*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 2) || mSupportedExtensions.textureCubeMapArrayAny())
761*8975f5c5SAndroid Build Coastguard Worker     {
762*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTextureCubeMapArray =
763*8975f5c5SAndroid Build Coastguard Worker             new Texture(mImplementation.get(), {0}, TextureType::CubeMapArray);
764*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::CubeMapArray].set(this, zeroTextureCubeMapArray);
765*8975f5c5SAndroid Build Coastguard Worker     }
766*8975f5c5SAndroid Build Coastguard Worker 
767*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 2) || mSupportedExtensions.textureBufferAny())
768*8975f5c5SAndroid Build Coastguard Worker     {
769*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTextureBuffer = new Texture(mImplementation.get(), {0}, TextureType::Buffer);
770*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::Buffer].set(this, zeroTextureBuffer);
771*8975f5c5SAndroid Build Coastguard Worker     }
772*8975f5c5SAndroid Build Coastguard Worker 
773*8975f5c5SAndroid Build Coastguard Worker     if (mSupportedExtensions.textureRectangleANGLE)
774*8975f5c5SAndroid Build Coastguard Worker     {
775*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTextureRectangle =
776*8975f5c5SAndroid Build Coastguard Worker             new Texture(mImplementation.get(), {0}, TextureType::Rectangle);
777*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::Rectangle].set(this, zeroTextureRectangle);
778*8975f5c5SAndroid Build Coastguard Worker     }
779*8975f5c5SAndroid Build Coastguard Worker 
780*8975f5c5SAndroid Build Coastguard Worker     if (mSupportedExtensions.EGLImageExternalOES ||
781*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.EGLStreamConsumerExternalNV)
782*8975f5c5SAndroid Build Coastguard Worker     {
783*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTextureExternal =
784*8975f5c5SAndroid Build Coastguard Worker             new Texture(mImplementation.get(), {0}, TextureType::External);
785*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::External].set(this, zeroTextureExternal);
786*8975f5c5SAndroid Build Coastguard Worker     }
787*8975f5c5SAndroid Build Coastguard Worker 
788*8975f5c5SAndroid Build Coastguard Worker     // This may change native TEXTURE_2D, TEXTURE_EXTERNAL_OES and TEXTURE_RECTANGLE,
789*8975f5c5SAndroid Build Coastguard Worker     // binding states. Ensure state manager is aware of this when binding
790*8975f5c5SAndroid Build Coastguard Worker     // this texture type.
791*8975f5c5SAndroid Build Coastguard Worker     if (mSupportedExtensions.videoTextureWEBGL)
792*8975f5c5SAndroid Build Coastguard Worker     {
793*8975f5c5SAndroid Build Coastguard Worker         Texture *zeroTextureVideoImage =
794*8975f5c5SAndroid Build Coastguard Worker             new Texture(mImplementation.get(), {0}, TextureType::VideoImage);
795*8975f5c5SAndroid Build Coastguard Worker         mZeroTextures[TextureType::VideoImage].set(this, zeroTextureVideoImage);
796*8975f5c5SAndroid Build Coastguard Worker     }
797*8975f5c5SAndroid Build Coastguard Worker 
798*8975f5c5SAndroid Build Coastguard Worker     mState.initializeZeroTextures(this, mZeroTextures);
799*8975f5c5SAndroid Build Coastguard Worker 
800*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->initialize(mDisplay->getImageLoadContext()));
801*8975f5c5SAndroid Build Coastguard Worker 
802*8975f5c5SAndroid Build Coastguard Worker     // Add context into the share group
803*8975f5c5SAndroid Build Coastguard Worker     mState.getShareGroup()->addSharedContext(this);
804*8975f5c5SAndroid Build Coastguard Worker 
805*8975f5c5SAndroid Build Coastguard Worker     bindVertexArray({0});
806*8975f5c5SAndroid Build Coastguard Worker 
807*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= Version(3, 0))
808*8975f5c5SAndroid Build Coastguard Worker     {
809*8975f5c5SAndroid Build Coastguard Worker         // [OpenGL ES 3.0.2] section 2.14.1 pg 85:
810*8975f5c5SAndroid Build Coastguard Worker         // In the initial state, a default transform feedback object is bound and treated as
811*8975f5c5SAndroid Build Coastguard Worker         // a transform feedback object with a name of zero. That object is bound any time
812*8975f5c5SAndroid Build Coastguard Worker         // BindTransformFeedback is called with id of zero
813*8975f5c5SAndroid Build Coastguard Worker         bindTransformFeedback(GL_TRANSFORM_FEEDBACK, {0});
814*8975f5c5SAndroid Build Coastguard Worker     }
815*8975f5c5SAndroid Build Coastguard Worker 
816*8975f5c5SAndroid Build Coastguard Worker     for (auto type : angle::AllEnums<BufferBinding>())
817*8975f5c5SAndroid Build Coastguard Worker     {
818*8975f5c5SAndroid Build Coastguard Worker         bindBuffer(type, {0});
819*8975f5c5SAndroid Build Coastguard Worker     }
820*8975f5c5SAndroid Build Coastguard Worker 
821*8975f5c5SAndroid Build Coastguard Worker     bindRenderbuffer(GL_RENDERBUFFER, {0});
822*8975f5c5SAndroid Build Coastguard Worker 
823*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < mState.getCaps().maxUniformBufferBindings; i++)
824*8975f5c5SAndroid Build Coastguard Worker     {
825*8975f5c5SAndroid Build Coastguard Worker         bindBufferRange(BufferBinding::Uniform, i, {0}, 0, -1);
826*8975f5c5SAndroid Build Coastguard Worker     }
827*8975f5c5SAndroid Build Coastguard Worker 
828*8975f5c5SAndroid Build Coastguard Worker     // Initialize GLES1 renderer if appropriate.
829*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < Version(2, 0))
830*8975f5c5SAndroid Build Coastguard Worker     {
831*8975f5c5SAndroid Build Coastguard Worker         mGLES1Renderer.reset(new GLES1Renderer());
832*8975f5c5SAndroid Build Coastguard Worker     }
833*8975f5c5SAndroid Build Coastguard Worker 
834*8975f5c5SAndroid Build Coastguard Worker     // Initialize dirty bit masks (in addition to what updateCaps() might have set up).
835*8975f5c5SAndroid Build Coastguard Worker     mDrawDirtyObjects |= kDrawDirtyObjectsBase;
836*8975f5c5SAndroid Build Coastguard Worker     mTexImageDirtyObjects |= kTexImageDirtyObjects;
837*8975f5c5SAndroid Build Coastguard Worker     mReadPixelsDirtyObjects |= kReadPixelsDirtyObjectsBase;
838*8975f5c5SAndroid Build Coastguard Worker     mClearDirtyObjects |= kClearDirtyObjects;
839*8975f5c5SAndroid Build Coastguard Worker     mBlitDirtyObjects |= kBlitDirtyObjectsBase;
840*8975f5c5SAndroid Build Coastguard Worker     mComputeDirtyObjects |= kComputeDirtyObjectsBase;
841*8975f5c5SAndroid Build Coastguard Worker     mCopyImageDirtyBits |= kCopyImageDirtyBitsBase;
842*8975f5c5SAndroid Build Coastguard Worker     mCopyImageDirtyObjects |= kCopyImageDirtyObjectsBase;
843*8975f5c5SAndroid Build Coastguard Worker 
844*8975f5c5SAndroid Build Coastguard Worker     mOverlay.init();
845*8975f5c5SAndroid Build Coastguard Worker }
846*8975f5c5SAndroid Build Coastguard Worker 
onDestroy(const egl::Display * display)847*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::onDestroy(const egl::Display *display)
848*8975f5c5SAndroid Build Coastguard Worker {
849*8975f5c5SAndroid Build Coastguard Worker     if (!mHasBeenCurrent)
850*8975f5c5SAndroid Build Coastguard Worker     {
851*8975f5c5SAndroid Build Coastguard Worker         // Shared objects and ShareGroup must be released regardless.
852*8975f5c5SAndroid Build Coastguard Worker         releaseSharedObjects();
853*8975f5c5SAndroid Build Coastguard Worker         mState.mShareGroup->release(display);
854*8975f5c5SAndroid Build Coastguard Worker         // The context is never current, so default resources are not allocated.
855*8975f5c5SAndroid Build Coastguard Worker         return egl::NoError();
856*8975f5c5SAndroid Build Coastguard Worker     }
857*8975f5c5SAndroid Build Coastguard Worker 
858*8975f5c5SAndroid Build Coastguard Worker     mState.ensureNoPendingLink(this);
859*8975f5c5SAndroid Build Coastguard Worker 
860*8975f5c5SAndroid Build Coastguard Worker     // eglDestoryContext() must have been called for this Context and there must not be any Threads
861*8975f5c5SAndroid Build Coastguard Worker     // that still have it current.
862*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mIsDestroyed == true && mRefCount == 0);
863*8975f5c5SAndroid Build Coastguard Worker 
864*8975f5c5SAndroid Build Coastguard Worker     // Dump frame capture if enabled.
865*8975f5c5SAndroid Build Coastguard Worker     getShareGroup()->getFrameCaptureShared()->onDestroyContext(this);
866*8975f5c5SAndroid Build Coastguard Worker 
867*8975f5c5SAndroid Build Coastguard Worker     // Remove context from the capture share group
868*8975f5c5SAndroid Build Coastguard Worker     getShareGroup()->removeSharedContext(this);
869*8975f5c5SAndroid Build Coastguard Worker 
870*8975f5c5SAndroid Build Coastguard Worker     if (mGLES1Renderer)
871*8975f5c5SAndroid Build Coastguard Worker     {
872*8975f5c5SAndroid Build Coastguard Worker         mGLES1Renderer->onDestroy(this, &mState);
873*8975f5c5SAndroid Build Coastguard Worker     }
874*8975f5c5SAndroid Build Coastguard Worker 
875*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(unMakeCurrent(display));
876*8975f5c5SAndroid Build Coastguard Worker 
877*8975f5c5SAndroid Build Coastguard Worker     mDefaultFramebuffer->onDestroy(this);
878*8975f5c5SAndroid Build Coastguard Worker     mDefaultFramebuffer.reset();
879*8975f5c5SAndroid Build Coastguard Worker 
880*8975f5c5SAndroid Build Coastguard Worker     for (auto fence : UnsafeResourceMapIter(mFenceNVMap))
881*8975f5c5SAndroid Build Coastguard Worker     {
882*8975f5c5SAndroid Build Coastguard Worker         if (fence.second)
883*8975f5c5SAndroid Build Coastguard Worker         {
884*8975f5c5SAndroid Build Coastguard Worker             fence.second->onDestroy(this);
885*8975f5c5SAndroid Build Coastguard Worker         }
886*8975f5c5SAndroid Build Coastguard Worker         SafeDelete(fence.second);
887*8975f5c5SAndroid Build Coastguard Worker     }
888*8975f5c5SAndroid Build Coastguard Worker     mFenceNVMap.clear();
889*8975f5c5SAndroid Build Coastguard Worker 
890*8975f5c5SAndroid Build Coastguard Worker     for (auto query : UnsafeResourceMapIter(mQueryMap))
891*8975f5c5SAndroid Build Coastguard Worker     {
892*8975f5c5SAndroid Build Coastguard Worker         if (query.second != nullptr)
893*8975f5c5SAndroid Build Coastguard Worker         {
894*8975f5c5SAndroid Build Coastguard Worker             query.second->release(this);
895*8975f5c5SAndroid Build Coastguard Worker         }
896*8975f5c5SAndroid Build Coastguard Worker     }
897*8975f5c5SAndroid Build Coastguard Worker     mQueryMap.clear();
898*8975f5c5SAndroid Build Coastguard Worker 
899*8975f5c5SAndroid Build Coastguard Worker     for (auto vertexArray : UnsafeResourceMapIter(mVertexArrayMap))
900*8975f5c5SAndroid Build Coastguard Worker     {
901*8975f5c5SAndroid Build Coastguard Worker         if (vertexArray.second)
902*8975f5c5SAndroid Build Coastguard Worker         {
903*8975f5c5SAndroid Build Coastguard Worker             vertexArray.second->onDestroy(this);
904*8975f5c5SAndroid Build Coastguard Worker         }
905*8975f5c5SAndroid Build Coastguard Worker     }
906*8975f5c5SAndroid Build Coastguard Worker     mVertexArrayMap.clear();
907*8975f5c5SAndroid Build Coastguard Worker 
908*8975f5c5SAndroid Build Coastguard Worker     for (auto transformFeedback : UnsafeResourceMapIter(mTransformFeedbackMap))
909*8975f5c5SAndroid Build Coastguard Worker     {
910*8975f5c5SAndroid Build Coastguard Worker         if (transformFeedback.second != nullptr)
911*8975f5c5SAndroid Build Coastguard Worker         {
912*8975f5c5SAndroid Build Coastguard Worker             transformFeedback.second->release(this);
913*8975f5c5SAndroid Build Coastguard Worker         }
914*8975f5c5SAndroid Build Coastguard Worker     }
915*8975f5c5SAndroid Build Coastguard Worker     mTransformFeedbackMap.clear();
916*8975f5c5SAndroid Build Coastguard Worker 
917*8975f5c5SAndroid Build Coastguard Worker     for (BindingPointer<Texture> &zeroTexture : mZeroTextures)
918*8975f5c5SAndroid Build Coastguard Worker     {
919*8975f5c5SAndroid Build Coastguard Worker         if (zeroTexture.get() != nullptr)
920*8975f5c5SAndroid Build Coastguard Worker         {
921*8975f5c5SAndroid Build Coastguard Worker             zeroTexture.set(this, nullptr);
922*8975f5c5SAndroid Build Coastguard Worker         }
923*8975f5c5SAndroid Build Coastguard Worker     }
924*8975f5c5SAndroid Build Coastguard Worker 
925*8975f5c5SAndroid Build Coastguard Worker     releaseShaderCompiler();
926*8975f5c5SAndroid Build Coastguard Worker 
927*8975f5c5SAndroid Build Coastguard Worker     mState.reset(this);
928*8975f5c5SAndroid Build Coastguard Worker 
929*8975f5c5SAndroid Build Coastguard Worker     releaseSharedObjects();
930*8975f5c5SAndroid Build Coastguard Worker 
931*8975f5c5SAndroid Build Coastguard Worker     mImplementation->onDestroy(this);
932*8975f5c5SAndroid Build Coastguard Worker 
933*8975f5c5SAndroid Build Coastguard Worker     // Backend requires implementation to be destroyed first to close down all the objects
934*8975f5c5SAndroid Build Coastguard Worker     mState.mShareGroup->release(display);
935*8975f5c5SAndroid Build Coastguard Worker 
936*8975f5c5SAndroid Build Coastguard Worker     mOverlay.destroy(this);
937*8975f5c5SAndroid Build Coastguard Worker 
938*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
939*8975f5c5SAndroid Build Coastguard Worker }
940*8975f5c5SAndroid Build Coastguard Worker 
releaseSharedObjects()941*8975f5c5SAndroid Build Coastguard Worker void Context::releaseSharedObjects()
942*8975f5c5SAndroid Build Coastguard Worker {
943*8975f5c5SAndroid Build Coastguard Worker     mState.mBufferManager->release(this);
944*8975f5c5SAndroid Build Coastguard Worker     // mProgramPipelineManager must be before mShaderProgramManager to give each
945*8975f5c5SAndroid Build Coastguard Worker     // PPO the chance to release any references they have to the Programs that
946*8975f5c5SAndroid Build Coastguard Worker     // are bound to them before the Programs are released()'ed.
947*8975f5c5SAndroid Build Coastguard Worker     mState.mProgramPipelineManager->release(this);
948*8975f5c5SAndroid Build Coastguard Worker     mState.mShaderProgramManager->release(this);
949*8975f5c5SAndroid Build Coastguard Worker     mState.mTextureManager->release(this);
950*8975f5c5SAndroid Build Coastguard Worker     mState.mRenderbufferManager->release(this);
951*8975f5c5SAndroid Build Coastguard Worker     mState.mSamplerManager->release(this);
952*8975f5c5SAndroid Build Coastguard Worker     mState.mSyncManager->release(this);
953*8975f5c5SAndroid Build Coastguard Worker     mState.mFramebufferManager->release(this);
954*8975f5c5SAndroid Build Coastguard Worker     mState.mMemoryObjectManager->release(this);
955*8975f5c5SAndroid Build Coastguard Worker     mState.mSemaphoreManager->release(this);
956*8975f5c5SAndroid Build Coastguard Worker }
957*8975f5c5SAndroid Build Coastguard Worker 
~Context()958*8975f5c5SAndroid Build Coastguard Worker Context::~Context() {}
959*8975f5c5SAndroid Build Coastguard Worker 
setLabel(EGLLabelKHR label)960*8975f5c5SAndroid Build Coastguard Worker void Context::setLabel(EGLLabelKHR label)
961*8975f5c5SAndroid Build Coastguard Worker {
962*8975f5c5SAndroid Build Coastguard Worker     mLabel = label;
963*8975f5c5SAndroid Build Coastguard Worker }
964*8975f5c5SAndroid Build Coastguard Worker 
getLabel() const965*8975f5c5SAndroid Build Coastguard Worker EGLLabelKHR Context::getLabel() const
966*8975f5c5SAndroid Build Coastguard Worker {
967*8975f5c5SAndroid Build Coastguard Worker     return mLabel;
968*8975f5c5SAndroid Build Coastguard Worker }
969*8975f5c5SAndroid Build Coastguard Worker 
makeCurrent(egl::Display * display,egl::Surface * drawSurface,egl::Surface * readSurface)970*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::makeCurrent(egl::Display *display,
971*8975f5c5SAndroid Build Coastguard Worker                                 egl::Surface *drawSurface,
972*8975f5c5SAndroid Build Coastguard Worker                                 egl::Surface *readSurface)
973*8975f5c5SAndroid Build Coastguard Worker {
974*8975f5c5SAndroid Build Coastguard Worker     mDisplay = display;
975*8975f5c5SAndroid Build Coastguard Worker 
976*8975f5c5SAndroid Build Coastguard Worker     if (!mHasBeenCurrent)
977*8975f5c5SAndroid Build Coastguard Worker     {
978*8975f5c5SAndroid Build Coastguard Worker         initializeDefaultResources();
979*8975f5c5SAndroid Build Coastguard Worker         initRendererString();
980*8975f5c5SAndroid Build Coastguard Worker         initVendorString();
981*8975f5c5SAndroid Build Coastguard Worker         initVersionStrings();
982*8975f5c5SAndroid Build Coastguard Worker         initExtensionStrings();
983*8975f5c5SAndroid Build Coastguard Worker 
984*8975f5c5SAndroid Build Coastguard Worker         int width  = 0;
985*8975f5c5SAndroid Build Coastguard Worker         int height = 0;
986*8975f5c5SAndroid Build Coastguard Worker         if (drawSurface != nullptr)
987*8975f5c5SAndroid Build Coastguard Worker         {
988*8975f5c5SAndroid Build Coastguard Worker             width  = drawSurface->getWidth();
989*8975f5c5SAndroid Build Coastguard Worker             height = drawSurface->getHeight();
990*8975f5c5SAndroid Build Coastguard Worker         }
991*8975f5c5SAndroid Build Coastguard Worker 
992*8975f5c5SAndroid Build Coastguard Worker         ContextPrivateViewport(getMutablePrivateState(), getMutablePrivateStateCache(), 0, 0, width,
993*8975f5c5SAndroid Build Coastguard Worker                                height);
994*8975f5c5SAndroid Build Coastguard Worker         ContextPrivateScissor(getMutablePrivateState(), getMutablePrivateStateCache(), 0, 0, width,
995*8975f5c5SAndroid Build Coastguard Worker                               height);
996*8975f5c5SAndroid Build Coastguard Worker 
997*8975f5c5SAndroid Build Coastguard Worker         mHasBeenCurrent = true;
998*8975f5c5SAndroid Build Coastguard Worker     }
999*8975f5c5SAndroid Build Coastguard Worker 
1000*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(unsetDefaultFramebuffer());
1001*8975f5c5SAndroid Build Coastguard Worker 
1002*8975f5c5SAndroid Build Coastguard Worker     getShareGroup()->getFrameCaptureShared()->onMakeCurrent(this, drawSurface);
1003*8975f5c5SAndroid Build Coastguard Worker 
1004*8975f5c5SAndroid Build Coastguard Worker     // TODO(jmadill): Rework this when we support ContextImpl
1005*8975f5c5SAndroid Build Coastguard Worker     mState.setAllDirtyBits();
1006*8975f5c5SAndroid Build Coastguard Worker     mState.setAllDirtyObjects();
1007*8975f5c5SAndroid Build Coastguard Worker 
1008*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(setDefaultFramebuffer(drawSurface, readSurface));
1009*8975f5c5SAndroid Build Coastguard Worker 
1010*8975f5c5SAndroid Build Coastguard Worker     // Notify the renderer of a context switch.
1011*8975f5c5SAndroid Build Coastguard Worker     angle::Result implResult = mImplementation->onMakeCurrent(this);
1012*8975f5c5SAndroid Build Coastguard Worker 
1013*8975f5c5SAndroid Build Coastguard Worker     // If the implementation fails onMakeCurrent, unset the default framebuffer.
1014*8975f5c5SAndroid Build Coastguard Worker     if (implResult != angle::Result::Continue)
1015*8975f5c5SAndroid Build Coastguard Worker     {
1016*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(unsetDefaultFramebuffer());
1017*8975f5c5SAndroid Build Coastguard Worker         return angle::ResultToEGL(implResult);
1018*8975f5c5SAndroid Build Coastguard Worker     }
1019*8975f5c5SAndroid Build Coastguard Worker 
1020*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
1021*8975f5c5SAndroid Build Coastguard Worker }
1022*8975f5c5SAndroid Build Coastguard Worker 
unMakeCurrent(const egl::Display * display)1023*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::unMakeCurrent(const egl::Display *display)
1024*8975f5c5SAndroid Build Coastguard Worker {
1025*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(angle::ResultToEGL(mImplementation->onUnMakeCurrent(this)));
1026*8975f5c5SAndroid Build Coastguard Worker 
1027*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(unsetDefaultFramebuffer());
1028*8975f5c5SAndroid Build Coastguard Worker 
1029*8975f5c5SAndroid Build Coastguard Worker     // Return the scratch buffers to the display so they can be shared with other contexts while
1030*8975f5c5SAndroid Build Coastguard Worker     // this one is not current.
1031*8975f5c5SAndroid Build Coastguard Worker     if (mScratchBuffer.valid())
1032*8975f5c5SAndroid Build Coastguard Worker     {
1033*8975f5c5SAndroid Build Coastguard Worker         mDisplay->returnScratchBuffer(mScratchBuffer.release());
1034*8975f5c5SAndroid Build Coastguard Worker     }
1035*8975f5c5SAndroid Build Coastguard Worker     if (mZeroFilledBuffer.valid())
1036*8975f5c5SAndroid Build Coastguard Worker     {
1037*8975f5c5SAndroid Build Coastguard Worker         mDisplay->returnZeroFilledBuffer(mZeroFilledBuffer.release());
1038*8975f5c5SAndroid Build Coastguard Worker     }
1039*8975f5c5SAndroid Build Coastguard Worker 
1040*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
1041*8975f5c5SAndroid Build Coastguard Worker }
1042*8975f5c5SAndroid Build Coastguard Worker 
createBuffer()1043*8975f5c5SAndroid Build Coastguard Worker BufferID Context::createBuffer()
1044*8975f5c5SAndroid Build Coastguard Worker {
1045*8975f5c5SAndroid Build Coastguard Worker     return mState.mBufferManager->createBuffer();
1046*8975f5c5SAndroid Build Coastguard Worker }
1047*8975f5c5SAndroid Build Coastguard Worker 
createProgram()1048*8975f5c5SAndroid Build Coastguard Worker GLuint Context::createProgram()
1049*8975f5c5SAndroid Build Coastguard Worker {
1050*8975f5c5SAndroid Build Coastguard Worker     return mState.mShaderProgramManager->createProgram(mImplementation.get()).value;
1051*8975f5c5SAndroid Build Coastguard Worker }
1052*8975f5c5SAndroid Build Coastguard Worker 
createShader(ShaderType type)1053*8975f5c5SAndroid Build Coastguard Worker GLuint Context::createShader(ShaderType type)
1054*8975f5c5SAndroid Build Coastguard Worker {
1055*8975f5c5SAndroid Build Coastguard Worker     return mState.mShaderProgramManager
1056*8975f5c5SAndroid Build Coastguard Worker         ->createShader(mImplementation.get(), mState.getLimitations(), type)
1057*8975f5c5SAndroid Build Coastguard Worker         .value;
1058*8975f5c5SAndroid Build Coastguard Worker }
1059*8975f5c5SAndroid Build Coastguard Worker 
createTexture()1060*8975f5c5SAndroid Build Coastguard Worker TextureID Context::createTexture()
1061*8975f5c5SAndroid Build Coastguard Worker {
1062*8975f5c5SAndroid Build Coastguard Worker     return mState.mTextureManager->createTexture();
1063*8975f5c5SAndroid Build Coastguard Worker }
1064*8975f5c5SAndroid Build Coastguard Worker 
createRenderbuffer()1065*8975f5c5SAndroid Build Coastguard Worker RenderbufferID Context::createRenderbuffer()
1066*8975f5c5SAndroid Build Coastguard Worker {
1067*8975f5c5SAndroid Build Coastguard Worker     return mState.mRenderbufferManager->createRenderbuffer();
1068*8975f5c5SAndroid Build Coastguard Worker }
1069*8975f5c5SAndroid Build Coastguard Worker 
1070*8975f5c5SAndroid Build Coastguard Worker // Returns an unused framebuffer name
createFramebuffer()1071*8975f5c5SAndroid Build Coastguard Worker FramebufferID Context::createFramebuffer()
1072*8975f5c5SAndroid Build Coastguard Worker {
1073*8975f5c5SAndroid Build Coastguard Worker     return mState.mFramebufferManager->createFramebuffer();
1074*8975f5c5SAndroid Build Coastguard Worker }
1075*8975f5c5SAndroid Build Coastguard Worker 
genFencesNV(GLsizei n,FenceNVID * fences)1076*8975f5c5SAndroid Build Coastguard Worker void Context::genFencesNV(GLsizei n, FenceNVID *fences)
1077*8975f5c5SAndroid Build Coastguard Worker {
1078*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
1079*8975f5c5SAndroid Build Coastguard Worker     {
1080*8975f5c5SAndroid Build Coastguard Worker         GLuint handle = mFenceNVHandleAllocator.allocate();
1081*8975f5c5SAndroid Build Coastguard Worker         mFenceNVMap.assign({handle}, new FenceNV(mImplementation.get()));
1082*8975f5c5SAndroid Build Coastguard Worker         fences[i] = {handle};
1083*8975f5c5SAndroid Build Coastguard Worker     }
1084*8975f5c5SAndroid Build Coastguard Worker }
1085*8975f5c5SAndroid Build Coastguard Worker 
createProgramPipeline()1086*8975f5c5SAndroid Build Coastguard Worker ProgramPipelineID Context::createProgramPipeline()
1087*8975f5c5SAndroid Build Coastguard Worker {
1088*8975f5c5SAndroid Build Coastguard Worker     return mState.mProgramPipelineManager->createProgramPipeline();
1089*8975f5c5SAndroid Build Coastguard Worker }
1090*8975f5c5SAndroid Build Coastguard Worker 
createShaderProgramv(ShaderType type,GLsizei count,const GLchar * const * strings)1091*8975f5c5SAndroid Build Coastguard Worker GLuint Context::createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings)
1092*8975f5c5SAndroid Build Coastguard Worker {
1093*8975f5c5SAndroid Build Coastguard Worker     const ShaderProgramID shaderID = PackParam<ShaderProgramID>(createShader(type));
1094*8975f5c5SAndroid Build Coastguard Worker     if (shaderID.value)
1095*8975f5c5SAndroid Build Coastguard Worker     {
1096*8975f5c5SAndroid Build Coastguard Worker         Shader *shaderObject = getShaderNoResolveCompile(shaderID);
1097*8975f5c5SAndroid Build Coastguard Worker         ASSERT(shaderObject);
1098*8975f5c5SAndroid Build Coastguard Worker         shaderObject->setSource(this, count, strings, nullptr);
1099*8975f5c5SAndroid Build Coastguard Worker         shaderObject->compile(this, angle::JobResultExpectancy::Immediate);
1100*8975f5c5SAndroid Build Coastguard Worker         const ShaderProgramID programID = PackParam<ShaderProgramID>(createProgram());
1101*8975f5c5SAndroid Build Coastguard Worker         if (programID.value)
1102*8975f5c5SAndroid Build Coastguard Worker         {
1103*8975f5c5SAndroid Build Coastguard Worker             gl::Program *programObject = getProgramNoResolveLink(programID);
1104*8975f5c5SAndroid Build Coastguard Worker             ASSERT(programObject);
1105*8975f5c5SAndroid Build Coastguard Worker 
1106*8975f5c5SAndroid Build Coastguard Worker             // Note: this call serializes the compilation with the following link.  For backends
1107*8975f5c5SAndroid Build Coastguard Worker             // that prefer parallel compile and link, it's more efficient to remove this check, and
1108*8975f5c5SAndroid Build Coastguard Worker             // let link fail instead.
1109*8975f5c5SAndroid Build Coastguard Worker             if (shaderObject->isCompiled(this))
1110*8975f5c5SAndroid Build Coastguard Worker             {
1111*8975f5c5SAndroid Build Coastguard Worker                 // As per Khronos issue 2261:
1112*8975f5c5SAndroid Build Coastguard Worker                 // https://gitlab.khronos.org/Tracker/vk-gl-cts/issues/2261
1113*8975f5c5SAndroid Build Coastguard Worker                 // We must wait to mark the program separable until it's successfully compiled.
1114*8975f5c5SAndroid Build Coastguard Worker                 programObject->setSeparable(this, true);
1115*8975f5c5SAndroid Build Coastguard Worker 
1116*8975f5c5SAndroid Build Coastguard Worker                 programObject->attachShader(this, shaderObject);
1117*8975f5c5SAndroid Build Coastguard Worker 
1118*8975f5c5SAndroid Build Coastguard Worker                 // Note: the result expectancy of this link could be turned to Future if
1119*8975f5c5SAndroid Build Coastguard Worker                 // |detachShader| below is made not to resolve the link.
1120*8975f5c5SAndroid Build Coastguard Worker                 if (programObject->link(this, angle::JobResultExpectancy::Immediate) !=
1121*8975f5c5SAndroid Build Coastguard Worker                     angle::Result::Continue)
1122*8975f5c5SAndroid Build Coastguard Worker                 {
1123*8975f5c5SAndroid Build Coastguard Worker                     deleteShader(shaderID);
1124*8975f5c5SAndroid Build Coastguard Worker                     deleteProgram(programID);
1125*8975f5c5SAndroid Build Coastguard Worker                     return 0u;
1126*8975f5c5SAndroid Build Coastguard Worker                 }
1127*8975f5c5SAndroid Build Coastguard Worker 
1128*8975f5c5SAndroid Build Coastguard Worker                 programObject->detachShader(this, shaderObject);
1129*8975f5c5SAndroid Build Coastguard Worker             }
1130*8975f5c5SAndroid Build Coastguard Worker 
1131*8975f5c5SAndroid Build Coastguard Worker             InfoLog &programInfoLog = programObject->getInfoLog();
1132*8975f5c5SAndroid Build Coastguard Worker             programInfoLog << shaderObject->getInfoLogString();
1133*8975f5c5SAndroid Build Coastguard Worker         }
1134*8975f5c5SAndroid Build Coastguard Worker 
1135*8975f5c5SAndroid Build Coastguard Worker         deleteShader(shaderID);
1136*8975f5c5SAndroid Build Coastguard Worker 
1137*8975f5c5SAndroid Build Coastguard Worker         return programID.value;
1138*8975f5c5SAndroid Build Coastguard Worker     }
1139*8975f5c5SAndroid Build Coastguard Worker 
1140*8975f5c5SAndroid Build Coastguard Worker     return 0u;
1141*8975f5c5SAndroid Build Coastguard Worker }
1142*8975f5c5SAndroid Build Coastguard Worker 
createMemoryObject()1143*8975f5c5SAndroid Build Coastguard Worker MemoryObjectID Context::createMemoryObject()
1144*8975f5c5SAndroid Build Coastguard Worker {
1145*8975f5c5SAndroid Build Coastguard Worker     return mState.mMemoryObjectManager->createMemoryObject(mImplementation.get());
1146*8975f5c5SAndroid Build Coastguard Worker }
1147*8975f5c5SAndroid Build Coastguard Worker 
createSemaphore()1148*8975f5c5SAndroid Build Coastguard Worker SemaphoreID Context::createSemaphore()
1149*8975f5c5SAndroid Build Coastguard Worker {
1150*8975f5c5SAndroid Build Coastguard Worker     return mState.mSemaphoreManager->createSemaphore(mImplementation.get());
1151*8975f5c5SAndroid Build Coastguard Worker }
1152*8975f5c5SAndroid Build Coastguard Worker 
deleteBuffer(BufferID bufferName)1153*8975f5c5SAndroid Build Coastguard Worker void Context::deleteBuffer(BufferID bufferName)
1154*8975f5c5SAndroid Build Coastguard Worker {
1155*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.mBufferManager->getBuffer(bufferName);
1156*8975f5c5SAndroid Build Coastguard Worker     if (buffer)
1157*8975f5c5SAndroid Build Coastguard Worker     {
1158*8975f5c5SAndroid Build Coastguard Worker         detachBuffer(buffer);
1159*8975f5c5SAndroid Build Coastguard Worker     }
1160*8975f5c5SAndroid Build Coastguard Worker 
1161*8975f5c5SAndroid Build Coastguard Worker     mState.mBufferManager->deleteObject(this, bufferName);
1162*8975f5c5SAndroid Build Coastguard Worker }
1163*8975f5c5SAndroid Build Coastguard Worker 
deleteShader(ShaderProgramID shader)1164*8975f5c5SAndroid Build Coastguard Worker void Context::deleteShader(ShaderProgramID shader)
1165*8975f5c5SAndroid Build Coastguard Worker {
1166*8975f5c5SAndroid Build Coastguard Worker     mState.mShaderProgramManager->deleteShader(this, shader);
1167*8975f5c5SAndroid Build Coastguard Worker }
1168*8975f5c5SAndroid Build Coastguard Worker 
deleteProgram(ShaderProgramID program)1169*8975f5c5SAndroid Build Coastguard Worker void Context::deleteProgram(ShaderProgramID program)
1170*8975f5c5SAndroid Build Coastguard Worker {
1171*8975f5c5SAndroid Build Coastguard Worker     mState.mShaderProgramManager->deleteProgram(this, program);
1172*8975f5c5SAndroid Build Coastguard Worker }
1173*8975f5c5SAndroid Build Coastguard Worker 
deleteTexture(TextureID textureID)1174*8975f5c5SAndroid Build Coastguard Worker void Context::deleteTexture(TextureID textureID)
1175*8975f5c5SAndroid Build Coastguard Worker {
1176*8975f5c5SAndroid Build Coastguard Worker     // If a texture object is deleted while its image is bound to a pixel local storage plane on the
1177*8975f5c5SAndroid Build Coastguard Worker     // currently bound draw framebuffer, and pixel local storage is active, then it is as if
1178*8975f5c5SAndroid Build Coastguard Worker     // EndPixelLocalStorageANGLE() had been called with <n>=PIXEL_LOCAL_STORAGE_ACTIVE_PLANES_ANGLE
1179*8975f5c5SAndroid Build Coastguard Worker     // and <storeops> of STORE_OP_STORE_ANGLE.
1180*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0)
1181*8975f5c5SAndroid Build Coastguard Worker     {
1182*8975f5c5SAndroid Build Coastguard Worker         PixelLocalStorage *pls = mState.getDrawFramebuffer()->peekPixelLocalStorage();
1183*8975f5c5SAndroid Build Coastguard Worker         // Even though there is a nonzero number of active PLS planes, peekPixelLocalStorage() may
1184*8975f5c5SAndroid Build Coastguard Worker         // still return null if we are in the middle of deleting the active framebuffer.
1185*8975f5c5SAndroid Build Coastguard Worker         if (pls != nullptr)
1186*8975f5c5SAndroid Build Coastguard Worker         {
1187*8975f5c5SAndroid Build Coastguard Worker             for (GLuint i = 0; i < mState.getCaps().maxPixelLocalStoragePlanes; ++i)
1188*8975f5c5SAndroid Build Coastguard Worker             {
1189*8975f5c5SAndroid Build Coastguard Worker                 if (pls->getPlane(i).getTextureID() == textureID)
1190*8975f5c5SAndroid Build Coastguard Worker                 {
1191*8975f5c5SAndroid Build Coastguard Worker                     endPixelLocalStorageImplicit();
1192*8975f5c5SAndroid Build Coastguard Worker                     break;
1193*8975f5c5SAndroid Build Coastguard Worker                 }
1194*8975f5c5SAndroid Build Coastguard Worker             }
1195*8975f5c5SAndroid Build Coastguard Worker         }
1196*8975f5c5SAndroid Build Coastguard Worker     }
1197*8975f5c5SAndroid Build Coastguard Worker 
1198*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = mState.mTextureManager->getTexture(textureID);
1199*8975f5c5SAndroid Build Coastguard Worker     if (texture != nullptr)
1200*8975f5c5SAndroid Build Coastguard Worker     {
1201*8975f5c5SAndroid Build Coastguard Worker         texture->onStateChange(angle::SubjectMessage::TextureIDDeleted);
1202*8975f5c5SAndroid Build Coastguard Worker         detachTexture(textureID);
1203*8975f5c5SAndroid Build Coastguard Worker     }
1204*8975f5c5SAndroid Build Coastguard Worker 
1205*8975f5c5SAndroid Build Coastguard Worker     mState.mTextureManager->deleteObject(this, textureID);
1206*8975f5c5SAndroid Build Coastguard Worker }
1207*8975f5c5SAndroid Build Coastguard Worker 
deleteRenderbuffer(RenderbufferID renderbuffer)1208*8975f5c5SAndroid Build Coastguard Worker void Context::deleteRenderbuffer(RenderbufferID renderbuffer)
1209*8975f5c5SAndroid Build Coastguard Worker {
1210*8975f5c5SAndroid Build Coastguard Worker     if (mState.mRenderbufferManager->getRenderbuffer(renderbuffer))
1211*8975f5c5SAndroid Build Coastguard Worker     {
1212*8975f5c5SAndroid Build Coastguard Worker         detachRenderbuffer(renderbuffer);
1213*8975f5c5SAndroid Build Coastguard Worker     }
1214*8975f5c5SAndroid Build Coastguard Worker 
1215*8975f5c5SAndroid Build Coastguard Worker     mState.mRenderbufferManager->deleteObject(this, renderbuffer);
1216*8975f5c5SAndroid Build Coastguard Worker }
1217*8975f5c5SAndroid Build Coastguard Worker 
deleteSync(SyncID syncPacked)1218*8975f5c5SAndroid Build Coastguard Worker void Context::deleteSync(SyncID syncPacked)
1219*8975f5c5SAndroid Build Coastguard Worker {
1220*8975f5c5SAndroid Build Coastguard Worker     // The spec specifies the underlying Fence object is not deleted until all current
1221*8975f5c5SAndroid Build Coastguard Worker     // wait commands finish. However, since the name becomes invalid, we cannot query the fence,
1222*8975f5c5SAndroid Build Coastguard Worker     // and since our API is currently designed for being called from a single thread, we can delete
1223*8975f5c5SAndroid Build Coastguard Worker     // the fence immediately.
1224*8975f5c5SAndroid Build Coastguard Worker     mState.mSyncManager->deleteObject(this, syncPacked);
1225*8975f5c5SAndroid Build Coastguard Worker }
1226*8975f5c5SAndroid Build Coastguard Worker 
deleteProgramPipeline(ProgramPipelineID pipelineID)1227*8975f5c5SAndroid Build Coastguard Worker void Context::deleteProgramPipeline(ProgramPipelineID pipelineID)
1228*8975f5c5SAndroid Build Coastguard Worker {
1229*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *pipeline = mState.mProgramPipelineManager->getProgramPipeline(pipelineID);
1230*8975f5c5SAndroid Build Coastguard Worker     if (pipeline)
1231*8975f5c5SAndroid Build Coastguard Worker     {
1232*8975f5c5SAndroid Build Coastguard Worker         detachProgramPipeline(pipelineID);
1233*8975f5c5SAndroid Build Coastguard Worker     }
1234*8975f5c5SAndroid Build Coastguard Worker 
1235*8975f5c5SAndroid Build Coastguard Worker     mState.mProgramPipelineManager->deleteObject(this, pipelineID);
1236*8975f5c5SAndroid Build Coastguard Worker }
1237*8975f5c5SAndroid Build Coastguard Worker 
deleteMemoryObject(MemoryObjectID memoryObject)1238*8975f5c5SAndroid Build Coastguard Worker void Context::deleteMemoryObject(MemoryObjectID memoryObject)
1239*8975f5c5SAndroid Build Coastguard Worker {
1240*8975f5c5SAndroid Build Coastguard Worker     mState.mMemoryObjectManager->deleteMemoryObject(this, memoryObject);
1241*8975f5c5SAndroid Build Coastguard Worker }
1242*8975f5c5SAndroid Build Coastguard Worker 
deleteSemaphore(SemaphoreID semaphore)1243*8975f5c5SAndroid Build Coastguard Worker void Context::deleteSemaphore(SemaphoreID semaphore)
1244*8975f5c5SAndroid Build Coastguard Worker {
1245*8975f5c5SAndroid Build Coastguard Worker     mState.mSemaphoreManager->deleteSemaphore(this, semaphore);
1246*8975f5c5SAndroid Build Coastguard Worker }
1247*8975f5c5SAndroid Build Coastguard Worker 
1248*8975f5c5SAndroid Build Coastguard Worker // GL_CHROMIUM_lose_context
loseContext(GraphicsResetStatus current,GraphicsResetStatus other)1249*8975f5c5SAndroid Build Coastguard Worker void Context::loseContext(GraphicsResetStatus current, GraphicsResetStatus other)
1250*8975f5c5SAndroid Build Coastguard Worker {
1251*8975f5c5SAndroid Build Coastguard Worker     // TODO(geofflang): mark the rest of the share group lost. Requires access to the entire share
1252*8975f5c5SAndroid Build Coastguard Worker     // group from a context. http://anglebug.com/42262046
1253*8975f5c5SAndroid Build Coastguard Worker     markContextLost(current);
1254*8975f5c5SAndroid Build Coastguard Worker }
1255*8975f5c5SAndroid Build Coastguard Worker 
deleteFramebuffer(FramebufferID framebufferID)1256*8975f5c5SAndroid Build Coastguard Worker void Context::deleteFramebuffer(FramebufferID framebufferID)
1257*8975f5c5SAndroid Build Coastguard Worker {
1258*8975f5c5SAndroid Build Coastguard Worker     // We are responsible for deleting the GL objects from the Framebuffer's pixel local storage.
1259*8975f5c5SAndroid Build Coastguard Worker     std::unique_ptr<PixelLocalStorage> plsToDelete;
1260*8975f5c5SAndroid Build Coastguard Worker 
1261*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.mFramebufferManager->getFramebuffer(framebufferID);
1262*8975f5c5SAndroid Build Coastguard Worker     if (framebuffer != nullptr)
1263*8975f5c5SAndroid Build Coastguard Worker     {
1264*8975f5c5SAndroid Build Coastguard Worker         if (mState.getPixelLocalStorageActivePlanes() != 0 &&
1265*8975f5c5SAndroid Build Coastguard Worker             framebuffer == mState.getDrawFramebuffer())
1266*8975f5c5SAndroid Build Coastguard Worker         {
1267*8975f5c5SAndroid Build Coastguard Worker             endPixelLocalStorageImplicit();
1268*8975f5c5SAndroid Build Coastguard Worker         }
1269*8975f5c5SAndroid Build Coastguard Worker         plsToDelete = framebuffer->detachPixelLocalStorage();
1270*8975f5c5SAndroid Build Coastguard Worker         detachFramebuffer(framebufferID);
1271*8975f5c5SAndroid Build Coastguard Worker     }
1272*8975f5c5SAndroid Build Coastguard Worker 
1273*8975f5c5SAndroid Build Coastguard Worker     mState.mFramebufferManager->deleteObject(this, framebufferID);
1274*8975f5c5SAndroid Build Coastguard Worker 
1275*8975f5c5SAndroid Build Coastguard Worker     // Delete the pixel local storage GL objects after the framebuffer, in order to avoid any
1276*8975f5c5SAndroid Build Coastguard Worker     // potential trickyness with orphaning.
1277*8975f5c5SAndroid Build Coastguard Worker     if (plsToDelete != nullptr)
1278*8975f5c5SAndroid Build Coastguard Worker     {
1279*8975f5c5SAndroid Build Coastguard Worker         plsToDelete->deleteContextObjects(this);
1280*8975f5c5SAndroid Build Coastguard Worker     }
1281*8975f5c5SAndroid Build Coastguard Worker }
1282*8975f5c5SAndroid Build Coastguard Worker 
deleteFencesNV(GLsizei n,const FenceNVID * fences)1283*8975f5c5SAndroid Build Coastguard Worker void Context::deleteFencesNV(GLsizei n, const FenceNVID *fences)
1284*8975f5c5SAndroid Build Coastguard Worker {
1285*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
1286*8975f5c5SAndroid Build Coastguard Worker     {
1287*8975f5c5SAndroid Build Coastguard Worker         FenceNVID fence = fences[i];
1288*8975f5c5SAndroid Build Coastguard Worker 
1289*8975f5c5SAndroid Build Coastguard Worker         FenceNV *fenceObject = nullptr;
1290*8975f5c5SAndroid Build Coastguard Worker         if (mFenceNVMap.erase(fence, &fenceObject))
1291*8975f5c5SAndroid Build Coastguard Worker         {
1292*8975f5c5SAndroid Build Coastguard Worker             mFenceNVHandleAllocator.release(fence.value);
1293*8975f5c5SAndroid Build Coastguard Worker             if (fenceObject)
1294*8975f5c5SAndroid Build Coastguard Worker             {
1295*8975f5c5SAndroid Build Coastguard Worker                 fenceObject->onDestroy(this);
1296*8975f5c5SAndroid Build Coastguard Worker             }
1297*8975f5c5SAndroid Build Coastguard Worker             delete fenceObject;
1298*8975f5c5SAndroid Build Coastguard Worker         }
1299*8975f5c5SAndroid Build Coastguard Worker     }
1300*8975f5c5SAndroid Build Coastguard Worker }
1301*8975f5c5SAndroid Build Coastguard Worker 
getBuffer(BufferID handle) const1302*8975f5c5SAndroid Build Coastguard Worker Buffer *Context::getBuffer(BufferID handle) const
1303*8975f5c5SAndroid Build Coastguard Worker {
1304*8975f5c5SAndroid Build Coastguard Worker     return mState.mBufferManager->getBuffer(handle);
1305*8975f5c5SAndroid Build Coastguard Worker }
1306*8975f5c5SAndroid Build Coastguard Worker 
getRenderbuffer(RenderbufferID handle) const1307*8975f5c5SAndroid Build Coastguard Worker Renderbuffer *Context::getRenderbuffer(RenderbufferID handle) const
1308*8975f5c5SAndroid Build Coastguard Worker {
1309*8975f5c5SAndroid Build Coastguard Worker     return mState.mRenderbufferManager->getRenderbuffer(handle);
1310*8975f5c5SAndroid Build Coastguard Worker }
1311*8975f5c5SAndroid Build Coastguard Worker 
getContextPriority() const1312*8975f5c5SAndroid Build Coastguard Worker EGLenum Context::getContextPriority() const
1313*8975f5c5SAndroid Build Coastguard Worker {
1314*8975f5c5SAndroid Build Coastguard Worker     return egl::ToEGLenum(mImplementation->getContextPriority());
1315*8975f5c5SAndroid Build Coastguard Worker }
1316*8975f5c5SAndroid Build Coastguard Worker 
getSync(SyncID syncPacked) const1317*8975f5c5SAndroid Build Coastguard Worker Sync *Context::getSync(SyncID syncPacked) const
1318*8975f5c5SAndroid Build Coastguard Worker {
1319*8975f5c5SAndroid Build Coastguard Worker     return mState.mSyncManager->getSync(syncPacked);
1320*8975f5c5SAndroid Build Coastguard Worker }
1321*8975f5c5SAndroid Build Coastguard Worker 
getVertexArray(VertexArrayID handle) const1322*8975f5c5SAndroid Build Coastguard Worker VertexArray *Context::getVertexArray(VertexArrayID handle) const
1323*8975f5c5SAndroid Build Coastguard Worker {
1324*8975f5c5SAndroid Build Coastguard Worker     return mVertexArrayMap.query(handle);
1325*8975f5c5SAndroid Build Coastguard Worker }
1326*8975f5c5SAndroid Build Coastguard Worker 
getSampler(SamplerID handle) const1327*8975f5c5SAndroid Build Coastguard Worker Sampler *Context::getSampler(SamplerID handle) const
1328*8975f5c5SAndroid Build Coastguard Worker {
1329*8975f5c5SAndroid Build Coastguard Worker     return mState.mSamplerManager->getSampler(handle);
1330*8975f5c5SAndroid Build Coastguard Worker }
1331*8975f5c5SAndroid Build Coastguard Worker 
getTransformFeedback(TransformFeedbackID handle) const1332*8975f5c5SAndroid Build Coastguard Worker TransformFeedback *Context::getTransformFeedback(TransformFeedbackID handle) const
1333*8975f5c5SAndroid Build Coastguard Worker {
1334*8975f5c5SAndroid Build Coastguard Worker     return mTransformFeedbackMap.query(handle);
1335*8975f5c5SAndroid Build Coastguard Worker }
1336*8975f5c5SAndroid Build Coastguard Worker 
getProgramPipeline(ProgramPipelineID handle) const1337*8975f5c5SAndroid Build Coastguard Worker ProgramPipeline *Context::getProgramPipeline(ProgramPipelineID handle) const
1338*8975f5c5SAndroid Build Coastguard Worker {
1339*8975f5c5SAndroid Build Coastguard Worker     return mState.mProgramPipelineManager->getProgramPipeline(handle);
1340*8975f5c5SAndroid Build Coastguard Worker }
1341*8975f5c5SAndroid Build Coastguard Worker 
getLabeledObject(GLenum identifier,GLuint name) const1342*8975f5c5SAndroid Build Coastguard Worker gl::LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const
1343*8975f5c5SAndroid Build Coastguard Worker {
1344*8975f5c5SAndroid Build Coastguard Worker     switch (identifier)
1345*8975f5c5SAndroid Build Coastguard Worker     {
1346*8975f5c5SAndroid Build Coastguard Worker         case GL_BUFFER:
1347*8975f5c5SAndroid Build Coastguard Worker         case GL_BUFFER_OBJECT_EXT:
1348*8975f5c5SAndroid Build Coastguard Worker             return getBuffer({name});
1349*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADER:
1350*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADER_OBJECT_EXT:
1351*8975f5c5SAndroid Build Coastguard Worker             return getShaderNoResolveCompile({name});
1352*8975f5c5SAndroid Build Coastguard Worker         case GL_PROGRAM:
1353*8975f5c5SAndroid Build Coastguard Worker         case GL_PROGRAM_OBJECT_EXT:
1354*8975f5c5SAndroid Build Coastguard Worker             return getProgramNoResolveLink({name});
1355*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY:
1356*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY_OBJECT_EXT:
1357*8975f5c5SAndroid Build Coastguard Worker             return getVertexArray({name});
1358*8975f5c5SAndroid Build Coastguard Worker         case GL_QUERY:
1359*8975f5c5SAndroid Build Coastguard Worker         case GL_QUERY_OBJECT_EXT:
1360*8975f5c5SAndroid Build Coastguard Worker             return getQuery({name});
1361*8975f5c5SAndroid Build Coastguard Worker         case GL_TRANSFORM_FEEDBACK:
1362*8975f5c5SAndroid Build Coastguard Worker             return getTransformFeedback({name});
1363*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLER:
1364*8975f5c5SAndroid Build Coastguard Worker             return getSampler({name});
1365*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE:
1366*8975f5c5SAndroid Build Coastguard Worker             return getTexture({name});
1367*8975f5c5SAndroid Build Coastguard Worker         case GL_RENDERBUFFER:
1368*8975f5c5SAndroid Build Coastguard Worker             return getRenderbuffer({name});
1369*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAMEBUFFER:
1370*8975f5c5SAndroid Build Coastguard Worker             return getFramebuffer({name});
1371*8975f5c5SAndroid Build Coastguard Worker         case GL_PROGRAM_PIPELINE:
1372*8975f5c5SAndroid Build Coastguard Worker         case GL_PROGRAM_PIPELINE_OBJECT_EXT:
1373*8975f5c5SAndroid Build Coastguard Worker             return getProgramPipeline({name});
1374*8975f5c5SAndroid Build Coastguard Worker         default:
1375*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
1376*8975f5c5SAndroid Build Coastguard Worker             return nullptr;
1377*8975f5c5SAndroid Build Coastguard Worker     }
1378*8975f5c5SAndroid Build Coastguard Worker }
1379*8975f5c5SAndroid Build Coastguard Worker 
getLabeledObjectFromPtr(const void * ptr) const1380*8975f5c5SAndroid Build Coastguard Worker gl::LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const
1381*8975f5c5SAndroid Build Coastguard Worker {
1382*8975f5c5SAndroid Build Coastguard Worker     return getSync({unsafe_pointer_to_int_cast<uint32_t>(ptr)});
1383*8975f5c5SAndroid Build Coastguard Worker }
1384*8975f5c5SAndroid Build Coastguard Worker 
objectLabel(GLenum identifier,GLuint name,GLsizei length,const GLchar * label)1385*8975f5c5SAndroid Build Coastguard Worker void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label)
1386*8975f5c5SAndroid Build Coastguard Worker {
1387*8975f5c5SAndroid Build Coastguard Worker     gl::LabeledObject *object = getLabeledObject(identifier, name);
1388*8975f5c5SAndroid Build Coastguard Worker     ASSERT(object != nullptr);
1389*8975f5c5SAndroid Build Coastguard Worker 
1390*8975f5c5SAndroid Build Coastguard Worker     std::string labelName = GetObjectLabelFromPointer(length, label);
1391*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(object->setLabel(this, labelName));
1392*8975f5c5SAndroid Build Coastguard Worker 
1393*8975f5c5SAndroid Build Coastguard Worker     // TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the
1394*8975f5c5SAndroid Build Coastguard Worker     // specified object is active until we do this.
1395*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(identifier);
1396*8975f5c5SAndroid Build Coastguard Worker }
1397*8975f5c5SAndroid Build Coastguard Worker 
labelObject(GLenum type,GLuint object,GLsizei length,const GLchar * label)1398*8975f5c5SAndroid Build Coastguard Worker void Context::labelObject(GLenum type, GLuint object, GLsizei length, const GLchar *label)
1399*8975f5c5SAndroid Build Coastguard Worker {
1400*8975f5c5SAndroid Build Coastguard Worker     gl::LabeledObject *obj = getLabeledObject(type, object);
1401*8975f5c5SAndroid Build Coastguard Worker     ASSERT(obj != nullptr);
1402*8975f5c5SAndroid Build Coastguard Worker 
1403*8975f5c5SAndroid Build Coastguard Worker     std::string labelName = "";
1404*8975f5c5SAndroid Build Coastguard Worker     if (label != nullptr)
1405*8975f5c5SAndroid Build Coastguard Worker     {
1406*8975f5c5SAndroid Build Coastguard Worker         size_t labelLength = length == 0 ? strlen(label) : length;
1407*8975f5c5SAndroid Build Coastguard Worker         labelName          = std::string(label, labelLength);
1408*8975f5c5SAndroid Build Coastguard Worker     }
1409*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(obj->setLabel(this, labelName));
1410*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(type);
1411*8975f5c5SAndroid Build Coastguard Worker }
1412*8975f5c5SAndroid Build Coastguard Worker 
objectPtrLabel(const void * ptr,GLsizei length,const GLchar * label)1413*8975f5c5SAndroid Build Coastguard Worker void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label)
1414*8975f5c5SAndroid Build Coastguard Worker {
1415*8975f5c5SAndroid Build Coastguard Worker     gl::LabeledObject *object = getLabeledObjectFromPtr(ptr);
1416*8975f5c5SAndroid Build Coastguard Worker     ASSERT(object != nullptr);
1417*8975f5c5SAndroid Build Coastguard Worker 
1418*8975f5c5SAndroid Build Coastguard Worker     std::string labelName = GetObjectLabelFromPointer(length, label);
1419*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(object->setLabel(this, labelName));
1420*8975f5c5SAndroid Build Coastguard Worker }
1421*8975f5c5SAndroid Build Coastguard Worker 
getObjectLabel(GLenum identifier,GLuint name,GLsizei bufSize,GLsizei * length,GLchar * label)1422*8975f5c5SAndroid Build Coastguard Worker void Context::getObjectLabel(GLenum identifier,
1423*8975f5c5SAndroid Build Coastguard Worker                              GLuint name,
1424*8975f5c5SAndroid Build Coastguard Worker                              GLsizei bufSize,
1425*8975f5c5SAndroid Build Coastguard Worker                              GLsizei *length,
1426*8975f5c5SAndroid Build Coastguard Worker                              GLchar *label)
1427*8975f5c5SAndroid Build Coastguard Worker {
1428*8975f5c5SAndroid Build Coastguard Worker     gl::LabeledObject *object = getLabeledObject(identifier, name);
1429*8975f5c5SAndroid Build Coastguard Worker     ASSERT(object != nullptr);
1430*8975f5c5SAndroid Build Coastguard Worker 
1431*8975f5c5SAndroid Build Coastguard Worker     const std::string &objectLabel = object->getLabel();
1432*8975f5c5SAndroid Build Coastguard Worker     GetObjectLabelBase(objectLabel, bufSize, length, label);
1433*8975f5c5SAndroid Build Coastguard Worker }
1434*8975f5c5SAndroid Build Coastguard Worker 
getObjectPtrLabel(const void * ptr,GLsizei bufSize,GLsizei * length,GLchar * label)1435*8975f5c5SAndroid Build Coastguard Worker void Context::getObjectPtrLabel(const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label)
1436*8975f5c5SAndroid Build Coastguard Worker {
1437*8975f5c5SAndroid Build Coastguard Worker     gl::LabeledObject *object = getLabeledObjectFromPtr(ptr);
1438*8975f5c5SAndroid Build Coastguard Worker     ASSERT(object != nullptr);
1439*8975f5c5SAndroid Build Coastguard Worker 
1440*8975f5c5SAndroid Build Coastguard Worker     const std::string &objectLabel = object->getLabel();
1441*8975f5c5SAndroid Build Coastguard Worker     GetObjectLabelBase(objectLabel, bufSize, length, label);
1442*8975f5c5SAndroid Build Coastguard Worker }
1443*8975f5c5SAndroid Build Coastguard Worker 
isSampler(SamplerID samplerName) const1444*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isSampler(SamplerID samplerName) const
1445*8975f5c5SAndroid Build Coastguard Worker {
1446*8975f5c5SAndroid Build Coastguard Worker     return mState.mSamplerManager->isSampler(samplerName);
1447*8975f5c5SAndroid Build Coastguard Worker }
1448*8975f5c5SAndroid Build Coastguard Worker 
bindTexture(TextureType target,TextureID handle)1449*8975f5c5SAndroid Build Coastguard Worker void Context::bindTexture(TextureType target, TextureID handle)
1450*8975f5c5SAndroid Build Coastguard Worker {
1451*8975f5c5SAndroid Build Coastguard Worker     // Some apps enable KHR_create_context_no_error but pass in an invalid texture type.
1452*8975f5c5SAndroid Build Coastguard Worker     // Workaround this by silently returning in such situations.
1453*8975f5c5SAndroid Build Coastguard Worker     if (target == TextureType::InvalidEnum)
1454*8975f5c5SAndroid Build Coastguard Worker     {
1455*8975f5c5SAndroid Build Coastguard Worker         return;
1456*8975f5c5SAndroid Build Coastguard Worker     }
1457*8975f5c5SAndroid Build Coastguard Worker 
1458*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = nullptr;
1459*8975f5c5SAndroid Build Coastguard Worker     if (handle.value == 0)
1460*8975f5c5SAndroid Build Coastguard Worker     {
1461*8975f5c5SAndroid Build Coastguard Worker         texture = mZeroTextures[target].get();
1462*8975f5c5SAndroid Build Coastguard Worker     }
1463*8975f5c5SAndroid Build Coastguard Worker     else
1464*8975f5c5SAndroid Build Coastguard Worker     {
1465*8975f5c5SAndroid Build Coastguard Worker         texture =
1466*8975f5c5SAndroid Build Coastguard Worker             mState.mTextureManager->checkTextureAllocation(mImplementation.get(), handle, target);
1467*8975f5c5SAndroid Build Coastguard Worker     }
1468*8975f5c5SAndroid Build Coastguard Worker 
1469*8975f5c5SAndroid Build Coastguard Worker     ASSERT(texture);
1470*8975f5c5SAndroid Build Coastguard Worker     // Early return if rebinding the same texture
1471*8975f5c5SAndroid Build Coastguard Worker     if (texture == mState.getTargetTexture(target))
1472*8975f5c5SAndroid Build Coastguard Worker     {
1473*8975f5c5SAndroid Build Coastguard Worker         return;
1474*8975f5c5SAndroid Build Coastguard Worker     }
1475*8975f5c5SAndroid Build Coastguard Worker 
1476*8975f5c5SAndroid Build Coastguard Worker     mState.setSamplerTexture(this, target, texture);
1477*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTextureChange(this);
1478*8975f5c5SAndroid Build Coastguard Worker }
1479*8975f5c5SAndroid Build Coastguard Worker 
bindReadFramebuffer(FramebufferID framebufferHandle)1480*8975f5c5SAndroid Build Coastguard Worker void Context::bindReadFramebuffer(FramebufferID framebufferHandle)
1481*8975f5c5SAndroid Build Coastguard Worker {
1482*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation(
1483*8975f5c5SAndroid Build Coastguard Worker         mImplementation.get(), this, framebufferHandle);
1484*8975f5c5SAndroid Build Coastguard Worker     mState.setReadFramebufferBinding(framebuffer);
1485*8975f5c5SAndroid Build Coastguard Worker     mReadFramebufferObserverBinding.bind(framebuffer);
1486*8975f5c5SAndroid Build Coastguard Worker }
1487*8975f5c5SAndroid Build Coastguard Worker 
bindDrawFramebuffer(FramebufferID framebufferHandle)1488*8975f5c5SAndroid Build Coastguard Worker void Context::bindDrawFramebuffer(FramebufferID framebufferHandle)
1489*8975f5c5SAndroid Build Coastguard Worker {
1490*8975f5c5SAndroid Build Coastguard Worker     endTilingImplicit();
1491*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0)
1492*8975f5c5SAndroid Build Coastguard Worker     {
1493*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
1494*8975f5c5SAndroid Build Coastguard Worker     }
1495*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation(
1496*8975f5c5SAndroid Build Coastguard Worker         mImplementation.get(), this, framebufferHandle);
1497*8975f5c5SAndroid Build Coastguard Worker     mState.setDrawFramebufferBinding(framebuffer);
1498*8975f5c5SAndroid Build Coastguard Worker     mDrawFramebufferObserverBinding.bind(framebuffer);
1499*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onDrawFramebufferChange(this);
1500*8975f5c5SAndroid Build Coastguard Worker }
1501*8975f5c5SAndroid Build Coastguard Worker 
bindVertexArray(VertexArrayID vertexArrayHandle)1502*8975f5c5SAndroid Build Coastguard Worker void Context::bindVertexArray(VertexArrayID vertexArrayHandle)
1503*8975f5c5SAndroid Build Coastguard Worker {
1504*8975f5c5SAndroid Build Coastguard Worker     VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle);
1505*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexArrayBinding(this, vertexArray);
1506*8975f5c5SAndroid Build Coastguard Worker     mVertexArrayObserverBinding.bind(vertexArray);
1507*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayBindingChange(this);
1508*8975f5c5SAndroid Build Coastguard Worker }
1509*8975f5c5SAndroid Build Coastguard Worker 
bindVertexBuffer(GLuint bindingIndex,BufferID bufferHandle,GLintptr offset,GLsizei stride)1510*8975f5c5SAndroid Build Coastguard Worker void Context::bindVertexBuffer(GLuint bindingIndex,
1511*8975f5c5SAndroid Build Coastguard Worker                                BufferID bufferHandle,
1512*8975f5c5SAndroid Build Coastguard Worker                                GLintptr offset,
1513*8975f5c5SAndroid Build Coastguard Worker                                GLsizei stride)
1514*8975f5c5SAndroid Build Coastguard Worker {
1515*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer =
1516*8975f5c5SAndroid Build Coastguard Worker         mState.mBufferManager->checkBufferAllocation(mImplementation.get(), bufferHandle);
1517*8975f5c5SAndroid Build Coastguard Worker     mState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride);
1518*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayStateChange(this);
1519*8975f5c5SAndroid Build Coastguard Worker }
1520*8975f5c5SAndroid Build Coastguard Worker 
bindSampler(GLuint textureUnit,SamplerID samplerHandle)1521*8975f5c5SAndroid Build Coastguard Worker void Context::bindSampler(GLuint textureUnit, SamplerID samplerHandle)
1522*8975f5c5SAndroid Build Coastguard Worker {
1523*8975f5c5SAndroid Build Coastguard Worker     ASSERT(textureUnit < static_cast<GLuint>(mState.getCaps().maxCombinedTextureImageUnits));
1524*8975f5c5SAndroid Build Coastguard Worker     Sampler *sampler =
1525*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), samplerHandle);
1526*8975f5c5SAndroid Build Coastguard Worker 
1527*8975f5c5SAndroid Build Coastguard Worker     // Early return if rebinding the same sampler
1528*8975f5c5SAndroid Build Coastguard Worker     if (sampler == mState.getSampler(textureUnit))
1529*8975f5c5SAndroid Build Coastguard Worker     {
1530*8975f5c5SAndroid Build Coastguard Worker         return;
1531*8975f5c5SAndroid Build Coastguard Worker     }
1532*8975f5c5SAndroid Build Coastguard Worker 
1533*8975f5c5SAndroid Build Coastguard Worker     mState.setSamplerBinding(this, textureUnit, sampler);
1534*8975f5c5SAndroid Build Coastguard Worker     mSamplerObserverBindings[textureUnit].bind(sampler);
1535*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTextureChange(this);
1536*8975f5c5SAndroid Build Coastguard Worker }
1537*8975f5c5SAndroid Build Coastguard Worker 
bindImageTexture(GLuint unit,TextureID texture,GLint level,GLboolean layered,GLint layer,GLenum access,GLenum format)1538*8975f5c5SAndroid Build Coastguard Worker void Context::bindImageTexture(GLuint unit,
1539*8975f5c5SAndroid Build Coastguard Worker                                TextureID texture,
1540*8975f5c5SAndroid Build Coastguard Worker                                GLint level,
1541*8975f5c5SAndroid Build Coastguard Worker                                GLboolean layered,
1542*8975f5c5SAndroid Build Coastguard Worker                                GLint layer,
1543*8975f5c5SAndroid Build Coastguard Worker                                GLenum access,
1544*8975f5c5SAndroid Build Coastguard Worker                                GLenum format)
1545*8975f5c5SAndroid Build Coastguard Worker {
1546*8975f5c5SAndroid Build Coastguard Worker     Texture *tex = mState.mTextureManager->getTexture(texture);
1547*8975f5c5SAndroid Build Coastguard Worker     mState.setImageUnit(this, unit, tex, level, layered, layer, access, format);
1548*8975f5c5SAndroid Build Coastguard Worker     mImageObserverBindings[unit].bind(tex);
1549*8975f5c5SAndroid Build Coastguard Worker }
1550*8975f5c5SAndroid Build Coastguard Worker 
useProgram(ShaderProgramID program)1551*8975f5c5SAndroid Build Coastguard Worker void Context::useProgram(ShaderProgramID program)
1552*8975f5c5SAndroid Build Coastguard Worker {
1553*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
1554*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mState.setProgram(this, programObject));
1555*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onProgramExecutableChange(this);
1556*8975f5c5SAndroid Build Coastguard Worker     mProgramObserverBinding.bind(programObject);
1557*8975f5c5SAndroid Build Coastguard Worker }
1558*8975f5c5SAndroid Build Coastguard Worker 
useProgramStages(ProgramPipelineID pipeline,GLbitfield stages,ShaderProgramID program)1559*8975f5c5SAndroid Build Coastguard Worker void Context::useProgramStages(ProgramPipelineID pipeline,
1560*8975f5c5SAndroid Build Coastguard Worker                                GLbitfield stages,
1561*8975f5c5SAndroid Build Coastguard Worker                                ShaderProgramID program)
1562*8975f5c5SAndroid Build Coastguard Worker {
1563*8975f5c5SAndroid Build Coastguard Worker     Program *shaderProgram = getProgramNoResolveLink(program);
1564*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *programPipeline =
1565*8975f5c5SAndroid Build Coastguard Worker         mState.mProgramPipelineManager->checkProgramPipelineAllocation(mImplementation.get(),
1566*8975f5c5SAndroid Build Coastguard Worker                                                                        pipeline);
1567*8975f5c5SAndroid Build Coastguard Worker 
1568*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programPipeline);
1569*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(programPipeline->useProgramStages(this, stages, shaderProgram));
1570*8975f5c5SAndroid Build Coastguard Worker }
1571*8975f5c5SAndroid Build Coastguard Worker 
bindTransformFeedback(GLenum target,TransformFeedbackID transformFeedbackHandle)1572*8975f5c5SAndroid Build Coastguard Worker void Context::bindTransformFeedback(GLenum target, TransformFeedbackID transformFeedbackHandle)
1573*8975f5c5SAndroid Build Coastguard Worker {
1574*8975f5c5SAndroid Build Coastguard Worker     ASSERT(target == GL_TRANSFORM_FEEDBACK);
1575*8975f5c5SAndroid Build Coastguard Worker     TransformFeedback *transformFeedback =
1576*8975f5c5SAndroid Build Coastguard Worker         checkTransformFeedbackAllocation(transformFeedbackHandle);
1577*8975f5c5SAndroid Build Coastguard Worker     mState.setTransformFeedbackBinding(this, transformFeedback);
1578*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTransformFeedbackChange(this);
1579*8975f5c5SAndroid Build Coastguard Worker }
1580*8975f5c5SAndroid Build Coastguard Worker 
bindProgramPipeline(ProgramPipelineID pipelineHandle)1581*8975f5c5SAndroid Build Coastguard Worker void Context::bindProgramPipeline(ProgramPipelineID pipelineHandle)
1582*8975f5c5SAndroid Build Coastguard Worker {
1583*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *pipeline = mState.mProgramPipelineManager->checkProgramPipelineAllocation(
1584*8975f5c5SAndroid Build Coastguard Worker         mImplementation.get(), pipelineHandle);
1585*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mState.setProgramPipelineBinding(this, pipeline));
1586*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onProgramExecutableChange(this);
1587*8975f5c5SAndroid Build Coastguard Worker     mProgramPipelineObserverBinding.bind(pipeline);
1588*8975f5c5SAndroid Build Coastguard Worker }
1589*8975f5c5SAndroid Build Coastguard Worker 
beginQuery(QueryType target,QueryID query)1590*8975f5c5SAndroid Build Coastguard Worker void Context::beginQuery(QueryType target, QueryID query)
1591*8975f5c5SAndroid Build Coastguard Worker {
1592*8975f5c5SAndroid Build Coastguard Worker     Query *queryObject = getOrCreateQuery(query, target);
1593*8975f5c5SAndroid Build Coastguard Worker     ASSERT(queryObject);
1594*8975f5c5SAndroid Build Coastguard Worker 
1595*8975f5c5SAndroid Build Coastguard Worker     // begin query
1596*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(queryObject->begin(this));
1597*8975f5c5SAndroid Build Coastguard Worker 
1598*8975f5c5SAndroid Build Coastguard Worker     // set query as active for specified target only if begin succeeded
1599*8975f5c5SAndroid Build Coastguard Worker     mState.setActiveQuery(this, target, queryObject);
1600*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onQueryChange(this);
1601*8975f5c5SAndroid Build Coastguard Worker }
1602*8975f5c5SAndroid Build Coastguard Worker 
endQuery(QueryType target)1603*8975f5c5SAndroid Build Coastguard Worker void Context::endQuery(QueryType target)
1604*8975f5c5SAndroid Build Coastguard Worker {
1605*8975f5c5SAndroid Build Coastguard Worker     Query *queryObject = mState.getActiveQuery(target);
1606*8975f5c5SAndroid Build Coastguard Worker     ASSERT(queryObject);
1607*8975f5c5SAndroid Build Coastguard Worker 
1608*8975f5c5SAndroid Build Coastguard Worker     // Intentionally don't call try here. We don't want an early return.
1609*8975f5c5SAndroid Build Coastguard Worker     (void)(queryObject->end(this));
1610*8975f5c5SAndroid Build Coastguard Worker 
1611*8975f5c5SAndroid Build Coastguard Worker     // Always unbind the query, even if there was an error. This may delete the query object.
1612*8975f5c5SAndroid Build Coastguard Worker     mState.setActiveQuery(this, target, nullptr);
1613*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onQueryChange(this);
1614*8975f5c5SAndroid Build Coastguard Worker }
1615*8975f5c5SAndroid Build Coastguard Worker 
queryCounter(QueryID id,QueryType target)1616*8975f5c5SAndroid Build Coastguard Worker void Context::queryCounter(QueryID id, QueryType target)
1617*8975f5c5SAndroid Build Coastguard Worker {
1618*8975f5c5SAndroid Build Coastguard Worker     ASSERT(target == QueryType::Timestamp);
1619*8975f5c5SAndroid Build Coastguard Worker 
1620*8975f5c5SAndroid Build Coastguard Worker     Query *queryObject = getOrCreateQuery(id, target);
1621*8975f5c5SAndroid Build Coastguard Worker     ASSERT(queryObject);
1622*8975f5c5SAndroid Build Coastguard Worker 
1623*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(queryObject->queryCounter(this));
1624*8975f5c5SAndroid Build Coastguard Worker }
1625*8975f5c5SAndroid Build Coastguard Worker 
getQueryiv(QueryType target,GLenum pname,GLint * params)1626*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryiv(QueryType target, GLenum pname, GLint *params)
1627*8975f5c5SAndroid Build Coastguard Worker {
1628*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
1629*8975f5c5SAndroid Build Coastguard Worker     {
1630*8975f5c5SAndroid Build Coastguard Worker         case GL_CURRENT_QUERY_EXT:
1631*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getActiveQueryId(target).value;
1632*8975f5c5SAndroid Build Coastguard Worker             break;
1633*8975f5c5SAndroid Build Coastguard Worker         case GL_QUERY_COUNTER_BITS_EXT:
1634*8975f5c5SAndroid Build Coastguard Worker             switch (target)
1635*8975f5c5SAndroid Build Coastguard Worker             {
1636*8975f5c5SAndroid Build Coastguard Worker                 case QueryType::TimeElapsed:
1637*8975f5c5SAndroid Build Coastguard Worker                     params[0] = getCaps().queryCounterBitsTimeElapsed;
1638*8975f5c5SAndroid Build Coastguard Worker                     break;
1639*8975f5c5SAndroid Build Coastguard Worker                 case QueryType::Timestamp:
1640*8975f5c5SAndroid Build Coastguard Worker                     params[0] = getCaps().queryCounterBitsTimestamp;
1641*8975f5c5SAndroid Build Coastguard Worker                     break;
1642*8975f5c5SAndroid Build Coastguard Worker                 default:
1643*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
1644*8975f5c5SAndroid Build Coastguard Worker                     params[0] = 0;
1645*8975f5c5SAndroid Build Coastguard Worker                     break;
1646*8975f5c5SAndroid Build Coastguard Worker             }
1647*8975f5c5SAndroid Build Coastguard Worker             break;
1648*8975f5c5SAndroid Build Coastguard Worker         default:
1649*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
1650*8975f5c5SAndroid Build Coastguard Worker             return;
1651*8975f5c5SAndroid Build Coastguard Worker     }
1652*8975f5c5SAndroid Build Coastguard Worker }
1653*8975f5c5SAndroid Build Coastguard Worker 
getQueryivRobust(QueryType target,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)1654*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryivRobust(QueryType target,
1655*8975f5c5SAndroid Build Coastguard Worker                                GLenum pname,
1656*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufSize,
1657*8975f5c5SAndroid Build Coastguard Worker                                GLsizei *length,
1658*8975f5c5SAndroid Build Coastguard Worker                                GLint *params)
1659*8975f5c5SAndroid Build Coastguard Worker {
1660*8975f5c5SAndroid Build Coastguard Worker     getQueryiv(target, pname, params);
1661*8975f5c5SAndroid Build Coastguard Worker }
1662*8975f5c5SAndroid Build Coastguard Worker 
getUnsignedBytev(GLenum pname,GLubyte * data)1663*8975f5c5SAndroid Build Coastguard Worker void Context::getUnsignedBytev(GLenum pname, GLubyte *data)
1664*8975f5c5SAndroid Build Coastguard Worker {
1665*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
1666*8975f5c5SAndroid Build Coastguard Worker }
1667*8975f5c5SAndroid Build Coastguard Worker 
getUnsignedBytei_v(GLenum target,GLuint index,GLubyte * data)1668*8975f5c5SAndroid Build Coastguard Worker void Context::getUnsignedBytei_v(GLenum target, GLuint index, GLubyte *data)
1669*8975f5c5SAndroid Build Coastguard Worker {
1670*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
1671*8975f5c5SAndroid Build Coastguard Worker }
1672*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjectiv(QueryID id,GLenum pname,GLint * params)1673*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjectiv(QueryID id, GLenum pname, GLint *params)
1674*8975f5c5SAndroid Build Coastguard Worker {
1675*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
1676*8975f5c5SAndroid Build Coastguard Worker }
1677*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjectivRobust(QueryID id,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)1678*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjectivRobust(QueryID id,
1679*8975f5c5SAndroid Build Coastguard Worker                                      GLenum pname,
1680*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei bufSize,
1681*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei *length,
1682*8975f5c5SAndroid Build Coastguard Worker                                      GLint *params)
1683*8975f5c5SAndroid Build Coastguard Worker {
1684*8975f5c5SAndroid Build Coastguard Worker     getQueryObjectiv(id, pname, params);
1685*8975f5c5SAndroid Build Coastguard Worker }
1686*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjectuiv(QueryID id,GLenum pname,GLuint * params)1687*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjectuiv(QueryID id, GLenum pname, GLuint *params)
1688*8975f5c5SAndroid Build Coastguard Worker {
1689*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
1690*8975f5c5SAndroid Build Coastguard Worker }
1691*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjectuivRobust(QueryID id,GLenum pname,GLsizei bufSize,GLsizei * length,GLuint * params)1692*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjectuivRobust(QueryID id,
1693*8975f5c5SAndroid Build Coastguard Worker                                       GLenum pname,
1694*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei bufSize,
1695*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei *length,
1696*8975f5c5SAndroid Build Coastguard Worker                                       GLuint *params)
1697*8975f5c5SAndroid Build Coastguard Worker {
1698*8975f5c5SAndroid Build Coastguard Worker     getQueryObjectuiv(id, pname, params);
1699*8975f5c5SAndroid Build Coastguard Worker }
1700*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjecti64v(QueryID id,GLenum pname,GLint64 * params)1701*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjecti64v(QueryID id, GLenum pname, GLint64 *params)
1702*8975f5c5SAndroid Build Coastguard Worker {
1703*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
1704*8975f5c5SAndroid Build Coastguard Worker }
1705*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjecti64vRobust(QueryID id,GLenum pname,GLsizei bufSize,GLsizei * length,GLint64 * params)1706*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjecti64vRobust(QueryID id,
1707*8975f5c5SAndroid Build Coastguard Worker                                        GLenum pname,
1708*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei bufSize,
1709*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei *length,
1710*8975f5c5SAndroid Build Coastguard Worker                                        GLint64 *params)
1711*8975f5c5SAndroid Build Coastguard Worker {
1712*8975f5c5SAndroid Build Coastguard Worker     getQueryObjecti64v(id, pname, params);
1713*8975f5c5SAndroid Build Coastguard Worker }
1714*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjectui64v(QueryID id,GLenum pname,GLuint64 * params)1715*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjectui64v(QueryID id, GLenum pname, GLuint64 *params)
1716*8975f5c5SAndroid Build Coastguard Worker {
1717*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
1718*8975f5c5SAndroid Build Coastguard Worker }
1719*8975f5c5SAndroid Build Coastguard Worker 
getQueryObjectui64vRobust(QueryID id,GLenum pname,GLsizei bufSize,GLsizei * length,GLuint64 * params)1720*8975f5c5SAndroid Build Coastguard Worker void Context::getQueryObjectui64vRobust(QueryID id,
1721*8975f5c5SAndroid Build Coastguard Worker                                         GLenum pname,
1722*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
1723*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
1724*8975f5c5SAndroid Build Coastguard Worker                                         GLuint64 *params)
1725*8975f5c5SAndroid Build Coastguard Worker {
1726*8975f5c5SAndroid Build Coastguard Worker     getQueryObjectui64v(id, pname, params);
1727*8975f5c5SAndroid Build Coastguard Worker }
1728*8975f5c5SAndroid Build Coastguard Worker 
getFramebuffer(FramebufferID handle) const1729*8975f5c5SAndroid Build Coastguard Worker Framebuffer *Context::getFramebuffer(FramebufferID handle) const
1730*8975f5c5SAndroid Build Coastguard Worker {
1731*8975f5c5SAndroid Build Coastguard Worker     return mState.mFramebufferManager->getFramebuffer(handle);
1732*8975f5c5SAndroid Build Coastguard Worker }
1733*8975f5c5SAndroid Build Coastguard Worker 
getFenceNV(FenceNVID handle) const1734*8975f5c5SAndroid Build Coastguard Worker FenceNV *Context::getFenceNV(FenceNVID handle) const
1735*8975f5c5SAndroid Build Coastguard Worker {
1736*8975f5c5SAndroid Build Coastguard Worker     return mFenceNVMap.query(handle);
1737*8975f5c5SAndroid Build Coastguard Worker }
1738*8975f5c5SAndroid Build Coastguard Worker 
getOrCreateQuery(QueryID handle,QueryType type)1739*8975f5c5SAndroid Build Coastguard Worker Query *Context::getOrCreateQuery(QueryID handle, QueryType type)
1740*8975f5c5SAndroid Build Coastguard Worker {
1741*8975f5c5SAndroid Build Coastguard Worker     if (!mQueryMap.contains(handle))
1742*8975f5c5SAndroid Build Coastguard Worker     {
1743*8975f5c5SAndroid Build Coastguard Worker         return nullptr;
1744*8975f5c5SAndroid Build Coastguard Worker     }
1745*8975f5c5SAndroid Build Coastguard Worker 
1746*8975f5c5SAndroid Build Coastguard Worker     Query *query = mQueryMap.query(handle);
1747*8975f5c5SAndroid Build Coastguard Worker     if (!query)
1748*8975f5c5SAndroid Build Coastguard Worker     {
1749*8975f5c5SAndroid Build Coastguard Worker         ASSERT(type != QueryType::InvalidEnum);
1750*8975f5c5SAndroid Build Coastguard Worker         query = new Query(mImplementation.get(), type, handle);
1751*8975f5c5SAndroid Build Coastguard Worker         query->addRef();
1752*8975f5c5SAndroid Build Coastguard Worker         mQueryMap.assign(handle, query);
1753*8975f5c5SAndroid Build Coastguard Worker     }
1754*8975f5c5SAndroid Build Coastguard Worker     return query;
1755*8975f5c5SAndroid Build Coastguard Worker }
1756*8975f5c5SAndroid Build Coastguard Worker 
getQuery(QueryID handle) const1757*8975f5c5SAndroid Build Coastguard Worker Query *Context::getQuery(QueryID handle) const
1758*8975f5c5SAndroid Build Coastguard Worker {
1759*8975f5c5SAndroid Build Coastguard Worker     return mQueryMap.query(handle);
1760*8975f5c5SAndroid Build Coastguard Worker }
1761*8975f5c5SAndroid Build Coastguard Worker 
getTextureByType(TextureType type) const1762*8975f5c5SAndroid Build Coastguard Worker Texture *Context::getTextureByType(TextureType type) const
1763*8975f5c5SAndroid Build Coastguard Worker {
1764*8975f5c5SAndroid Build Coastguard Worker     ASSERT(ValidTextureTarget(this, type) || ValidTextureExternalTarget(this, type));
1765*8975f5c5SAndroid Build Coastguard Worker     return mState.getTargetTexture(type);
1766*8975f5c5SAndroid Build Coastguard Worker }
1767*8975f5c5SAndroid Build Coastguard Worker 
getTextureByTarget(TextureTarget target) const1768*8975f5c5SAndroid Build Coastguard Worker Texture *Context::getTextureByTarget(TextureTarget target) const
1769*8975f5c5SAndroid Build Coastguard Worker {
1770*8975f5c5SAndroid Build Coastguard Worker     return getTextureByType(TextureTargetToType(target));
1771*8975f5c5SAndroid Build Coastguard Worker }
1772*8975f5c5SAndroid Build Coastguard Worker 
getSamplerTexture(unsigned int sampler,TextureType type) const1773*8975f5c5SAndroid Build Coastguard Worker Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const
1774*8975f5c5SAndroid Build Coastguard Worker {
1775*8975f5c5SAndroid Build Coastguard Worker     return mState.getSamplerTexture(sampler, type);
1776*8975f5c5SAndroid Build Coastguard Worker }
1777*8975f5c5SAndroid Build Coastguard Worker 
getCompiler() const1778*8975f5c5SAndroid Build Coastguard Worker Compiler *Context::getCompiler() const
1779*8975f5c5SAndroid Build Coastguard Worker {
1780*8975f5c5SAndroid Build Coastguard Worker     if (mCompiler.get() == nullptr)
1781*8975f5c5SAndroid Build Coastguard Worker     {
1782*8975f5c5SAndroid Build Coastguard Worker         mCompiler.set(this, new Compiler(mImplementation.get(), mState, mDisplay));
1783*8975f5c5SAndroid Build Coastguard Worker     }
1784*8975f5c5SAndroid Build Coastguard Worker     return mCompiler.get();
1785*8975f5c5SAndroid Build Coastguard Worker }
1786*8975f5c5SAndroid Build Coastguard Worker 
getBooleanvImpl(GLenum pname,GLboolean * params) const1787*8975f5c5SAndroid Build Coastguard Worker void Context::getBooleanvImpl(GLenum pname, GLboolean *params) const
1788*8975f5c5SAndroid Build Coastguard Worker {
1789*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
1790*8975f5c5SAndroid Build Coastguard Worker     {
1791*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADER_COMPILER:
1792*8975f5c5SAndroid Build Coastguard Worker             *params = GL_TRUE;
1793*8975f5c5SAndroid Build Coastguard Worker             break;
1794*8975f5c5SAndroid Build Coastguard Worker         case GL_CONTEXT_ROBUST_ACCESS_EXT:
1795*8975f5c5SAndroid Build Coastguard Worker             *params = ConvertToGLBoolean(mState.hasRobustAccess());
1796*8975f5c5SAndroid Build Coastguard Worker             break;
1797*8975f5c5SAndroid Build Coastguard Worker 
1798*8975f5c5SAndroid Build Coastguard Worker         default:
1799*8975f5c5SAndroid Build Coastguard Worker             mState.getBooleanv(pname, params);
1800*8975f5c5SAndroid Build Coastguard Worker             break;
1801*8975f5c5SAndroid Build Coastguard Worker     }
1802*8975f5c5SAndroid Build Coastguard Worker }
1803*8975f5c5SAndroid Build Coastguard Worker 
getFloatvImpl(GLenum pname,GLfloat * params) const1804*8975f5c5SAndroid Build Coastguard Worker void Context::getFloatvImpl(GLenum pname, GLfloat *params) const
1805*8975f5c5SAndroid Build Coastguard Worker {
1806*8975f5c5SAndroid Build Coastguard Worker     // Queries about context capabilities and maximums are answered by Context.
1807*8975f5c5SAndroid Build Coastguard Worker     // Queries about current GL state values are answered by State.
1808*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
1809*8975f5c5SAndroid Build Coastguard Worker     {
1810*8975f5c5SAndroid Build Coastguard Worker         case GL_ALIASED_LINE_WIDTH_RANGE:
1811*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getCaps().minAliasedLineWidth;
1812*8975f5c5SAndroid Build Coastguard Worker             params[1] = mState.getCaps().maxAliasedLineWidth;
1813*8975f5c5SAndroid Build Coastguard Worker             break;
1814*8975f5c5SAndroid Build Coastguard Worker         case GL_ALIASED_POINT_SIZE_RANGE:
1815*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getCaps().minAliasedPointSize;
1816*8975f5c5SAndroid Build Coastguard Worker             params[1] = mState.getCaps().maxAliasedPointSize;
1817*8975f5c5SAndroid Build Coastguard Worker             break;
1818*8975f5c5SAndroid Build Coastguard Worker         case GL_SMOOTH_POINT_SIZE_RANGE:
1819*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getCaps().minSmoothPointSize;
1820*8975f5c5SAndroid Build Coastguard Worker             params[1] = mState.getCaps().maxSmoothPointSize;
1821*8975f5c5SAndroid Build Coastguard Worker             break;
1822*8975f5c5SAndroid Build Coastguard Worker         case GL_SMOOTH_LINE_WIDTH_RANGE:
1823*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getCaps().minSmoothLineWidth;
1824*8975f5c5SAndroid Build Coastguard Worker             params[1] = mState.getCaps().maxSmoothLineWidth;
1825*8975f5c5SAndroid Build Coastguard Worker             break;
1826*8975f5c5SAndroid Build Coastguard Worker         case GL_MULTISAMPLE_LINE_WIDTH_RANGE:
1827*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getCaps().minMultisampleLineWidth;
1828*8975f5c5SAndroid Build Coastguard Worker             params[1] = mState.getCaps().maxMultisampleLineWidth;
1829*8975f5c5SAndroid Build Coastguard Worker             break;
1830*8975f5c5SAndroid Build Coastguard Worker         case GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY:
1831*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().lineWidthGranularity;
1832*8975f5c5SAndroid Build Coastguard Worker             break;
1833*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
1834*8975f5c5SAndroid Build Coastguard Worker             ASSERT(mState.getExtensions().textureFilterAnisotropicEXT);
1835*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTextureAnisotropy;
1836*8975f5c5SAndroid Build Coastguard Worker             break;
1837*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TEXTURE_LOD_BIAS:
1838*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxLODBias;
1839*8975f5c5SAndroid Build Coastguard Worker             break;
1840*8975f5c5SAndroid Build Coastguard Worker         case GL_MIN_FRAGMENT_INTERPOLATION_OFFSET:
1841*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().minInterpolationOffset;
1842*8975f5c5SAndroid Build Coastguard Worker             break;
1843*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_INTERPOLATION_OFFSET:
1844*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxInterpolationOffset;
1845*8975f5c5SAndroid Build Coastguard Worker             break;
1846*8975f5c5SAndroid Build Coastguard Worker         case GL_PRIMITIVE_BOUNDING_BOX:
1847*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getBoundingBoxMinX();
1848*8975f5c5SAndroid Build Coastguard Worker             params[1] = mState.getBoundingBoxMinY();
1849*8975f5c5SAndroid Build Coastguard Worker             params[2] = mState.getBoundingBoxMinZ();
1850*8975f5c5SAndroid Build Coastguard Worker             params[3] = mState.getBoundingBoxMinW();
1851*8975f5c5SAndroid Build Coastguard Worker             params[4] = mState.getBoundingBoxMaxX();
1852*8975f5c5SAndroid Build Coastguard Worker             params[5] = mState.getBoundingBoxMaxY();
1853*8975f5c5SAndroid Build Coastguard Worker             params[6] = mState.getBoundingBoxMaxZ();
1854*8975f5c5SAndroid Build Coastguard Worker             params[7] = mState.getBoundingBoxMaxW();
1855*8975f5c5SAndroid Build Coastguard Worker             break;
1856*8975f5c5SAndroid Build Coastguard Worker         default:
1857*8975f5c5SAndroid Build Coastguard Worker             mState.getFloatv(pname, params);
1858*8975f5c5SAndroid Build Coastguard Worker             break;
1859*8975f5c5SAndroid Build Coastguard Worker     }
1860*8975f5c5SAndroid Build Coastguard Worker }
1861*8975f5c5SAndroid Build Coastguard Worker 
getIntegervImpl(GLenum pname,GLint * params) const1862*8975f5c5SAndroid Build Coastguard Worker void Context::getIntegervImpl(GLenum pname, GLint *params) const
1863*8975f5c5SAndroid Build Coastguard Worker {
1864*8975f5c5SAndroid Build Coastguard Worker     // Queries about context capabilities and maximums are answered by Context.
1865*8975f5c5SAndroid Build Coastguard Worker     // Queries about current GL state values are answered by State.
1866*8975f5c5SAndroid Build Coastguard Worker 
1867*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
1868*8975f5c5SAndroid Build Coastguard Worker     {
1869*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_ATTRIBS:
1870*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVertexAttributes;
1871*8975f5c5SAndroid Build Coastguard Worker             break;
1872*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_UNIFORM_VECTORS:
1873*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVertexUniformVectors;
1874*8975f5c5SAndroid Build Coastguard Worker             break;
1875*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_UNIFORM_COMPONENTS:
1876*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformComponents[ShaderType::Vertex];
1877*8975f5c5SAndroid Build Coastguard Worker             break;
1878*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VARYING_VECTORS:
1879*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVaryingVectors;
1880*8975f5c5SAndroid Build Coastguard Worker             break;
1881*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VARYING_COMPONENTS:
1882*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVaryingVectors * 4;
1883*8975f5c5SAndroid Build Coastguard Worker             break;
1884*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
1885*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedTextureImageUnits;
1886*8975f5c5SAndroid Build Coastguard Worker             break;
1887*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
1888*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderTextureImageUnits[ShaderType::Vertex];
1889*8975f5c5SAndroid Build Coastguard Worker             break;
1890*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TEXTURE_IMAGE_UNITS:
1891*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderTextureImageUnits[ShaderType::Fragment];
1892*8975f5c5SAndroid Build Coastguard Worker             break;
1893*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
1894*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxFragmentUniformVectors;
1895*8975f5c5SAndroid Build Coastguard Worker             break;
1896*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
1897*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformComponents[ShaderType::Fragment];
1898*8975f5c5SAndroid Build Coastguard Worker             break;
1899*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_RENDERBUFFER_SIZE:
1900*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxRenderbufferSize;
1901*8975f5c5SAndroid Build Coastguard Worker             break;
1902*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COLOR_ATTACHMENTS_EXT:
1903*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxColorAttachments;
1904*8975f5c5SAndroid Build Coastguard Worker             break;
1905*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_DRAW_BUFFERS_EXT:
1906*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxDrawBuffers;
1907*8975f5c5SAndroid Build Coastguard Worker             break;
1908*8975f5c5SAndroid Build Coastguard Worker         case GL_SUBPIXEL_BITS:
1909*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().subPixelBits;
1910*8975f5c5SAndroid Build Coastguard Worker             break;
1911*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TEXTURE_SIZE:
1912*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().max2DTextureSize;
1913*8975f5c5SAndroid Build Coastguard Worker             break;
1914*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE:
1915*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxRectangleTextureSize;
1916*8975f5c5SAndroid Build Coastguard Worker             break;
1917*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
1918*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCubeMapTextureSize;
1919*8975f5c5SAndroid Build Coastguard Worker             break;
1920*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_3D_TEXTURE_SIZE:
1921*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().max3DTextureSize;
1922*8975f5c5SAndroid Build Coastguard Worker             break;
1923*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_ARRAY_TEXTURE_LAYERS:
1924*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxArrayTextureLayers;
1925*8975f5c5SAndroid Build Coastguard Worker             break;
1926*8975f5c5SAndroid Build Coastguard Worker         case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
1927*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().uniformBufferOffsetAlignment;
1928*8975f5c5SAndroid Build Coastguard Worker             break;
1929*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_UNIFORM_BUFFER_BINDINGS:
1930*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxUniformBufferBindings;
1931*8975f5c5SAndroid Build Coastguard Worker             break;
1932*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_UNIFORM_BLOCKS:
1933*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformBlocks[ShaderType::Vertex];
1934*8975f5c5SAndroid Build Coastguard Worker             break;
1935*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_UNIFORM_BLOCKS:
1936*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformBlocks[ShaderType::Fragment];
1937*8975f5c5SAndroid Build Coastguard Worker             break;
1938*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_UNIFORM_BLOCKS:
1939*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedUniformBlocks;
1940*8975f5c5SAndroid Build Coastguard Worker             break;
1941*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_OUTPUT_COMPONENTS:
1942*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVertexOutputComponents;
1943*8975f5c5SAndroid Build Coastguard Worker             break;
1944*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_INPUT_COMPONENTS:
1945*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxFragmentInputComponents;
1946*8975f5c5SAndroid Build Coastguard Worker             break;
1947*8975f5c5SAndroid Build Coastguard Worker         case GL_MIN_PROGRAM_TEXEL_OFFSET:
1948*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().minProgramTexelOffset;
1949*8975f5c5SAndroid Build Coastguard Worker             break;
1950*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_PROGRAM_TEXEL_OFFSET:
1951*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxProgramTexelOffset;
1952*8975f5c5SAndroid Build Coastguard Worker             break;
1953*8975f5c5SAndroid Build Coastguard Worker         case GL_MAJOR_VERSION:
1954*8975f5c5SAndroid Build Coastguard Worker             *params = getClientVersion().major;
1955*8975f5c5SAndroid Build Coastguard Worker             break;
1956*8975f5c5SAndroid Build Coastguard Worker         case GL_MINOR_VERSION:
1957*8975f5c5SAndroid Build Coastguard Worker             *params = getClientVersion().minor;
1958*8975f5c5SAndroid Build Coastguard Worker             break;
1959*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_ELEMENTS_INDICES:
1960*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxElementsIndices;
1961*8975f5c5SAndroid Build Coastguard Worker             break;
1962*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_ELEMENTS_VERTICES:
1963*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxElementsVertices;
1964*8975f5c5SAndroid Build Coastguard Worker             break;
1965*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
1966*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTransformFeedbackInterleavedComponents;
1967*8975f5c5SAndroid Build Coastguard Worker             break;
1968*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
1969*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTransformFeedbackSeparateAttributes;
1970*8975f5c5SAndroid Build Coastguard Worker             break;
1971*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
1972*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTransformFeedbackSeparateComponents;
1973*8975f5c5SAndroid Build Coastguard Worker             break;
1974*8975f5c5SAndroid Build Coastguard Worker         case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
1975*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(mState.getCaps().compressedTextureFormats.size());
1976*8975f5c5SAndroid Build Coastguard Worker             break;
1977*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_SAMPLES_ANGLE:
1978*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxSamples;
1979*8975f5c5SAndroid Build Coastguard Worker             break;
1980*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VIEWPORT_DIMS:
1981*8975f5c5SAndroid Build Coastguard Worker         {
1982*8975f5c5SAndroid Build Coastguard Worker             params[0] = mState.getCaps().maxViewportWidth;
1983*8975f5c5SAndroid Build Coastguard Worker             params[1] = mState.getCaps().maxViewportHeight;
1984*8975f5c5SAndroid Build Coastguard Worker         }
1985*8975f5c5SAndroid Build Coastguard Worker         break;
1986*8975f5c5SAndroid Build Coastguard Worker         case GL_COMPRESSED_TEXTURE_FORMATS:
1987*8975f5c5SAndroid Build Coastguard Worker             std::copy(mState.getCaps().compressedTextureFormats.begin(),
1988*8975f5c5SAndroid Build Coastguard Worker                       mState.getCaps().compressedTextureFormats.end(), params);
1989*8975f5c5SAndroid Build Coastguard Worker             break;
1990*8975f5c5SAndroid Build Coastguard Worker         case GL_RESET_NOTIFICATION_STRATEGY_EXT:
1991*8975f5c5SAndroid Build Coastguard Worker             *params = mErrors.getResetStrategy();
1992*8975f5c5SAndroid Build Coastguard Worker             break;
1993*8975f5c5SAndroid Build Coastguard Worker         case GL_NUM_SHADER_BINARY_FORMATS:
1994*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(mState.getCaps().shaderBinaryFormats.size());
1995*8975f5c5SAndroid Build Coastguard Worker             break;
1996*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADER_BINARY_FORMATS:
1997*8975f5c5SAndroid Build Coastguard Worker             std::copy(mState.getCaps().shaderBinaryFormats.begin(),
1998*8975f5c5SAndroid Build Coastguard Worker                       mState.getCaps().shaderBinaryFormats.end(), params);
1999*8975f5c5SAndroid Build Coastguard Worker             break;
2000*8975f5c5SAndroid Build Coastguard Worker         case GL_NUM_PROGRAM_BINARY_FORMATS:
2001*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(mState.getCaps().programBinaryFormats.size());
2002*8975f5c5SAndroid Build Coastguard Worker             break;
2003*8975f5c5SAndroid Build Coastguard Worker         case GL_PROGRAM_BINARY_FORMATS:
2004*8975f5c5SAndroid Build Coastguard Worker             std::copy(mState.getCaps().programBinaryFormats.begin(),
2005*8975f5c5SAndroid Build Coastguard Worker                       mState.getCaps().programBinaryFormats.end(), params);
2006*8975f5c5SAndroid Build Coastguard Worker             break;
2007*8975f5c5SAndroid Build Coastguard Worker         case GL_NUM_EXTENSIONS:
2008*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(mExtensionStrings.size());
2009*8975f5c5SAndroid Build Coastguard Worker             break;
2010*8975f5c5SAndroid Build Coastguard Worker 
2011*8975f5c5SAndroid Build Coastguard Worker         // GLES3.2 client flags
2012*8975f5c5SAndroid Build Coastguard Worker         case GL_CONTEXT_FLAGS:
2013*8975f5c5SAndroid Build Coastguard Worker         {
2014*8975f5c5SAndroid Build Coastguard Worker             GLint contextFlags = 0;
2015*8975f5c5SAndroid Build Coastguard Worker             if (mState.hasProtectedContent())
2016*8975f5c5SAndroid Build Coastguard Worker             {
2017*8975f5c5SAndroid Build Coastguard Worker                 contextFlags |= GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT;
2018*8975f5c5SAndroid Build Coastguard Worker             }
2019*8975f5c5SAndroid Build Coastguard Worker 
2020*8975f5c5SAndroid Build Coastguard Worker             if (mState.isDebugContext())
2021*8975f5c5SAndroid Build Coastguard Worker             {
2022*8975f5c5SAndroid Build Coastguard Worker                 contextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT_KHR;
2023*8975f5c5SAndroid Build Coastguard Worker             }
2024*8975f5c5SAndroid Build Coastguard Worker 
2025*8975f5c5SAndroid Build Coastguard Worker             if (mState.hasRobustAccess())
2026*8975f5c5SAndroid Build Coastguard Worker             {
2027*8975f5c5SAndroid Build Coastguard Worker                 contextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT;
2028*8975f5c5SAndroid Build Coastguard Worker             }
2029*8975f5c5SAndroid Build Coastguard Worker             *params = contextFlags;
2030*8975f5c5SAndroid Build Coastguard Worker         }
2031*8975f5c5SAndroid Build Coastguard Worker         break;
2032*8975f5c5SAndroid Build Coastguard Worker 
2033*8975f5c5SAndroid Build Coastguard Worker         // GL_ANGLE_request_extension
2034*8975f5c5SAndroid Build Coastguard Worker         case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE:
2035*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(mRequestableExtensionStrings.size());
2036*8975f5c5SAndroid Build Coastguard Worker             break;
2037*8975f5c5SAndroid Build Coastguard Worker 
2038*8975f5c5SAndroid Build Coastguard Worker         // GL_KHR_debug
2039*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_DEBUG_MESSAGE_LENGTH:
2040*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxDebugMessageLength;
2041*8975f5c5SAndroid Build Coastguard Worker             break;
2042*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_DEBUG_LOGGED_MESSAGES:
2043*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxDebugLoggedMessages;
2044*8975f5c5SAndroid Build Coastguard Worker             break;
2045*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_DEBUG_GROUP_STACK_DEPTH:
2046*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxDebugGroupStackDepth;
2047*8975f5c5SAndroid Build Coastguard Worker             break;
2048*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_LABEL_LENGTH:
2049*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxLabelLength;
2050*8975f5c5SAndroid Build Coastguard Worker             break;
2051*8975f5c5SAndroid Build Coastguard Worker 
2052*8975f5c5SAndroid Build Coastguard Worker         // GL_OVR_multiview2
2053*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VIEWS_OVR:
2054*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxViews;
2055*8975f5c5SAndroid Build Coastguard Worker             break;
2056*8975f5c5SAndroid Build Coastguard Worker 
2057*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_disjoint_timer_query
2058*8975f5c5SAndroid Build Coastguard Worker         case GL_GPU_DISJOINT_EXT:
2059*8975f5c5SAndroid Build Coastguard Worker             *params = mImplementation->getGPUDisjoint();
2060*8975f5c5SAndroid Build Coastguard Worker             break;
2061*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAMEBUFFER_WIDTH:
2062*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxFramebufferWidth;
2063*8975f5c5SAndroid Build Coastguard Worker             break;
2064*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAMEBUFFER_HEIGHT:
2065*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxFramebufferHeight;
2066*8975f5c5SAndroid Build Coastguard Worker             break;
2067*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAMEBUFFER_SAMPLES:
2068*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxFramebufferSamples;
2069*8975f5c5SAndroid Build Coastguard Worker             break;
2070*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_SAMPLE_MASK_WORDS:
2071*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxSampleMaskWords;
2072*8975f5c5SAndroid Build Coastguard Worker             break;
2073*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COLOR_TEXTURE_SAMPLES:
2074*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxColorTextureSamples;
2075*8975f5c5SAndroid Build Coastguard Worker             break;
2076*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_DEPTH_TEXTURE_SAMPLES:
2077*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxDepthTextureSamples;
2078*8975f5c5SAndroid Build Coastguard Worker             break;
2079*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_INTEGER_SAMPLES:
2080*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxIntegerSamples;
2081*8975f5c5SAndroid Build Coastguard Worker             break;
2082*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET:
2083*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVertexAttribRelativeOffset;
2084*8975f5c5SAndroid Build Coastguard Worker             break;
2085*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_ATTRIB_BINDINGS:
2086*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVertexAttribBindings;
2087*8975f5c5SAndroid Build Coastguard Worker             break;
2088*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_ATTRIB_STRIDE:
2089*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxVertexAttribStride;
2090*8975f5c5SAndroid Build Coastguard Worker             break;
2091*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS:
2092*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounterBuffers[ShaderType::Vertex];
2093*8975f5c5SAndroid Build Coastguard Worker             break;
2094*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_ATOMIC_COUNTERS:
2095*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounters[ShaderType::Vertex];
2096*8975f5c5SAndroid Build Coastguard Worker             break;
2097*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_IMAGE_UNIFORMS:
2098*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderImageUniforms[ShaderType::Vertex];
2099*8975f5c5SAndroid Build Coastguard Worker             break;
2100*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS:
2101*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBlocks[ShaderType::Vertex];
2102*8975f5c5SAndroid Build Coastguard Worker             break;
2103*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS:
2104*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounterBuffers[ShaderType::Fragment];
2105*8975f5c5SAndroid Build Coastguard Worker             break;
2106*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_ATOMIC_COUNTERS:
2107*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounters[ShaderType::Fragment];
2108*8975f5c5SAndroid Build Coastguard Worker             break;
2109*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_IMAGE_UNIFORMS:
2110*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderImageUniforms[ShaderType::Fragment];
2111*8975f5c5SAndroid Build Coastguard Worker             break;
2112*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS:
2113*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBlocks[ShaderType::Fragment];
2114*8975f5c5SAndroid Build Coastguard Worker             break;
2115*8975f5c5SAndroid Build Coastguard Worker         case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET:
2116*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().minProgramTextureGatherOffset;
2117*8975f5c5SAndroid Build Coastguard Worker             break;
2118*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET:
2119*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxProgramTextureGatherOffset;
2120*8975f5c5SAndroid Build Coastguard Worker             break;
2121*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS:
2122*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxComputeWorkGroupInvocations;
2123*8975f5c5SAndroid Build Coastguard Worker             break;
2124*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_UNIFORM_BLOCKS:
2125*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformBlocks[ShaderType::Compute];
2126*8975f5c5SAndroid Build Coastguard Worker             break;
2127*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS:
2128*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderTextureImageUnits[ShaderType::Compute];
2129*8975f5c5SAndroid Build Coastguard Worker             break;
2130*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE:
2131*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxComputeSharedMemorySize;
2132*8975f5c5SAndroid Build Coastguard Worker             break;
2133*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_UNIFORM_COMPONENTS:
2134*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformComponents[ShaderType::Compute];
2135*8975f5c5SAndroid Build Coastguard Worker             break;
2136*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS:
2137*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounterBuffers[ShaderType::Compute];
2138*8975f5c5SAndroid Build Coastguard Worker             break;
2139*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_ATOMIC_COUNTERS:
2140*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounters[ShaderType::Compute];
2141*8975f5c5SAndroid Build Coastguard Worker             break;
2142*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_IMAGE_UNIFORMS:
2143*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderImageUniforms[ShaderType::Compute];
2144*8975f5c5SAndroid Build Coastguard Worker             break;
2145*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS:
2146*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(
2147*8975f5c5SAndroid Build Coastguard Worker                 mState.getCaps().maxCombinedShaderUniformComponents[ShaderType::Compute]);
2148*8975f5c5SAndroid Build Coastguard Worker             break;
2149*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS:
2150*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBlocks[ShaderType::Compute];
2151*8975f5c5SAndroid Build Coastguard Worker             break;
2152*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
2153*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedShaderOutputResources;
2154*8975f5c5SAndroid Build Coastguard Worker             break;
2155*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_UNIFORM_LOCATIONS:
2156*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxUniformLocations;
2157*8975f5c5SAndroid Build Coastguard Worker             break;
2158*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS:
2159*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxAtomicCounterBufferBindings;
2160*8975f5c5SAndroid Build Coastguard Worker             break;
2161*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE:
2162*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxAtomicCounterBufferSize;
2163*8975f5c5SAndroid Build Coastguard Worker             break;
2164*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS:
2165*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedAtomicCounterBuffers;
2166*8975f5c5SAndroid Build Coastguard Worker             break;
2167*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_ATOMIC_COUNTERS:
2168*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedAtomicCounters;
2169*8975f5c5SAndroid Build Coastguard Worker             break;
2170*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_IMAGE_UNITS:
2171*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxImageUnits;
2172*8975f5c5SAndroid Build Coastguard Worker             break;
2173*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_IMAGE_UNIFORMS:
2174*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedImageUniforms;
2175*8975f5c5SAndroid Build Coastguard Worker             break;
2176*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS:
2177*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBufferBindings;
2178*8975f5c5SAndroid Build Coastguard Worker             break;
2179*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS:
2180*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedShaderStorageBlocks;
2181*8975f5c5SAndroid Build Coastguard Worker             break;
2182*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT:
2183*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().shaderStorageBufferOffsetAlignment;
2184*8975f5c5SAndroid Build Coastguard Worker             break;
2185*8975f5c5SAndroid Build Coastguard Worker 
2186*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_geometry_shader
2187*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_FRAMEBUFFER_LAYERS_EXT:
2188*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxFramebufferLayers;
2189*8975f5c5SAndroid Build Coastguard Worker             break;
2190*8975f5c5SAndroid Build Coastguard Worker         case GL_LAYER_PROVOKING_VERTEX_EXT:
2191*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().layerProvokingVertex;
2192*8975f5c5SAndroid Build Coastguard Worker             break;
2193*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT:
2194*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformComponents[ShaderType::Geometry];
2195*8975f5c5SAndroid Build Coastguard Worker             break;
2196*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT:
2197*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformBlocks[ShaderType::Geometry];
2198*8975f5c5SAndroid Build Coastguard Worker             break;
2199*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT:
2200*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(
2201*8975f5c5SAndroid Build Coastguard Worker                 mState.getCaps().maxCombinedShaderUniformComponents[ShaderType::Geometry]);
2202*8975f5c5SAndroid Build Coastguard Worker             break;
2203*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT:
2204*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxGeometryInputComponents;
2205*8975f5c5SAndroid Build Coastguard Worker             break;
2206*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT:
2207*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxGeometryOutputComponents;
2208*8975f5c5SAndroid Build Coastguard Worker             break;
2209*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT:
2210*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxGeometryOutputVertices;
2211*8975f5c5SAndroid Build Coastguard Worker             break;
2212*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT:
2213*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxGeometryTotalOutputComponents;
2214*8975f5c5SAndroid Build Coastguard Worker             break;
2215*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT:
2216*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxGeometryShaderInvocations;
2217*8975f5c5SAndroid Build Coastguard Worker             break;
2218*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT:
2219*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderTextureImageUnits[ShaderType::Geometry];
2220*8975f5c5SAndroid Build Coastguard Worker             break;
2221*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT:
2222*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounterBuffers[ShaderType::Geometry];
2223*8975f5c5SAndroid Build Coastguard Worker             break;
2224*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT:
2225*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounters[ShaderType::Geometry];
2226*8975f5c5SAndroid Build Coastguard Worker             break;
2227*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT:
2228*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderImageUniforms[ShaderType::Geometry];
2229*8975f5c5SAndroid Build Coastguard Worker             break;
2230*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT:
2231*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBlocks[ShaderType::Geometry];
2232*8975f5c5SAndroid Build Coastguard Worker             break;
2233*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_tessellation_shader
2234*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_PATCH_VERTICES_EXT:
2235*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxPatchVertices;
2236*8975f5c5SAndroid Build Coastguard Worker             break;
2237*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_GEN_LEVEL_EXT:
2238*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTessGenLevel;
2239*8975f5c5SAndroid Build Coastguard Worker             break;
2240*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT:
2241*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformComponents[ShaderType::TessControl];
2242*8975f5c5SAndroid Build Coastguard Worker             break;
2243*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT:
2244*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformComponents[ShaderType::TessEvaluation];
2245*8975f5c5SAndroid Build Coastguard Worker             break;
2246*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT:
2247*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderTextureImageUnits[ShaderType::TessControl];
2248*8975f5c5SAndroid Build Coastguard Worker             break;
2249*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT:
2250*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderTextureImageUnits[ShaderType::TessEvaluation];
2251*8975f5c5SAndroid Build Coastguard Worker             break;
2252*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT:
2253*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTessControlOutputComponents;
2254*8975f5c5SAndroid Build Coastguard Worker             break;
2255*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_PATCH_COMPONENTS_EXT:
2256*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTessPatchComponents;
2257*8975f5c5SAndroid Build Coastguard Worker             break;
2258*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT:
2259*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTessControlTotalOutputComponents;
2260*8975f5c5SAndroid Build Coastguard Worker             break;
2261*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT:
2262*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTessEvaluationOutputComponents;
2263*8975f5c5SAndroid Build Coastguard Worker             break;
2264*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT:
2265*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformBlocks[ShaderType::TessControl];
2266*8975f5c5SAndroid Build Coastguard Worker             break;
2267*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT:
2268*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderUniformBlocks[ShaderType::TessEvaluation];
2269*8975f5c5SAndroid Build Coastguard Worker             break;
2270*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT:
2271*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTessControlInputComponents;
2272*8975f5c5SAndroid Build Coastguard Worker             break;
2273*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT:
2274*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTessEvaluationInputComponents;
2275*8975f5c5SAndroid Build Coastguard Worker             break;
2276*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT:
2277*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(
2278*8975f5c5SAndroid Build Coastguard Worker                 mState.getCaps().maxCombinedShaderUniformComponents[ShaderType::TessControl]);
2279*8975f5c5SAndroid Build Coastguard Worker             break;
2280*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT:
2281*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(
2282*8975f5c5SAndroid Build Coastguard Worker                 mState.getCaps().maxCombinedShaderUniformComponents[ShaderType::TessEvaluation]);
2283*8975f5c5SAndroid Build Coastguard Worker             break;
2284*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT:
2285*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounterBuffers[ShaderType::TessControl];
2286*8975f5c5SAndroid Build Coastguard Worker             break;
2287*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT:
2288*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounterBuffers[ShaderType::TessEvaluation];
2289*8975f5c5SAndroid Build Coastguard Worker             break;
2290*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT:
2291*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounters[ShaderType::TessControl];
2292*8975f5c5SAndroid Build Coastguard Worker             break;
2293*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT:
2294*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderAtomicCounters[ShaderType::TessEvaluation];
2295*8975f5c5SAndroid Build Coastguard Worker             break;
2296*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT:
2297*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderImageUniforms[ShaderType::TessControl];
2298*8975f5c5SAndroid Build Coastguard Worker             break;
2299*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT:
2300*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderImageUniforms[ShaderType::TessEvaluation];
2301*8975f5c5SAndroid Build Coastguard Worker             break;
2302*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT:
2303*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBlocks[ShaderType::TessControl];
2304*8975f5c5SAndroid Build Coastguard Worker             break;
2305*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT:
2306*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBlocks[ShaderType::TessEvaluation];
2307*8975f5c5SAndroid Build Coastguard Worker             break;
2308*8975f5c5SAndroid Build Coastguard Worker         // GLES1 emulation: Caps queries
2309*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TEXTURE_UNITS:
2310*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxMultitextureUnits;
2311*8975f5c5SAndroid Build Coastguard Worker             break;
2312*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_MODELVIEW_STACK_DEPTH:
2313*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxModelviewMatrixStackDepth;
2314*8975f5c5SAndroid Build Coastguard Worker             break;
2315*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_PROJECTION_STACK_DEPTH:
2316*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxProjectionMatrixStackDepth;
2317*8975f5c5SAndroid Build Coastguard Worker             break;
2318*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TEXTURE_STACK_DEPTH:
2319*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTextureMatrixStackDepth;
2320*8975f5c5SAndroid Build Coastguard Worker             break;
2321*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_LIGHTS:
2322*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxLights;
2323*8975f5c5SAndroid Build Coastguard Worker             break;
2324*8975f5c5SAndroid Build Coastguard Worker 
2325*8975f5c5SAndroid Build Coastguard Worker         // case GL_MAX_CLIP_DISTANCES_EXT:  Conflict enum value
2326*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_CLIP_PLANES:
2327*8975f5c5SAndroid Build Coastguard Worker             if (getClientVersion().major >= 2)
2328*8975f5c5SAndroid Build Coastguard Worker             {
2329*8975f5c5SAndroid Build Coastguard Worker                 // GL_APPLE_clip_distance / GL_EXT_clip_cull_distance / GL_ANGLE_clip_cull_distance
2330*8975f5c5SAndroid Build Coastguard Worker                 *params = mState.getCaps().maxClipDistances;
2331*8975f5c5SAndroid Build Coastguard Worker             }
2332*8975f5c5SAndroid Build Coastguard Worker             else
2333*8975f5c5SAndroid Build Coastguard Worker             {
2334*8975f5c5SAndroid Build Coastguard Worker                 *params = mState.getCaps().maxClipPlanes;
2335*8975f5c5SAndroid Build Coastguard Worker             }
2336*8975f5c5SAndroid Build Coastguard Worker             break;
2337*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_CULL_DISTANCES_EXT:
2338*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCullDistances;
2339*8975f5c5SAndroid Build Coastguard Worker             break;
2340*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT:
2341*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedClipAndCullDistances;
2342*8975f5c5SAndroid Build Coastguard Worker             break;
2343*8975f5c5SAndroid Build Coastguard Worker         // GLES1 emulation: Vertex attribute queries
2344*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY_BUFFER_BINDING:
2345*8975f5c5SAndroid Build Coastguard Worker         case GL_NORMAL_ARRAY_BUFFER_BINDING:
2346*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR_ARRAY_BUFFER_BINDING:
2347*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
2348*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
2349*8975f5c5SAndroid Build Coastguard Worker             getIntegerVertexAttribImpl(pname, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, params);
2350*8975f5c5SAndroid Build Coastguard Worker             break;
2351*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY_STRIDE:
2352*8975f5c5SAndroid Build Coastguard Worker         case GL_NORMAL_ARRAY_STRIDE:
2353*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR_ARRAY_STRIDE:
2354*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SIZE_ARRAY_STRIDE_OES:
2355*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_COORD_ARRAY_STRIDE:
2356*8975f5c5SAndroid Build Coastguard Worker             getIntegerVertexAttribImpl(pname, GL_VERTEX_ATTRIB_ARRAY_STRIDE, params);
2357*8975f5c5SAndroid Build Coastguard Worker             break;
2358*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY_SIZE:
2359*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR_ARRAY_SIZE:
2360*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_COORD_ARRAY_SIZE:
2361*8975f5c5SAndroid Build Coastguard Worker             getIntegerVertexAttribImpl(pname, GL_VERTEX_ATTRIB_ARRAY_SIZE, params);
2362*8975f5c5SAndroid Build Coastguard Worker             break;
2363*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_ARRAY_TYPE:
2364*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR_ARRAY_TYPE:
2365*8975f5c5SAndroid Build Coastguard Worker         case GL_NORMAL_ARRAY_TYPE:
2366*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SIZE_ARRAY_TYPE_OES:
2367*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_COORD_ARRAY_TYPE:
2368*8975f5c5SAndroid Build Coastguard Worker             getIntegerVertexAttribImpl(pname, GL_VERTEX_ATTRIB_ARRAY_TYPE, params);
2369*8975f5c5SAndroid Build Coastguard Worker             break;
2370*8975f5c5SAndroid Build Coastguard Worker 
2371*8975f5c5SAndroid Build Coastguard Worker         // GL_KHR_parallel_shader_compile
2372*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_SHADER_COMPILER_THREADS_KHR:
2373*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getMaxShaderCompilerThreads();
2374*8975f5c5SAndroid Build Coastguard Worker             break;
2375*8975f5c5SAndroid Build Coastguard Worker 
2376*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_blend_func_extended
2377*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT:
2378*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxDualSourceDrawBuffers;
2379*8975f5c5SAndroid Build Coastguard Worker             break;
2380*8975f5c5SAndroid Build Coastguard Worker 
2381*8975f5c5SAndroid Build Coastguard Worker         // OES_shader_multisample_interpolation
2382*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES:
2383*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().subPixelInterpolationOffsetBits;
2384*8975f5c5SAndroid Build Coastguard Worker             break;
2385*8975f5c5SAndroid Build Coastguard Worker 
2386*8975f5c5SAndroid Build Coastguard Worker         // GL_OES_texture_buffer
2387*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_TEXTURE_BUFFER_SIZE:
2388*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxTextureBufferSize;
2389*8975f5c5SAndroid Build Coastguard Worker             break;
2390*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
2391*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().textureBufferOffsetAlignment;
2392*8975f5c5SAndroid Build Coastguard Worker             break;
2393*8975f5c5SAndroid Build Coastguard Worker 
2394*8975f5c5SAndroid Build Coastguard Worker         // ANGLE_shader_pixel_local_storage
2395*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_PIXEL_LOCAL_STORAGE_PLANES_ANGLE:
2396*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxPixelLocalStoragePlanes;
2397*8975f5c5SAndroid Build Coastguard Worker             break;
2398*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COLOR_ATTACHMENTS_WITH_ACTIVE_PIXEL_LOCAL_STORAGE_ANGLE:
2399*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxColorAttachmentsWithActivePixelLocalStorage;
2400*8975f5c5SAndroid Build Coastguard Worker             break;
2401*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES_ANGLE:
2402*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedDrawBuffersAndPixelLocalStoragePlanes;
2403*8975f5c5SAndroid Build Coastguard Worker             break;
2404*8975f5c5SAndroid Build Coastguard Worker 
2405*8975f5c5SAndroid Build Coastguard Worker         case GL_QUERY_COUNTER_BITS_EXT:
2406*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().queryCounterBitsTimestamp;
2407*8975f5c5SAndroid Build Coastguard Worker             break;
2408*8975f5c5SAndroid Build Coastguard Worker 
2409*8975f5c5SAndroid Build Coastguard Worker         default:
2410*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(mState.getIntegerv(this, pname, params));
2411*8975f5c5SAndroid Build Coastguard Worker             break;
2412*8975f5c5SAndroid Build Coastguard Worker     }
2413*8975f5c5SAndroid Build Coastguard Worker }
2414*8975f5c5SAndroid Build Coastguard Worker 
getIntegerVertexAttribImpl(GLenum pname,GLenum attribpname,GLint * params) const2415*8975f5c5SAndroid Build Coastguard Worker void Context::getIntegerVertexAttribImpl(GLenum pname, GLenum attribpname, GLint *params) const
2416*8975f5c5SAndroid Build Coastguard Worker {
2417*8975f5c5SAndroid Build Coastguard Worker     getVertexAttribivImpl(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))),
2418*8975f5c5SAndroid Build Coastguard Worker                           attribpname, params);
2419*8975f5c5SAndroid Build Coastguard Worker }
2420*8975f5c5SAndroid Build Coastguard Worker 
getInteger64vImpl(GLenum pname,GLint64 * params) const2421*8975f5c5SAndroid Build Coastguard Worker void Context::getInteger64vImpl(GLenum pname, GLint64 *params) const
2422*8975f5c5SAndroid Build Coastguard Worker {
2423*8975f5c5SAndroid Build Coastguard Worker     // Queries about context capabilities and maximums are answered by Context.
2424*8975f5c5SAndroid Build Coastguard Worker     // Queries about current GL state values are answered by State.
2425*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
2426*8975f5c5SAndroid Build Coastguard Worker     {
2427*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_ELEMENT_INDEX:
2428*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxElementIndex;
2429*8975f5c5SAndroid Build Coastguard Worker             break;
2430*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_UNIFORM_BLOCK_SIZE:
2431*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxUniformBlockSize;
2432*8975f5c5SAndroid Build Coastguard Worker             break;
2433*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:
2434*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedShaderUniformComponents[ShaderType::Vertex];
2435*8975f5c5SAndroid Build Coastguard Worker             break;
2436*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:
2437*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxCombinedShaderUniformComponents[ShaderType::Fragment];
2438*8975f5c5SAndroid Build Coastguard Worker             break;
2439*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_SERVER_WAIT_TIMEOUT:
2440*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxServerWaitTimeout;
2441*8975f5c5SAndroid Build Coastguard Worker             break;
2442*8975f5c5SAndroid Build Coastguard Worker 
2443*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_disjoint_timer_query
2444*8975f5c5SAndroid Build Coastguard Worker         case GL_TIMESTAMP_EXT:
2445*8975f5c5SAndroid Build Coastguard Worker             *params = mImplementation->getTimestamp();
2446*8975f5c5SAndroid Build Coastguard Worker             break;
2447*8975f5c5SAndroid Build Coastguard Worker 
2448*8975f5c5SAndroid Build Coastguard Worker         case GL_MAX_SHADER_STORAGE_BLOCK_SIZE:
2449*8975f5c5SAndroid Build Coastguard Worker             *params = mState.getCaps().maxShaderStorageBlockSize;
2450*8975f5c5SAndroid Build Coastguard Worker             break;
2451*8975f5c5SAndroid Build Coastguard Worker         default:
2452*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
2453*8975f5c5SAndroid Build Coastguard Worker             break;
2454*8975f5c5SAndroid Build Coastguard Worker     }
2455*8975f5c5SAndroid Build Coastguard Worker }
2456*8975f5c5SAndroid Build Coastguard Worker 
getPointerv(GLenum pname,void ** params)2457*8975f5c5SAndroid Build Coastguard Worker void Context::getPointerv(GLenum pname, void **params)
2458*8975f5c5SAndroid Build Coastguard Worker {
2459*8975f5c5SAndroid Build Coastguard Worker     mState.getPointerv(this, pname, params);
2460*8975f5c5SAndroid Build Coastguard Worker }
2461*8975f5c5SAndroid Build Coastguard Worker 
getPointervRobustANGLERobust(GLenum pname,GLsizei bufSize,GLsizei * length,void ** params)2462*8975f5c5SAndroid Build Coastguard Worker void Context::getPointervRobustANGLERobust(GLenum pname,
2463*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei bufSize,
2464*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei *length,
2465*8975f5c5SAndroid Build Coastguard Worker                                            void **params)
2466*8975f5c5SAndroid Build Coastguard Worker {
2467*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2468*8975f5c5SAndroid Build Coastguard Worker }
2469*8975f5c5SAndroid Build Coastguard Worker 
getIntegeri_v(GLenum target,GLuint index,GLint * data)2470*8975f5c5SAndroid Build Coastguard Worker void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data)
2471*8975f5c5SAndroid Build Coastguard Worker {
2472*8975f5c5SAndroid Build Coastguard Worker     // Queries about context capabilities and maximums are answered by Context.
2473*8975f5c5SAndroid Build Coastguard Worker     // Queries about current GL state values are answered by State.
2474*8975f5c5SAndroid Build Coastguard Worker 
2475*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
2476*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams;
2477*8975f5c5SAndroid Build Coastguard Worker     bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
2478*8975f5c5SAndroid Build Coastguard Worker     ASSERT(queryStatus);
2479*8975f5c5SAndroid Build Coastguard Worker 
2480*8975f5c5SAndroid Build Coastguard Worker     if (nativeType == GL_INT)
2481*8975f5c5SAndroid Build Coastguard Worker     {
2482*8975f5c5SAndroid Build Coastguard Worker         switch (target)
2483*8975f5c5SAndroid Build Coastguard Worker         {
2484*8975f5c5SAndroid Build Coastguard Worker             case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
2485*8975f5c5SAndroid Build Coastguard Worker                 ASSERT(index < 3u);
2486*8975f5c5SAndroid Build Coastguard Worker                 *data = mState.getCaps().maxComputeWorkGroupCount[index];
2487*8975f5c5SAndroid Build Coastguard Worker                 break;
2488*8975f5c5SAndroid Build Coastguard Worker             case GL_MAX_COMPUTE_WORK_GROUP_SIZE:
2489*8975f5c5SAndroid Build Coastguard Worker                 ASSERT(index < 3u);
2490*8975f5c5SAndroid Build Coastguard Worker                 *data = mState.getCaps().maxComputeWorkGroupSize[index];
2491*8975f5c5SAndroid Build Coastguard Worker                 break;
2492*8975f5c5SAndroid Build Coastguard Worker             default:
2493*8975f5c5SAndroid Build Coastguard Worker                 mState.getIntegeri_v(this, target, index, data);
2494*8975f5c5SAndroid Build Coastguard Worker         }
2495*8975f5c5SAndroid Build Coastguard Worker     }
2496*8975f5c5SAndroid Build Coastguard Worker     else
2497*8975f5c5SAndroid Build Coastguard Worker     {
2498*8975f5c5SAndroid Build Coastguard Worker         CastIndexedStateValues(this, nativeType, target, index, numParams, data);
2499*8975f5c5SAndroid Build Coastguard Worker     }
2500*8975f5c5SAndroid Build Coastguard Worker }
2501*8975f5c5SAndroid Build Coastguard Worker 
getIntegeri_vRobust(GLenum target,GLuint index,GLsizei bufSize,GLsizei * length,GLint * data)2502*8975f5c5SAndroid Build Coastguard Worker void Context::getIntegeri_vRobust(GLenum target,
2503*8975f5c5SAndroid Build Coastguard Worker                                   GLuint index,
2504*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
2505*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei *length,
2506*8975f5c5SAndroid Build Coastguard Worker                                   GLint *data)
2507*8975f5c5SAndroid Build Coastguard Worker {
2508*8975f5c5SAndroid Build Coastguard Worker     getIntegeri_v(target, index, data);
2509*8975f5c5SAndroid Build Coastguard Worker }
2510*8975f5c5SAndroid Build Coastguard Worker 
getInteger64i_v(GLenum target,GLuint index,GLint64 * data)2511*8975f5c5SAndroid Build Coastguard Worker void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data)
2512*8975f5c5SAndroid Build Coastguard Worker {
2513*8975f5c5SAndroid Build Coastguard Worker     // Queries about context capabilities and maximums are answered by Context.
2514*8975f5c5SAndroid Build Coastguard Worker     // Queries about current GL state values are answered by State.
2515*8975f5c5SAndroid Build Coastguard Worker 
2516*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
2517*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams;
2518*8975f5c5SAndroid Build Coastguard Worker     bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
2519*8975f5c5SAndroid Build Coastguard Worker     ASSERT(queryStatus);
2520*8975f5c5SAndroid Build Coastguard Worker 
2521*8975f5c5SAndroid Build Coastguard Worker     if (nativeType == GL_INT_64_ANGLEX)
2522*8975f5c5SAndroid Build Coastguard Worker     {
2523*8975f5c5SAndroid Build Coastguard Worker         mState.getInteger64i_v(target, index, data);
2524*8975f5c5SAndroid Build Coastguard Worker     }
2525*8975f5c5SAndroid Build Coastguard Worker     else
2526*8975f5c5SAndroid Build Coastguard Worker     {
2527*8975f5c5SAndroid Build Coastguard Worker         CastIndexedStateValues(this, nativeType, target, index, numParams, data);
2528*8975f5c5SAndroid Build Coastguard Worker     }
2529*8975f5c5SAndroid Build Coastguard Worker }
2530*8975f5c5SAndroid Build Coastguard Worker 
getInteger64i_vRobust(GLenum target,GLuint index,GLsizei bufSize,GLsizei * length,GLint64 * data)2531*8975f5c5SAndroid Build Coastguard Worker void Context::getInteger64i_vRobust(GLenum target,
2532*8975f5c5SAndroid Build Coastguard Worker                                     GLuint index,
2533*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei bufSize,
2534*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei *length,
2535*8975f5c5SAndroid Build Coastguard Worker                                     GLint64 *data)
2536*8975f5c5SAndroid Build Coastguard Worker {
2537*8975f5c5SAndroid Build Coastguard Worker     getInteger64i_v(target, index, data);
2538*8975f5c5SAndroid Build Coastguard Worker }
2539*8975f5c5SAndroid Build Coastguard Worker 
getBooleani_v(GLenum target,GLuint index,GLboolean * data)2540*8975f5c5SAndroid Build Coastguard Worker void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data)
2541*8975f5c5SAndroid Build Coastguard Worker {
2542*8975f5c5SAndroid Build Coastguard Worker     // Queries about context capabilities and maximums are answered by Context.
2543*8975f5c5SAndroid Build Coastguard Worker     // Queries about current GL state values are answered by State.
2544*8975f5c5SAndroid Build Coastguard Worker 
2545*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
2546*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams;
2547*8975f5c5SAndroid Build Coastguard Worker     bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
2548*8975f5c5SAndroid Build Coastguard Worker     ASSERT(queryStatus);
2549*8975f5c5SAndroid Build Coastguard Worker 
2550*8975f5c5SAndroid Build Coastguard Worker     if (nativeType == GL_BOOL)
2551*8975f5c5SAndroid Build Coastguard Worker     {
2552*8975f5c5SAndroid Build Coastguard Worker         mState.getBooleani_v(target, index, data);
2553*8975f5c5SAndroid Build Coastguard Worker     }
2554*8975f5c5SAndroid Build Coastguard Worker     else
2555*8975f5c5SAndroid Build Coastguard Worker     {
2556*8975f5c5SAndroid Build Coastguard Worker         CastIndexedStateValues(this, nativeType, target, index, numParams, data);
2557*8975f5c5SAndroid Build Coastguard Worker     }
2558*8975f5c5SAndroid Build Coastguard Worker }
2559*8975f5c5SAndroid Build Coastguard Worker 
getBooleani_vRobust(GLenum target,GLuint index,GLsizei bufSize,GLsizei * length,GLboolean * data)2560*8975f5c5SAndroid Build Coastguard Worker void Context::getBooleani_vRobust(GLenum target,
2561*8975f5c5SAndroid Build Coastguard Worker                                   GLuint index,
2562*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
2563*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei *length,
2564*8975f5c5SAndroid Build Coastguard Worker                                   GLboolean *data)
2565*8975f5c5SAndroid Build Coastguard Worker {
2566*8975f5c5SAndroid Build Coastguard Worker     getBooleani_v(target, index, data);
2567*8975f5c5SAndroid Build Coastguard Worker }
2568*8975f5c5SAndroid Build Coastguard Worker 
getBufferParameteriv(BufferBinding target,GLenum pname,GLint * params)2569*8975f5c5SAndroid Build Coastguard Worker void Context::getBufferParameteriv(BufferBinding target, GLenum pname, GLint *params)
2570*8975f5c5SAndroid Build Coastguard Worker {
2571*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
2572*8975f5c5SAndroid Build Coastguard Worker     QueryBufferParameteriv(buffer, pname, params);
2573*8975f5c5SAndroid Build Coastguard Worker }
2574*8975f5c5SAndroid Build Coastguard Worker 
getBufferParameterivRobust(BufferBinding target,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)2575*8975f5c5SAndroid Build Coastguard Worker void Context::getBufferParameterivRobust(BufferBinding target,
2576*8975f5c5SAndroid Build Coastguard Worker                                          GLenum pname,
2577*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei bufSize,
2578*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei *length,
2579*8975f5c5SAndroid Build Coastguard Worker                                          GLint *params)
2580*8975f5c5SAndroid Build Coastguard Worker {
2581*8975f5c5SAndroid Build Coastguard Worker     getBufferParameteriv(target, pname, params);
2582*8975f5c5SAndroid Build Coastguard Worker }
2583*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferAttachmentParameteriv(GLenum target,GLenum attachment,GLenum pname,GLint * params)2584*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferAttachmentParameteriv(GLenum target,
2585*8975f5c5SAndroid Build Coastguard Worker                                                   GLenum attachment,
2586*8975f5c5SAndroid Build Coastguard Worker                                                   GLenum pname,
2587*8975f5c5SAndroid Build Coastguard Worker                                                   GLint *params)
2588*8975f5c5SAndroid Build Coastguard Worker {
2589*8975f5c5SAndroid Build Coastguard Worker     const Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
2590*8975f5c5SAndroid Build Coastguard Worker     QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params);
2591*8975f5c5SAndroid Build Coastguard Worker }
2592*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferAttachmentParameterivRobust(GLenum target,GLenum attachment,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)2593*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferAttachmentParameterivRobust(GLenum target,
2594*8975f5c5SAndroid Build Coastguard Worker                                                         GLenum attachment,
2595*8975f5c5SAndroid Build Coastguard Worker                                                         GLenum pname,
2596*8975f5c5SAndroid Build Coastguard Worker                                                         GLsizei bufSize,
2597*8975f5c5SAndroid Build Coastguard Worker                                                         GLsizei *length,
2598*8975f5c5SAndroid Build Coastguard Worker                                                         GLint *params)
2599*8975f5c5SAndroid Build Coastguard Worker {
2600*8975f5c5SAndroid Build Coastguard Worker     getFramebufferAttachmentParameteriv(target, attachment, pname, params);
2601*8975f5c5SAndroid Build Coastguard Worker }
2602*8975f5c5SAndroid Build Coastguard Worker 
getRenderbufferParameteriv(GLenum target,GLenum pname,GLint * params)2603*8975f5c5SAndroid Build Coastguard Worker void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
2604*8975f5c5SAndroid Build Coastguard Worker {
2605*8975f5c5SAndroid Build Coastguard Worker     Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer();
2606*8975f5c5SAndroid Build Coastguard Worker     QueryRenderbufferiv(this, renderbuffer, pname, params);
2607*8975f5c5SAndroid Build Coastguard Worker }
2608*8975f5c5SAndroid Build Coastguard Worker 
getRenderbufferParameterivRobust(GLenum target,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)2609*8975f5c5SAndroid Build Coastguard Worker void Context::getRenderbufferParameterivRobust(GLenum target,
2610*8975f5c5SAndroid Build Coastguard Worker                                                GLenum pname,
2611*8975f5c5SAndroid Build Coastguard Worker                                                GLsizei bufSize,
2612*8975f5c5SAndroid Build Coastguard Worker                                                GLsizei *length,
2613*8975f5c5SAndroid Build Coastguard Worker                                                GLint *params)
2614*8975f5c5SAndroid Build Coastguard Worker {
2615*8975f5c5SAndroid Build Coastguard Worker     getRenderbufferParameteriv(target, pname, params);
2616*8975f5c5SAndroid Build Coastguard Worker }
2617*8975f5c5SAndroid Build Coastguard Worker 
texBuffer(TextureType target,GLenum internalformat,BufferID buffer)2618*8975f5c5SAndroid Build Coastguard Worker void Context::texBuffer(TextureType target, GLenum internalformat, BufferID buffer)
2619*8975f5c5SAndroid Build Coastguard Worker {
2620*8975f5c5SAndroid Build Coastguard Worker     ASSERT(target == TextureType::Buffer);
2621*8975f5c5SAndroid Build Coastguard Worker 
2622*8975f5c5SAndroid Build Coastguard Worker     Texture *texture  = getTextureByType(target);
2623*8975f5c5SAndroid Build Coastguard Worker     Buffer *bufferObj = mState.mBufferManager->getBuffer(buffer);
2624*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setBuffer(this, bufferObj, internalformat));
2625*8975f5c5SAndroid Build Coastguard Worker }
2626*8975f5c5SAndroid Build Coastguard Worker 
texBufferRange(TextureType target,GLenum internalformat,BufferID buffer,GLintptr offset,GLsizeiptr size)2627*8975f5c5SAndroid Build Coastguard Worker void Context::texBufferRange(TextureType target,
2628*8975f5c5SAndroid Build Coastguard Worker                              GLenum internalformat,
2629*8975f5c5SAndroid Build Coastguard Worker                              BufferID buffer,
2630*8975f5c5SAndroid Build Coastguard Worker                              GLintptr offset,
2631*8975f5c5SAndroid Build Coastguard Worker                              GLsizeiptr size)
2632*8975f5c5SAndroid Build Coastguard Worker {
2633*8975f5c5SAndroid Build Coastguard Worker     ASSERT(target == TextureType::Buffer);
2634*8975f5c5SAndroid Build Coastguard Worker 
2635*8975f5c5SAndroid Build Coastguard Worker     Texture *texture  = getTextureByType(target);
2636*8975f5c5SAndroid Build Coastguard Worker     Buffer *bufferObj = mState.mBufferManager->getBuffer(buffer);
2637*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setBufferRange(this, bufferObj, internalformat, offset, size));
2638*8975f5c5SAndroid Build Coastguard Worker }
2639*8975f5c5SAndroid Build Coastguard Worker 
getTexParameterfv(TextureType target,GLenum pname,GLfloat * params)2640*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameterfv(TextureType target, GLenum pname, GLfloat *params)
2641*8975f5c5SAndroid Build Coastguard Worker {
2642*8975f5c5SAndroid Build Coastguard Worker     const Texture *const texture = getTextureByType(target);
2643*8975f5c5SAndroid Build Coastguard Worker     QueryTexParameterfv(this, texture, pname, params);
2644*8975f5c5SAndroid Build Coastguard Worker }
2645*8975f5c5SAndroid Build Coastguard Worker 
getTexParameterfvRobust(TextureType target,GLenum pname,GLsizei bufSize,GLsizei * length,GLfloat * params)2646*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameterfvRobust(TextureType target,
2647*8975f5c5SAndroid Build Coastguard Worker                                       GLenum pname,
2648*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei bufSize,
2649*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei *length,
2650*8975f5c5SAndroid Build Coastguard Worker                                       GLfloat *params)
2651*8975f5c5SAndroid Build Coastguard Worker {
2652*8975f5c5SAndroid Build Coastguard Worker     getTexParameterfv(target, pname, params);
2653*8975f5c5SAndroid Build Coastguard Worker }
2654*8975f5c5SAndroid Build Coastguard Worker 
getTexParameteriv(TextureType target,GLenum pname,GLint * params)2655*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameteriv(TextureType target, GLenum pname, GLint *params)
2656*8975f5c5SAndroid Build Coastguard Worker {
2657*8975f5c5SAndroid Build Coastguard Worker     const Texture *const texture = getTextureByType(target);
2658*8975f5c5SAndroid Build Coastguard Worker     QueryTexParameteriv(this, texture, pname, params);
2659*8975f5c5SAndroid Build Coastguard Worker }
2660*8975f5c5SAndroid Build Coastguard Worker 
getTexParameterIiv(TextureType target,GLenum pname,GLint * params)2661*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameterIiv(TextureType target, GLenum pname, GLint *params)
2662*8975f5c5SAndroid Build Coastguard Worker {
2663*8975f5c5SAndroid Build Coastguard Worker     const Texture *const texture = getTextureByType(target);
2664*8975f5c5SAndroid Build Coastguard Worker     QueryTexParameterIiv(this, texture, pname, params);
2665*8975f5c5SAndroid Build Coastguard Worker }
2666*8975f5c5SAndroid Build Coastguard Worker 
getTexParameterIuiv(TextureType target,GLenum pname,GLuint * params)2667*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameterIuiv(TextureType target, GLenum pname, GLuint *params)
2668*8975f5c5SAndroid Build Coastguard Worker {
2669*8975f5c5SAndroid Build Coastguard Worker     const Texture *const texture = getTextureByType(target);
2670*8975f5c5SAndroid Build Coastguard Worker     QueryTexParameterIuiv(this, texture, pname, params);
2671*8975f5c5SAndroid Build Coastguard Worker }
2672*8975f5c5SAndroid Build Coastguard Worker 
getTexParameterivRobust(TextureType target,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)2673*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameterivRobust(TextureType target,
2674*8975f5c5SAndroid Build Coastguard Worker                                       GLenum pname,
2675*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei bufSize,
2676*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei *length,
2677*8975f5c5SAndroid Build Coastguard Worker                                       GLint *params)
2678*8975f5c5SAndroid Build Coastguard Worker {
2679*8975f5c5SAndroid Build Coastguard Worker     getTexParameteriv(target, pname, params);
2680*8975f5c5SAndroid Build Coastguard Worker }
2681*8975f5c5SAndroid Build Coastguard Worker 
getTexParameterIivRobust(TextureType target,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)2682*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameterIivRobust(TextureType target,
2683*8975f5c5SAndroid Build Coastguard Worker                                        GLenum pname,
2684*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei bufSize,
2685*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei *length,
2686*8975f5c5SAndroid Build Coastguard Worker                                        GLint *params)
2687*8975f5c5SAndroid Build Coastguard Worker {
2688*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2689*8975f5c5SAndroid Build Coastguard Worker }
2690*8975f5c5SAndroid Build Coastguard Worker 
getTexParameterIuivRobust(TextureType target,GLenum pname,GLsizei bufSize,GLsizei * length,GLuint * params)2691*8975f5c5SAndroid Build Coastguard Worker void Context::getTexParameterIuivRobust(TextureType target,
2692*8975f5c5SAndroid Build Coastguard Worker                                         GLenum pname,
2693*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
2694*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
2695*8975f5c5SAndroid Build Coastguard Worker                                         GLuint *params)
2696*8975f5c5SAndroid Build Coastguard Worker {
2697*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2698*8975f5c5SAndroid Build Coastguard Worker }
2699*8975f5c5SAndroid Build Coastguard Worker 
getTexLevelParameteriv(TextureTarget target,GLint level,GLenum pname,GLint * params)2700*8975f5c5SAndroid Build Coastguard Worker void Context::getTexLevelParameteriv(TextureTarget target, GLint level, GLenum pname, GLint *params)
2701*8975f5c5SAndroid Build Coastguard Worker {
2702*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
2703*8975f5c5SAndroid Build Coastguard Worker     QueryTexLevelParameteriv(texture, target, level, pname, params);
2704*8975f5c5SAndroid Build Coastguard Worker }
2705*8975f5c5SAndroid Build Coastguard Worker 
getTexLevelParameterivRobust(TextureTarget target,GLint level,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)2706*8975f5c5SAndroid Build Coastguard Worker void Context::getTexLevelParameterivRobust(TextureTarget target,
2707*8975f5c5SAndroid Build Coastguard Worker                                            GLint level,
2708*8975f5c5SAndroid Build Coastguard Worker                                            GLenum pname,
2709*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei bufSize,
2710*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei *length,
2711*8975f5c5SAndroid Build Coastguard Worker                                            GLint *params)
2712*8975f5c5SAndroid Build Coastguard Worker {
2713*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2714*8975f5c5SAndroid Build Coastguard Worker }
2715*8975f5c5SAndroid Build Coastguard Worker 
getTexLevelParameterfv(TextureTarget target,GLint level,GLenum pname,GLfloat * params)2716*8975f5c5SAndroid Build Coastguard Worker void Context::getTexLevelParameterfv(TextureTarget target,
2717*8975f5c5SAndroid Build Coastguard Worker                                      GLint level,
2718*8975f5c5SAndroid Build Coastguard Worker                                      GLenum pname,
2719*8975f5c5SAndroid Build Coastguard Worker                                      GLfloat *params)
2720*8975f5c5SAndroid Build Coastguard Worker {
2721*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
2722*8975f5c5SAndroid Build Coastguard Worker     QueryTexLevelParameterfv(texture, target, level, pname, params);
2723*8975f5c5SAndroid Build Coastguard Worker }
2724*8975f5c5SAndroid Build Coastguard Worker 
getTexLevelParameterfvRobust(TextureTarget target,GLint level,GLenum pname,GLsizei bufSize,GLsizei * length,GLfloat * params)2725*8975f5c5SAndroid Build Coastguard Worker void Context::getTexLevelParameterfvRobust(TextureTarget target,
2726*8975f5c5SAndroid Build Coastguard Worker                                            GLint level,
2727*8975f5c5SAndroid Build Coastguard Worker                                            GLenum pname,
2728*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei bufSize,
2729*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei *length,
2730*8975f5c5SAndroid Build Coastguard Worker                                            GLfloat *params)
2731*8975f5c5SAndroid Build Coastguard Worker {
2732*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2733*8975f5c5SAndroid Build Coastguard Worker }
2734*8975f5c5SAndroid Build Coastguard Worker 
texParameterf(TextureType target,GLenum pname,GLfloat param)2735*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterf(TextureType target, GLenum pname, GLfloat param)
2736*8975f5c5SAndroid Build Coastguard Worker {
2737*8975f5c5SAndroid Build Coastguard Worker     Texture *const texture = getTextureByType(target);
2738*8975f5c5SAndroid Build Coastguard Worker     SetTexParameterf(this, texture, pname, param);
2739*8975f5c5SAndroid Build Coastguard Worker }
2740*8975f5c5SAndroid Build Coastguard Worker 
texParameterfv(TextureType target,GLenum pname,const GLfloat * params)2741*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params)
2742*8975f5c5SAndroid Build Coastguard Worker {
2743*8975f5c5SAndroid Build Coastguard Worker     Texture *const texture = getTextureByType(target);
2744*8975f5c5SAndroid Build Coastguard Worker     SetTexParameterfv(this, texture, pname, params);
2745*8975f5c5SAndroid Build Coastguard Worker }
2746*8975f5c5SAndroid Build Coastguard Worker 
texParameterfvRobust(TextureType target,GLenum pname,GLsizei bufSize,const GLfloat * params)2747*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterfvRobust(TextureType target,
2748*8975f5c5SAndroid Build Coastguard Worker                                    GLenum pname,
2749*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
2750*8975f5c5SAndroid Build Coastguard Worker                                    const GLfloat *params)
2751*8975f5c5SAndroid Build Coastguard Worker {
2752*8975f5c5SAndroid Build Coastguard Worker     texParameterfv(target, pname, params);
2753*8975f5c5SAndroid Build Coastguard Worker }
2754*8975f5c5SAndroid Build Coastguard Worker 
texParameteri(TextureType target,GLenum pname,GLint param)2755*8975f5c5SAndroid Build Coastguard Worker void Context::texParameteri(TextureType target, GLenum pname, GLint param)
2756*8975f5c5SAndroid Build Coastguard Worker {
2757*8975f5c5SAndroid Build Coastguard Worker     // Some apps enable KHR_create_context_no_error but pass in an invalid texture type.
2758*8975f5c5SAndroid Build Coastguard Worker     // Workaround this by silently returning in such situations.
2759*8975f5c5SAndroid Build Coastguard Worker     if (target == TextureType::InvalidEnum)
2760*8975f5c5SAndroid Build Coastguard Worker     {
2761*8975f5c5SAndroid Build Coastguard Worker         return;
2762*8975f5c5SAndroid Build Coastguard Worker     }
2763*8975f5c5SAndroid Build Coastguard Worker 
2764*8975f5c5SAndroid Build Coastguard Worker     Texture *const texture = getTextureByType(target);
2765*8975f5c5SAndroid Build Coastguard Worker     SetTexParameteri(this, texture, pname, param);
2766*8975f5c5SAndroid Build Coastguard Worker }
2767*8975f5c5SAndroid Build Coastguard Worker 
texParameteriv(TextureType target,GLenum pname,const GLint * params)2768*8975f5c5SAndroid Build Coastguard Worker void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params)
2769*8975f5c5SAndroid Build Coastguard Worker {
2770*8975f5c5SAndroid Build Coastguard Worker     Texture *const texture = getTextureByType(target);
2771*8975f5c5SAndroid Build Coastguard Worker     SetTexParameteriv(this, texture, pname, params);
2772*8975f5c5SAndroid Build Coastguard Worker }
2773*8975f5c5SAndroid Build Coastguard Worker 
texParameterIiv(TextureType target,GLenum pname,const GLint * params)2774*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params)
2775*8975f5c5SAndroid Build Coastguard Worker {
2776*8975f5c5SAndroid Build Coastguard Worker     Texture *const texture = getTextureByType(target);
2777*8975f5c5SAndroid Build Coastguard Worker     SetTexParameterIiv(this, texture, pname, params);
2778*8975f5c5SAndroid Build Coastguard Worker }
2779*8975f5c5SAndroid Build Coastguard Worker 
texParameterIuiv(TextureType target,GLenum pname,const GLuint * params)2780*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params)
2781*8975f5c5SAndroid Build Coastguard Worker {
2782*8975f5c5SAndroid Build Coastguard Worker     Texture *const texture = getTextureByType(target);
2783*8975f5c5SAndroid Build Coastguard Worker     SetTexParameterIuiv(this, texture, pname, params);
2784*8975f5c5SAndroid Build Coastguard Worker }
2785*8975f5c5SAndroid Build Coastguard Worker 
texParameterivRobust(TextureType target,GLenum pname,GLsizei bufSize,const GLint * params)2786*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterivRobust(TextureType target,
2787*8975f5c5SAndroid Build Coastguard Worker                                    GLenum pname,
2788*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
2789*8975f5c5SAndroid Build Coastguard Worker                                    const GLint *params)
2790*8975f5c5SAndroid Build Coastguard Worker {
2791*8975f5c5SAndroid Build Coastguard Worker     texParameteriv(target, pname, params);
2792*8975f5c5SAndroid Build Coastguard Worker }
2793*8975f5c5SAndroid Build Coastguard Worker 
texParameterIivRobust(TextureType target,GLenum pname,GLsizei bufSize,const GLint * params)2794*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterIivRobust(TextureType target,
2795*8975f5c5SAndroid Build Coastguard Worker                                     GLenum pname,
2796*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei bufSize,
2797*8975f5c5SAndroid Build Coastguard Worker                                     const GLint *params)
2798*8975f5c5SAndroid Build Coastguard Worker {
2799*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2800*8975f5c5SAndroid Build Coastguard Worker }
2801*8975f5c5SAndroid Build Coastguard Worker 
texParameterIuivRobust(TextureType target,GLenum pname,GLsizei bufSize,const GLuint * params)2802*8975f5c5SAndroid Build Coastguard Worker void Context::texParameterIuivRobust(TextureType target,
2803*8975f5c5SAndroid Build Coastguard Worker                                      GLenum pname,
2804*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei bufSize,
2805*8975f5c5SAndroid Build Coastguard Worker                                      const GLuint *params)
2806*8975f5c5SAndroid Build Coastguard Worker {
2807*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
2808*8975f5c5SAndroid Build Coastguard Worker }
2809*8975f5c5SAndroid Build Coastguard Worker 
drawArraysInstanced(PrimitiveMode mode,GLint first,GLsizei count,GLsizei instanceCount)2810*8975f5c5SAndroid Build Coastguard Worker void Context::drawArraysInstanced(PrimitiveMode mode,
2811*8975f5c5SAndroid Build Coastguard Worker                                   GLint first,
2812*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei count,
2813*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei instanceCount)
2814*8975f5c5SAndroid Build Coastguard Worker {
2815*8975f5c5SAndroid Build Coastguard Worker     // No-op if count draws no primitives for given mode
2816*8975f5c5SAndroid Build Coastguard Worker     if (noopDrawInstanced(mode, count, instanceCount))
2817*8975f5c5SAndroid Build Coastguard Worker     {
2818*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
2819*8975f5c5SAndroid Build Coastguard Worker         return;
2820*8975f5c5SAndroid Build Coastguard Worker     }
2821*8975f5c5SAndroid Build Coastguard Worker 
2822*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2823*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
2824*8975f5c5SAndroid Build Coastguard Worker         mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount));
2825*8975f5c5SAndroid Build Coastguard Worker     MarkTransformFeedbackBufferUsage(this, count, instanceCount);
2826*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2827*8975f5c5SAndroid Build Coastguard Worker }
2828*8975f5c5SAndroid Build Coastguard Worker 
drawElementsInstanced(PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instances)2829*8975f5c5SAndroid Build Coastguard Worker void Context::drawElementsInstanced(PrimitiveMode mode,
2830*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei count,
2831*8975f5c5SAndroid Build Coastguard Worker                                     DrawElementsType type,
2832*8975f5c5SAndroid Build Coastguard Worker                                     const void *indices,
2833*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei instances)
2834*8975f5c5SAndroid Build Coastguard Worker {
2835*8975f5c5SAndroid Build Coastguard Worker     // No-op if count draws no primitives for given mode
2836*8975f5c5SAndroid Build Coastguard Worker     if (noopDrawInstanced(mode, count, instances))
2837*8975f5c5SAndroid Build Coastguard Worker     {
2838*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
2839*8975f5c5SAndroid Build Coastguard Worker         return;
2840*8975f5c5SAndroid Build Coastguard Worker     }
2841*8975f5c5SAndroid Build Coastguard Worker 
2842*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2843*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
2844*8975f5c5SAndroid Build Coastguard Worker         mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances));
2845*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2846*8975f5c5SAndroid Build Coastguard Worker }
2847*8975f5c5SAndroid Build Coastguard Worker 
drawElementsBaseVertex(PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)2848*8975f5c5SAndroid Build Coastguard Worker void Context::drawElementsBaseVertex(PrimitiveMode mode,
2849*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei count,
2850*8975f5c5SAndroid Build Coastguard Worker                                      DrawElementsType type,
2851*8975f5c5SAndroid Build Coastguard Worker                                      const void *indices,
2852*8975f5c5SAndroid Build Coastguard Worker                                      GLint basevertex)
2853*8975f5c5SAndroid Build Coastguard Worker {
2854*8975f5c5SAndroid Build Coastguard Worker     // No-op if count draws no primitives for given mode
2855*8975f5c5SAndroid Build Coastguard Worker     if (noopDraw(mode, count))
2856*8975f5c5SAndroid Build Coastguard Worker     {
2857*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
2858*8975f5c5SAndroid Build Coastguard Worker         return;
2859*8975f5c5SAndroid Build Coastguard Worker     }
2860*8975f5c5SAndroid Build Coastguard Worker 
2861*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2862*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
2863*8975f5c5SAndroid Build Coastguard Worker         mImplementation->drawElementsBaseVertex(this, mode, count, type, indices, basevertex));
2864*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2865*8975f5c5SAndroid Build Coastguard Worker }
2866*8975f5c5SAndroid Build Coastguard Worker 
drawElementsInstancedBaseVertex(PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instancecount,GLint basevertex)2867*8975f5c5SAndroid Build Coastguard Worker void Context::drawElementsInstancedBaseVertex(PrimitiveMode mode,
2868*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei count,
2869*8975f5c5SAndroid Build Coastguard Worker                                               DrawElementsType type,
2870*8975f5c5SAndroid Build Coastguard Worker                                               const void *indices,
2871*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei instancecount,
2872*8975f5c5SAndroid Build Coastguard Worker                                               GLint basevertex)
2873*8975f5c5SAndroid Build Coastguard Worker {
2874*8975f5c5SAndroid Build Coastguard Worker     // No-op if count draws no primitives for given mode
2875*8975f5c5SAndroid Build Coastguard Worker     if (noopDrawInstanced(mode, count, instancecount))
2876*8975f5c5SAndroid Build Coastguard Worker     {
2877*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
2878*8975f5c5SAndroid Build Coastguard Worker         return;
2879*8975f5c5SAndroid Build Coastguard Worker     }
2880*8975f5c5SAndroid Build Coastguard Worker 
2881*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2882*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstancedBaseVertex(
2883*8975f5c5SAndroid Build Coastguard Worker         this, mode, count, type, indices, instancecount, basevertex));
2884*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2885*8975f5c5SAndroid Build Coastguard Worker }
2886*8975f5c5SAndroid Build Coastguard Worker 
drawRangeElements(PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices)2887*8975f5c5SAndroid Build Coastguard Worker void Context::drawRangeElements(PrimitiveMode mode,
2888*8975f5c5SAndroid Build Coastguard Worker                                 GLuint start,
2889*8975f5c5SAndroid Build Coastguard Worker                                 GLuint end,
2890*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
2891*8975f5c5SAndroid Build Coastguard Worker                                 DrawElementsType type,
2892*8975f5c5SAndroid Build Coastguard Worker                                 const void *indices)
2893*8975f5c5SAndroid Build Coastguard Worker {
2894*8975f5c5SAndroid Build Coastguard Worker     // No-op if count draws no primitives for given mode
2895*8975f5c5SAndroid Build Coastguard Worker     if (noopDraw(mode, count))
2896*8975f5c5SAndroid Build Coastguard Worker     {
2897*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
2898*8975f5c5SAndroid Build Coastguard Worker         return;
2899*8975f5c5SAndroid Build Coastguard Worker     }
2900*8975f5c5SAndroid Build Coastguard Worker 
2901*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2902*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
2903*8975f5c5SAndroid Build Coastguard Worker         mImplementation->drawRangeElements(this, mode, start, end, count, type, indices));
2904*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2905*8975f5c5SAndroid Build Coastguard Worker }
2906*8975f5c5SAndroid Build Coastguard Worker 
drawRangeElementsBaseVertex(PrimitiveMode mode,GLuint start,GLuint end,GLsizei count,DrawElementsType type,const void * indices,GLint basevertex)2907*8975f5c5SAndroid Build Coastguard Worker void Context::drawRangeElementsBaseVertex(PrimitiveMode mode,
2908*8975f5c5SAndroid Build Coastguard Worker                                           GLuint start,
2909*8975f5c5SAndroid Build Coastguard Worker                                           GLuint end,
2910*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei count,
2911*8975f5c5SAndroid Build Coastguard Worker                                           DrawElementsType type,
2912*8975f5c5SAndroid Build Coastguard Worker                                           const void *indices,
2913*8975f5c5SAndroid Build Coastguard Worker                                           GLint basevertex)
2914*8975f5c5SAndroid Build Coastguard Worker {
2915*8975f5c5SAndroid Build Coastguard Worker     // No-op if count draws no primitives for given mode
2916*8975f5c5SAndroid Build Coastguard Worker     if (noopDraw(mode, count))
2917*8975f5c5SAndroid Build Coastguard Worker     {
2918*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
2919*8975f5c5SAndroid Build Coastguard Worker         return;
2920*8975f5c5SAndroid Build Coastguard Worker     }
2921*8975f5c5SAndroid Build Coastguard Worker 
2922*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2923*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->drawRangeElementsBaseVertex(this, mode, start, end, count,
2924*8975f5c5SAndroid Build Coastguard Worker                                                                    type, indices, basevertex));
2925*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2926*8975f5c5SAndroid Build Coastguard Worker }
2927*8975f5c5SAndroid Build Coastguard Worker 
drawArraysIndirect(PrimitiveMode mode,const void * indirect)2928*8975f5c5SAndroid Build Coastguard Worker void Context::drawArraysIndirect(PrimitiveMode mode, const void *indirect)
2929*8975f5c5SAndroid Build Coastguard Worker {
2930*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2931*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect));
2932*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2933*8975f5c5SAndroid Build Coastguard Worker }
2934*8975f5c5SAndroid Build Coastguard Worker 
drawElementsIndirect(PrimitiveMode mode,DrawElementsType type,const void * indirect)2935*8975f5c5SAndroid Build Coastguard Worker void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, const void *indirect)
2936*8975f5c5SAndroid Build Coastguard Worker {
2937*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
2938*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect));
2939*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
2940*8975f5c5SAndroid Build Coastguard Worker }
2941*8975f5c5SAndroid Build Coastguard Worker 
flush()2942*8975f5c5SAndroid Build Coastguard Worker void Context::flush()
2943*8975f5c5SAndroid Build Coastguard Worker {
2944*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->flush(this));
2945*8975f5c5SAndroid Build Coastguard Worker }
2946*8975f5c5SAndroid Build Coastguard Worker 
finish()2947*8975f5c5SAndroid Build Coastguard Worker void Context::finish()
2948*8975f5c5SAndroid Build Coastguard Worker {
2949*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->finish(this));
2950*8975f5c5SAndroid Build Coastguard Worker }
2951*8975f5c5SAndroid Build Coastguard Worker 
insertEventMarker(GLsizei length,const char * marker)2952*8975f5c5SAndroid Build Coastguard Worker void Context::insertEventMarker(GLsizei length, const char *marker)
2953*8975f5c5SAndroid Build Coastguard Worker {
2954*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mImplementation);
2955*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->insertEventMarker(length, marker));
2956*8975f5c5SAndroid Build Coastguard Worker }
2957*8975f5c5SAndroid Build Coastguard Worker 
pushGroupMarker(GLsizei length,const char * marker)2958*8975f5c5SAndroid Build Coastguard Worker void Context::pushGroupMarker(GLsizei length, const char *marker)
2959*8975f5c5SAndroid Build Coastguard Worker {
2960*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mImplementation);
2961*8975f5c5SAndroid Build Coastguard Worker 
2962*8975f5c5SAndroid Build Coastguard Worker     if (marker == nullptr)
2963*8975f5c5SAndroid Build Coastguard Worker     {
2964*8975f5c5SAndroid Build Coastguard Worker         // From the EXT_debug_marker spec,
2965*8975f5c5SAndroid Build Coastguard Worker         // "If <marker> is null then an empty string is pushed on the stack."
2966*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->pushGroupMarker(length, ""));
2967*8975f5c5SAndroid Build Coastguard Worker     }
2968*8975f5c5SAndroid Build Coastguard Worker     else
2969*8975f5c5SAndroid Build Coastguard Worker     {
2970*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->pushGroupMarker(length, marker));
2971*8975f5c5SAndroid Build Coastguard Worker     }
2972*8975f5c5SAndroid Build Coastguard Worker }
2973*8975f5c5SAndroid Build Coastguard Worker 
popGroupMarker()2974*8975f5c5SAndroid Build Coastguard Worker void Context::popGroupMarker()
2975*8975f5c5SAndroid Build Coastguard Worker {
2976*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mImplementation);
2977*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->popGroupMarker());
2978*8975f5c5SAndroid Build Coastguard Worker }
2979*8975f5c5SAndroid Build Coastguard Worker 
bindUniformLocation(ShaderProgramID program,UniformLocation location,const GLchar * name)2980*8975f5c5SAndroid Build Coastguard Worker void Context::bindUniformLocation(ShaderProgramID program,
2981*8975f5c5SAndroid Build Coastguard Worker                                   UniformLocation location,
2982*8975f5c5SAndroid Build Coastguard Worker                                   const GLchar *name)
2983*8975f5c5SAndroid Build Coastguard Worker {
2984*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
2985*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
2986*8975f5c5SAndroid Build Coastguard Worker 
2987*8975f5c5SAndroid Build Coastguard Worker     programObject->bindUniformLocation(this, location, name);
2988*8975f5c5SAndroid Build Coastguard Worker }
2989*8975f5c5SAndroid Build Coastguard Worker 
getProgramResourceIndex(ShaderProgramID program,GLenum programInterface,const GLchar * name)2990*8975f5c5SAndroid Build Coastguard Worker GLuint Context::getProgramResourceIndex(ShaderProgramID program,
2991*8975f5c5SAndroid Build Coastguard Worker                                         GLenum programInterface,
2992*8975f5c5SAndroid Build Coastguard Worker                                         const GLchar *name)
2993*8975f5c5SAndroid Build Coastguard Worker {
2994*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
2995*8975f5c5SAndroid Build Coastguard Worker     return QueryProgramResourceIndex(programObject, programInterface, name);
2996*8975f5c5SAndroid Build Coastguard Worker }
2997*8975f5c5SAndroid Build Coastguard Worker 
getProgramResourceName(ShaderProgramID program,GLenum programInterface,GLuint index,GLsizei bufSize,GLsizei * length,GLchar * name)2998*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramResourceName(ShaderProgramID program,
2999*8975f5c5SAndroid Build Coastguard Worker                                      GLenum programInterface,
3000*8975f5c5SAndroid Build Coastguard Worker                                      GLuint index,
3001*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei bufSize,
3002*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei *length,
3003*8975f5c5SAndroid Build Coastguard Worker                                      GLchar *name)
3004*8975f5c5SAndroid Build Coastguard Worker {
3005*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
3006*8975f5c5SAndroid Build Coastguard Worker     QueryProgramResourceName(this, programObject, programInterface, index, bufSize, length, name);
3007*8975f5c5SAndroid Build Coastguard Worker }
3008*8975f5c5SAndroid Build Coastguard Worker 
getProgramResourceLocation(ShaderProgramID program,GLenum programInterface,const GLchar * name)3009*8975f5c5SAndroid Build Coastguard Worker GLint Context::getProgramResourceLocation(ShaderProgramID program,
3010*8975f5c5SAndroid Build Coastguard Worker                                           GLenum programInterface,
3011*8975f5c5SAndroid Build Coastguard Worker                                           const GLchar *name)
3012*8975f5c5SAndroid Build Coastguard Worker {
3013*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
3014*8975f5c5SAndroid Build Coastguard Worker     return QueryProgramResourceLocation(programObject, programInterface, name);
3015*8975f5c5SAndroid Build Coastguard Worker }
3016*8975f5c5SAndroid Build Coastguard Worker 
getProgramResourceiv(ShaderProgramID program,GLenum programInterface,GLuint index,GLsizei propCount,const GLenum * props,GLsizei bufSize,GLsizei * length,GLint * params)3017*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramResourceiv(ShaderProgramID program,
3018*8975f5c5SAndroid Build Coastguard Worker                                    GLenum programInterface,
3019*8975f5c5SAndroid Build Coastguard Worker                                    GLuint index,
3020*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei propCount,
3021*8975f5c5SAndroid Build Coastguard Worker                                    const GLenum *props,
3022*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
3023*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei *length,
3024*8975f5c5SAndroid Build Coastguard Worker                                    GLint *params)
3025*8975f5c5SAndroid Build Coastguard Worker {
3026*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
3027*8975f5c5SAndroid Build Coastguard Worker     QueryProgramResourceiv(programObject, programInterface, {index}, propCount, props, bufSize,
3028*8975f5c5SAndroid Build Coastguard Worker                            length, params);
3029*8975f5c5SAndroid Build Coastguard Worker }
3030*8975f5c5SAndroid Build Coastguard Worker 
getProgramInterfaceiv(ShaderProgramID program,GLenum programInterface,GLenum pname,GLint * params)3031*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramInterfaceiv(ShaderProgramID program,
3032*8975f5c5SAndroid Build Coastguard Worker                                     GLenum programInterface,
3033*8975f5c5SAndroid Build Coastguard Worker                                     GLenum pname,
3034*8975f5c5SAndroid Build Coastguard Worker                                     GLint *params)
3035*8975f5c5SAndroid Build Coastguard Worker {
3036*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
3037*8975f5c5SAndroid Build Coastguard Worker     QueryProgramInterfaceiv(programObject, programInterface, pname, params);
3038*8975f5c5SAndroid Build Coastguard Worker }
3039*8975f5c5SAndroid Build Coastguard Worker 
getProgramInterfaceivRobust(ShaderProgramID program,GLenum programInterface,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)3040*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramInterfaceivRobust(ShaderProgramID program,
3041*8975f5c5SAndroid Build Coastguard Worker                                           GLenum programInterface,
3042*8975f5c5SAndroid Build Coastguard Worker                                           GLenum pname,
3043*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei bufSize,
3044*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei *length,
3045*8975f5c5SAndroid Build Coastguard Worker                                           GLint *params)
3046*8975f5c5SAndroid Build Coastguard Worker {
3047*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
3048*8975f5c5SAndroid Build Coastguard Worker }
3049*8975f5c5SAndroid Build Coastguard Worker 
handleError(GLenum errorCode,const char * message,const char * file,const char * function,unsigned int line)3050*8975f5c5SAndroid Build Coastguard Worker void Context::handleError(GLenum errorCode,
3051*8975f5c5SAndroid Build Coastguard Worker                           const char *message,
3052*8975f5c5SAndroid Build Coastguard Worker                           const char *file,
3053*8975f5c5SAndroid Build Coastguard Worker                           const char *function,
3054*8975f5c5SAndroid Build Coastguard Worker                           unsigned int line)
3055*8975f5c5SAndroid Build Coastguard Worker {
3056*8975f5c5SAndroid Build Coastguard Worker     mErrors.handleError(errorCode, message, file, function, line);
3057*8975f5c5SAndroid Build Coastguard Worker }
3058*8975f5c5SAndroid Build Coastguard Worker 
3059*8975f5c5SAndroid Build Coastguard Worker // Get one of the recorded errors and clear its flag, if any.
3060*8975f5c5SAndroid Build Coastguard Worker // [OpenGL ES 2.0.24] section 2.5 page 13.
getError()3061*8975f5c5SAndroid Build Coastguard Worker GLenum Context::getError()
3062*8975f5c5SAndroid Build Coastguard Worker {
3063*8975f5c5SAndroid Build Coastguard Worker     if (mErrors.empty())
3064*8975f5c5SAndroid Build Coastguard Worker     {
3065*8975f5c5SAndroid Build Coastguard Worker         return GL_NO_ERROR;
3066*8975f5c5SAndroid Build Coastguard Worker     }
3067*8975f5c5SAndroid Build Coastguard Worker     else
3068*8975f5c5SAndroid Build Coastguard Worker     {
3069*8975f5c5SAndroid Build Coastguard Worker         return mErrors.popError();
3070*8975f5c5SAndroid Build Coastguard Worker     }
3071*8975f5c5SAndroid Build Coastguard Worker }
3072*8975f5c5SAndroid Build Coastguard Worker 
getGraphicsResetStatus()3073*8975f5c5SAndroid Build Coastguard Worker GLenum Context::getGraphicsResetStatus()
3074*8975f5c5SAndroid Build Coastguard Worker {
3075*8975f5c5SAndroid Build Coastguard Worker     return mErrors.getGraphicsResetStatus(mImplementation.get());
3076*8975f5c5SAndroid Build Coastguard Worker }
3077*8975f5c5SAndroid Build Coastguard Worker 
isResetNotificationEnabled() const3078*8975f5c5SAndroid Build Coastguard Worker bool Context::isResetNotificationEnabled() const
3079*8975f5c5SAndroid Build Coastguard Worker {
3080*8975f5c5SAndroid Build Coastguard Worker     return mErrors.getResetStrategy() == GL_LOSE_CONTEXT_ON_RESET_EXT;
3081*8975f5c5SAndroid Build Coastguard Worker }
3082*8975f5c5SAndroid Build Coastguard Worker 
getRenderBuffer() const3083*8975f5c5SAndroid Build Coastguard Worker EGLenum Context::getRenderBuffer() const
3084*8975f5c5SAndroid Build Coastguard Worker {
3085*8975f5c5SAndroid Build Coastguard Worker     const Framebuffer *framebuffer =
3086*8975f5c5SAndroid Build Coastguard Worker         mState.mFramebufferManager->getFramebuffer(Framebuffer::kDefaultDrawFramebufferHandle);
3087*8975f5c5SAndroid Build Coastguard Worker     if (framebuffer == nullptr)
3088*8975f5c5SAndroid Build Coastguard Worker     {
3089*8975f5c5SAndroid Build Coastguard Worker         return EGL_NONE;
3090*8975f5c5SAndroid Build Coastguard Worker     }
3091*8975f5c5SAndroid Build Coastguard Worker 
3092*8975f5c5SAndroid Build Coastguard Worker     const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK);
3093*8975f5c5SAndroid Build Coastguard Worker     ASSERT(backAttachment != nullptr);
3094*8975f5c5SAndroid Build Coastguard Worker     return backAttachment->getSurface()->getRenderBuffer();
3095*8975f5c5SAndroid Build Coastguard Worker }
3096*8975f5c5SAndroid Build Coastguard Worker 
checkVertexArrayAllocation(VertexArrayID vertexArrayHandle)3097*8975f5c5SAndroid Build Coastguard Worker VertexArray *Context::checkVertexArrayAllocation(VertexArrayID vertexArrayHandle)
3098*8975f5c5SAndroid Build Coastguard Worker {
3099*8975f5c5SAndroid Build Coastguard Worker     // Only called after a prior call to Gen.
3100*8975f5c5SAndroid Build Coastguard Worker     VertexArray *vertexArray = getVertexArray(vertexArrayHandle);
3101*8975f5c5SAndroid Build Coastguard Worker     if (!vertexArray)
3102*8975f5c5SAndroid Build Coastguard Worker     {
3103*8975f5c5SAndroid Build Coastguard Worker         vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle,
3104*8975f5c5SAndroid Build Coastguard Worker                                       mState.getCaps().maxVertexAttributes,
3105*8975f5c5SAndroid Build Coastguard Worker                                       mState.getCaps().maxVertexAttribBindings);
3106*8975f5c5SAndroid Build Coastguard Worker         vertexArray->setBufferAccessValidationEnabled(mBufferAccessValidationEnabled);
3107*8975f5c5SAndroid Build Coastguard Worker 
3108*8975f5c5SAndroid Build Coastguard Worker         mVertexArrayMap.assign(vertexArrayHandle, vertexArray);
3109*8975f5c5SAndroid Build Coastguard Worker     }
3110*8975f5c5SAndroid Build Coastguard Worker 
3111*8975f5c5SAndroid Build Coastguard Worker     return vertexArray;
3112*8975f5c5SAndroid Build Coastguard Worker }
3113*8975f5c5SAndroid Build Coastguard Worker 
checkTransformFeedbackAllocation(TransformFeedbackID transformFeedbackHandle)3114*8975f5c5SAndroid Build Coastguard Worker TransformFeedback *Context::checkTransformFeedbackAllocation(
3115*8975f5c5SAndroid Build Coastguard Worker     TransformFeedbackID transformFeedbackHandle)
3116*8975f5c5SAndroid Build Coastguard Worker {
3117*8975f5c5SAndroid Build Coastguard Worker     // Only called after a prior call to Gen.
3118*8975f5c5SAndroid Build Coastguard Worker     TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle);
3119*8975f5c5SAndroid Build Coastguard Worker     if (!transformFeedback)
3120*8975f5c5SAndroid Build Coastguard Worker     {
3121*8975f5c5SAndroid Build Coastguard Worker         transformFeedback =
3122*8975f5c5SAndroid Build Coastguard Worker             new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mState.getCaps());
3123*8975f5c5SAndroid Build Coastguard Worker         transformFeedback->addRef();
3124*8975f5c5SAndroid Build Coastguard Worker         mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback);
3125*8975f5c5SAndroid Build Coastguard Worker     }
3126*8975f5c5SAndroid Build Coastguard Worker 
3127*8975f5c5SAndroid Build Coastguard Worker     return transformFeedback;
3128*8975f5c5SAndroid Build Coastguard Worker }
3129*8975f5c5SAndroid Build Coastguard Worker 
isVertexArrayGenerated(VertexArrayID vertexArray) const3130*8975f5c5SAndroid Build Coastguard Worker bool Context::isVertexArrayGenerated(VertexArrayID vertexArray) const
3131*8975f5c5SAndroid Build Coastguard Worker {
3132*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mVertexArrayMap.contains({0}));
3133*8975f5c5SAndroid Build Coastguard Worker     return mVertexArrayMap.contains(vertexArray);
3134*8975f5c5SAndroid Build Coastguard Worker }
3135*8975f5c5SAndroid Build Coastguard Worker 
isTransformFeedbackGenerated(TransformFeedbackID transformFeedback) const3136*8975f5c5SAndroid Build Coastguard Worker bool Context::isTransformFeedbackGenerated(TransformFeedbackID transformFeedback) const
3137*8975f5c5SAndroid Build Coastguard Worker {
3138*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mTransformFeedbackMap.contains({0}));
3139*8975f5c5SAndroid Build Coastguard Worker     return mTransformFeedbackMap.contains(transformFeedback);
3140*8975f5c5SAndroid Build Coastguard Worker }
3141*8975f5c5SAndroid Build Coastguard Worker 
detachTexture(TextureID texture)3142*8975f5c5SAndroid Build Coastguard Worker void Context::detachTexture(TextureID texture)
3143*8975f5c5SAndroid Build Coastguard Worker {
3144*8975f5c5SAndroid Build Coastguard Worker     // The State cannot unbind image observers itself, they are owned by the Context
3145*8975f5c5SAndroid Build Coastguard Worker     Texture *tex = mState.mTextureManager->getTexture(texture);
3146*8975f5c5SAndroid Build Coastguard Worker     for (auto &imageBinding : mImageObserverBindings)
3147*8975f5c5SAndroid Build Coastguard Worker     {
3148*8975f5c5SAndroid Build Coastguard Worker         if (imageBinding.getSubject() == tex)
3149*8975f5c5SAndroid Build Coastguard Worker         {
3150*8975f5c5SAndroid Build Coastguard Worker             imageBinding.reset();
3151*8975f5c5SAndroid Build Coastguard Worker         }
3152*8975f5c5SAndroid Build Coastguard Worker     }
3153*8975f5c5SAndroid Build Coastguard Worker 
3154*8975f5c5SAndroid Build Coastguard Worker     // Simple pass-through to State's detachTexture method, as textures do not require
3155*8975f5c5SAndroid Build Coastguard Worker     // allocation map management either here or in the resource manager at detach time.
3156*8975f5c5SAndroid Build Coastguard Worker     // Zero textures are held by the Context, and we don't attempt to request them from
3157*8975f5c5SAndroid Build Coastguard Worker     // the State.
3158*8975f5c5SAndroid Build Coastguard Worker     mState.detachTexture(this, mZeroTextures, texture);
3159*8975f5c5SAndroid Build Coastguard Worker }
3160*8975f5c5SAndroid Build Coastguard Worker 
detachBuffer(Buffer * buffer)3161*8975f5c5SAndroid Build Coastguard Worker void Context::detachBuffer(Buffer *buffer)
3162*8975f5c5SAndroid Build Coastguard Worker {
3163*8975f5c5SAndroid Build Coastguard Worker     // Simple pass-through to State's detachBuffer method, since
3164*8975f5c5SAndroid Build Coastguard Worker     // only buffer attachments to container objects that are bound to the current context
3165*8975f5c5SAndroid Build Coastguard Worker     // should be detached. And all those are available in State.
3166*8975f5c5SAndroid Build Coastguard Worker 
3167*8975f5c5SAndroid Build Coastguard Worker     // [OpenGL ES 3.2] section 5.1.2 page 45:
3168*8975f5c5SAndroid Build Coastguard Worker     // Attachments to unbound container objects, such as
3169*8975f5c5SAndroid Build Coastguard Worker     // deletion of a buffer attached to a vertex array object which is not bound to the context,
3170*8975f5c5SAndroid Build Coastguard Worker     // are not affected and continue to act as references on the deleted object
3171*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mState.detachBuffer(this, buffer));
3172*8975f5c5SAndroid Build Coastguard Worker }
3173*8975f5c5SAndroid Build Coastguard Worker 
detachFramebuffer(FramebufferID framebuffer)3174*8975f5c5SAndroid Build Coastguard Worker void Context::detachFramebuffer(FramebufferID framebuffer)
3175*8975f5c5SAndroid Build Coastguard Worker {
3176*8975f5c5SAndroid Build Coastguard Worker     // Framebuffer detachment is handled by Context, because 0 is a valid
3177*8975f5c5SAndroid Build Coastguard Worker     // Framebuffer object, and a pointer to it must be passed from Context
3178*8975f5c5SAndroid Build Coastguard Worker     // to State at binding time.
3179*8975f5c5SAndroid Build Coastguard Worker 
3180*8975f5c5SAndroid Build Coastguard Worker     // [OpenGL ES 2.0.24] section 4.4 page 107:
3181*8975f5c5SAndroid Build Coastguard Worker     // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as
3182*8975f5c5SAndroid Build Coastguard Worker     // though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of
3183*8975f5c5SAndroid Build Coastguard Worker     // zero.
3184*8975f5c5SAndroid Build Coastguard Worker 
3185*8975f5c5SAndroid Build Coastguard Worker     if (mState.removeReadFramebufferBinding(framebuffer) && framebuffer.value != 0)
3186*8975f5c5SAndroid Build Coastguard Worker     {
3187*8975f5c5SAndroid Build Coastguard Worker         bindReadFramebuffer({0});
3188*8975f5c5SAndroid Build Coastguard Worker     }
3189*8975f5c5SAndroid Build Coastguard Worker 
3190*8975f5c5SAndroid Build Coastguard Worker     if (mState.removeDrawFramebufferBinding(framebuffer) && framebuffer.value != 0)
3191*8975f5c5SAndroid Build Coastguard Worker     {
3192*8975f5c5SAndroid Build Coastguard Worker         bindDrawFramebuffer({0});
3193*8975f5c5SAndroid Build Coastguard Worker     }
3194*8975f5c5SAndroid Build Coastguard Worker }
3195*8975f5c5SAndroid Build Coastguard Worker 
detachRenderbuffer(RenderbufferID renderbuffer)3196*8975f5c5SAndroid Build Coastguard Worker void Context::detachRenderbuffer(RenderbufferID renderbuffer)
3197*8975f5c5SAndroid Build Coastguard Worker {
3198*8975f5c5SAndroid Build Coastguard Worker     mState.detachRenderbuffer(this, renderbuffer);
3199*8975f5c5SAndroid Build Coastguard Worker }
3200*8975f5c5SAndroid Build Coastguard Worker 
detachVertexArray(VertexArrayID vertexArray)3201*8975f5c5SAndroid Build Coastguard Worker void Context::detachVertexArray(VertexArrayID vertexArray)
3202*8975f5c5SAndroid Build Coastguard Worker {
3203*8975f5c5SAndroid Build Coastguard Worker     // Vertex array detachment is handled by Context, because 0 is a valid
3204*8975f5c5SAndroid Build Coastguard Worker     // VAO, and a pointer to it must be passed from Context to State at
3205*8975f5c5SAndroid Build Coastguard Worker     // binding time.
3206*8975f5c5SAndroid Build Coastguard Worker 
3207*8975f5c5SAndroid Build Coastguard Worker     // [OpenGL ES 3.0.2] section 2.10 page 43:
3208*8975f5c5SAndroid Build Coastguard Worker     // If a vertex array object that is currently bound is deleted, the binding
3209*8975f5c5SAndroid Build Coastguard Worker     // for that object reverts to zero and the default vertex array becomes current.
3210*8975f5c5SAndroid Build Coastguard Worker     if (mState.removeVertexArrayBinding(this, vertexArray))
3211*8975f5c5SAndroid Build Coastguard Worker     {
3212*8975f5c5SAndroid Build Coastguard Worker         bindVertexArray({0});
3213*8975f5c5SAndroid Build Coastguard Worker     }
3214*8975f5c5SAndroid Build Coastguard Worker }
3215*8975f5c5SAndroid Build Coastguard Worker 
detachTransformFeedback(TransformFeedbackID transformFeedback)3216*8975f5c5SAndroid Build Coastguard Worker void Context::detachTransformFeedback(TransformFeedbackID transformFeedback)
3217*8975f5c5SAndroid Build Coastguard Worker {
3218*8975f5c5SAndroid Build Coastguard Worker     // Transform feedback detachment is handled by Context, because 0 is a valid
3219*8975f5c5SAndroid Build Coastguard Worker     // transform feedback, and a pointer to it must be passed from Context to State at
3220*8975f5c5SAndroid Build Coastguard Worker     // binding time.
3221*8975f5c5SAndroid Build Coastguard Worker 
3222*8975f5c5SAndroid Build Coastguard Worker     // The OpenGL specification doesn't mention what should happen when the currently bound
3223*8975f5c5SAndroid Build Coastguard Worker     // transform feedback object is deleted. Since it is a container object, we treat it like
3224*8975f5c5SAndroid Build Coastguard Worker     // VAOs and FBOs and set the current bound transform feedback back to 0.
3225*8975f5c5SAndroid Build Coastguard Worker     if (mState.removeTransformFeedbackBinding(this, transformFeedback))
3226*8975f5c5SAndroid Build Coastguard Worker     {
3227*8975f5c5SAndroid Build Coastguard Worker         bindTransformFeedback(GL_TRANSFORM_FEEDBACK, {0});
3228*8975f5c5SAndroid Build Coastguard Worker         mStateCache.onActiveTransformFeedbackChange(this);
3229*8975f5c5SAndroid Build Coastguard Worker     }
3230*8975f5c5SAndroid Build Coastguard Worker }
3231*8975f5c5SAndroid Build Coastguard Worker 
detachSampler(SamplerID sampler)3232*8975f5c5SAndroid Build Coastguard Worker void Context::detachSampler(SamplerID sampler)
3233*8975f5c5SAndroid Build Coastguard Worker {
3234*8975f5c5SAndroid Build Coastguard Worker     mState.detachSampler(this, sampler);
3235*8975f5c5SAndroid Build Coastguard Worker }
3236*8975f5c5SAndroid Build Coastguard Worker 
detachProgramPipeline(ProgramPipelineID pipeline)3237*8975f5c5SAndroid Build Coastguard Worker void Context::detachProgramPipeline(ProgramPipelineID pipeline)
3238*8975f5c5SAndroid Build Coastguard Worker {
3239*8975f5c5SAndroid Build Coastguard Worker     mState.detachProgramPipeline(this, pipeline);
3240*8975f5c5SAndroid Build Coastguard Worker }
3241*8975f5c5SAndroid Build Coastguard Worker 
vertexAttribDivisor(GLuint index,GLuint divisor)3242*8975f5c5SAndroid Build Coastguard Worker void Context::vertexAttribDivisor(GLuint index, GLuint divisor)
3243*8975f5c5SAndroid Build Coastguard Worker {
3244*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexAttribDivisor(this, index, divisor);
3245*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayStateChange(this);
3246*8975f5c5SAndroid Build Coastguard Worker }
3247*8975f5c5SAndroid Build Coastguard Worker 
samplerParameteri(SamplerID sampler,GLenum pname,GLint param)3248*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameteri(SamplerID sampler, GLenum pname, GLint param)
3249*8975f5c5SAndroid Build Coastguard Worker {
3250*8975f5c5SAndroid Build Coastguard Worker     Sampler *const samplerObject =
3251*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3252*8975f5c5SAndroid Build Coastguard Worker     SetSamplerParameteri(this, samplerObject, pname, param);
3253*8975f5c5SAndroid Build Coastguard Worker }
3254*8975f5c5SAndroid Build Coastguard Worker 
samplerParameteriv(SamplerID sampler,GLenum pname,const GLint * param)3255*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameteriv(SamplerID sampler, GLenum pname, const GLint *param)
3256*8975f5c5SAndroid Build Coastguard Worker {
3257*8975f5c5SAndroid Build Coastguard Worker     Sampler *const samplerObject =
3258*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3259*8975f5c5SAndroid Build Coastguard Worker     SetSamplerParameteriv(this, samplerObject, pname, param);
3260*8975f5c5SAndroid Build Coastguard Worker }
3261*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterIiv(SamplerID sampler,GLenum pname,const GLint * param)3262*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterIiv(SamplerID sampler, GLenum pname, const GLint *param)
3263*8975f5c5SAndroid Build Coastguard Worker {
3264*8975f5c5SAndroid Build Coastguard Worker     Sampler *const samplerObject =
3265*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3266*8975f5c5SAndroid Build Coastguard Worker     SetSamplerParameterIiv(this, samplerObject, pname, param);
3267*8975f5c5SAndroid Build Coastguard Worker }
3268*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterIuiv(SamplerID sampler,GLenum pname,const GLuint * param)3269*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterIuiv(SamplerID sampler, GLenum pname, const GLuint *param)
3270*8975f5c5SAndroid Build Coastguard Worker {
3271*8975f5c5SAndroid Build Coastguard Worker     Sampler *const samplerObject =
3272*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3273*8975f5c5SAndroid Build Coastguard Worker     SetSamplerParameterIuiv(this, samplerObject, pname, param);
3274*8975f5c5SAndroid Build Coastguard Worker }
3275*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterivRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,const GLint * param)3276*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterivRobust(SamplerID sampler,
3277*8975f5c5SAndroid Build Coastguard Worker                                        GLenum pname,
3278*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei bufSize,
3279*8975f5c5SAndroid Build Coastguard Worker                                        const GLint *param)
3280*8975f5c5SAndroid Build Coastguard Worker {
3281*8975f5c5SAndroid Build Coastguard Worker     samplerParameteriv(sampler, pname, param);
3282*8975f5c5SAndroid Build Coastguard Worker }
3283*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterIivRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,const GLint * param)3284*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterIivRobust(SamplerID sampler,
3285*8975f5c5SAndroid Build Coastguard Worker                                         GLenum pname,
3286*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
3287*8975f5c5SAndroid Build Coastguard Worker                                         const GLint *param)
3288*8975f5c5SAndroid Build Coastguard Worker {
3289*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
3290*8975f5c5SAndroid Build Coastguard Worker }
3291*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterIuivRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,const GLuint * param)3292*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterIuivRobust(SamplerID sampler,
3293*8975f5c5SAndroid Build Coastguard Worker                                          GLenum pname,
3294*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei bufSize,
3295*8975f5c5SAndroid Build Coastguard Worker                                          const GLuint *param)
3296*8975f5c5SAndroid Build Coastguard Worker {
3297*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
3298*8975f5c5SAndroid Build Coastguard Worker }
3299*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterf(SamplerID sampler,GLenum pname,GLfloat param)3300*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterf(SamplerID sampler, GLenum pname, GLfloat param)
3301*8975f5c5SAndroid Build Coastguard Worker {
3302*8975f5c5SAndroid Build Coastguard Worker     Sampler *const samplerObject =
3303*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3304*8975f5c5SAndroid Build Coastguard Worker     SetSamplerParameterf(this, samplerObject, pname, param);
3305*8975f5c5SAndroid Build Coastguard Worker }
3306*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterfv(SamplerID sampler,GLenum pname,const GLfloat * param)3307*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterfv(SamplerID sampler, GLenum pname, const GLfloat *param)
3308*8975f5c5SAndroid Build Coastguard Worker {
3309*8975f5c5SAndroid Build Coastguard Worker     Sampler *const samplerObject =
3310*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3311*8975f5c5SAndroid Build Coastguard Worker     SetSamplerParameterfv(this, samplerObject, pname, param);
3312*8975f5c5SAndroid Build Coastguard Worker }
3313*8975f5c5SAndroid Build Coastguard Worker 
samplerParameterfvRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,const GLfloat * param)3314*8975f5c5SAndroid Build Coastguard Worker void Context::samplerParameterfvRobust(SamplerID sampler,
3315*8975f5c5SAndroid Build Coastguard Worker                                        GLenum pname,
3316*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei bufSize,
3317*8975f5c5SAndroid Build Coastguard Worker                                        const GLfloat *param)
3318*8975f5c5SAndroid Build Coastguard Worker {
3319*8975f5c5SAndroid Build Coastguard Worker     samplerParameterfv(sampler, pname, param);
3320*8975f5c5SAndroid Build Coastguard Worker }
3321*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameteriv(SamplerID sampler,GLenum pname,GLint * params)3322*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameteriv(SamplerID sampler, GLenum pname, GLint *params)
3323*8975f5c5SAndroid Build Coastguard Worker {
3324*8975f5c5SAndroid Build Coastguard Worker     const Sampler *const samplerObject =
3325*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3326*8975f5c5SAndroid Build Coastguard Worker     QuerySamplerParameteriv(samplerObject, pname, params);
3327*8975f5c5SAndroid Build Coastguard Worker }
3328*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameterIiv(SamplerID sampler,GLenum pname,GLint * params)3329*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameterIiv(SamplerID sampler, GLenum pname, GLint *params)
3330*8975f5c5SAndroid Build Coastguard Worker {
3331*8975f5c5SAndroid Build Coastguard Worker     const Sampler *const samplerObject =
3332*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3333*8975f5c5SAndroid Build Coastguard Worker     QuerySamplerParameterIiv(samplerObject, pname, params);
3334*8975f5c5SAndroid Build Coastguard Worker }
3335*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameterIuiv(SamplerID sampler,GLenum pname,GLuint * params)3336*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameterIuiv(SamplerID sampler, GLenum pname, GLuint *params)
3337*8975f5c5SAndroid Build Coastguard Worker {
3338*8975f5c5SAndroid Build Coastguard Worker     const Sampler *const samplerObject =
3339*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3340*8975f5c5SAndroid Build Coastguard Worker     QuerySamplerParameterIuiv(samplerObject, pname, params);
3341*8975f5c5SAndroid Build Coastguard Worker }
3342*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameterivRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)3343*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameterivRobust(SamplerID sampler,
3344*8975f5c5SAndroid Build Coastguard Worker                                           GLenum pname,
3345*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei bufSize,
3346*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei *length,
3347*8975f5c5SAndroid Build Coastguard Worker                                           GLint *params)
3348*8975f5c5SAndroid Build Coastguard Worker {
3349*8975f5c5SAndroid Build Coastguard Worker     getSamplerParameteriv(sampler, pname, params);
3350*8975f5c5SAndroid Build Coastguard Worker }
3351*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameterIivRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)3352*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameterIivRobust(SamplerID sampler,
3353*8975f5c5SAndroid Build Coastguard Worker                                            GLenum pname,
3354*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei bufSize,
3355*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei *length,
3356*8975f5c5SAndroid Build Coastguard Worker                                            GLint *params)
3357*8975f5c5SAndroid Build Coastguard Worker {
3358*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
3359*8975f5c5SAndroid Build Coastguard Worker }
3360*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameterIuivRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,GLsizei * length,GLuint * params)3361*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameterIuivRobust(SamplerID sampler,
3362*8975f5c5SAndroid Build Coastguard Worker                                             GLenum pname,
3363*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei bufSize,
3364*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei *length,
3365*8975f5c5SAndroid Build Coastguard Worker                                             GLuint *params)
3366*8975f5c5SAndroid Build Coastguard Worker {
3367*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
3368*8975f5c5SAndroid Build Coastguard Worker }
3369*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameterfv(SamplerID sampler,GLenum pname,GLfloat * params)3370*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameterfv(SamplerID sampler, GLenum pname, GLfloat *params)
3371*8975f5c5SAndroid Build Coastguard Worker {
3372*8975f5c5SAndroid Build Coastguard Worker     const Sampler *const samplerObject =
3373*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
3374*8975f5c5SAndroid Build Coastguard Worker     QuerySamplerParameterfv(samplerObject, pname, params);
3375*8975f5c5SAndroid Build Coastguard Worker }
3376*8975f5c5SAndroid Build Coastguard Worker 
getSamplerParameterfvRobust(SamplerID sampler,GLenum pname,GLsizei bufSize,GLsizei * length,GLfloat * params)3377*8975f5c5SAndroid Build Coastguard Worker void Context::getSamplerParameterfvRobust(SamplerID sampler,
3378*8975f5c5SAndroid Build Coastguard Worker                                           GLenum pname,
3379*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei bufSize,
3380*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei *length,
3381*8975f5c5SAndroid Build Coastguard Worker                                           GLfloat *params)
3382*8975f5c5SAndroid Build Coastguard Worker {
3383*8975f5c5SAndroid Build Coastguard Worker     getSamplerParameterfv(sampler, pname, params);
3384*8975f5c5SAndroid Build Coastguard Worker }
3385*8975f5c5SAndroid Build Coastguard Worker 
programParameteri(ShaderProgramID program,GLenum pname,GLint value)3386*8975f5c5SAndroid Build Coastguard Worker void Context::programParameteri(ShaderProgramID program, GLenum pname, GLint value)
3387*8975f5c5SAndroid Build Coastguard Worker {
3388*8975f5c5SAndroid Build Coastguard Worker     gl::Program *programObject = getProgramResolveLink(program);
3389*8975f5c5SAndroid Build Coastguard Worker     SetProgramParameteri(this, programObject, pname, value);
3390*8975f5c5SAndroid Build Coastguard Worker }
3391*8975f5c5SAndroid Build Coastguard Worker 
initRendererString()3392*8975f5c5SAndroid Build Coastguard Worker void Context::initRendererString()
3393*8975f5c5SAndroid Build Coastguard Worker {
3394*8975f5c5SAndroid Build Coastguard Worker     std::ostringstream frontendRendererString;
3395*8975f5c5SAndroid Build Coastguard Worker 
3396*8975f5c5SAndroid Build Coastguard Worker     constexpr char kRendererString[]        = "ANGLE_GL_RENDERER";
3397*8975f5c5SAndroid Build Coastguard Worker     constexpr char kAndroidRendererString[] = "debug.angle.gl_renderer";
3398*8975f5c5SAndroid Build Coastguard Worker 
3399*8975f5c5SAndroid Build Coastguard Worker     std::string overrideRenderer =
3400*8975f5c5SAndroid Build Coastguard Worker         angle::GetEnvironmentVarOrAndroidProperty(kRendererString, kAndroidRendererString);
3401*8975f5c5SAndroid Build Coastguard Worker     if (!overrideRenderer.empty())
3402*8975f5c5SAndroid Build Coastguard Worker     {
3403*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << overrideRenderer;
3404*8975f5c5SAndroid Build Coastguard Worker     }
3405*8975f5c5SAndroid Build Coastguard Worker     else
3406*8975f5c5SAndroid Build Coastguard Worker     {
3407*8975f5c5SAndroid Build Coastguard Worker         std::string vendorString(mDisplay->getBackendVendorString());
3408*8975f5c5SAndroid Build Coastguard Worker         std::string rendererString(mDisplay->getBackendRendererDescription());
3409*8975f5c5SAndroid Build Coastguard Worker         std::string versionString(mDisplay->getBackendVersionString(!isWebGL()));
3410*8975f5c5SAndroid Build Coastguard Worker         // Commas are used as a separator in ANGLE's renderer string, so remove commas from each
3411*8975f5c5SAndroid Build Coastguard Worker         // element.
3412*8975f5c5SAndroid Build Coastguard Worker         vendorString.erase(std::remove(vendorString.begin(), vendorString.end(), ','),
3413*8975f5c5SAndroid Build Coastguard Worker                            vendorString.end());
3414*8975f5c5SAndroid Build Coastguard Worker         rendererString.erase(std::remove(rendererString.begin(), rendererString.end(), ','),
3415*8975f5c5SAndroid Build Coastguard Worker                              rendererString.end());
3416*8975f5c5SAndroid Build Coastguard Worker         versionString.erase(std::remove(versionString.begin(), versionString.end(), ','),
3417*8975f5c5SAndroid Build Coastguard Worker                             versionString.end());
3418*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << "ANGLE (";
3419*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << vendorString;
3420*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << ", ";
3421*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << rendererString;
3422*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << ", ";
3423*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << versionString;
3424*8975f5c5SAndroid Build Coastguard Worker         frontendRendererString << ")";
3425*8975f5c5SAndroid Build Coastguard Worker     }
3426*8975f5c5SAndroid Build Coastguard Worker 
3427*8975f5c5SAndroid Build Coastguard Worker     mRendererString = MakeStaticString(frontendRendererString.str());
3428*8975f5c5SAndroid Build Coastguard Worker }
3429*8975f5c5SAndroid Build Coastguard Worker 
initVendorString()3430*8975f5c5SAndroid Build Coastguard Worker void Context::initVendorString()
3431*8975f5c5SAndroid Build Coastguard Worker {
3432*8975f5c5SAndroid Build Coastguard Worker     std::ostringstream vendorString;
3433*8975f5c5SAndroid Build Coastguard Worker 
3434*8975f5c5SAndroid Build Coastguard Worker     constexpr char kVendorString[]        = "ANGLE_GL_VENDOR";
3435*8975f5c5SAndroid Build Coastguard Worker     constexpr char kAndroidVendorString[] = "debug.angle.gl_vendor";
3436*8975f5c5SAndroid Build Coastguard Worker 
3437*8975f5c5SAndroid Build Coastguard Worker     std::string overrideVendor =
3438*8975f5c5SAndroid Build Coastguard Worker         angle::GetEnvironmentVarOrAndroidProperty(kVendorString, kAndroidVendorString);
3439*8975f5c5SAndroid Build Coastguard Worker 
3440*8975f5c5SAndroid Build Coastguard Worker     if (!overrideVendor.empty())
3441*8975f5c5SAndroid Build Coastguard Worker     {
3442*8975f5c5SAndroid Build Coastguard Worker         vendorString << overrideVendor;
3443*8975f5c5SAndroid Build Coastguard Worker     }
3444*8975f5c5SAndroid Build Coastguard Worker     else
3445*8975f5c5SAndroid Build Coastguard Worker     {
3446*8975f5c5SAndroid Build Coastguard Worker         vendorString << mDisplay->getVendorString();
3447*8975f5c5SAndroid Build Coastguard Worker     }
3448*8975f5c5SAndroid Build Coastguard Worker 
3449*8975f5c5SAndroid Build Coastguard Worker     mVendorString = MakeStaticString(vendorString.str());
3450*8975f5c5SAndroid Build Coastguard Worker }
3451*8975f5c5SAndroid Build Coastguard Worker 
initVersionStrings()3452*8975f5c5SAndroid Build Coastguard Worker void Context::initVersionStrings()
3453*8975f5c5SAndroid Build Coastguard Worker {
3454*8975f5c5SAndroid Build Coastguard Worker     const Version &clientVersion = getClientVersion();
3455*8975f5c5SAndroid Build Coastguard Worker 
3456*8975f5c5SAndroid Build Coastguard Worker     std::ostringstream versionString;
3457*8975f5c5SAndroid Build Coastguard Worker     versionString << "OpenGL ES ";
3458*8975f5c5SAndroid Build Coastguard Worker     versionString << clientVersion.major << "." << clientVersion.minor << ".0 (ANGLE "
3459*8975f5c5SAndroid Build Coastguard Worker                   << angle::GetANGLEVersionString() << ")";
3460*8975f5c5SAndroid Build Coastguard Worker     mVersionString = MakeStaticString(versionString.str());
3461*8975f5c5SAndroid Build Coastguard Worker 
3462*8975f5c5SAndroid Build Coastguard Worker     std::ostringstream shadingLanguageVersionString;
3463*8975f5c5SAndroid Build Coastguard Worker     shadingLanguageVersionString << "OpenGL ES GLSL ES ";
3464*8975f5c5SAndroid Build Coastguard Worker     shadingLanguageVersionString << (clientVersion.major == 2 ? 1 : clientVersion.major) << "."
3465*8975f5c5SAndroid Build Coastguard Worker                                  << clientVersion.minor << "0 (ANGLE "
3466*8975f5c5SAndroid Build Coastguard Worker                                  << angle::GetANGLEVersionString() << ")";
3467*8975f5c5SAndroid Build Coastguard Worker     mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str());
3468*8975f5c5SAndroid Build Coastguard Worker }
3469*8975f5c5SAndroid Build Coastguard Worker 
initExtensionStrings()3470*8975f5c5SAndroid Build Coastguard Worker void Context::initExtensionStrings()
3471*8975f5c5SAndroid Build Coastguard Worker {
3472*8975f5c5SAndroid Build Coastguard Worker     auto mergeExtensionStrings = [](const std::vector<const char *> &strings) {
3473*8975f5c5SAndroid Build Coastguard Worker         std::ostringstream combinedStringStream;
3474*8975f5c5SAndroid Build Coastguard Worker         std::copy(strings.begin(), strings.end(),
3475*8975f5c5SAndroid Build Coastguard Worker                   std::ostream_iterator<const char *>(combinedStringStream, " "));
3476*8975f5c5SAndroid Build Coastguard Worker         return MakeStaticString(combinedStringStream.str());
3477*8975f5c5SAndroid Build Coastguard Worker     };
3478*8975f5c5SAndroid Build Coastguard Worker 
3479*8975f5c5SAndroid Build Coastguard Worker     mExtensionStrings.clear();
3480*8975f5c5SAndroid Build Coastguard Worker     for (const auto &extensionString : mState.getExtensions().getStrings())
3481*8975f5c5SAndroid Build Coastguard Worker     {
3482*8975f5c5SAndroid Build Coastguard Worker         mExtensionStrings.push_back(MakeStaticString(extensionString));
3483*8975f5c5SAndroid Build Coastguard Worker     }
3484*8975f5c5SAndroid Build Coastguard Worker     mExtensionString = mergeExtensionStrings(mExtensionStrings);
3485*8975f5c5SAndroid Build Coastguard Worker 
3486*8975f5c5SAndroid Build Coastguard Worker     mRequestableExtensionStrings.clear();
3487*8975f5c5SAndroid Build Coastguard Worker     for (const auto &extensionInfo : GetExtensionInfoMap())
3488*8975f5c5SAndroid Build Coastguard Worker     {
3489*8975f5c5SAndroid Build Coastguard Worker         if (extensionInfo.second.Requestable &&
3490*8975f5c5SAndroid Build Coastguard Worker             !(mState.getExtensions().*(extensionInfo.second.ExtensionsMember)) &&
3491*8975f5c5SAndroid Build Coastguard Worker             mSupportedExtensions.*(extensionInfo.second.ExtensionsMember))
3492*8975f5c5SAndroid Build Coastguard Worker         {
3493*8975f5c5SAndroid Build Coastguard Worker             mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first));
3494*8975f5c5SAndroid Build Coastguard Worker         }
3495*8975f5c5SAndroid Build Coastguard Worker     }
3496*8975f5c5SAndroid Build Coastguard Worker     mRequestableExtensionString = mergeExtensionStrings(mRequestableExtensionStrings);
3497*8975f5c5SAndroid Build Coastguard Worker }
3498*8975f5c5SAndroid Build Coastguard Worker 
getString(GLenum name)3499*8975f5c5SAndroid Build Coastguard Worker const GLubyte *Context::getString(GLenum name)
3500*8975f5c5SAndroid Build Coastguard Worker {
3501*8975f5c5SAndroid Build Coastguard Worker     return static_cast<const Context *>(this)->getString(name);
3502*8975f5c5SAndroid Build Coastguard Worker }
3503*8975f5c5SAndroid Build Coastguard Worker 
getStringi(GLenum name,GLuint index)3504*8975f5c5SAndroid Build Coastguard Worker const GLubyte *Context::getStringi(GLenum name, GLuint index)
3505*8975f5c5SAndroid Build Coastguard Worker {
3506*8975f5c5SAndroid Build Coastguard Worker     return static_cast<const Context *>(this)->getStringi(name, index);
3507*8975f5c5SAndroid Build Coastguard Worker }
3508*8975f5c5SAndroid Build Coastguard Worker 
getString(GLenum name) const3509*8975f5c5SAndroid Build Coastguard Worker const GLubyte *Context::getString(GLenum name) const
3510*8975f5c5SAndroid Build Coastguard Worker {
3511*8975f5c5SAndroid Build Coastguard Worker     switch (name)
3512*8975f5c5SAndroid Build Coastguard Worker     {
3513*8975f5c5SAndroid Build Coastguard Worker         case GL_VENDOR:
3514*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mVendorString);
3515*8975f5c5SAndroid Build Coastguard Worker 
3516*8975f5c5SAndroid Build Coastguard Worker         case GL_RENDERER:
3517*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mRendererString);
3518*8975f5c5SAndroid Build Coastguard Worker 
3519*8975f5c5SAndroid Build Coastguard Worker         case GL_VERSION:
3520*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mVersionString);
3521*8975f5c5SAndroid Build Coastguard Worker 
3522*8975f5c5SAndroid Build Coastguard Worker         case GL_SHADING_LANGUAGE_VERSION:
3523*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mShadingLanguageString);
3524*8975f5c5SAndroid Build Coastguard Worker 
3525*8975f5c5SAndroid Build Coastguard Worker         case GL_EXTENSIONS:
3526*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mExtensionString);
3527*8975f5c5SAndroid Build Coastguard Worker 
3528*8975f5c5SAndroid Build Coastguard Worker         case GL_REQUESTABLE_EXTENSIONS_ANGLE:
3529*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mRequestableExtensionString);
3530*8975f5c5SAndroid Build Coastguard Worker 
3531*8975f5c5SAndroid Build Coastguard Worker         case GL_SERIALIZED_CONTEXT_STRING_ANGLE:
3532*8975f5c5SAndroid Build Coastguard Worker             if (angle::SerializeContextToString(this, &mCachedSerializedStateString) ==
3533*8975f5c5SAndroid Build Coastguard Worker                 angle::Result::Continue)
3534*8975f5c5SAndroid Build Coastguard Worker             {
3535*8975f5c5SAndroid Build Coastguard Worker                 return reinterpret_cast<const GLubyte *>(mCachedSerializedStateString.c_str());
3536*8975f5c5SAndroid Build Coastguard Worker             }
3537*8975f5c5SAndroid Build Coastguard Worker             else
3538*8975f5c5SAndroid Build Coastguard Worker             {
3539*8975f5c5SAndroid Build Coastguard Worker                 return nullptr;
3540*8975f5c5SAndroid Build Coastguard Worker             }
3541*8975f5c5SAndroid Build Coastguard Worker 
3542*8975f5c5SAndroid Build Coastguard Worker         default:
3543*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
3544*8975f5c5SAndroid Build Coastguard Worker             return nullptr;
3545*8975f5c5SAndroid Build Coastguard Worker     }
3546*8975f5c5SAndroid Build Coastguard Worker }
3547*8975f5c5SAndroid Build Coastguard Worker 
getStringi(GLenum name,GLuint index) const3548*8975f5c5SAndroid Build Coastguard Worker const GLubyte *Context::getStringi(GLenum name, GLuint index) const
3549*8975f5c5SAndroid Build Coastguard Worker {
3550*8975f5c5SAndroid Build Coastguard Worker     switch (name)
3551*8975f5c5SAndroid Build Coastguard Worker     {
3552*8975f5c5SAndroid Build Coastguard Worker         case GL_EXTENSIONS:
3553*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mExtensionStrings[index]);
3554*8975f5c5SAndroid Build Coastguard Worker 
3555*8975f5c5SAndroid Build Coastguard Worker         case GL_REQUESTABLE_EXTENSIONS_ANGLE:
3556*8975f5c5SAndroid Build Coastguard Worker             return reinterpret_cast<const GLubyte *>(mRequestableExtensionStrings[index]);
3557*8975f5c5SAndroid Build Coastguard Worker 
3558*8975f5c5SAndroid Build Coastguard Worker         default:
3559*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
3560*8975f5c5SAndroid Build Coastguard Worker             return nullptr;
3561*8975f5c5SAndroid Build Coastguard Worker     }
3562*8975f5c5SAndroid Build Coastguard Worker }
3563*8975f5c5SAndroid Build Coastguard Worker 
getExtensionStringCount() const3564*8975f5c5SAndroid Build Coastguard Worker size_t Context::getExtensionStringCount() const
3565*8975f5c5SAndroid Build Coastguard Worker {
3566*8975f5c5SAndroid Build Coastguard Worker     return mExtensionStrings.size();
3567*8975f5c5SAndroid Build Coastguard Worker }
3568*8975f5c5SAndroid Build Coastguard Worker 
isExtensionRequestable(const char * name) const3569*8975f5c5SAndroid Build Coastguard Worker bool Context::isExtensionRequestable(const char *name) const
3570*8975f5c5SAndroid Build Coastguard Worker {
3571*8975f5c5SAndroid Build Coastguard Worker     const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap();
3572*8975f5c5SAndroid Build Coastguard Worker     auto extension                         = extensionInfos.find(name);
3573*8975f5c5SAndroid Build Coastguard Worker 
3574*8975f5c5SAndroid Build Coastguard Worker     return extension != extensionInfos.end() && extension->second.Requestable &&
3575*8975f5c5SAndroid Build Coastguard Worker            mSupportedExtensions.*(extension->second.ExtensionsMember);
3576*8975f5c5SAndroid Build Coastguard Worker }
3577*8975f5c5SAndroid Build Coastguard Worker 
isExtensionDisablable(const char * name) const3578*8975f5c5SAndroid Build Coastguard Worker bool Context::isExtensionDisablable(const char *name) const
3579*8975f5c5SAndroid Build Coastguard Worker {
3580*8975f5c5SAndroid Build Coastguard Worker     const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap();
3581*8975f5c5SAndroid Build Coastguard Worker     auto extension                         = extensionInfos.find(name);
3582*8975f5c5SAndroid Build Coastguard Worker 
3583*8975f5c5SAndroid Build Coastguard Worker     return extension != extensionInfos.end() && extension->second.Disablable &&
3584*8975f5c5SAndroid Build Coastguard Worker            mSupportedExtensions.*(extension->second.ExtensionsMember);
3585*8975f5c5SAndroid Build Coastguard Worker }
3586*8975f5c5SAndroid Build Coastguard Worker 
requestExtension(const char * name)3587*8975f5c5SAndroid Build Coastguard Worker void Context::requestExtension(const char *name)
3588*8975f5c5SAndroid Build Coastguard Worker {
3589*8975f5c5SAndroid Build Coastguard Worker     setExtensionEnabled(name, true);
3590*8975f5c5SAndroid Build Coastguard Worker }
disableExtension(const char * name)3591*8975f5c5SAndroid Build Coastguard Worker void Context::disableExtension(const char *name)
3592*8975f5c5SAndroid Build Coastguard Worker {
3593*8975f5c5SAndroid Build Coastguard Worker     setExtensionEnabled(name, false);
3594*8975f5c5SAndroid Build Coastguard Worker }
3595*8975f5c5SAndroid Build Coastguard Worker 
setExtensionEnabled(const char * name,bool enabled)3596*8975f5c5SAndroid Build Coastguard Worker void Context::setExtensionEnabled(const char *name, bool enabled)
3597*8975f5c5SAndroid Build Coastguard Worker {
3598*8975f5c5SAndroid Build Coastguard Worker     const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap();
3599*8975f5c5SAndroid Build Coastguard Worker     ASSERT(extensionInfos.find(name) != extensionInfos.end());
3600*8975f5c5SAndroid Build Coastguard Worker     const auto &extension = extensionInfos.at(name);
3601*8975f5c5SAndroid Build Coastguard Worker     ASSERT(extension.Requestable);
3602*8975f5c5SAndroid Build Coastguard Worker     ASSERT(isExtensionRequestable(name));
3603*8975f5c5SAndroid Build Coastguard Worker 
3604*8975f5c5SAndroid Build Coastguard Worker     if (mState.getExtensions().*(extension.ExtensionsMember) == enabled)
3605*8975f5c5SAndroid Build Coastguard Worker     {
3606*8975f5c5SAndroid Build Coastguard Worker         // No change
3607*8975f5c5SAndroid Build Coastguard Worker         return;
3608*8975f5c5SAndroid Build Coastguard Worker     }
3609*8975f5c5SAndroid Build Coastguard Worker 
3610*8975f5c5SAndroid Build Coastguard Worker     mState.getMutableExtensions()->*(extension.ExtensionsMember) = enabled;
3611*8975f5c5SAndroid Build Coastguard Worker 
3612*8975f5c5SAndroid Build Coastguard Worker     if (enabled)
3613*8975f5c5SAndroid Build Coastguard Worker     {
3614*8975f5c5SAndroid Build Coastguard Worker         if (strcmp(name, "GL_OVR_multiview2") == 0)
3615*8975f5c5SAndroid Build Coastguard Worker         {
3616*8975f5c5SAndroid Build Coastguard Worker             // OVR_multiview is implicitly enabled when OVR_multiview2 is enabled
3617*8975f5c5SAndroid Build Coastguard Worker             requestExtension("GL_OVR_multiview");
3618*8975f5c5SAndroid Build Coastguard Worker         }
3619*8975f5c5SAndroid Build Coastguard Worker         else if (strcmp(name, "GL_ANGLE_shader_pixel_local_storage") == 0 ||
3620*8975f5c5SAndroid Build Coastguard Worker                  strcmp(name, "GL_ANGLE_shader_pixel_local_storage_coherent") == 0)
3621*8975f5c5SAndroid Build Coastguard Worker         {
3622*8975f5c5SAndroid Build Coastguard Worker             // ANGLE_shader_pixel_local_storage/ANGLE_shader_pixel_local_storage_coherent have
3623*8975f5c5SAndroid Build Coastguard Worker             // various dependency extensions, including each other.
3624*8975f5c5SAndroid Build Coastguard Worker             const auto enableIfRequestable = [this](const char *extensionName) {
3625*8975f5c5SAndroid Build Coastguard Worker                 for (const char *requestableExtension : mRequestableExtensionStrings)
3626*8975f5c5SAndroid Build Coastguard Worker                 {
3627*8975f5c5SAndroid Build Coastguard Worker                     if (strcmp(extensionName, requestableExtension) == 0)
3628*8975f5c5SAndroid Build Coastguard Worker                     {
3629*8975f5c5SAndroid Build Coastguard Worker                         requestExtension(extensionName);
3630*8975f5c5SAndroid Build Coastguard Worker                         return;
3631*8975f5c5SAndroid Build Coastguard Worker                     }
3632*8975f5c5SAndroid Build Coastguard Worker                 }
3633*8975f5c5SAndroid Build Coastguard Worker             };
3634*8975f5c5SAndroid Build Coastguard Worker             enableIfRequestable("GL_OES_draw_buffers_indexed");
3635*8975f5c5SAndroid Build Coastguard Worker             enableIfRequestable("GL_EXT_draw_buffers_indexed");
3636*8975f5c5SAndroid Build Coastguard Worker             enableIfRequestable("GL_EXT_color_buffer_float");
3637*8975f5c5SAndroid Build Coastguard Worker             enableIfRequestable("GL_EXT_color_buffer_half_float");
3638*8975f5c5SAndroid Build Coastguard Worker             enableIfRequestable("GL_ANGLE_shader_pixel_local_storage_coherent");
3639*8975f5c5SAndroid Build Coastguard Worker             enableIfRequestable("GL_ANGLE_shader_pixel_local_storage");
3640*8975f5c5SAndroid Build Coastguard Worker         }
3641*8975f5c5SAndroid Build Coastguard Worker     }
3642*8975f5c5SAndroid Build Coastguard Worker 
3643*8975f5c5SAndroid Build Coastguard Worker     reinitializeAfterExtensionsChanged();
3644*8975f5c5SAndroid Build Coastguard Worker }
3645*8975f5c5SAndroid Build Coastguard Worker 
reinitializeAfterExtensionsChanged()3646*8975f5c5SAndroid Build Coastguard Worker void Context::reinitializeAfterExtensionsChanged()
3647*8975f5c5SAndroid Build Coastguard Worker {
3648*8975f5c5SAndroid Build Coastguard Worker     updateCaps();
3649*8975f5c5SAndroid Build Coastguard Worker     initExtensionStrings();
3650*8975f5c5SAndroid Build Coastguard Worker 
3651*8975f5c5SAndroid Build Coastguard Worker     // Release the shader compiler so it will be re-created with the requested extensions enabled.
3652*8975f5c5SAndroid Build Coastguard Worker     releaseShaderCompiler();
3653*8975f5c5SAndroid Build Coastguard Worker 
3654*8975f5c5SAndroid Build Coastguard Worker     // Invalidate all textures and framebuffer. Some extensions make new formats renderable or
3655*8975f5c5SAndroid Build Coastguard Worker     // sampleable.
3656*8975f5c5SAndroid Build Coastguard Worker     mState.mTextureManager->signalAllTexturesDirty();
3657*8975f5c5SAndroid Build Coastguard Worker     for (auto &zeroTexture : mZeroTextures)
3658*8975f5c5SAndroid Build Coastguard Worker     {
3659*8975f5c5SAndroid Build Coastguard Worker         if (zeroTexture.get() != nullptr)
3660*8975f5c5SAndroid Build Coastguard Worker         {
3661*8975f5c5SAndroid Build Coastguard Worker             zeroTexture->signalDirtyStorage(InitState::Initialized);
3662*8975f5c5SAndroid Build Coastguard Worker         }
3663*8975f5c5SAndroid Build Coastguard Worker     }
3664*8975f5c5SAndroid Build Coastguard Worker 
3665*8975f5c5SAndroid Build Coastguard Worker     mState.mFramebufferManager->invalidateFramebufferCompletenessCache();
3666*8975f5c5SAndroid Build Coastguard Worker }
3667*8975f5c5SAndroid Build Coastguard Worker 
getRequestableExtensionStringCount() const3668*8975f5c5SAndroid Build Coastguard Worker size_t Context::getRequestableExtensionStringCount() const
3669*8975f5c5SAndroid Build Coastguard Worker {
3670*8975f5c5SAndroid Build Coastguard Worker     return mRequestableExtensionStrings.size();
3671*8975f5c5SAndroid Build Coastguard Worker }
3672*8975f5c5SAndroid Build Coastguard Worker 
beginTransformFeedback(PrimitiveMode primitiveMode)3673*8975f5c5SAndroid Build Coastguard Worker void Context::beginTransformFeedback(PrimitiveMode primitiveMode)
3674*8975f5c5SAndroid Build Coastguard Worker {
3675*8975f5c5SAndroid Build Coastguard Worker     TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback();
3676*8975f5c5SAndroid Build Coastguard Worker     ASSERT(transformFeedback != nullptr);
3677*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!transformFeedback->isPaused());
3678*8975f5c5SAndroid Build Coastguard Worker 
3679*8975f5c5SAndroid Build Coastguard Worker     // TODO: http://anglebug.com/42265705: Handle PPOs
3680*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(transformFeedback->begin(this, primitiveMode, mState.getProgram()));
3681*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTransformFeedbackChange(this);
3682*8975f5c5SAndroid Build Coastguard Worker }
3683*8975f5c5SAndroid Build Coastguard Worker 
hasActiveTransformFeedback(ShaderProgramID program) const3684*8975f5c5SAndroid Build Coastguard Worker bool Context::hasActiveTransformFeedback(ShaderProgramID program) const
3685*8975f5c5SAndroid Build Coastguard Worker {
3686*8975f5c5SAndroid Build Coastguard Worker     // Note: transform feedback objects are private to context and so the map doesn't need locking
3687*8975f5c5SAndroid Build Coastguard Worker     for (auto pair : UnsafeResourceMapIter(mTransformFeedbackMap))
3688*8975f5c5SAndroid Build Coastguard Worker     {
3689*8975f5c5SAndroid Build Coastguard Worker         if (pair.second != nullptr && pair.second->hasBoundProgram(program))
3690*8975f5c5SAndroid Build Coastguard Worker         {
3691*8975f5c5SAndroid Build Coastguard Worker             return true;
3692*8975f5c5SAndroid Build Coastguard Worker         }
3693*8975f5c5SAndroid Build Coastguard Worker     }
3694*8975f5c5SAndroid Build Coastguard Worker     return false;
3695*8975f5c5SAndroid Build Coastguard Worker }
3696*8975f5c5SAndroid Build Coastguard Worker 
generateSupportedExtensions() const3697*8975f5c5SAndroid Build Coastguard Worker Extensions Context::generateSupportedExtensions() const
3698*8975f5c5SAndroid Build Coastguard Worker {
3699*8975f5c5SAndroid Build Coastguard Worker     Extensions supportedExtensions = mImplementation->getNativeExtensions();
3700*8975f5c5SAndroid Build Coastguard Worker 
3701*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < ES_2_0)
3702*8975f5c5SAndroid Build Coastguard Worker     {
3703*8975f5c5SAndroid Build Coastguard Worker         // Default extensions for GLES1
3704*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.blendSubtractOES         = true;
3705*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.pointSizeArrayOES        = true;
3706*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureCubeMapOES        = true;
3707*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureMirroredRepeatOES = true;
3708*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.pointSpriteOES           = true;
3709*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.drawTextureOES           = true;
3710*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.framebufferObjectOES     = true;
3711*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.parallelShaderCompileKHR = false;
3712*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.texture3DOES             = false;
3713*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.clipDistanceAPPLE        = false;
3714*8975f5c5SAndroid Build Coastguard Worker     }
3715*8975f5c5SAndroid Build Coastguard Worker 
3716*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < ES_3_0)
3717*8975f5c5SAndroid Build Coastguard Worker     {
3718*8975f5c5SAndroid Build Coastguard Worker         // Disable ES3+ extensions
3719*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.colorBufferFloatEXT          = false;
3720*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.EGLImageExternalEssl3OES     = false;
3721*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.multiviewOVR                 = false;
3722*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.multiview2OVR                = false;
3723*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.multiviewMultisampleANGLE    = false;
3724*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.copyTexture3dANGLE           = false;
3725*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureMultisampleANGLE      = false;
3726*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureQueryLodEXT           = false;
3727*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureShadowLodEXT          = false;
3728*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureStencil8OES           = false;
3729*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.conservativeDepthEXT         = false;
3730*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.drawBuffersIndexedEXT        = false;
3731*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.drawBuffersIndexedOES        = false;
3732*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.EGLImageArrayEXT             = false;
3733*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.stencilTexturingANGLE        = false;
3734*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureFormatSRGBOverrideEXT = false;
3735*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.renderSharedExponentQCOM     = false;
3736*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.renderSnormEXT               = false;
3737*8975f5c5SAndroid Build Coastguard Worker 
3738*8975f5c5SAndroid Build Coastguard Worker         // Support GL_EXT_texture_norm16 on non-WebGL ES2 contexts. This is needed for R16/RG16
3739*8975f5c5SAndroid Build Coastguard Worker         // texturing for HDR video playback in Chromium which uses ES2 for compositor contexts.
3740*8975f5c5SAndroid Build Coastguard Worker         // Remove this workaround after Chromium migrates to ES3 for compositor contexts.
3741*8975f5c5SAndroid Build Coastguard Worker         if (mWebGLContext || getClientVersion() < ES_2_0)
3742*8975f5c5SAndroid Build Coastguard Worker         {
3743*8975f5c5SAndroid Build Coastguard Worker             supportedExtensions.textureNorm16EXT = false;
3744*8975f5c5SAndroid Build Coastguard Worker         }
3745*8975f5c5SAndroid Build Coastguard Worker 
3746*8975f5c5SAndroid Build Coastguard Worker         // Requires immutable textures
3747*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.yuvInternalFormatANGLE = false;
3748*8975f5c5SAndroid Build Coastguard Worker 
3749*8975f5c5SAndroid Build Coastguard Worker         // Require ESSL 3.0
3750*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderMultisampleInterpolationOES  = false;
3751*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderNoperspectiveInterpolationNV = false;
3752*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.sampleVariablesOES                 = false;
3753*8975f5c5SAndroid Build Coastguard Worker 
3754*8975f5c5SAndroid Build Coastguard Worker         // Require ES 3.1 but could likely be exposed on 3.0
3755*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureCubeMapArrayEXT = false;
3756*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureCubeMapArrayOES = false;
3757*8975f5c5SAndroid Build Coastguard Worker 
3758*8975f5c5SAndroid Build Coastguard Worker         // Require RED and RG formats
3759*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureSRGBR8EXT  = false;
3760*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureSRGBRG8EXT = false;
3761*8975f5c5SAndroid Build Coastguard Worker 
3762*8975f5c5SAndroid Build Coastguard Worker         // Requires glCompressedTexImage3D
3763*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureCompressionAstcOES = false;
3764*8975f5c5SAndroid Build Coastguard Worker 
3765*8975f5c5SAndroid Build Coastguard Worker         // Don't expose GL_EXT_texture_sRGB_decode without sRGB texture support
3766*8975f5c5SAndroid Build Coastguard Worker         if (!supportedExtensions.sRGBEXT)
3767*8975f5c5SAndroid Build Coastguard Worker         {
3768*8975f5c5SAndroid Build Coastguard Worker             supportedExtensions.textureSRGBDecodeEXT = false;
3769*8975f5c5SAndroid Build Coastguard Worker         }
3770*8975f5c5SAndroid Build Coastguard Worker 
3771*8975f5c5SAndroid Build Coastguard Worker         // Don't expose GL_OES_texture_float_linear without full legacy float texture support
3772*8975f5c5SAndroid Build Coastguard Worker         // The renderer may report OES_texture_float_linear without OES_texture_float
3773*8975f5c5SAndroid Build Coastguard Worker         // This is valid in a GLES 3.0 context, but not in a GLES 2.0 context
3774*8975f5c5SAndroid Build Coastguard Worker         if (!(supportedExtensions.textureFloatOES && supportedExtensions.textureHalfFloatOES))
3775*8975f5c5SAndroid Build Coastguard Worker         {
3776*8975f5c5SAndroid Build Coastguard Worker             supportedExtensions.textureFloatLinearOES     = false;
3777*8975f5c5SAndroid Build Coastguard Worker             supportedExtensions.textureHalfFloatLinearOES = false;
3778*8975f5c5SAndroid Build Coastguard Worker         }
3779*8975f5c5SAndroid Build Coastguard Worker 
3780*8975f5c5SAndroid Build Coastguard Worker         // Because of the difference in the SNORM to FLOAT conversion formula
3781*8975f5c5SAndroid Build Coastguard Worker         // between GLES 2.0 and 3.0, vertex type 10_10_10_2 is disabled
3782*8975f5c5SAndroid Build Coastguard Worker         // when the context version is lower than 3.0
3783*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.vertexType1010102OES = false;
3784*8975f5c5SAndroid Build Coastguard Worker 
3785*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_EGL_image_storage requires ESSL3
3786*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.EGLImageStorageEXT = false;
3787*8975f5c5SAndroid Build Coastguard Worker 
3788*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_YUV_target requires ESSL3
3789*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.YUVTargetEXT = false;
3790*8975f5c5SAndroid Build Coastguard Worker 
3791*8975f5c5SAndroid Build Coastguard Worker         // GL_EXT_clip_cull_distance / GL_ANGLE_clip_cull_distance require ESSL3
3792*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.clipCullDistanceEXT   = false;
3793*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.clipCullDistanceANGLE = false;
3794*8975f5c5SAndroid Build Coastguard Worker 
3795*8975f5c5SAndroid Build Coastguard Worker         // ANGLE_shader_pixel_local_storage requires ES3
3796*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderPixelLocalStorageANGLE         = false;
3797*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderPixelLocalStorageCoherentANGLE = false;
3798*8975f5c5SAndroid Build Coastguard Worker     }
3799*8975f5c5SAndroid Build Coastguard Worker 
3800*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < ES_3_1)
3801*8975f5c5SAndroid Build Coastguard Worker     {
3802*8975f5c5SAndroid Build Coastguard Worker         // Disable ES3.1+ extensions
3803*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.geometryShaderEXT       = false;
3804*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.geometryShaderOES       = false;
3805*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.gpuShader5EXT           = false;
3806*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.gpuShader5OES           = false;
3807*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.primitiveBoundingBoxEXT = false;
3808*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderImageAtomicOES    = false;
3809*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderIoBlocksEXT       = false;
3810*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderIoBlocksOES       = false;
3811*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.tessellationShaderEXT   = false;
3812*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.tessellationShaderOES   = false;
3813*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureBufferEXT        = false;
3814*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureBufferOES        = false;
3815*8975f5c5SAndroid Build Coastguard Worker 
3816*8975f5c5SAndroid Build Coastguard Worker         // TODO(http://anglebug.com/42261478): Multisample arrays could be supported on ES 3.0 as
3817*8975f5c5SAndroid Build Coastguard Worker         // well once 2D multisample texture extension is exposed there.
3818*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureStorageMultisample2dArrayOES = false;
3819*8975f5c5SAndroid Build Coastguard Worker     }
3820*8975f5c5SAndroid Build Coastguard Worker 
3821*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() > ES_2_0)
3822*8975f5c5SAndroid Build Coastguard Worker     {
3823*8975f5c5SAndroid Build Coastguard Worker         // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts
3824*8975f5c5SAndroid Build Coastguard Worker         // supportedExtensions.sRGB = false;
3825*8975f5c5SAndroid Build Coastguard Worker 
3826*8975f5c5SAndroid Build Coastguard Worker         // If colorBufferFloatEXT is disabled but colorBufferHalfFloatEXT is enabled, then we will
3827*8975f5c5SAndroid Build Coastguard Worker         // expose some floating-point formats as color buffer targets but reject blits between
3828*8975f5c5SAndroid Build Coastguard Worker         // fixed-point and floating-point formats (this behavior is only enabled in
3829*8975f5c5SAndroid Build Coastguard Worker         // colorBufferFloatEXT, and must be rejected if only colorBufferHalfFloatEXT is enabled).
3830*8975f5c5SAndroid Build Coastguard Worker         // dEQP does not check for this, and will assume that floating-point and fixed-point formats
3831*8975f5c5SAndroid Build Coastguard Worker         // can be blit onto each other if the format is available.
3832*8975f5c5SAndroid Build Coastguard Worker         // We require colorBufferFloatEXT to be present in order to enable colorBufferHalfFloatEXT,
3833*8975f5c5SAndroid Build Coastguard Worker         // so that blitting is always allowed if the requested formats are exposed and have the
3834*8975f5c5SAndroid Build Coastguard Worker         // correct feature capabilities. WebGL 2 wants to support colorBufferHalfFloatEXT without
3835*8975f5c5SAndroid Build Coastguard Worker         // colorBufferFloatEXT.
3836*8975f5c5SAndroid Build Coastguard Worker         if (!supportedExtensions.colorBufferFloatEXT && !mWebGLContext)
3837*8975f5c5SAndroid Build Coastguard Worker         {
3838*8975f5c5SAndroid Build Coastguard Worker             supportedExtensions.colorBufferHalfFloatEXT = false;
3839*8975f5c5SAndroid Build Coastguard Worker         }
3840*8975f5c5SAndroid Build Coastguard Worker 
3841*8975f5c5SAndroid Build Coastguard Worker         // Disable support for CHROMIUM_color_buffer_float_rgb[a] in ES 3.0+, these extensions are
3842*8975f5c5SAndroid Build Coastguard Worker         // non-conformant in ES 3.0 and superseded by EXT_color_buffer_float.
3843*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.colorBufferFloatRgbCHROMIUM  = false;
3844*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.colorBufferFloatRgbaCHROMIUM = false;
3845*8975f5c5SAndroid Build Coastguard Worker     }
3846*8975f5c5SAndroid Build Coastguard Worker 
3847*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= ES_3_0)
3848*8975f5c5SAndroid Build Coastguard Worker     {
3849*8975f5c5SAndroid Build Coastguard Worker         // Enable this extension for GLES3+.
3850*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.renderabilityValidationANGLE = true;
3851*8975f5c5SAndroid Build Coastguard Worker     }
3852*8975f5c5SAndroid Build Coastguard Worker 
3853*8975f5c5SAndroid Build Coastguard Worker     if (getFrontendFeatures().disableDrawBuffersIndexed.enabled)
3854*8975f5c5SAndroid Build Coastguard Worker     {
3855*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.drawBuffersIndexedEXT = false;
3856*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.drawBuffersIndexedOES = false;
3857*8975f5c5SAndroid Build Coastguard Worker     }
3858*8975f5c5SAndroid Build Coastguard Worker 
3859*8975f5c5SAndroid Build Coastguard Worker     if (getFrontendFeatures().disableAnisotropicFiltering.enabled)
3860*8975f5c5SAndroid Build Coastguard Worker     {
3861*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureFilterAnisotropicEXT = false;
3862*8975f5c5SAndroid Build Coastguard Worker     }
3863*8975f5c5SAndroid Build Coastguard Worker 
3864*8975f5c5SAndroid Build Coastguard Worker     if (!getFrontendFeatures().emulatePixelLocalStorage.enabled)
3865*8975f5c5SAndroid Build Coastguard Worker     {
3866*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderPixelLocalStorageANGLE         = false;
3867*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.shaderPixelLocalStorageCoherentANGLE = false;
3868*8975f5c5SAndroid Build Coastguard Worker     }
3869*8975f5c5SAndroid Build Coastguard Worker 
3870*8975f5c5SAndroid Build Coastguard Worker     // Some extensions are always available because they are implemented in the GL layer.
3871*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.bindUniformLocationCHROMIUM      = true;
3872*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.vertexArrayObjectOES             = true;
3873*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.bindGeneratesResourceCHROMIUM    = true;
3874*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.clientArraysANGLE                = true;
3875*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.requestExtensionANGLE            = true;
3876*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.multiDrawANGLE                   = true;
3877*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.programBinaryReadinessQueryANGLE = true;
3878*8975f5c5SAndroid Build Coastguard Worker 
3879*8975f5c5SAndroid Build Coastguard Worker     const Limitations &limitations                  = getLimitations();
3880*8975f5c5SAndroid Build Coastguard Worker     const angle::FrontendFeatures &frontendFeatures = mDisplay->getFrontendFeatures();
3881*8975f5c5SAndroid Build Coastguard Worker 
3882*8975f5c5SAndroid Build Coastguard Worker     if (limitations.multidrawEmulated &&
3883*8975f5c5SAndroid Build Coastguard Worker         !frontendFeatures.alwaysEnableEmulatedMultidrawExtensions.enabled && !mWebGLContext)
3884*8975f5c5SAndroid Build Coastguard Worker     {
3885*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.multiDrawANGLE       = false;
3886*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.multiDrawIndirectEXT = false;
3887*8975f5c5SAndroid Build Coastguard Worker     }
3888*8975f5c5SAndroid Build Coastguard Worker 
3889*8975f5c5SAndroid Build Coastguard Worker     if (limitations.baseInstanceBaseVertexEmulated &&
3890*8975f5c5SAndroid Build Coastguard Worker         !frontendFeatures.alwaysEnableEmulatedMultidrawExtensions.enabled && !mWebGLContext)
3891*8975f5c5SAndroid Build Coastguard Worker     {
3892*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.baseVertexBaseInstanceANGLE = false;
3893*8975f5c5SAndroid Build Coastguard Worker     }
3894*8975f5c5SAndroid Build Coastguard Worker 
3895*8975f5c5SAndroid Build Coastguard Worker     if (limitations.baseInstanceEmulated &&
3896*8975f5c5SAndroid Build Coastguard Worker         !frontendFeatures.alwaysEnableEmulatedMultidrawExtensions.enabled && !mWebGLContext)
3897*8975f5c5SAndroid Build Coastguard Worker     {
3898*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.baseInstanceEXT = false;
3899*8975f5c5SAndroid Build Coastguard Worker     }
3900*8975f5c5SAndroid Build Coastguard Worker 
3901*8975f5c5SAndroid Build Coastguard Worker     // Enable the no error extension if the context was created with the flag.
3902*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.noErrorKHR = skipValidation();
3903*8975f5c5SAndroid Build Coastguard Worker 
3904*8975f5c5SAndroid Build Coastguard Worker     // Enable surfaceless to advertise we'll have the correct behavior when there is no default FBO
3905*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.surfacelessContextOES = mSurfacelessSupported;
3906*8975f5c5SAndroid Build Coastguard Worker 
3907*8975f5c5SAndroid Build Coastguard Worker     // Explicitly enable GL_KHR_debug
3908*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.debugKHR = true;
3909*8975f5c5SAndroid Build Coastguard Worker 
3910*8975f5c5SAndroid Build Coastguard Worker     // Explicitly enable GL_EXT_debug_label
3911*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.debugLabelEXT = true;
3912*8975f5c5SAndroid Build Coastguard Worker 
3913*8975f5c5SAndroid Build Coastguard Worker     // Explicitly enable GL_ANGLE_robust_client_memory if the context supports validation.
3914*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.robustClientMemoryANGLE = !skipValidation();
3915*8975f5c5SAndroid Build Coastguard Worker 
3916*8975f5c5SAndroid Build Coastguard Worker     // Determine robust resource init availability from EGL.
3917*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.robustResourceInitializationANGLE = mState.isRobustResourceInitEnabled();
3918*8975f5c5SAndroid Build Coastguard Worker 
3919*8975f5c5SAndroid Build Coastguard Worker     // mState.getExtensions().robustBufferAccessBehaviorKHR is true only if robust access is true
3920*8975f5c5SAndroid Build Coastguard Worker     // and the backend supports it.
3921*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.robustBufferAccessBehaviorKHR =
3922*8975f5c5SAndroid Build Coastguard Worker         mState.hasRobustAccess() && supportedExtensions.robustBufferAccessBehaviorKHR;
3923*8975f5c5SAndroid Build Coastguard Worker 
3924*8975f5c5SAndroid Build Coastguard Worker     // Enable the cache control query unconditionally.
3925*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.programCacheControlANGLE = true;
3926*8975f5c5SAndroid Build Coastguard Worker 
3927*8975f5c5SAndroid Build Coastguard Worker     // If EGL_KHR_fence_sync is not enabled, don't expose GL_OES_EGL_sync.
3928*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mDisplay);
3929*8975f5c5SAndroid Build Coastguard Worker     if (!mDisplay->getExtensions().fenceSync)
3930*8975f5c5SAndroid Build Coastguard Worker     {
3931*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.EGLSyncOES = false;
3932*8975f5c5SAndroid Build Coastguard Worker     }
3933*8975f5c5SAndroid Build Coastguard Worker 
3934*8975f5c5SAndroid Build Coastguard Worker     if (mDisplay->getExtensions().robustnessVideoMemoryPurgeNV)
3935*8975f5c5SAndroid Build Coastguard Worker     {
3936*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.robustnessVideoMemoryPurgeNV = true;
3937*8975f5c5SAndroid Build Coastguard Worker     }
3938*8975f5c5SAndroid Build Coastguard Worker 
3939*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.memorySizeANGLE = true;
3940*8975f5c5SAndroid Build Coastguard Worker 
3941*8975f5c5SAndroid Build Coastguard Worker     // GL_CHROMIUM_lose_context is implemented in the frontend
3942*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.loseContextCHROMIUM = true;
3943*8975f5c5SAndroid Build Coastguard Worker 
3944*8975f5c5SAndroid Build Coastguard Worker     // The ASTC texture extensions have dependency requirements.
3945*8975f5c5SAndroid Build Coastguard Worker     if (supportedExtensions.textureCompressionAstcHdrKHR ||
3946*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.textureCompressionAstcSliced3dKHR)
3947*8975f5c5SAndroid Build Coastguard Worker     {
3948*8975f5c5SAndroid Build Coastguard Worker         // GL_KHR_texture_compression_astc_hdr cannot be exposed without also exposing
3949*8975f5c5SAndroid Build Coastguard Worker         // GL_KHR_texture_compression_astc_ldr
3950*8975f5c5SAndroid Build Coastguard Worker         ASSERT(supportedExtensions.textureCompressionAstcLdrKHR);
3951*8975f5c5SAndroid Build Coastguard Worker     }
3952*8975f5c5SAndroid Build Coastguard Worker 
3953*8975f5c5SAndroid Build Coastguard Worker     if (supportedExtensions.textureCompressionAstcOES)
3954*8975f5c5SAndroid Build Coastguard Worker     {
3955*8975f5c5SAndroid Build Coastguard Worker         // GL_OES_texture_compression_astc cannot be exposed without also exposing
3956*8975f5c5SAndroid Build Coastguard Worker         // GL_KHR_texture_compression_astc_ldr and GL_KHR_texture_compression_astc_hdr
3957*8975f5c5SAndroid Build Coastguard Worker         ASSERT(supportedExtensions.textureCompressionAstcLdrKHR);
3958*8975f5c5SAndroid Build Coastguard Worker         ASSERT(supportedExtensions.textureCompressionAstcHdrKHR);
3959*8975f5c5SAndroid Build Coastguard Worker     }
3960*8975f5c5SAndroid Build Coastguard Worker 
3961*8975f5c5SAndroid Build Coastguard Worker     // GL_KHR_protected_textures
3962*8975f5c5SAndroid Build Coastguard Worker     // If EGL_KHR_protected_content is not supported then GL_EXT_protected_texture
3963*8975f5c5SAndroid Build Coastguard Worker     // can not be supported.
3964*8975f5c5SAndroid Build Coastguard Worker     if (!mDisplay->getExtensions().protectedContentEXT)
3965*8975f5c5SAndroid Build Coastguard Worker     {
3966*8975f5c5SAndroid Build Coastguard Worker         supportedExtensions.protectedTexturesEXT = false;
3967*8975f5c5SAndroid Build Coastguard Worker     }
3968*8975f5c5SAndroid Build Coastguard Worker 
3969*8975f5c5SAndroid Build Coastguard Worker     // GL_ANGLE_get_tex_level_parameter is implemented in the front-end
3970*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.getTexLevelParameterANGLE = true;
3971*8975f5c5SAndroid Build Coastguard Worker 
3972*8975f5c5SAndroid Build Coastguard Worker     // Always enabled. Will return a default string if capture is not enabled.
3973*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.getSerializedContextStringANGLE = true;
3974*8975f5c5SAndroid Build Coastguard Worker 
3975*8975f5c5SAndroid Build Coastguard Worker     // Performance counter queries are always supported. Different groups exist on each back-end.
3976*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.performanceMonitorAMD = true;
3977*8975f5c5SAndroid Build Coastguard Worker 
3978*8975f5c5SAndroid Build Coastguard Worker     // GL_ANDROID_extension_pack_es31a
3979*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.extensionPackEs31aANDROID =
3980*8975f5c5SAndroid Build Coastguard Worker         CanSupportAEP(getClientVersion(), supportedExtensions);
3981*8975f5c5SAndroid Build Coastguard Worker 
3982*8975f5c5SAndroid Build Coastguard Worker     // Blob cache extension is provided by the ANGLE frontend
3983*8975f5c5SAndroid Build Coastguard Worker     supportedExtensions.blobCacheANGLE = true;
3984*8975f5c5SAndroid Build Coastguard Worker 
3985*8975f5c5SAndroid Build Coastguard Worker     return supportedExtensions;
3986*8975f5c5SAndroid Build Coastguard Worker }
3987*8975f5c5SAndroid Build Coastguard Worker 
initCaps()3988*8975f5c5SAndroid Build Coastguard Worker void Context::initCaps()
3989*8975f5c5SAndroid Build Coastguard Worker {
3990*8975f5c5SAndroid Build Coastguard Worker     Caps *caps = mState.getMutableCaps();
3991*8975f5c5SAndroid Build Coastguard Worker     *caps      = mImplementation->getNativeCaps();
3992*8975f5c5SAndroid Build Coastguard Worker 
3993*8975f5c5SAndroid Build Coastguard Worker     // TODO (http://anglebug.com/42264543): mSupportedExtensions should not be modified here
3994*8975f5c5SAndroid Build Coastguard Worker     mSupportedExtensions = generateSupportedExtensions();
3995*8975f5c5SAndroid Build Coastguard Worker 
3996*8975f5c5SAndroid Build Coastguard Worker     if (!mDisplay->getFrontendFeatures().allowCompressedFormats.enabled)
3997*8975f5c5SAndroid Build Coastguard Worker     {
3998*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting compressed format support.\n";
3999*8975f5c5SAndroid Build Coastguard Worker 
4000*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedEACR11SignedTextureOES                = false;
4001*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedEACR11UnsignedTextureOES              = false;
4002*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedEACRG11SignedTextureOES               = false;
4003*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedEACRG11UnsignedTextureOES             = false;
4004*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC1RGB8SubTextureEXT                 = false;
4005*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC1RGB8TextureOES                    = false;
4006*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC2PunchthroughARGBA8TextureOES      = false;
4007*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC2PunchthroughASRGB8AlphaTextureOES = false;
4008*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC2RGB8TextureOES                    = false;
4009*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC2RGBA8TextureOES                   = false;
4010*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC2SRGB8Alpha8TextureOES             = false;
4011*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC2SRGB8TextureOES                   = false;
4012*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedTextureEtcANGLE                       = false;
4013*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionPvrtcIMG                      = false;
4014*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.pvrtcSRGBEXT                                    = false;
4015*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.copyCompressedTextureCHROMIUM                   = false;
4016*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionAstcHdrKHR                    = false;
4017*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionAstcLdrKHR                    = false;
4018*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionAstcOES                       = false;
4019*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionBptcEXT                       = false;
4020*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionDxt1EXT                       = false;
4021*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionDxt3ANGLE                     = false;
4022*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionDxt5ANGLE                     = false;
4023*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionRgtcEXT                       = false;
4024*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionS3tcSrgbEXT                   = false;
4025*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionAstcSliced3dKHR               = false;
4026*8975f5c5SAndroid Build Coastguard Worker 
4027*8975f5c5SAndroid Build Coastguard Worker         caps->compressedTextureFormats.clear();
4028*8975f5c5SAndroid Build Coastguard Worker     }
4029*8975f5c5SAndroid Build Coastguard Worker 
4030*8975f5c5SAndroid Build Coastguard Worker     Extensions *extensions = mState.getMutableExtensions();
4031*8975f5c5SAndroid Build Coastguard Worker     *extensions            = mSupportedExtensions;
4032*8975f5c5SAndroid Build Coastguard Worker 
4033*8975f5c5SAndroid Build Coastguard Worker     *mState.getMutableLimitations() = mImplementation->getNativeLimitations();
4034*8975f5c5SAndroid Build Coastguard Worker 
4035*8975f5c5SAndroid Build Coastguard Worker     // GLES1 emulation: Initialize caps (Table 6.20 / 6.22 in the ES 1.1 spec)
4036*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < Version(2, 0))
4037*8975f5c5SAndroid Build Coastguard Worker     {
4038*8975f5c5SAndroid Build Coastguard Worker         caps->maxMultitextureUnits          = 4;
4039*8975f5c5SAndroid Build Coastguard Worker         caps->maxClipPlanes                 = 6;
4040*8975f5c5SAndroid Build Coastguard Worker         caps->maxLights                     = 8;
4041*8975f5c5SAndroid Build Coastguard Worker         caps->maxModelviewMatrixStackDepth  = Caps::GlobalMatrixStackDepth;
4042*8975f5c5SAndroid Build Coastguard Worker         caps->maxProjectionMatrixStackDepth = Caps::GlobalMatrixStackDepth;
4043*8975f5c5SAndroid Build Coastguard Worker         caps->maxTextureMatrixStackDepth    = Caps::GlobalMatrixStackDepth;
4044*8975f5c5SAndroid Build Coastguard Worker         caps->minSmoothPointSize            = 1.0f;
4045*8975f5c5SAndroid Build Coastguard Worker         caps->maxSmoothPointSize            = 1.0f;
4046*8975f5c5SAndroid Build Coastguard Worker         caps->minSmoothLineWidth            = 1.0f;
4047*8975f5c5SAndroid Build Coastguard Worker         caps->maxSmoothLineWidth            = 1.0f;
4048*8975f5c5SAndroid Build Coastguard Worker     }
4049*8975f5c5SAndroid Build Coastguard Worker 
4050*8975f5c5SAndroid Build Coastguard Worker     caps->maxDebugMessageLength   = 1024;
4051*8975f5c5SAndroid Build Coastguard Worker     caps->maxDebugLoggedMessages  = 1024;
4052*8975f5c5SAndroid Build Coastguard Worker     caps->maxDebugGroupStackDepth = 1024;
4053*8975f5c5SAndroid Build Coastguard Worker     caps->maxLabelLength          = 1024;
4054*8975f5c5SAndroid Build Coastguard Worker 
4055*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < Version(3, 0))
4056*8975f5c5SAndroid Build Coastguard Worker     {
4057*8975f5c5SAndroid Build Coastguard Worker         caps->maxViews = 1u;
4058*8975f5c5SAndroid Build Coastguard Worker     }
4059*8975f5c5SAndroid Build Coastguard Worker 
4060*8975f5c5SAndroid Build Coastguard Worker #if 0
4061*8975f5c5SAndroid Build Coastguard Worker // This logging can generate a lot of spam in test suites that create many contexts
4062*8975f5c5SAndroid Build Coastguard Worker #    define ANGLE_LOG_LIMITED_CAP(cap, limit)                                               \
4063*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting " << #cap << " to implementation limit " << (limit) << " (was " \
4064*8975f5c5SAndroid Build Coastguard Worker                << (cap) << ")."
4065*8975f5c5SAndroid Build Coastguard Worker #else
4066*8975f5c5SAndroid Build Coastguard Worker #    define ANGLE_LOG_LIMITED_CAP(cap, limit)
4067*8975f5c5SAndroid Build Coastguard Worker #endif
4068*8975f5c5SAndroid Build Coastguard Worker 
4069*8975f5c5SAndroid Build Coastguard Worker #define ANGLE_LIMIT_CAP(cap, limit)            \
4070*8975f5c5SAndroid Build Coastguard Worker     do                                         \
4071*8975f5c5SAndroid Build Coastguard Worker     {                                          \
4072*8975f5c5SAndroid Build Coastguard Worker         if ((cap) > (limit))                   \
4073*8975f5c5SAndroid Build Coastguard Worker         {                                      \
4074*8975f5c5SAndroid Build Coastguard Worker             ANGLE_LOG_LIMITED_CAP(cap, limit); \
4075*8975f5c5SAndroid Build Coastguard Worker             (cap) = (limit);                   \
4076*8975f5c5SAndroid Build Coastguard Worker         }                                      \
4077*8975f5c5SAndroid Build Coastguard Worker     } while (0)
4078*8975f5c5SAndroid Build Coastguard Worker 
4079*8975f5c5SAndroid Build Coastguard Worker     // Apply/Verify implementation limits
4080*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxDrawBuffers, IMPLEMENTATION_MAX_DRAW_BUFFERS);
4081*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxFramebufferWidth, IMPLEMENTATION_MAX_FRAMEBUFFER_SIZE);
4082*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxFramebufferHeight, IMPLEMENTATION_MAX_FRAMEBUFFER_SIZE);
4083*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxRenderbufferSize, IMPLEMENTATION_MAX_RENDERBUFFER_SIZE);
4084*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxColorAttachments, IMPLEMENTATION_MAX_DRAW_BUFFERS);
4085*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxVertexAttributes, MAX_VERTEX_ATTRIBS);
4086*8975f5c5SAndroid Build Coastguard Worker     if (mDisplay->getFrontendFeatures().forceMinimumMaxVertexAttributes.enabled &&
4087*8975f5c5SAndroid Build Coastguard Worker         getClientVersion() <= Version(2, 0))
4088*8975f5c5SAndroid Build Coastguard Worker     {
4089*8975f5c5SAndroid Build Coastguard Worker         // Only limit GL_MAX_VERTEX_ATTRIBS on ES2 or lower, the ES3+ cap is already at the minimum
4090*8975f5c5SAndroid Build Coastguard Worker         // (16)
4091*8975f5c5SAndroid Build Coastguard Worker         static_assert(MAX_VERTEX_ATTRIBS == 16);
4092*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxVertexAttributes, 8);
4093*8975f5c5SAndroid Build Coastguard Worker     }
4094*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxVertexAttribStride,
4095*8975f5c5SAndroid Build Coastguard Worker                     static_cast<GLint>(limits::kMaxVertexAttribStride));
4096*8975f5c5SAndroid Build Coastguard Worker 
4097*8975f5c5SAndroid Build Coastguard Worker     ASSERT(caps->minAliasedPointSize >= 1.0f);
4098*8975f5c5SAndroid Build Coastguard Worker 
4099*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < ES_3_1)
4100*8975f5c5SAndroid Build Coastguard Worker     {
4101*8975f5c5SAndroid Build Coastguard Worker         caps->maxVertexAttribBindings = caps->maxVertexAttributes;
4102*8975f5c5SAndroid Build Coastguard Worker     }
4103*8975f5c5SAndroid Build Coastguard Worker     else
4104*8975f5c5SAndroid Build Coastguard Worker     {
4105*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS);
4106*8975f5c5SAndroid Build Coastguard Worker     }
4107*8975f5c5SAndroid Build Coastguard Worker 
4108*8975f5c5SAndroid Build Coastguard Worker     const Limitations &limitations = getLimitations();
4109*8975f5c5SAndroid Build Coastguard Worker 
4110*8975f5c5SAndroid Build Coastguard Worker     if (mWebGLContext && limitations.webGLTextureSizeLimit > 0)
4111*8975f5c5SAndroid Build Coastguard Worker     {
4112*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->max2DTextureSize, limitations.webGLTextureSizeLimit);
4113*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->max3DTextureSize, limitations.webGLTextureSizeLimit);
4114*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxCubeMapTextureSize, limitations.webGLTextureSizeLimit);
4115*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxArrayTextureLayers, limitations.webGLTextureSizeLimit);
4116*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxRectangleTextureSize, limitations.webGLTextureSizeLimit);
4117*8975f5c5SAndroid Build Coastguard Worker     }
4118*8975f5c5SAndroid Build Coastguard Worker 
4119*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->max2DTextureSize, IMPLEMENTATION_MAX_2D_TEXTURE_SIZE);
4120*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxCubeMapTextureSize, IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE);
4121*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->max3DTextureSize, IMPLEMENTATION_MAX_3D_TEXTURE_SIZE);
4122*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxArrayTextureLayers, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS);
4123*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxRectangleTextureSize, IMPLEMENTATION_MAX_2D_TEXTURE_SIZE);
4124*8975f5c5SAndroid Build Coastguard Worker 
4125*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxShaderUniformBlocks[ShaderType::Vertex],
4126*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS);
4127*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxShaderUniformBlocks[ShaderType::Geometry],
4128*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_GEOMETRY_SHADER_UNIFORM_BUFFERS);
4129*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxShaderUniformBlocks[ShaderType::Fragment],
4130*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS);
4131*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxShaderUniformBlocks[ShaderType::Compute],
4132*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_COMPUTE_SHADER_UNIFORM_BUFFERS);
4133*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxCombinedUniformBlocks,
4134*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS);
4135*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxUniformBufferBindings, IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS);
4136*8975f5c5SAndroid Build Coastguard Worker 
4137*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4);
4138*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4);
4139*8975f5c5SAndroid Build Coastguard Worker 
4140*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxTransformFeedbackInterleavedComponents,
4141*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS);
4142*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxTransformFeedbackSeparateAttributes,
4143*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);
4144*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxTransformFeedbackSeparateComponents,
4145*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS);
4146*8975f5c5SAndroid Build Coastguard Worker 
4147*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() < ES_3_2 && !extensions->tessellationShaderAny())
4148*8975f5c5SAndroid Build Coastguard Worker     {
4149*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxCombinedTextureImageUnits,
4150*8975f5c5SAndroid Build Coastguard Worker                         IMPLEMENTATION_MAX_ES31_ACTIVE_TEXTURES);
4151*8975f5c5SAndroid Build Coastguard Worker     }
4152*8975f5c5SAndroid Build Coastguard Worker     else
4153*8975f5c5SAndroid Build Coastguard Worker     {
4154*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxCombinedTextureImageUnits, IMPLEMENTATION_MAX_ACTIVE_TEXTURES);
4155*8975f5c5SAndroid Build Coastguard Worker     }
4156*8975f5c5SAndroid Build Coastguard Worker 
4157*8975f5c5SAndroid Build Coastguard Worker     for (ShaderType shaderType : AllShaderTypes())
4158*8975f5c5SAndroid Build Coastguard Worker     {
4159*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxShaderTextureImageUnits[shaderType],
4160*8975f5c5SAndroid Build Coastguard Worker                         IMPLEMENTATION_MAX_SHADER_TEXTURES);
4161*8975f5c5SAndroid Build Coastguard Worker     }
4162*8975f5c5SAndroid Build Coastguard Worker 
4163*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxImageUnits, IMPLEMENTATION_MAX_IMAGE_UNITS);
4164*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxCombinedImageUniforms, IMPLEMENTATION_MAX_IMAGE_UNITS);
4165*8975f5c5SAndroid Build Coastguard Worker     for (ShaderType shaderType : AllShaderTypes())
4166*8975f5c5SAndroid Build Coastguard Worker     {
4167*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxShaderImageUniforms[shaderType], IMPLEMENTATION_MAX_IMAGE_UNITS);
4168*8975f5c5SAndroid Build Coastguard Worker     }
4169*8975f5c5SAndroid Build Coastguard Worker 
4170*8975f5c5SAndroid Build Coastguard Worker     for (ShaderType shaderType : AllShaderTypes())
4171*8975f5c5SAndroid Build Coastguard Worker     {
4172*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxShaderAtomicCounterBuffers[shaderType],
4173*8975f5c5SAndroid Build Coastguard Worker                         IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS);
4174*8975f5c5SAndroid Build Coastguard Worker     }
4175*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxAtomicCounterBufferBindings,
4176*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS);
4177*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxCombinedAtomicCounterBuffers,
4178*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS);
4179*8975f5c5SAndroid Build Coastguard Worker 
4180*8975f5c5SAndroid Build Coastguard Worker     for (ShaderType shaderType : AllShaderTypes())
4181*8975f5c5SAndroid Build Coastguard Worker     {
4182*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxShaderStorageBlocks[shaderType],
4183*8975f5c5SAndroid Build Coastguard Worker                         IMPLEMENTATION_MAX_SHADER_STORAGE_BUFFER_BINDINGS);
4184*8975f5c5SAndroid Build Coastguard Worker     }
4185*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxShaderStorageBufferBindings,
4186*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_SHADER_STORAGE_BUFFER_BINDINGS);
4187*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxCombinedShaderStorageBlocks,
4188*8975f5c5SAndroid Build Coastguard Worker                     IMPLEMENTATION_MAX_SHADER_STORAGE_BUFFER_BINDINGS);
4189*8975f5c5SAndroid Build Coastguard Worker 
4190*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxClipDistances, IMPLEMENTATION_MAX_CLIP_DISTANCES);
4191*8975f5c5SAndroid Build Coastguard Worker 
4192*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxFramebufferLayers, IMPLEMENTATION_MAX_FRAMEBUFFER_LAYERS);
4193*8975f5c5SAndroid Build Coastguard Worker 
4194*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxSampleMaskWords, IMPLEMENTATION_MAX_SAMPLE_MASK_WORDS);
4195*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxSamples, IMPLEMENTATION_MAX_SAMPLES);
4196*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxFramebufferSamples, IMPLEMENTATION_MAX_SAMPLES);
4197*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxColorTextureSamples, IMPLEMENTATION_MAX_SAMPLES);
4198*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxDepthTextureSamples, IMPLEMENTATION_MAX_SAMPLES);
4199*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxIntegerSamples, IMPLEMENTATION_MAX_SAMPLES);
4200*8975f5c5SAndroid Build Coastguard Worker 
4201*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxViews, IMPLEMENTATION_ANGLE_MULTIVIEW_MAX_VIEWS);
4202*8975f5c5SAndroid Build Coastguard Worker 
4203*8975f5c5SAndroid Build Coastguard Worker     ANGLE_LIMIT_CAP(caps->maxDualSourceDrawBuffers, IMPLEMENTATION_MAX_DUAL_SOURCE_DRAW_BUFFERS);
4204*8975f5c5SAndroid Build Coastguard Worker 
4205*8975f5c5SAndroid Build Coastguard Worker     // WebGL compatibility
4206*8975f5c5SAndroid Build Coastguard Worker     extensions->webglCompatibilityANGLE = mWebGLContext;
4207*8975f5c5SAndroid Build Coastguard Worker     for (const auto &extensionInfo : GetExtensionInfoMap())
4208*8975f5c5SAndroid Build Coastguard Worker     {
4209*8975f5c5SAndroid Build Coastguard Worker         // If the user has requested that extensions start disabled and they are requestable,
4210*8975f5c5SAndroid Build Coastguard Worker         // disable them.
4211*8975f5c5SAndroid Build Coastguard Worker         if (!mExtensionsEnabled && extensionInfo.second.Requestable)
4212*8975f5c5SAndroid Build Coastguard Worker         {
4213*8975f5c5SAndroid Build Coastguard Worker             extensions->*(extensionInfo.second.ExtensionsMember) = false;
4214*8975f5c5SAndroid Build Coastguard Worker         }
4215*8975f5c5SAndroid Build Coastguard Worker     }
4216*8975f5c5SAndroid Build Coastguard Worker 
4217*8975f5c5SAndroid Build Coastguard Worker     // Hide emulated ETC1 extension from WebGL contexts.
4218*8975f5c5SAndroid Build Coastguard Worker     if (mWebGLContext && limitations.emulatedEtc1)
4219*8975f5c5SAndroid Build Coastguard Worker     {
4220*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC1RGB8SubTextureEXT = false;
4221*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.compressedETC1RGB8TextureOES    = false;
4222*8975f5c5SAndroid Build Coastguard Worker     }
4223*8975f5c5SAndroid Build Coastguard Worker 
4224*8975f5c5SAndroid Build Coastguard Worker     if (limitations.emulatedAstc)
4225*8975f5c5SAndroid Build Coastguard Worker     {
4226*8975f5c5SAndroid Build Coastguard Worker         // Hide emulated ASTC extension from WebGL contexts.
4227*8975f5c5SAndroid Build Coastguard Worker         if (mWebGLContext)
4228*8975f5c5SAndroid Build Coastguard Worker         {
4229*8975f5c5SAndroid Build Coastguard Worker             mSupportedExtensions.textureCompressionAstcLdrKHR = false;
4230*8975f5c5SAndroid Build Coastguard Worker             extensions->textureCompressionAstcLdrKHR          = false;
4231*8975f5c5SAndroid Build Coastguard Worker         }
4232*8975f5c5SAndroid Build Coastguard Worker #if !defined(ANGLE_HAS_ASTCENC)
4233*8975f5c5SAndroid Build Coastguard Worker         // Don't expose emulated ASTC when it's not built.
4234*8975f5c5SAndroid Build Coastguard Worker         mSupportedExtensions.textureCompressionAstcLdrKHR = false;
4235*8975f5c5SAndroid Build Coastguard Worker         extensions->textureCompressionAstcLdrKHR          = false;
4236*8975f5c5SAndroid Build Coastguard Worker #endif
4237*8975f5c5SAndroid Build Coastguard Worker     }
4238*8975f5c5SAndroid Build Coastguard Worker 
4239*8975f5c5SAndroid Build Coastguard Worker     // If we're capturing application calls for replay, apply some feature limits to increase
4240*8975f5c5SAndroid Build Coastguard Worker     // portability of the trace.
4241*8975f5c5SAndroid Build Coastguard Worker     if (getShareGroup()->getFrameCaptureShared()->enabled() ||
4242*8975f5c5SAndroid Build Coastguard Worker         getFrontendFeatures().enableCaptureLimits.enabled)
4243*8975f5c5SAndroid Build Coastguard Worker     {
4244*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limit some features because "
4245*8975f5c5SAndroid Build Coastguard Worker                << (getShareGroup()->getFrameCaptureShared()->enabled()
4246*8975f5c5SAndroid Build Coastguard Worker                        ? "FrameCapture is enabled"
4247*8975f5c5SAndroid Build Coastguard Worker                        : "FrameCapture limits were forced")
4248*8975f5c5SAndroid Build Coastguard Worker                << std::endl;
4249*8975f5c5SAndroid Build Coastguard Worker 
4250*8975f5c5SAndroid Build Coastguard Worker         if (!getFrontendFeatures().enableProgramBinaryForCapture.enabled)
4251*8975f5c5SAndroid Build Coastguard Worker         {
4252*8975f5c5SAndroid Build Coastguard Worker             // Some apps insist on being able to use glProgramBinary. For those, we'll allow the
4253*8975f5c5SAndroid Build Coastguard Worker             // extension to remain on. Otherwise, force the extension off.
4254*8975f5c5SAndroid Build Coastguard Worker             INFO() << "Disabling GL_OES_get_program_binary for trace portability";
4255*8975f5c5SAndroid Build Coastguard Worker             mDisplay->overrideFrontendFeatures({"disable_program_binary"}, true);
4256*8975f5c5SAndroid Build Coastguard Worker         }
4257*8975f5c5SAndroid Build Coastguard Worker 
4258*8975f5c5SAndroid Build Coastguard Worker         // Set to the most common limit per gpuinfo.org. Required for several platforms we test.
4259*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint maxImageUnits = 8;
4260*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting image unit count to " << maxImageUnits;
4261*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxImageUnits, maxImageUnits);
4262*8975f5c5SAndroid Build Coastguard Worker         for (ShaderType shaderType : AllShaderTypes())
4263*8975f5c5SAndroid Build Coastguard Worker         {
4264*8975f5c5SAndroid Build Coastguard Worker             ANGLE_LIMIT_CAP(caps->maxShaderImageUniforms[shaderType], maxImageUnits);
4265*8975f5c5SAndroid Build Coastguard Worker         }
4266*8975f5c5SAndroid Build Coastguard Worker 
4267*8975f5c5SAndroid Build Coastguard Worker         // Set a large uniform buffer offset alignment that works on multiple platforms.
4268*8975f5c5SAndroid Build Coastguard Worker         // The offset used by the trace needs to be divisible by the device's actual value.
4269*8975f5c5SAndroid Build Coastguard Worker         // Values seen during development: ARM (16), Intel (32), Qualcomm (128), Nvidia (256)
4270*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint uniformBufferOffsetAlignment = 256;
4271*8975f5c5SAndroid Build Coastguard Worker         ASSERT(uniformBufferOffsetAlignment % caps->uniformBufferOffsetAlignment == 0);
4272*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Setting uniform buffer offset alignment to " << uniformBufferOffsetAlignment;
4273*8975f5c5SAndroid Build Coastguard Worker         caps->uniformBufferOffsetAlignment = uniformBufferOffsetAlignment;
4274*8975f5c5SAndroid Build Coastguard Worker 
4275*8975f5c5SAndroid Build Coastguard Worker         // Also limit texture buffer offset alignment, if enabled
4276*8975f5c5SAndroid Build Coastguard Worker         if (extensions->textureBufferAny())
4277*8975f5c5SAndroid Build Coastguard Worker         {
4278*8975f5c5SAndroid Build Coastguard Worker             constexpr GLint textureBufferOffsetAlignment =
4279*8975f5c5SAndroid Build Coastguard Worker                 gl::limits::kMinTextureBufferOffsetAlignment;
4280*8975f5c5SAndroid Build Coastguard Worker             ASSERT(textureBufferOffsetAlignment % caps->textureBufferOffsetAlignment == 0);
4281*8975f5c5SAndroid Build Coastguard Worker             INFO() << "Setting texture buffer offset alignment to " << textureBufferOffsetAlignment;
4282*8975f5c5SAndroid Build Coastguard Worker             caps->textureBufferOffsetAlignment = textureBufferOffsetAlignment;
4283*8975f5c5SAndroid Build Coastguard Worker         }
4284*8975f5c5SAndroid Build Coastguard Worker 
4285*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Disabling GL_EXT_map_buffer_range and GL_OES_mapbuffer during capture, which "
4286*8975f5c5SAndroid Build Coastguard Worker                   "are not supported on some native drivers";
4287*8975f5c5SAndroid Build Coastguard Worker         extensions->mapBufferRangeEXT = false;
4288*8975f5c5SAndroid Build Coastguard Worker         extensions->mapbufferOES      = false;
4289*8975f5c5SAndroid Build Coastguard Worker 
4290*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Disabling GL_CHROMIUM_bind_uniform_location during capture, which is not "
4291*8975f5c5SAndroid Build Coastguard Worker                   "supported on native drivers";
4292*8975f5c5SAndroid Build Coastguard Worker         extensions->bindUniformLocationCHROMIUM = false;
4293*8975f5c5SAndroid Build Coastguard Worker 
4294*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Disabling GL_NV_shader_noperspective_interpolation during capture, which is not "
4295*8975f5c5SAndroid Build Coastguard Worker                   "supported on some native drivers";
4296*8975f5c5SAndroid Build Coastguard Worker         extensions->shaderNoperspectiveInterpolationNV = false;
4297*8975f5c5SAndroid Build Coastguard Worker 
4298*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Disabling GL_NV_framebuffer_blit during capture, which is not "
4299*8975f5c5SAndroid Build Coastguard Worker                   "supported on some native drivers";
4300*8975f5c5SAndroid Build Coastguard Worker         extensions->framebufferBlitNV = false;
4301*8975f5c5SAndroid Build Coastguard Worker 
4302*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Disabling GL_EXT_texture_mirror_clamp_to_edge during capture, which is not "
4303*8975f5c5SAndroid Build Coastguard Worker                   "supported on some native drivers";
4304*8975f5c5SAndroid Build Coastguard Worker         extensions->textureMirrorClampToEdgeEXT = false;
4305*8975f5c5SAndroid Build Coastguard Worker 
4306*8975f5c5SAndroid Build Coastguard Worker         // NVIDIA's Vulkan driver only supports 4 draw buffers
4307*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint maxDrawBuffers = 4;
4308*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting draw buffer count to " << maxDrawBuffers;
4309*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxDrawBuffers, maxDrawBuffers);
4310*8975f5c5SAndroid Build Coastguard Worker 
4311*8975f5c5SAndroid Build Coastguard Worker         // Unity based applications are sending down GL streams with undefined behavior.
4312*8975f5c5SAndroid Build Coastguard Worker         // Disabling EGL_KHR_create_context_no_error (which enables a new EGL attrib) prevents that,
4313*8975f5c5SAndroid Build Coastguard Worker         // but we don't have the infrastructure for disabling EGL extensions yet.
4314*8975f5c5SAndroid Build Coastguard Worker         // Instead, disable GL_KHR_no_error (which disables exposing the GL extension), which
4315*8975f5c5SAndroid Build Coastguard Worker         // prevents writing invalid calls to the capture.
4316*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Enabling validation to prevent invalid calls from being captured. This "
4317*8975f5c5SAndroid Build Coastguard Worker                   "effectively disables GL_KHR_no_error and enables GL_ANGLE_robust_client_memory.";
4318*8975f5c5SAndroid Build Coastguard Worker         mErrors.forceValidation();
4319*8975f5c5SAndroid Build Coastguard Worker         extensions->noErrorKHR              = skipValidation();
4320*8975f5c5SAndroid Build Coastguard Worker         extensions->robustClientMemoryANGLE = !skipValidation();
4321*8975f5c5SAndroid Build Coastguard Worker 
4322*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Disabling GL_OES_depth32 during capture, which is not widely supported on "
4323*8975f5c5SAndroid Build Coastguard Worker                   "mobile";
4324*8975f5c5SAndroid Build Coastguard Worker         extensions->depth32OES = false;
4325*8975f5c5SAndroid Build Coastguard Worker 
4326*8975f5c5SAndroid Build Coastguard Worker         // Pixel 4 (Qualcomm) only supports 6 atomic counter buffer bindings.
4327*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint maxAtomicCounterBufferBindings = 6;
4328*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting max atomic counter buffer bindings to "
4329*8975f5c5SAndroid Build Coastguard Worker                << maxAtomicCounterBufferBindings;
4330*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxAtomicCounterBufferBindings, maxAtomicCounterBufferBindings);
4331*8975f5c5SAndroid Build Coastguard Worker         for (gl::ShaderType shaderType : gl::AllShaderTypes())
4332*8975f5c5SAndroid Build Coastguard Worker         {
4333*8975f5c5SAndroid Build Coastguard Worker             ANGLE_LIMIT_CAP(caps->maxShaderAtomicCounterBuffers[shaderType],
4334*8975f5c5SAndroid Build Coastguard Worker                             maxAtomicCounterBufferBindings);
4335*8975f5c5SAndroid Build Coastguard Worker         }
4336*8975f5c5SAndroid Build Coastguard Worker 
4337*8975f5c5SAndroid Build Coastguard Worker         // SwiftShader only supports 12 shader storage buffer bindings.
4338*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint maxShaderStorageBufferBindings = 12;
4339*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting max shader storage buffer bindings to "
4340*8975f5c5SAndroid Build Coastguard Worker                << maxShaderStorageBufferBindings;
4341*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxShaderStorageBufferBindings, maxShaderStorageBufferBindings);
4342*8975f5c5SAndroid Build Coastguard Worker         for (gl::ShaderType shaderType : gl::AllShaderTypes())
4343*8975f5c5SAndroid Build Coastguard Worker         {
4344*8975f5c5SAndroid Build Coastguard Worker             ANGLE_LIMIT_CAP(caps->maxShaderStorageBlocks[shaderType],
4345*8975f5c5SAndroid Build Coastguard Worker                             maxShaderStorageBufferBindings);
4346*8975f5c5SAndroid Build Coastguard Worker         }
4347*8975f5c5SAndroid Build Coastguard Worker 
4348*8975f5c5SAndroid Build Coastguard Worker         // Pixel 7 MAX_TEXTURE_SIZE is 16K
4349*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint max2DTextureSize = 16383;
4350*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting GL_MAX_TEXTURE_SIZE to " << max2DTextureSize;
4351*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->max2DTextureSize, max2DTextureSize);
4352*8975f5c5SAndroid Build Coastguard Worker 
4353*8975f5c5SAndroid Build Coastguard Worker         // Pixel 4 only supports GL_MAX_SAMPLES of 4
4354*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint maxSamples = 4;
4355*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting GL_MAX_SAMPLES to " << maxSamples;
4356*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxSamples, maxSamples);
4357*8975f5c5SAndroid Build Coastguard Worker 
4358*8975f5c5SAndroid Build Coastguard Worker         // Pixel 4/5 only supports GL_MAX_VERTEX_UNIFORM_VECTORS of 256
4359*8975f5c5SAndroid Build Coastguard Worker         constexpr GLint maxVertexUniformVectors = 256;
4360*8975f5c5SAndroid Build Coastguard Worker         INFO() << "Limiting GL_MAX_VERTEX_UNIFORM_VECTORS to " << maxVertexUniformVectors;
4361*8975f5c5SAndroid Build Coastguard Worker         ANGLE_LIMIT_CAP(caps->maxVertexUniformVectors, maxVertexUniformVectors);
4362*8975f5c5SAndroid Build Coastguard Worker 
4363*8975f5c5SAndroid Build Coastguard Worker         // Test if we require shadow memory for coherent buffer tracking
4364*8975f5c5SAndroid Build Coastguard Worker         getShareGroup()->getFrameCaptureShared()->determineMemoryProtectionSupport(this);
4365*8975f5c5SAndroid Build Coastguard Worker     }
4366*8975f5c5SAndroid Build Coastguard Worker 
4367*8975f5c5SAndroid Build Coastguard Worker     // Disable support for OES_get_program_binary
4368*8975f5c5SAndroid Build Coastguard Worker     if (mDisplay->getFrontendFeatures().disableProgramBinary.enabled)
4369*8975f5c5SAndroid Build Coastguard Worker     {
4370*8975f5c5SAndroid Build Coastguard Worker         extensions->getProgramBinaryOES = false;
4371*8975f5c5SAndroid Build Coastguard Worker         caps->shaderBinaryFormats.clear();
4372*8975f5c5SAndroid Build Coastguard Worker         caps->programBinaryFormats.clear();
4373*8975f5c5SAndroid Build Coastguard Worker         mMemoryProgramCache = nullptr;
4374*8975f5c5SAndroid Build Coastguard Worker     }
4375*8975f5c5SAndroid Build Coastguard Worker 
4376*8975f5c5SAndroid Build Coastguard Worker     // Initialize ANGLE_shader_pixel_local_storage caps based on frontend GL queries.
4377*8975f5c5SAndroid Build Coastguard Worker     //
4378*8975f5c5SAndroid Build Coastguard Worker     // The backend may have already initialized these caps with its own custom values, in which case
4379*8975f5c5SAndroid Build Coastguard Worker     // maxPixelLocalStoragePlanes will already be nonzero and we can skip this step.
4380*8975f5c5SAndroid Build Coastguard Worker     if (mSupportedExtensions.shaderPixelLocalStorageANGLE && caps->maxPixelLocalStoragePlanes == 0)
4381*8975f5c5SAndroid Build Coastguard Worker     {
4382*8975f5c5SAndroid Build Coastguard Worker         int maxDrawableAttachments = std::min(caps->maxDrawBuffers, caps->maxColorAttachments);
4383*8975f5c5SAndroid Build Coastguard Worker         switch (mImplementation->getNativePixelLocalStorageOptions().type)
4384*8975f5c5SAndroid Build Coastguard Worker         {
4385*8975f5c5SAndroid Build Coastguard Worker             case ShPixelLocalStorageType::ImageLoadStore:
4386*8975f5c5SAndroid Build Coastguard Worker                 caps->maxPixelLocalStoragePlanes =
4387*8975f5c5SAndroid Build Coastguard Worker                     caps->maxShaderImageUniforms[ShaderType::Fragment];
4388*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_LIMIT_CAP(caps->maxPixelLocalStoragePlanes,
4389*8975f5c5SAndroid Build Coastguard Worker                                 IMPLEMENTATION_MAX_PIXEL_LOCAL_STORAGE_PLANES);
4390*8975f5c5SAndroid Build Coastguard Worker                 caps->maxColorAttachmentsWithActivePixelLocalStorage = caps->maxColorAttachments;
4391*8975f5c5SAndroid Build Coastguard Worker                 caps->maxCombinedDrawBuffersAndPixelLocalStoragePlanes =
4392*8975f5c5SAndroid Build Coastguard Worker                     std::min<GLint>(caps->maxPixelLocalStoragePlanes +
4393*8975f5c5SAndroid Build Coastguard Worker                                         std::min(caps->maxDrawBuffers, caps->maxColorAttachments),
4394*8975f5c5SAndroid Build Coastguard Worker                                     caps->maxCombinedShaderOutputResources);
4395*8975f5c5SAndroid Build Coastguard Worker                 break;
4396*8975f5c5SAndroid Build Coastguard Worker 
4397*8975f5c5SAndroid Build Coastguard Worker             case ShPixelLocalStorageType::FramebufferFetch:
4398*8975f5c5SAndroid Build Coastguard Worker                 caps->maxPixelLocalStoragePlanes = maxDrawableAttachments;
4399*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_LIMIT_CAP(caps->maxPixelLocalStoragePlanes,
4400*8975f5c5SAndroid Build Coastguard Worker                                 IMPLEMENTATION_MAX_PIXEL_LOCAL_STORAGE_PLANES);
4401*8975f5c5SAndroid Build Coastguard Worker                 if (!mSupportedExtensions.drawBuffersIndexedAny())
4402*8975f5c5SAndroid Build Coastguard Worker                 {
4403*8975f5c5SAndroid Build Coastguard Worker                     // When pixel local storage is implemented as framebuffer attachments, we need
4404*8975f5c5SAndroid Build Coastguard Worker                     // to disable color masks and blending to its attachments. If the backend
4405*8975f5c5SAndroid Build Coastguard Worker                     // context doesn't have indexed blend and color mask support, then we will have
4406*8975f5c5SAndroid Build Coastguard Worker                     // have to disable them globally. This also means the application can't have its
4407*8975f5c5SAndroid Build Coastguard Worker                     // own draw buffers while PLS is active.
4408*8975f5c5SAndroid Build Coastguard Worker                     caps->maxColorAttachmentsWithActivePixelLocalStorage = 0;
4409*8975f5c5SAndroid Build Coastguard Worker                 }
4410*8975f5c5SAndroid Build Coastguard Worker                 else
4411*8975f5c5SAndroid Build Coastguard Worker                 {
4412*8975f5c5SAndroid Build Coastguard Worker                     caps->maxColorAttachmentsWithActivePixelLocalStorage =
4413*8975f5c5SAndroid Build Coastguard Worker                         maxDrawableAttachments - 1;
4414*8975f5c5SAndroid Build Coastguard Worker                 }
4415*8975f5c5SAndroid Build Coastguard Worker                 caps->maxCombinedDrawBuffersAndPixelLocalStoragePlanes = maxDrawableAttachments;
4416*8975f5c5SAndroid Build Coastguard Worker                 break;
4417*8975f5c5SAndroid Build Coastguard Worker 
4418*8975f5c5SAndroid Build Coastguard Worker             case ShPixelLocalStorageType::NotSupported:
4419*8975f5c5SAndroid Build Coastguard Worker                 UNREACHABLE();
4420*8975f5c5SAndroid Build Coastguard Worker                 break;
4421*8975f5c5SAndroid Build Coastguard Worker         }
4422*8975f5c5SAndroid Build Coastguard Worker     }
4423*8975f5c5SAndroid Build Coastguard Worker     // Validate that pixel local storage caps were initialized within implementation limits. We
4424*8975f5c5SAndroid Build Coastguard Worker     // can't just clamp this value here since it would potentially impact other caps.
4425*8975f5c5SAndroid Build Coastguard Worker     ASSERT(caps->maxPixelLocalStoragePlanes <= IMPLEMENTATION_MAX_PIXEL_LOCAL_STORAGE_PLANES);
4426*8975f5c5SAndroid Build Coastguard Worker 
4427*8975f5c5SAndroid Build Coastguard Worker #undef ANGLE_LIMIT_CAP
4428*8975f5c5SAndroid Build Coastguard Worker #undef ANGLE_LOG_CAP_LIMIT
4429*8975f5c5SAndroid Build Coastguard Worker 
4430*8975f5c5SAndroid Build Coastguard Worker     // Generate texture caps
4431*8975f5c5SAndroid Build Coastguard Worker     updateCaps();
4432*8975f5c5SAndroid Build Coastguard Worker }
4433*8975f5c5SAndroid Build Coastguard Worker 
updateCaps()4434*8975f5c5SAndroid Build Coastguard Worker void Context::updateCaps()
4435*8975f5c5SAndroid Build Coastguard Worker {
4436*8975f5c5SAndroid Build Coastguard Worker     Caps *caps                  = mState.getMutableCaps();
4437*8975f5c5SAndroid Build Coastguard Worker     TextureCapsMap *textureCaps = mState.getMutableTextureCaps();
4438*8975f5c5SAndroid Build Coastguard Worker 
4439*8975f5c5SAndroid Build Coastguard Worker     caps->compressedTextureFormats.clear();
4440*8975f5c5SAndroid Build Coastguard Worker     textureCaps->clear();
4441*8975f5c5SAndroid Build Coastguard Worker 
4442*8975f5c5SAndroid Build Coastguard Worker     for (GLenum sizedInternalFormat : GetAllSizedInternalFormats())
4443*8975f5c5SAndroid Build Coastguard Worker     {
4444*8975f5c5SAndroid Build Coastguard Worker         TextureCaps formatCaps = mImplementation->getNativeTextureCaps().get(sizedInternalFormat);
4445*8975f5c5SAndroid Build Coastguard Worker         const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat);
4446*8975f5c5SAndroid Build Coastguard Worker 
4447*8975f5c5SAndroid Build Coastguard Worker         // Update the format caps based on the client version and extensions.
4448*8975f5c5SAndroid Build Coastguard Worker         // Caps are AND'd with the renderer caps because some core formats are still unsupported in
4449*8975f5c5SAndroid Build Coastguard Worker         // ES3.
4450*8975f5c5SAndroid Build Coastguard Worker         formatCaps.texturable =
4451*8975f5c5SAndroid Build Coastguard Worker             formatCaps.texturable &&
4452*8975f5c5SAndroid Build Coastguard Worker             formatInfo.textureSupport(getClientVersion(), mState.getExtensions());
4453*8975f5c5SAndroid Build Coastguard Worker         formatCaps.filterable =
4454*8975f5c5SAndroid Build Coastguard Worker             formatCaps.filterable &&
4455*8975f5c5SAndroid Build Coastguard Worker             formatInfo.filterSupport(getClientVersion(), mState.getExtensions());
4456*8975f5c5SAndroid Build Coastguard Worker         formatCaps.textureAttachment =
4457*8975f5c5SAndroid Build Coastguard Worker             formatCaps.textureAttachment &&
4458*8975f5c5SAndroid Build Coastguard Worker             formatInfo.textureAttachmentSupport(getClientVersion(), mState.getExtensions());
4459*8975f5c5SAndroid Build Coastguard Worker         formatCaps.renderbuffer =
4460*8975f5c5SAndroid Build Coastguard Worker             formatCaps.renderbuffer &&
4461*8975f5c5SAndroid Build Coastguard Worker             formatInfo.renderbufferSupport(getClientVersion(), mState.getExtensions());
4462*8975f5c5SAndroid Build Coastguard Worker         formatCaps.blendable = formatCaps.blendable &&
4463*8975f5c5SAndroid Build Coastguard Worker                                formatInfo.blendSupport(getClientVersion(), mState.getExtensions());
4464*8975f5c5SAndroid Build Coastguard Worker 
4465*8975f5c5SAndroid Build Coastguard Worker         // OpenGL ES does not support multisampling with non-rendererable formats
4466*8975f5c5SAndroid Build Coastguard Worker         // OpenGL ES 3.0 or prior does not support multisampling with integer formats
4467*8975f5c5SAndroid Build Coastguard Worker         if (!formatCaps.renderbuffer ||
4468*8975f5c5SAndroid Build Coastguard Worker             (getClientVersion() < ES_3_1 && !mState.getExtensions().textureMultisampleANGLE &&
4469*8975f5c5SAndroid Build Coastguard Worker              formatInfo.isInt()))
4470*8975f5c5SAndroid Build Coastguard Worker         {
4471*8975f5c5SAndroid Build Coastguard Worker             formatCaps.sampleCounts.clear();
4472*8975f5c5SAndroid Build Coastguard Worker         }
4473*8975f5c5SAndroid Build Coastguard Worker         else
4474*8975f5c5SAndroid Build Coastguard Worker         {
4475*8975f5c5SAndroid Build Coastguard Worker             // We may have limited the max samples for some required renderbuffer formats due to
4476*8975f5c5SAndroid Build Coastguard Worker             // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly.
4477*8975f5c5SAndroid Build Coastguard Worker             GLuint formatMaxSamples = formatCaps.getMaxSamples();
4478*8975f5c5SAndroid Build Coastguard Worker 
4479*8975f5c5SAndroid Build Coastguard Worker             // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers
4480*8975f5c5SAndroid Build Coastguard Worker             // in these required formats with up to the value of MAX_SAMPLES multisamples, with the
4481*8975f5c5SAndroid Build Coastguard Worker             // exception of signed and unsigned integer formats."
4482*8975f5c5SAndroid Build Coastguard Worker             if (!formatInfo.isInt() && formatInfo.isRequiredRenderbufferFormat(getClientVersion()))
4483*8975f5c5SAndroid Build Coastguard Worker             {
4484*8975f5c5SAndroid Build Coastguard Worker                 ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4);
4485*8975f5c5SAndroid Build Coastguard Worker                 caps->maxSamples =
4486*8975f5c5SAndroid Build Coastguard Worker                     std::min(static_cast<GLuint>(caps->maxSamples), formatMaxSamples);
4487*8975f5c5SAndroid Build Coastguard Worker             }
4488*8975f5c5SAndroid Build Coastguard Worker 
4489*8975f5c5SAndroid Build Coastguard Worker             // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES.
4490*8975f5c5SAndroid Build Coastguard Worker             if (getClientVersion() >= ES_3_1 || mState.getExtensions().textureMultisampleANGLE)
4491*8975f5c5SAndroid Build Coastguard Worker             {
4492*8975f5c5SAndroid Build Coastguard Worker                 // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers
4493*8975f5c5SAndroid Build Coastguard Worker                 // in these required formats with up to the value of MAX_SAMPLES multisamples, with
4494*8975f5c5SAndroid Build Coastguard Worker                 // the exception that the signed and unsigned integer formats are required only to
4495*8975f5c5SAndroid Build Coastguard Worker                 // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES
4496*8975f5c5SAndroid Build Coastguard Worker                 // multisamples, which must be at least one."
4497*8975f5c5SAndroid Build Coastguard Worker                 if (formatInfo.isInt())
4498*8975f5c5SAndroid Build Coastguard Worker                 {
4499*8975f5c5SAndroid Build Coastguard Worker                     caps->maxIntegerSamples =
4500*8975f5c5SAndroid Build Coastguard Worker                         std::min(static_cast<GLuint>(caps->maxIntegerSamples), formatMaxSamples);
4501*8975f5c5SAndroid Build Coastguard Worker                 }
4502*8975f5c5SAndroid Build Coastguard Worker 
4503*8975f5c5SAndroid Build Coastguard Worker                 // GLES 3.1 section 19.3.1.
4504*8975f5c5SAndroid Build Coastguard Worker                 if (formatCaps.texturable)
4505*8975f5c5SAndroid Build Coastguard Worker                 {
4506*8975f5c5SAndroid Build Coastguard Worker                     if (formatInfo.depthBits > 0)
4507*8975f5c5SAndroid Build Coastguard Worker                     {
4508*8975f5c5SAndroid Build Coastguard Worker                         caps->maxDepthTextureSamples = std::min(
4509*8975f5c5SAndroid Build Coastguard Worker                             static_cast<GLuint>(caps->maxDepthTextureSamples), formatMaxSamples);
4510*8975f5c5SAndroid Build Coastguard Worker                     }
4511*8975f5c5SAndroid Build Coastguard Worker                     else if (formatInfo.redBits > 0)
4512*8975f5c5SAndroid Build Coastguard Worker                     {
4513*8975f5c5SAndroid Build Coastguard Worker                         caps->maxColorTextureSamples = std::min(
4514*8975f5c5SAndroid Build Coastguard Worker                             static_cast<GLuint>(caps->maxColorTextureSamples), formatMaxSamples);
4515*8975f5c5SAndroid Build Coastguard Worker                     }
4516*8975f5c5SAndroid Build Coastguard Worker                 }
4517*8975f5c5SAndroid Build Coastguard Worker             }
4518*8975f5c5SAndroid Build Coastguard Worker         }
4519*8975f5c5SAndroid Build Coastguard Worker 
4520*8975f5c5SAndroid Build Coastguard Worker         if (formatCaps.texturable && (formatInfo.compressed || formatInfo.paletted))
4521*8975f5c5SAndroid Build Coastguard Worker         {
4522*8975f5c5SAndroid Build Coastguard Worker             caps->compressedTextureFormats.push_back(sizedInternalFormat);
4523*8975f5c5SAndroid Build Coastguard Worker         }
4524*8975f5c5SAndroid Build Coastguard Worker 
4525*8975f5c5SAndroid Build Coastguard Worker         textureCaps->insert(sizedInternalFormat, formatCaps);
4526*8975f5c5SAndroid Build Coastguard Worker     }
4527*8975f5c5SAndroid Build Coastguard Worker 
4528*8975f5c5SAndroid Build Coastguard Worker     // If program binary is disabled, blank out the memory cache pointer.
4529*8975f5c5SAndroid Build Coastguard Worker     if (!mSupportedExtensions.getProgramBinaryOES)
4530*8975f5c5SAndroid Build Coastguard Worker     {
4531*8975f5c5SAndroid Build Coastguard Worker         mMemoryProgramCache = nullptr;
4532*8975f5c5SAndroid Build Coastguard Worker     }
4533*8975f5c5SAndroid Build Coastguard Worker 
4534*8975f5c5SAndroid Build Coastguard Worker     // Compute which buffer types are allowed
4535*8975f5c5SAndroid Build Coastguard Worker     mValidBufferBindings.reset();
4536*8975f5c5SAndroid Build Coastguard Worker     mValidBufferBindings.set(BufferBinding::ElementArray);
4537*8975f5c5SAndroid Build Coastguard Worker     mValidBufferBindings.set(BufferBinding::Array);
4538*8975f5c5SAndroid Build Coastguard Worker 
4539*8975f5c5SAndroid Build Coastguard Worker     if (mState.getExtensions().pixelBufferObjectNV || getClientVersion() >= ES_3_0)
4540*8975f5c5SAndroid Build Coastguard Worker     {
4541*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::PixelPack);
4542*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::PixelUnpack);
4543*8975f5c5SAndroid Build Coastguard Worker     }
4544*8975f5c5SAndroid Build Coastguard Worker 
4545*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= ES_3_0)
4546*8975f5c5SAndroid Build Coastguard Worker     {
4547*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::CopyRead);
4548*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::CopyWrite);
4549*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::TransformFeedback);
4550*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::Uniform);
4551*8975f5c5SAndroid Build Coastguard Worker     }
4552*8975f5c5SAndroid Build Coastguard Worker 
4553*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= ES_3_1)
4554*8975f5c5SAndroid Build Coastguard Worker     {
4555*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::AtomicCounter);
4556*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::ShaderStorage);
4557*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::DrawIndirect);
4558*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::DispatchIndirect);
4559*8975f5c5SAndroid Build Coastguard Worker     }
4560*8975f5c5SAndroid Build Coastguard Worker 
4561*8975f5c5SAndroid Build Coastguard Worker     if (getClientVersion() >= ES_3_2 || mState.getExtensions().textureBufferAny())
4562*8975f5c5SAndroid Build Coastguard Worker     {
4563*8975f5c5SAndroid Build Coastguard Worker         mValidBufferBindings.set(BufferBinding::Texture);
4564*8975f5c5SAndroid Build Coastguard Worker     }
4565*8975f5c5SAndroid Build Coastguard Worker 
4566*8975f5c5SAndroid Build Coastguard Worker     // Reinitialize some dirty bits that depend on extensions.
4567*8975f5c5SAndroid Build Coastguard Worker     if (mState.isRobustResourceInitEnabled())
4568*8975f5c5SAndroid Build Coastguard Worker     {
4569*8975f5c5SAndroid Build Coastguard Worker         mDrawDirtyObjects.set(state::DIRTY_OBJECT_DRAW_ATTACHMENTS);
4570*8975f5c5SAndroid Build Coastguard Worker         mDrawDirtyObjects.set(state::DIRTY_OBJECT_TEXTURES_INIT);
4571*8975f5c5SAndroid Build Coastguard Worker         mDrawDirtyObjects.set(state::DIRTY_OBJECT_IMAGES_INIT);
4572*8975f5c5SAndroid Build Coastguard Worker         mBlitDirtyObjects.set(state::DIRTY_OBJECT_DRAW_ATTACHMENTS);
4573*8975f5c5SAndroid Build Coastguard Worker         mBlitDirtyObjects.set(state::DIRTY_OBJECT_READ_ATTACHMENTS);
4574*8975f5c5SAndroid Build Coastguard Worker         mComputeDirtyObjects.set(state::DIRTY_OBJECT_TEXTURES_INIT);
4575*8975f5c5SAndroid Build Coastguard Worker         mComputeDirtyObjects.set(state::DIRTY_OBJECT_IMAGES_INIT);
4576*8975f5c5SAndroid Build Coastguard Worker         mReadPixelsDirtyObjects.set(state::DIRTY_OBJECT_READ_ATTACHMENTS);
4577*8975f5c5SAndroid Build Coastguard Worker         mCopyImageDirtyBits.set(state::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
4578*8975f5c5SAndroid Build Coastguard Worker         mCopyImageDirtyObjects.set(state::DIRTY_OBJECT_READ_ATTACHMENTS);
4579*8975f5c5SAndroid Build Coastguard Worker     }
4580*8975f5c5SAndroid Build Coastguard Worker 
4581*8975f5c5SAndroid Build Coastguard Worker     // We need to validate buffer bounds if we are in a WebGL or robust access context and the
4582*8975f5c5SAndroid Build Coastguard Worker     // back-end does not support robust buffer access behaviour.
4583*8975f5c5SAndroid Build Coastguard Worker     mBufferAccessValidationEnabled = (!mSupportedExtensions.robustBufferAccessBehaviorKHR &&
4584*8975f5c5SAndroid Build Coastguard Worker                                       (mState.isWebGL() || mState.hasRobustAccess()));
4585*8975f5c5SAndroid Build Coastguard Worker 
4586*8975f5c5SAndroid Build Coastguard Worker     // Cache this in the VertexArrays. They need to check it in state change notifications.
4587*8975f5c5SAndroid Build Coastguard Worker     // Note: vertex array objects are private to context and so the map doesn't need locking
4588*8975f5c5SAndroid Build Coastguard Worker     for (auto vaoIter : UnsafeResourceMapIter(mVertexArrayMap))
4589*8975f5c5SAndroid Build Coastguard Worker     {
4590*8975f5c5SAndroid Build Coastguard Worker         VertexArray *vao = vaoIter.second;
4591*8975f5c5SAndroid Build Coastguard Worker         vao->setBufferAccessValidationEnabled(mBufferAccessValidationEnabled);
4592*8975f5c5SAndroid Build Coastguard Worker     }
4593*8975f5c5SAndroid Build Coastguard Worker 
4594*8975f5c5SAndroid Build Coastguard Worker     // Reinitialize state cache after extension changes.
4595*8975f5c5SAndroid Build Coastguard Worker     mStateCache.initialize(this);
4596*8975f5c5SAndroid Build Coastguard Worker }
4597*8975f5c5SAndroid Build Coastguard Worker 
noopDrawInstanced(PrimitiveMode mode,GLsizei count,GLsizei instanceCount) const4598*8975f5c5SAndroid Build Coastguard Worker bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) const
4599*8975f5c5SAndroid Build Coastguard Worker {
4600*8975f5c5SAndroid Build Coastguard Worker     return (instanceCount == 0) || noopDraw(mode, count);
4601*8975f5c5SAndroid Build Coastguard Worker }
4602*8975f5c5SAndroid Build Coastguard Worker 
prepareForClear(GLbitfield mask)4603*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::prepareForClear(GLbitfield mask)
4604*8975f5c5SAndroid Build Coastguard Worker {
4605*8975f5c5SAndroid Build Coastguard Worker     // Sync the draw framebuffer manually after the clear attachments.
4606*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask));
4607*8975f5c5SAndroid Build Coastguard Worker     return syncStateForClear();
4608*8975f5c5SAndroid Build Coastguard Worker }
4609*8975f5c5SAndroid Build Coastguard Worker 
prepareForClearBuffer(GLenum buffer,GLint drawbuffer)4610*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer)
4611*8975f5c5SAndroid Build Coastguard Worker {
4612*8975f5c5SAndroid Build Coastguard Worker     // Sync the draw framebuffer manually after the clear attachments.
4613*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer,
4614*8975f5c5SAndroid Build Coastguard Worker                                                                                    drawbuffer));
4615*8975f5c5SAndroid Build Coastguard Worker     return syncStateForClear();
4616*8975f5c5SAndroid Build Coastguard Worker }
4617*8975f5c5SAndroid Build Coastguard Worker 
prepareForCopyImage()4618*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE angle::Result Context::prepareForCopyImage()
4619*8975f5c5SAndroid Build Coastguard Worker {
4620*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(syncDirtyObjects(mCopyImageDirtyObjects, Command::CopyImage));
4621*8975f5c5SAndroid Build Coastguard Worker     return syncDirtyBits(mCopyImageDirtyBits, kCopyImageExtendedDirtyBits, Command::CopyImage);
4622*8975f5c5SAndroid Build Coastguard Worker }
4623*8975f5c5SAndroid Build Coastguard Worker 
prepareForDispatch()4624*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE angle::Result Context::prepareForDispatch()
4625*8975f5c5SAndroid Build Coastguard Worker {
4626*8975f5c5SAndroid Build Coastguard Worker     // Converting a PPO from graphics to compute requires re-linking it.
4627*8975f5c5SAndroid Build Coastguard Worker     // The compute shader must have successfully linked before being included in the PPO, so no link
4628*8975f5c5SAndroid Build Coastguard Worker     // errors that would have been caught during validation should be possible when re-linking the
4629*8975f5c5SAndroid Build Coastguard Worker     // PPO with the compute shader.
4630*8975f5c5SAndroid Build Coastguard Worker     Program *program          = mState.getProgram();
4631*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *pipeline = mState.getProgramPipeline();
4632*8975f5c5SAndroid Build Coastguard Worker     if (!program && pipeline)
4633*8975f5c5SAndroid Build Coastguard Worker     {
4634*8975f5c5SAndroid Build Coastguard Worker         // Linking the PPO can't fail due to a validation error within the compute program,
4635*8975f5c5SAndroid Build Coastguard Worker         // since it successfully linked already in order to become part of the PPO in the first
4636*8975f5c5SAndroid Build Coastguard Worker         // place.
4637*8975f5c5SAndroid Build Coastguard Worker         pipeline->resolveLink(this);
4638*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CHECK(this, pipeline->isLinked(), "Program pipeline link failed",
4639*8975f5c5SAndroid Build Coastguard Worker                     GL_INVALID_OPERATION);
4640*8975f5c5SAndroid Build Coastguard Worker     }
4641*8975f5c5SAndroid Build Coastguard Worker 
4642*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(syncDirtyObjects(mComputeDirtyObjects, Command::Dispatch));
4643*8975f5c5SAndroid Build Coastguard Worker     return syncDirtyBits(kComputeDirtyBits, kComputeExtendedDirtyBits, Command::Dispatch);
4644*8975f5c5SAndroid Build Coastguard Worker }
4645*8975f5c5SAndroid Build Coastguard Worker 
prepareForInvalidate(GLenum target)4646*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::prepareForInvalidate(GLenum target)
4647*8975f5c5SAndroid Build Coastguard Worker {
4648*8975f5c5SAndroid Build Coastguard Worker     // Only sync the FBO that's being invalidated.  Per the GLES3 spec, GL_FRAMEBUFFER is equivalent
4649*8975f5c5SAndroid Build Coastguard Worker     // to GL_DRAW_FRAMEBUFFER for the purposes of invalidation.
4650*8975f5c5SAndroid Build Coastguard Worker     GLenum effectiveTarget = target;
4651*8975f5c5SAndroid Build Coastguard Worker     if (effectiveTarget == GL_FRAMEBUFFER)
4652*8975f5c5SAndroid Build Coastguard Worker     {
4653*8975f5c5SAndroid Build Coastguard Worker         effectiveTarget = GL_DRAW_FRAMEBUFFER;
4654*8975f5c5SAndroid Build Coastguard Worker     }
4655*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(mState.syncDirtyObject(this, effectiveTarget));
4656*8975f5c5SAndroid Build Coastguard Worker     const state::DirtyBits dirtyBits                 = effectiveTarget == GL_READ_FRAMEBUFFER
4657*8975f5c5SAndroid Build Coastguard Worker                                                            ? kReadInvalidateDirtyBits
4658*8975f5c5SAndroid Build Coastguard Worker                                                            : kDrawInvalidateDirtyBits;
4659*8975f5c5SAndroid Build Coastguard Worker     const state::ExtendedDirtyBits extendedDirtyBits = effectiveTarget == GL_READ_FRAMEBUFFER
4660*8975f5c5SAndroid Build Coastguard Worker                                                            ? kReadInvalidateExtendedDirtyBits
4661*8975f5c5SAndroid Build Coastguard Worker                                                            : kDrawInvalidateExtendedDirtyBits;
4662*8975f5c5SAndroid Build Coastguard Worker     return syncDirtyBits(dirtyBits, extendedDirtyBits, Command::Invalidate);
4663*8975f5c5SAndroid Build Coastguard Worker }
4664*8975f5c5SAndroid Build Coastguard Worker 
syncState(const state::DirtyBits bitMask,const state::ExtendedDirtyBits extendedBitMask,const state::DirtyObjects & objectMask,Command command)4665*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::syncState(const state::DirtyBits bitMask,
4666*8975f5c5SAndroid Build Coastguard Worker                                  const state::ExtendedDirtyBits extendedBitMask,
4667*8975f5c5SAndroid Build Coastguard Worker                                  const state::DirtyObjects &objectMask,
4668*8975f5c5SAndroid Build Coastguard Worker                                  Command command)
4669*8975f5c5SAndroid Build Coastguard Worker {
4670*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(syncDirtyObjects(objectMask, command));
4671*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(syncDirtyBits(bitMask, extendedBitMask, command));
4672*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
4673*8975f5c5SAndroid Build Coastguard Worker }
4674*8975f5c5SAndroid Build Coastguard Worker 
blitFramebuffer(GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)4675*8975f5c5SAndroid Build Coastguard Worker void Context::blitFramebuffer(GLint srcX0,
4676*8975f5c5SAndroid Build Coastguard Worker                               GLint srcY0,
4677*8975f5c5SAndroid Build Coastguard Worker                               GLint srcX1,
4678*8975f5c5SAndroid Build Coastguard Worker                               GLint srcY1,
4679*8975f5c5SAndroid Build Coastguard Worker                               GLint dstX0,
4680*8975f5c5SAndroid Build Coastguard Worker                               GLint dstY0,
4681*8975f5c5SAndroid Build Coastguard Worker                               GLint dstX1,
4682*8975f5c5SAndroid Build Coastguard Worker                               GLint dstY1,
4683*8975f5c5SAndroid Build Coastguard Worker                               GLbitfield mask,
4684*8975f5c5SAndroid Build Coastguard Worker                               GLenum filter)
4685*8975f5c5SAndroid Build Coastguard Worker {
4686*8975f5c5SAndroid Build Coastguard Worker     if (mask == 0)
4687*8975f5c5SAndroid Build Coastguard Worker     {
4688*8975f5c5SAndroid Build Coastguard Worker         // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no
4689*8975f5c5SAndroid Build Coastguard Worker         // buffers are copied.
4690*8975f5c5SAndroid Build Coastguard Worker         return;
4691*8975f5c5SAndroid Build Coastguard Worker     }
4692*8975f5c5SAndroid Build Coastguard Worker 
4693*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *drawFramebuffer = mState.getDrawFramebuffer();
4694*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *readFramebuffer = mState.getReadFramebuffer();
4695*8975f5c5SAndroid Build Coastguard Worker     ASSERT(drawFramebuffer);
4696*8975f5c5SAndroid Build Coastguard Worker     ASSERT(readFramebuffer);
4697*8975f5c5SAndroid Build Coastguard Worker 
4698*8975f5c5SAndroid Build Coastguard Worker     // Note that blitting is called against draw framebuffer.
4699*8975f5c5SAndroid Build Coastguard Worker     // See the code in gl::Context::blitFramebuffer.
4700*8975f5c5SAndroid Build Coastguard Worker     if ((mask & GL_COLOR_BUFFER_BIT) && (!drawFramebuffer->hasEnabledDrawBuffer() ||
4701*8975f5c5SAndroid Build Coastguard Worker                                          readFramebuffer->getReadColorAttachment() == nullptr))
4702*8975f5c5SAndroid Build Coastguard Worker     {
4703*8975f5c5SAndroid Build Coastguard Worker         mask &= ~GL_COLOR_BUFFER_BIT;
4704*8975f5c5SAndroid Build Coastguard Worker     }
4705*8975f5c5SAndroid Build Coastguard Worker 
4706*8975f5c5SAndroid Build Coastguard Worker     if ((mask & GL_STENCIL_BUFFER_BIT) &&
4707*8975f5c5SAndroid Build Coastguard Worker         (drawFramebuffer->getState().getStencilAttachment() == nullptr ||
4708*8975f5c5SAndroid Build Coastguard Worker          readFramebuffer->getState().getStencilAttachment() == nullptr))
4709*8975f5c5SAndroid Build Coastguard Worker     {
4710*8975f5c5SAndroid Build Coastguard Worker         mask &= ~GL_STENCIL_BUFFER_BIT;
4711*8975f5c5SAndroid Build Coastguard Worker     }
4712*8975f5c5SAndroid Build Coastguard Worker 
4713*8975f5c5SAndroid Build Coastguard Worker     if ((mask & GL_DEPTH_BUFFER_BIT) &&
4714*8975f5c5SAndroid Build Coastguard Worker         (drawFramebuffer->getState().getDepthAttachment() == nullptr ||
4715*8975f5c5SAndroid Build Coastguard Worker          readFramebuffer->getState().getDepthAttachment() == nullptr))
4716*8975f5c5SAndroid Build Coastguard Worker     {
4717*8975f5c5SAndroid Build Coastguard Worker         mask &= ~GL_DEPTH_BUFFER_BIT;
4718*8975f5c5SAndroid Build Coastguard Worker     }
4719*8975f5c5SAndroid Build Coastguard Worker 
4720*8975f5c5SAndroid Build Coastguard Worker     // Early out if none of the specified attachments exist or are enabled.
4721*8975f5c5SAndroid Build Coastguard Worker     if (mask == 0)
4722*8975f5c5SAndroid Build Coastguard Worker     {
4723*8975f5c5SAndroid Build Coastguard Worker         ANGLE_PERF_WARNING(mState.getDebug(), GL_DEBUG_SEVERITY_LOW,
4724*8975f5c5SAndroid Build Coastguard Worker                            "BlitFramebuffer called for non-existing buffers");
4725*8975f5c5SAndroid Build Coastguard Worker         return;
4726*8975f5c5SAndroid Build Coastguard Worker     }
4727*8975f5c5SAndroid Build Coastguard Worker 
4728*8975f5c5SAndroid Build Coastguard Worker     Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0);
4729*8975f5c5SAndroid Build Coastguard Worker     Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0);
4730*8975f5c5SAndroid Build Coastguard Worker 
4731*8975f5c5SAndroid Build Coastguard Worker     if (dstArea.width == 0 || dstArea.height == 0)
4732*8975f5c5SAndroid Build Coastguard Worker     {
4733*8975f5c5SAndroid Build Coastguard Worker         return;
4734*8975f5c5SAndroid Build Coastguard Worker     }
4735*8975f5c5SAndroid Build Coastguard Worker 
4736*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForBlit(mask));
4737*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter));
4738*8975f5c5SAndroid Build Coastguard Worker }
4739*8975f5c5SAndroid Build Coastguard Worker 
blitFramebufferNV(GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)4740*8975f5c5SAndroid Build Coastguard Worker void Context::blitFramebufferNV(GLint srcX0,
4741*8975f5c5SAndroid Build Coastguard Worker                                 GLint srcY0,
4742*8975f5c5SAndroid Build Coastguard Worker                                 GLint srcX1,
4743*8975f5c5SAndroid Build Coastguard Worker                                 GLint srcY1,
4744*8975f5c5SAndroid Build Coastguard Worker                                 GLint dstX0,
4745*8975f5c5SAndroid Build Coastguard Worker                                 GLint dstY0,
4746*8975f5c5SAndroid Build Coastguard Worker                                 GLint dstX1,
4747*8975f5c5SAndroid Build Coastguard Worker                                 GLint dstY1,
4748*8975f5c5SAndroid Build Coastguard Worker                                 GLbitfield mask,
4749*8975f5c5SAndroid Build Coastguard Worker                                 GLenum filter)
4750*8975f5c5SAndroid Build Coastguard Worker {
4751*8975f5c5SAndroid Build Coastguard Worker     blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
4752*8975f5c5SAndroid Build Coastguard Worker }
4753*8975f5c5SAndroid Build Coastguard Worker 
clear(GLbitfield mask)4754*8975f5c5SAndroid Build Coastguard Worker void Context::clear(GLbitfield mask)
4755*8975f5c5SAndroid Build Coastguard Worker {
4756*8975f5c5SAndroid Build Coastguard Worker     if (mState.isRasterizerDiscardEnabled())
4757*8975f5c5SAndroid Build Coastguard Worker     {
4758*8975f5c5SAndroid Build Coastguard Worker         return;
4759*8975f5c5SAndroid Build Coastguard Worker     }
4760*8975f5c5SAndroid Build Coastguard Worker 
4761*8975f5c5SAndroid Build Coastguard Worker     // Remove clear bits that are ineffective. An effective clear changes at least one fragment. If
4762*8975f5c5SAndroid Build Coastguard Worker     // color/depth/stencil masks make the clear ineffective we skip it altogether.
4763*8975f5c5SAndroid Build Coastguard Worker 
4764*8975f5c5SAndroid Build Coastguard Worker     // If all color channels in all draw buffers are masked, don't attempt to clear color.
4765*8975f5c5SAndroid Build Coastguard Worker     if (mState.allActiveDrawBufferChannelsMasked())
4766*8975f5c5SAndroid Build Coastguard Worker     {
4767*8975f5c5SAndroid Build Coastguard Worker         mask &= ~GL_COLOR_BUFFER_BIT;
4768*8975f5c5SAndroid Build Coastguard Worker     }
4769*8975f5c5SAndroid Build Coastguard Worker 
4770*8975f5c5SAndroid Build Coastguard Worker     // If depth write is disabled, don't attempt to clear depth.
4771*8975f5c5SAndroid Build Coastguard Worker     if (mState.getDrawFramebuffer()->getDepthAttachment() == nullptr ||
4772*8975f5c5SAndroid Build Coastguard Worker         mState.getDepthStencilState().isDepthMaskedOut())
4773*8975f5c5SAndroid Build Coastguard Worker     {
4774*8975f5c5SAndroid Build Coastguard Worker         mask &= ~GL_DEPTH_BUFFER_BIT;
4775*8975f5c5SAndroid Build Coastguard Worker     }
4776*8975f5c5SAndroid Build Coastguard Worker 
4777*8975f5c5SAndroid Build Coastguard Worker     // If all stencil bits are masked, don't attempt to clear stencil.
4778*8975f5c5SAndroid Build Coastguard Worker     if (mState.getDepthStencilState().isStencilMaskedOut(
4779*8975f5c5SAndroid Build Coastguard Worker             mState.getDrawFramebuffer()->getStencilBitCount()))
4780*8975f5c5SAndroid Build Coastguard Worker     {
4781*8975f5c5SAndroid Build Coastguard Worker         mask &= ~GL_STENCIL_BUFFER_BIT;
4782*8975f5c5SAndroid Build Coastguard Worker     }
4783*8975f5c5SAndroid Build Coastguard Worker 
4784*8975f5c5SAndroid Build Coastguard Worker     if (mask == 0)
4785*8975f5c5SAndroid Build Coastguard Worker     {
4786*8975f5c5SAndroid Build Coastguard Worker         ANGLE_PERF_WARNING(mState.getDebug(), GL_DEBUG_SEVERITY_LOW,
4787*8975f5c5SAndroid Build Coastguard Worker                            "Clear called for non-existing buffers");
4788*8975f5c5SAndroid Build Coastguard Worker         return;
4789*8975f5c5SAndroid Build Coastguard Worker     }
4790*8975f5c5SAndroid Build Coastguard Worker 
4791*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForClear(mask));
4792*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mState.getDrawFramebuffer()->clear(this, mask));
4793*8975f5c5SAndroid Build Coastguard Worker }
4794*8975f5c5SAndroid Build Coastguard Worker 
isClearBufferMaskedOut(GLenum buffer,GLint drawbuffer,GLuint framebufferStencilSize) const4795*8975f5c5SAndroid Build Coastguard Worker bool Context::isClearBufferMaskedOut(GLenum buffer,
4796*8975f5c5SAndroid Build Coastguard Worker                                      GLint drawbuffer,
4797*8975f5c5SAndroid Build Coastguard Worker                                      GLuint framebufferStencilSize) const
4798*8975f5c5SAndroid Build Coastguard Worker {
4799*8975f5c5SAndroid Build Coastguard Worker     switch (buffer)
4800*8975f5c5SAndroid Build Coastguard Worker     {
4801*8975f5c5SAndroid Build Coastguard Worker         case GL_COLOR:
4802*8975f5c5SAndroid Build Coastguard Worker             return IsColorMaskedOut(mState.getBlendStateExt(), drawbuffer);
4803*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH:
4804*8975f5c5SAndroid Build Coastguard Worker             return mState.getDepthStencilState().isDepthMaskedOut();
4805*8975f5c5SAndroid Build Coastguard Worker         case GL_STENCIL:
4806*8975f5c5SAndroid Build Coastguard Worker             return mState.getDepthStencilState().isStencilMaskedOut(framebufferStencilSize);
4807*8975f5c5SAndroid Build Coastguard Worker         case GL_DEPTH_STENCIL:
4808*8975f5c5SAndroid Build Coastguard Worker             return mState.getDepthStencilState().isDepthMaskedOut() &&
4809*8975f5c5SAndroid Build Coastguard Worker                    mState.getDepthStencilState().isStencilMaskedOut(framebufferStencilSize);
4810*8975f5c5SAndroid Build Coastguard Worker         default:
4811*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
4812*8975f5c5SAndroid Build Coastguard Worker             return true;
4813*8975f5c5SAndroid Build Coastguard Worker     }
4814*8975f5c5SAndroid Build Coastguard Worker }
4815*8975f5c5SAndroid Build Coastguard Worker 
noopClearBuffer(GLenum buffer,GLint drawbuffer) const4816*8975f5c5SAndroid Build Coastguard Worker bool Context::noopClearBuffer(GLenum buffer, GLint drawbuffer) const
4817*8975f5c5SAndroid Build Coastguard Worker {
4818*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebufferObject = mState.getDrawFramebuffer();
4819*8975f5c5SAndroid Build Coastguard Worker 
4820*8975f5c5SAndroid Build Coastguard Worker     if (buffer == GL_COLOR && getPrivateState().isActivelyOverriddenPLSDrawBuffer(drawbuffer))
4821*8975f5c5SAndroid Build Coastguard Worker     {
4822*8975f5c5SAndroid Build Coastguard Worker         // If pixel local storage is active and currently overriding the drawbuffer, do nothing.
4823*8975f5c5SAndroid Build Coastguard Worker         // From the client's perspective, there is effectively no buffer bound.
4824*8975f5c5SAndroid Build Coastguard Worker         return true;
4825*8975f5c5SAndroid Build Coastguard Worker     }
4826*8975f5c5SAndroid Build Coastguard Worker 
4827*8975f5c5SAndroid Build Coastguard Worker     return !IsClearBufferEnabled(framebufferObject->getState(), buffer, drawbuffer) ||
4828*8975f5c5SAndroid Build Coastguard Worker            mState.isRasterizerDiscardEnabled() ||
4829*8975f5c5SAndroid Build Coastguard Worker            isClearBufferMaskedOut(buffer, drawbuffer, framebufferObject->getStencilBitCount());
4830*8975f5c5SAndroid Build Coastguard Worker }
4831*8975f5c5SAndroid Build Coastguard Worker 
clearBufferfv(GLenum buffer,GLint drawbuffer,const GLfloat * values)4832*8975f5c5SAndroid Build Coastguard Worker void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values)
4833*8975f5c5SAndroid Build Coastguard Worker {
4834*8975f5c5SAndroid Build Coastguard Worker     if (noopClearBuffer(buffer, drawbuffer))
4835*8975f5c5SAndroid Build Coastguard Worker     {
4836*8975f5c5SAndroid Build Coastguard Worker         return;
4837*8975f5c5SAndroid Build Coastguard Worker     }
4838*8975f5c5SAndroid Build Coastguard Worker 
4839*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebufferObject          = mState.getDrawFramebuffer();
4840*8975f5c5SAndroid Build Coastguard Worker     const FramebufferAttachment *attachment = nullptr;
4841*8975f5c5SAndroid Build Coastguard Worker     if (buffer == GL_DEPTH)
4842*8975f5c5SAndroid Build Coastguard Worker     {
4843*8975f5c5SAndroid Build Coastguard Worker         attachment = framebufferObject->getDepthAttachment();
4844*8975f5c5SAndroid Build Coastguard Worker     }
4845*8975f5c5SAndroid Build Coastguard Worker     else if (buffer == GL_COLOR &&
4846*8975f5c5SAndroid Build Coastguard Worker              static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorAttachments())
4847*8975f5c5SAndroid Build Coastguard Worker     {
4848*8975f5c5SAndroid Build Coastguard Worker         attachment = framebufferObject->getColorAttachment(drawbuffer);
4849*8975f5c5SAndroid Build Coastguard Worker     }
4850*8975f5c5SAndroid Build Coastguard Worker     // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so
4851*8975f5c5SAndroid Build Coastguard Worker     // that the backend doesn't need to take this case into account.
4852*8975f5c5SAndroid Build Coastguard Worker     if (!attachment)
4853*8975f5c5SAndroid Build Coastguard Worker     {
4854*8975f5c5SAndroid Build Coastguard Worker         return;
4855*8975f5c5SAndroid Build Coastguard Worker     }
4856*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
4857*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfv(this, buffer, drawbuffer, values));
4858*8975f5c5SAndroid Build Coastguard Worker }
4859*8975f5c5SAndroid Build Coastguard Worker 
clearBufferuiv(GLenum buffer,GLint drawbuffer,const GLuint * values)4860*8975f5c5SAndroid Build Coastguard Worker void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values)
4861*8975f5c5SAndroid Build Coastguard Worker {
4862*8975f5c5SAndroid Build Coastguard Worker     if (noopClearBuffer(buffer, drawbuffer))
4863*8975f5c5SAndroid Build Coastguard Worker     {
4864*8975f5c5SAndroid Build Coastguard Worker         return;
4865*8975f5c5SAndroid Build Coastguard Worker     }
4866*8975f5c5SAndroid Build Coastguard Worker 
4867*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebufferObject          = mState.getDrawFramebuffer();
4868*8975f5c5SAndroid Build Coastguard Worker     const FramebufferAttachment *attachment = nullptr;
4869*8975f5c5SAndroid Build Coastguard Worker     if (buffer == GL_COLOR &&
4870*8975f5c5SAndroid Build Coastguard Worker         static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorAttachments())
4871*8975f5c5SAndroid Build Coastguard Worker     {
4872*8975f5c5SAndroid Build Coastguard Worker         attachment = framebufferObject->getColorAttachment(drawbuffer);
4873*8975f5c5SAndroid Build Coastguard Worker     }
4874*8975f5c5SAndroid Build Coastguard Worker     // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so
4875*8975f5c5SAndroid Build Coastguard Worker     // that the backend doesn't need to take this case into account.
4876*8975f5c5SAndroid Build Coastguard Worker     if (!attachment)
4877*8975f5c5SAndroid Build Coastguard Worker     {
4878*8975f5c5SAndroid Build Coastguard Worker         return;
4879*8975f5c5SAndroid Build Coastguard Worker     }
4880*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
4881*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(framebufferObject->clearBufferuiv(this, buffer, drawbuffer, values));
4882*8975f5c5SAndroid Build Coastguard Worker }
4883*8975f5c5SAndroid Build Coastguard Worker 
clearBufferiv(GLenum buffer,GLint drawbuffer,const GLint * values)4884*8975f5c5SAndroid Build Coastguard Worker void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values)
4885*8975f5c5SAndroid Build Coastguard Worker {
4886*8975f5c5SAndroid Build Coastguard Worker     if (noopClearBuffer(buffer, drawbuffer))
4887*8975f5c5SAndroid Build Coastguard Worker     {
4888*8975f5c5SAndroid Build Coastguard Worker         return;
4889*8975f5c5SAndroid Build Coastguard Worker     }
4890*8975f5c5SAndroid Build Coastguard Worker 
4891*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebufferObject          = mState.getDrawFramebuffer();
4892*8975f5c5SAndroid Build Coastguard Worker     const FramebufferAttachment *attachment = nullptr;
4893*8975f5c5SAndroid Build Coastguard Worker     if (buffer == GL_STENCIL)
4894*8975f5c5SAndroid Build Coastguard Worker     {
4895*8975f5c5SAndroid Build Coastguard Worker         attachment = framebufferObject->getStencilAttachment();
4896*8975f5c5SAndroid Build Coastguard Worker     }
4897*8975f5c5SAndroid Build Coastguard Worker     else if (buffer == GL_COLOR &&
4898*8975f5c5SAndroid Build Coastguard Worker              static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorAttachments())
4899*8975f5c5SAndroid Build Coastguard Worker     {
4900*8975f5c5SAndroid Build Coastguard Worker         attachment = framebufferObject->getColorAttachment(drawbuffer);
4901*8975f5c5SAndroid Build Coastguard Worker     }
4902*8975f5c5SAndroid Build Coastguard Worker     // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so
4903*8975f5c5SAndroid Build Coastguard Worker     // that the backend doesn't need to take this case into account.
4904*8975f5c5SAndroid Build Coastguard Worker     if (!attachment)
4905*8975f5c5SAndroid Build Coastguard Worker     {
4906*8975f5c5SAndroid Build Coastguard Worker         return;
4907*8975f5c5SAndroid Build Coastguard Worker     }
4908*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
4909*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(framebufferObject->clearBufferiv(this, buffer, drawbuffer, values));
4910*8975f5c5SAndroid Build Coastguard Worker }
4911*8975f5c5SAndroid Build Coastguard Worker 
clearBufferfi(GLenum buffer,GLint drawbuffer,GLfloat depth,GLint stencil)4912*8975f5c5SAndroid Build Coastguard Worker void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
4913*8975f5c5SAndroid Build Coastguard Worker {
4914*8975f5c5SAndroid Build Coastguard Worker     if (noopClearBuffer(buffer, drawbuffer))
4915*8975f5c5SAndroid Build Coastguard Worker     {
4916*8975f5c5SAndroid Build Coastguard Worker         return;
4917*8975f5c5SAndroid Build Coastguard Worker     }
4918*8975f5c5SAndroid Build Coastguard Worker 
4919*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebufferObject = mState.getDrawFramebuffer();
4920*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebufferObject);
4921*8975f5c5SAndroid Build Coastguard Worker 
4922*8975f5c5SAndroid Build Coastguard Worker     // If a buffer is not present, the clear has no effect
4923*8975f5c5SAndroid Build Coastguard Worker     if (framebufferObject->getDepthAttachment() == nullptr &&
4924*8975f5c5SAndroid Build Coastguard Worker         framebufferObject->getStencilAttachment() == nullptr)
4925*8975f5c5SAndroid Build Coastguard Worker     {
4926*8975f5c5SAndroid Build Coastguard Worker         return;
4927*8975f5c5SAndroid Build Coastguard Worker     }
4928*8975f5c5SAndroid Build Coastguard Worker 
4929*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
4930*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil));
4931*8975f5c5SAndroid Build Coastguard Worker }
4932*8975f5c5SAndroid Build Coastguard Worker 
readPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,void * pixels)4933*8975f5c5SAndroid Build Coastguard Worker void Context::readPixels(GLint x,
4934*8975f5c5SAndroid Build Coastguard Worker                          GLint y,
4935*8975f5c5SAndroid Build Coastguard Worker                          GLsizei width,
4936*8975f5c5SAndroid Build Coastguard Worker                          GLsizei height,
4937*8975f5c5SAndroid Build Coastguard Worker                          GLenum format,
4938*8975f5c5SAndroid Build Coastguard Worker                          GLenum type,
4939*8975f5c5SAndroid Build Coastguard Worker                          void *pixels)
4940*8975f5c5SAndroid Build Coastguard Worker {
4941*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0)
4942*8975f5c5SAndroid Build Coastguard Worker     {
4943*8975f5c5SAndroid Build Coastguard Worker         return;
4944*8975f5c5SAndroid Build Coastguard Worker     }
4945*8975f5c5SAndroid Build Coastguard Worker 
4946*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForReadPixels());
4947*8975f5c5SAndroid Build Coastguard Worker 
4948*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *readFBO = mState.getReadFramebuffer();
4949*8975f5c5SAndroid Build Coastguard Worker     ASSERT(readFBO);
4950*8975f5c5SAndroid Build Coastguard Worker 
4951*8975f5c5SAndroid Build Coastguard Worker     Rectangle area(x, y, width, height);
4952*8975f5c5SAndroid Build Coastguard Worker     PixelPackState packState = mState.getPackState();
4953*8975f5c5SAndroid Build Coastguard Worker     Buffer *packBuffer       = mState.getTargetBuffer(gl::BufferBinding::PixelPack);
4954*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, packState, packBuffer, pixels));
4955*8975f5c5SAndroid Build Coastguard Worker }
4956*8975f5c5SAndroid Build Coastguard Worker 
readPixelsRobust(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,GLsizei * length,GLsizei * columns,GLsizei * rows,void * pixels)4957*8975f5c5SAndroid Build Coastguard Worker void Context::readPixelsRobust(GLint x,
4958*8975f5c5SAndroid Build Coastguard Worker                                GLint y,
4959*8975f5c5SAndroid Build Coastguard Worker                                GLsizei width,
4960*8975f5c5SAndroid Build Coastguard Worker                                GLsizei height,
4961*8975f5c5SAndroid Build Coastguard Worker                                GLenum format,
4962*8975f5c5SAndroid Build Coastguard Worker                                GLenum type,
4963*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufSize,
4964*8975f5c5SAndroid Build Coastguard Worker                                GLsizei *length,
4965*8975f5c5SAndroid Build Coastguard Worker                                GLsizei *columns,
4966*8975f5c5SAndroid Build Coastguard Worker                                GLsizei *rows,
4967*8975f5c5SAndroid Build Coastguard Worker                                void *pixels)
4968*8975f5c5SAndroid Build Coastguard Worker {
4969*8975f5c5SAndroid Build Coastguard Worker     readPixels(x, y, width, height, format, type, pixels);
4970*8975f5c5SAndroid Build Coastguard Worker }
4971*8975f5c5SAndroid Build Coastguard Worker 
readnPixelsRobust(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,GLsizei * length,GLsizei * columns,GLsizei * rows,void * data)4972*8975f5c5SAndroid Build Coastguard Worker void Context::readnPixelsRobust(GLint x,
4973*8975f5c5SAndroid Build Coastguard Worker                                 GLint y,
4974*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei width,
4975*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei height,
4976*8975f5c5SAndroid Build Coastguard Worker                                 GLenum format,
4977*8975f5c5SAndroid Build Coastguard Worker                                 GLenum type,
4978*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei bufSize,
4979*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei *length,
4980*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei *columns,
4981*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei *rows,
4982*8975f5c5SAndroid Build Coastguard Worker                                 void *data)
4983*8975f5c5SAndroid Build Coastguard Worker {
4984*8975f5c5SAndroid Build Coastguard Worker     readPixels(x, y, width, height, format, type, data);
4985*8975f5c5SAndroid Build Coastguard Worker }
4986*8975f5c5SAndroid Build Coastguard Worker 
copyTexImage2D(TextureTarget target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)4987*8975f5c5SAndroid Build Coastguard Worker void Context::copyTexImage2D(TextureTarget target,
4988*8975f5c5SAndroid Build Coastguard Worker                              GLint level,
4989*8975f5c5SAndroid Build Coastguard Worker                              GLenum internalformat,
4990*8975f5c5SAndroid Build Coastguard Worker                              GLint x,
4991*8975f5c5SAndroid Build Coastguard Worker                              GLint y,
4992*8975f5c5SAndroid Build Coastguard Worker                              GLsizei width,
4993*8975f5c5SAndroid Build Coastguard Worker                              GLsizei height,
4994*8975f5c5SAndroid Build Coastguard Worker                              GLint border)
4995*8975f5c5SAndroid Build Coastguard Worker {
4996*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForCopyImage());
4997*8975f5c5SAndroid Build Coastguard Worker 
4998*8975f5c5SAndroid Build Coastguard Worker     Rectangle sourceArea(x, y, width, height);
4999*8975f5c5SAndroid Build Coastguard Worker 
5000*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getReadFramebuffer();
5001*8975f5c5SAndroid Build Coastguard Worker     Texture *texture         = getTextureByTarget(target);
5002*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
5003*8975f5c5SAndroid Build Coastguard Worker         texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer));
5004*8975f5c5SAndroid Build Coastguard Worker }
5005*8975f5c5SAndroid Build Coastguard Worker 
copyTexSubImage2D(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height)5006*8975f5c5SAndroid Build Coastguard Worker void Context::copyTexSubImage2D(TextureTarget target,
5007*8975f5c5SAndroid Build Coastguard Worker                                 GLint level,
5008*8975f5c5SAndroid Build Coastguard Worker                                 GLint xoffset,
5009*8975f5c5SAndroid Build Coastguard Worker                                 GLint yoffset,
5010*8975f5c5SAndroid Build Coastguard Worker                                 GLint x,
5011*8975f5c5SAndroid Build Coastguard Worker                                 GLint y,
5012*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei width,
5013*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei height)
5014*8975f5c5SAndroid Build Coastguard Worker {
5015*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0)
5016*8975f5c5SAndroid Build Coastguard Worker     {
5017*8975f5c5SAndroid Build Coastguard Worker         return;
5018*8975f5c5SAndroid Build Coastguard Worker     }
5019*8975f5c5SAndroid Build Coastguard Worker 
5020*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForCopyImage());
5021*8975f5c5SAndroid Build Coastguard Worker 
5022*8975f5c5SAndroid Build Coastguard Worker     Offset destOffset(xoffset, yoffset, 0);
5023*8975f5c5SAndroid Build Coastguard Worker     Rectangle sourceArea(x, y, width, height);
5024*8975f5c5SAndroid Build Coastguard Worker 
5025*8975f5c5SAndroid Build Coastguard Worker     ImageIndex index = ImageIndex::MakeFromTarget(target, level, 1);
5026*8975f5c5SAndroid Build Coastguard Worker 
5027*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getReadFramebuffer();
5028*8975f5c5SAndroid Build Coastguard Worker     Texture *texture         = getTextureByTarget(target);
5029*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->copySubImage(this, index, destOffset, sourceArea, framebuffer));
5030*8975f5c5SAndroid Build Coastguard Worker }
5031*8975f5c5SAndroid Build Coastguard Worker 
copyTexSubImage3D(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLsizei height)5032*8975f5c5SAndroid Build Coastguard Worker void Context::copyTexSubImage3D(TextureTarget target,
5033*8975f5c5SAndroid Build Coastguard Worker                                 GLint level,
5034*8975f5c5SAndroid Build Coastguard Worker                                 GLint xoffset,
5035*8975f5c5SAndroid Build Coastguard Worker                                 GLint yoffset,
5036*8975f5c5SAndroid Build Coastguard Worker                                 GLint zoffset,
5037*8975f5c5SAndroid Build Coastguard Worker                                 GLint x,
5038*8975f5c5SAndroid Build Coastguard Worker                                 GLint y,
5039*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei width,
5040*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei height)
5041*8975f5c5SAndroid Build Coastguard Worker {
5042*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0)
5043*8975f5c5SAndroid Build Coastguard Worker     {
5044*8975f5c5SAndroid Build Coastguard Worker         return;
5045*8975f5c5SAndroid Build Coastguard Worker     }
5046*8975f5c5SAndroid Build Coastguard Worker 
5047*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForCopyImage());
5048*8975f5c5SAndroid Build Coastguard Worker 
5049*8975f5c5SAndroid Build Coastguard Worker     Offset destOffset(xoffset, yoffset, zoffset);
5050*8975f5c5SAndroid Build Coastguard Worker     Rectangle sourceArea(x, y, width, height);
5051*8975f5c5SAndroid Build Coastguard Worker 
5052*8975f5c5SAndroid Build Coastguard Worker     ImageIndex index = ImageIndex::MakeFromType(TextureTargetToType(target), level, zoffset);
5053*8975f5c5SAndroid Build Coastguard Worker 
5054*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getReadFramebuffer();
5055*8975f5c5SAndroid Build Coastguard Worker     Texture *texture         = getTextureByTarget(target);
5056*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->copySubImage(this, index, destOffset, sourceArea, framebuffer));
5057*8975f5c5SAndroid Build Coastguard Worker }
5058*8975f5c5SAndroid Build Coastguard Worker 
copyImageSubData(GLuint srcName,GLenum srcTarget,GLint srcLevel,GLint srcX,GLint srcY,GLint srcZ,GLuint dstName,GLenum dstTarget,GLint dstLevel,GLint dstX,GLint dstY,GLint dstZ,GLsizei srcWidth,GLsizei srcHeight,GLsizei srcDepth)5059*8975f5c5SAndroid Build Coastguard Worker void Context::copyImageSubData(GLuint srcName,
5060*8975f5c5SAndroid Build Coastguard Worker                                GLenum srcTarget,
5061*8975f5c5SAndroid Build Coastguard Worker                                GLint srcLevel,
5062*8975f5c5SAndroid Build Coastguard Worker                                GLint srcX,
5063*8975f5c5SAndroid Build Coastguard Worker                                GLint srcY,
5064*8975f5c5SAndroid Build Coastguard Worker                                GLint srcZ,
5065*8975f5c5SAndroid Build Coastguard Worker                                GLuint dstName,
5066*8975f5c5SAndroid Build Coastguard Worker                                GLenum dstTarget,
5067*8975f5c5SAndroid Build Coastguard Worker                                GLint dstLevel,
5068*8975f5c5SAndroid Build Coastguard Worker                                GLint dstX,
5069*8975f5c5SAndroid Build Coastguard Worker                                GLint dstY,
5070*8975f5c5SAndroid Build Coastguard Worker                                GLint dstZ,
5071*8975f5c5SAndroid Build Coastguard Worker                                GLsizei srcWidth,
5072*8975f5c5SAndroid Build Coastguard Worker                                GLsizei srcHeight,
5073*8975f5c5SAndroid Build Coastguard Worker                                GLsizei srcDepth)
5074*8975f5c5SAndroid Build Coastguard Worker {
5075*8975f5c5SAndroid Build Coastguard Worker     // if copy region is zero, the copy is a successful no-op
5076*8975f5c5SAndroid Build Coastguard Worker     if ((srcWidth == 0) || (srcHeight == 0) || (srcDepth == 0))
5077*8975f5c5SAndroid Build Coastguard Worker     {
5078*8975f5c5SAndroid Build Coastguard Worker         return;
5079*8975f5c5SAndroid Build Coastguard Worker     }
5080*8975f5c5SAndroid Build Coastguard Worker 
5081*8975f5c5SAndroid Build Coastguard Worker     if (srcTarget == GL_RENDERBUFFER)
5082*8975f5c5SAndroid Build Coastguard Worker     {
5083*8975f5c5SAndroid Build Coastguard Worker         // Source target is a Renderbuffer
5084*8975f5c5SAndroid Build Coastguard Worker         Renderbuffer *readBuffer = getRenderbuffer(PackParam<RenderbufferID>(srcName));
5085*8975f5c5SAndroid Build Coastguard Worker         if (dstTarget == GL_RENDERBUFFER)
5086*8975f5c5SAndroid Build Coastguard Worker         {
5087*8975f5c5SAndroid Build Coastguard Worker             // Destination target is a Renderbuffer
5088*8975f5c5SAndroid Build Coastguard Worker             Renderbuffer *writeBuffer = getRenderbuffer(PackParam<RenderbufferID>(dstName));
5089*8975f5c5SAndroid Build Coastguard Worker 
5090*8975f5c5SAndroid Build Coastguard Worker             // Copy Renderbuffer to Renderbuffer
5091*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(writeBuffer->copyRenderbufferSubData(
5092*8975f5c5SAndroid Build Coastguard Worker                 this, readBuffer, srcLevel, srcX, srcY, srcZ, dstLevel, dstX, dstY, dstZ, srcWidth,
5093*8975f5c5SAndroid Build Coastguard Worker                 srcHeight, srcDepth));
5094*8975f5c5SAndroid Build Coastguard Worker         }
5095*8975f5c5SAndroid Build Coastguard Worker         else
5096*8975f5c5SAndroid Build Coastguard Worker         {
5097*8975f5c5SAndroid Build Coastguard Worker             // Destination target is a Texture
5098*8975f5c5SAndroid Build Coastguard Worker             ASSERT(dstTarget == GL_TEXTURE_2D || dstTarget == GL_TEXTURE_2D_ARRAY ||
5099*8975f5c5SAndroid Build Coastguard Worker                    dstTarget == GL_TEXTURE_3D || dstTarget == GL_TEXTURE_CUBE_MAP);
5100*8975f5c5SAndroid Build Coastguard Worker 
5101*8975f5c5SAndroid Build Coastguard Worker             Texture *writeTexture = getTexture(PackParam<TextureID>(dstName));
5102*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(syncTextureForCopy(writeTexture));
5103*8975f5c5SAndroid Build Coastguard Worker 
5104*8975f5c5SAndroid Build Coastguard Worker             // Copy Renderbuffer to Texture
5105*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(writeTexture->copyRenderbufferSubData(
5106*8975f5c5SAndroid Build Coastguard Worker                 this, readBuffer, srcLevel, srcX, srcY, srcZ, dstLevel, dstX, dstY, dstZ, srcWidth,
5107*8975f5c5SAndroid Build Coastguard Worker                 srcHeight, srcDepth));
5108*8975f5c5SAndroid Build Coastguard Worker         }
5109*8975f5c5SAndroid Build Coastguard Worker     }
5110*8975f5c5SAndroid Build Coastguard Worker     else
5111*8975f5c5SAndroid Build Coastguard Worker     {
5112*8975f5c5SAndroid Build Coastguard Worker         // Source target is a Texture
5113*8975f5c5SAndroid Build Coastguard Worker         ASSERT(srcTarget == GL_TEXTURE_2D || srcTarget == GL_TEXTURE_2D_ARRAY ||
5114*8975f5c5SAndroid Build Coastguard Worker                srcTarget == GL_TEXTURE_3D || srcTarget == GL_TEXTURE_CUBE_MAP ||
5115*8975f5c5SAndroid Build Coastguard Worker                srcTarget == GL_TEXTURE_EXTERNAL_OES);
5116*8975f5c5SAndroid Build Coastguard Worker 
5117*8975f5c5SAndroid Build Coastguard Worker         Texture *readTexture = getTexture(PackParam<TextureID>(srcName));
5118*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(syncTextureForCopy(readTexture));
5119*8975f5c5SAndroid Build Coastguard Worker 
5120*8975f5c5SAndroid Build Coastguard Worker         if (dstTarget == GL_RENDERBUFFER)
5121*8975f5c5SAndroid Build Coastguard Worker         {
5122*8975f5c5SAndroid Build Coastguard Worker             // Destination target is a Renderbuffer
5123*8975f5c5SAndroid Build Coastguard Worker             Renderbuffer *writeBuffer = getRenderbuffer(PackParam<RenderbufferID>(dstName));
5124*8975f5c5SAndroid Build Coastguard Worker 
5125*8975f5c5SAndroid Build Coastguard Worker             // Copy Texture to Renderbuffer
5126*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(writeBuffer->copyTextureSubData(this, readTexture, srcLevel, srcX,
5127*8975f5c5SAndroid Build Coastguard Worker                                                               srcY, srcZ, dstLevel, dstX, dstY,
5128*8975f5c5SAndroid Build Coastguard Worker                                                               dstZ, srcWidth, srcHeight, srcDepth));
5129*8975f5c5SAndroid Build Coastguard Worker         }
5130*8975f5c5SAndroid Build Coastguard Worker         else
5131*8975f5c5SAndroid Build Coastguard Worker         {
5132*8975f5c5SAndroid Build Coastguard Worker             // Destination target is a Texture
5133*8975f5c5SAndroid Build Coastguard Worker             ASSERT(dstTarget == GL_TEXTURE_2D || dstTarget == GL_TEXTURE_2D_ARRAY ||
5134*8975f5c5SAndroid Build Coastguard Worker                    dstTarget == GL_TEXTURE_3D || dstTarget == GL_TEXTURE_CUBE_MAP ||
5135*8975f5c5SAndroid Build Coastguard Worker                    dstTarget == GL_TEXTURE_EXTERNAL_OES);
5136*8975f5c5SAndroid Build Coastguard Worker 
5137*8975f5c5SAndroid Build Coastguard Worker             Texture *writeTexture = getTexture(PackParam<TextureID>(dstName));
5138*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(syncTextureForCopy(writeTexture));
5139*8975f5c5SAndroid Build Coastguard Worker 
5140*8975f5c5SAndroid Build Coastguard Worker             // Copy Texture to Texture
5141*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(writeTexture->copyTextureSubData(
5142*8975f5c5SAndroid Build Coastguard Worker                 this, readTexture, srcLevel, srcX, srcY, srcZ, dstLevel, dstX, dstY, dstZ, srcWidth,
5143*8975f5c5SAndroid Build Coastguard Worker                 srcHeight, srcDepth));
5144*8975f5c5SAndroid Build Coastguard Worker         }
5145*8975f5c5SAndroid Build Coastguard Worker     }
5146*8975f5c5SAndroid Build Coastguard Worker }
5147*8975f5c5SAndroid Build Coastguard Worker 
framebufferTexture2D(GLenum target,GLenum attachment,TextureTarget textarget,TextureID texture,GLint level)5148*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferTexture2D(GLenum target,
5149*8975f5c5SAndroid Build Coastguard Worker                                    GLenum attachment,
5150*8975f5c5SAndroid Build Coastguard Worker                                    TextureTarget textarget,
5151*8975f5c5SAndroid Build Coastguard Worker                                    TextureID texture,
5152*8975f5c5SAndroid Build Coastguard Worker                                    GLint level)
5153*8975f5c5SAndroid Build Coastguard Worker {
5154*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5155*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5156*8975f5c5SAndroid Build Coastguard Worker 
5157*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
5158*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
5159*8975f5c5SAndroid Build Coastguard Worker     {
5160*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
5161*8975f5c5SAndroid Build Coastguard Worker     }
5162*8975f5c5SAndroid Build Coastguard Worker 
5163*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
5164*8975f5c5SAndroid Build Coastguard Worker     {
5165*8975f5c5SAndroid Build Coastguard Worker         Texture *textureObj = getTexture(texture);
5166*8975f5c5SAndroid Build Coastguard Worker         ImageIndex index    = ImageIndex::MakeFromTarget(textarget, level, 1);
5167*8975f5c5SAndroid Build Coastguard Worker         framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj);
5168*8975f5c5SAndroid Build Coastguard Worker     }
5169*8975f5c5SAndroid Build Coastguard Worker     else
5170*8975f5c5SAndroid Build Coastguard Worker     {
5171*8975f5c5SAndroid Build Coastguard Worker         framebuffer->resetAttachment(this, attachment);
5172*8975f5c5SAndroid Build Coastguard Worker     }
5173*8975f5c5SAndroid Build Coastguard Worker 
5174*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(target);
5175*8975f5c5SAndroid Build Coastguard Worker }
5176*8975f5c5SAndroid Build Coastguard Worker 
framebufferTexture3D(GLenum target,GLenum attachment,TextureTarget textargetPacked,TextureID texture,GLint level,GLint zoffset)5177*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferTexture3D(GLenum target,
5178*8975f5c5SAndroid Build Coastguard Worker                                    GLenum attachment,
5179*8975f5c5SAndroid Build Coastguard Worker                                    TextureTarget textargetPacked,
5180*8975f5c5SAndroid Build Coastguard Worker                                    TextureID texture,
5181*8975f5c5SAndroid Build Coastguard Worker                                    GLint level,
5182*8975f5c5SAndroid Build Coastguard Worker                                    GLint zoffset)
5183*8975f5c5SAndroid Build Coastguard Worker {
5184*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5185*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5186*8975f5c5SAndroid Build Coastguard Worker 
5187*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
5188*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
5189*8975f5c5SAndroid Build Coastguard Worker     {
5190*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
5191*8975f5c5SAndroid Build Coastguard Worker     }
5192*8975f5c5SAndroid Build Coastguard Worker 
5193*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
5194*8975f5c5SAndroid Build Coastguard Worker     {
5195*8975f5c5SAndroid Build Coastguard Worker         Texture *textureObj = getTexture(texture);
5196*8975f5c5SAndroid Build Coastguard Worker         ImageIndex index    = ImageIndex::Make3D(level, zoffset);
5197*8975f5c5SAndroid Build Coastguard Worker         framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj);
5198*8975f5c5SAndroid Build Coastguard Worker     }
5199*8975f5c5SAndroid Build Coastguard Worker     else
5200*8975f5c5SAndroid Build Coastguard Worker     {
5201*8975f5c5SAndroid Build Coastguard Worker         framebuffer->resetAttachment(this, attachment);
5202*8975f5c5SAndroid Build Coastguard Worker     }
5203*8975f5c5SAndroid Build Coastguard Worker 
5204*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(target);
5205*8975f5c5SAndroid Build Coastguard Worker }
5206*8975f5c5SAndroid Build Coastguard Worker 
framebufferRenderbuffer(GLenum target,GLenum attachment,GLenum renderbuffertarget,RenderbufferID renderbuffer)5207*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferRenderbuffer(GLenum target,
5208*8975f5c5SAndroid Build Coastguard Worker                                       GLenum attachment,
5209*8975f5c5SAndroid Build Coastguard Worker                                       GLenum renderbuffertarget,
5210*8975f5c5SAndroid Build Coastguard Worker                                       RenderbufferID renderbuffer)
5211*8975f5c5SAndroid Build Coastguard Worker {
5212*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5213*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5214*8975f5c5SAndroid Build Coastguard Worker 
5215*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
5216*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
5217*8975f5c5SAndroid Build Coastguard Worker     {
5218*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
5219*8975f5c5SAndroid Build Coastguard Worker     }
5220*8975f5c5SAndroid Build Coastguard Worker 
5221*8975f5c5SAndroid Build Coastguard Worker     if (renderbuffer.value != 0)
5222*8975f5c5SAndroid Build Coastguard Worker     {
5223*8975f5c5SAndroid Build Coastguard Worker         Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer);
5224*8975f5c5SAndroid Build Coastguard Worker         GLsizei rbSamples                = renderbufferObject->getState().getSamples();
5225*8975f5c5SAndroid Build Coastguard Worker 
5226*8975f5c5SAndroid Build Coastguard Worker         framebuffer->setAttachmentMultisample(this, GL_RENDERBUFFER, attachment, gl::ImageIndex(),
5227*8975f5c5SAndroid Build Coastguard Worker                                               renderbufferObject, rbSamples);
5228*8975f5c5SAndroid Build Coastguard Worker     }
5229*8975f5c5SAndroid Build Coastguard Worker     else
5230*8975f5c5SAndroid Build Coastguard Worker     {
5231*8975f5c5SAndroid Build Coastguard Worker         framebuffer->resetAttachment(this, attachment);
5232*8975f5c5SAndroid Build Coastguard Worker     }
5233*8975f5c5SAndroid Build Coastguard Worker 
5234*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(target);
5235*8975f5c5SAndroid Build Coastguard Worker }
5236*8975f5c5SAndroid Build Coastguard Worker 
framebufferTextureLayer(GLenum target,GLenum attachment,TextureID texture,GLint level,GLint layer)5237*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferTextureLayer(GLenum target,
5238*8975f5c5SAndroid Build Coastguard Worker                                       GLenum attachment,
5239*8975f5c5SAndroid Build Coastguard Worker                                       TextureID texture,
5240*8975f5c5SAndroid Build Coastguard Worker                                       GLint level,
5241*8975f5c5SAndroid Build Coastguard Worker                                       GLint layer)
5242*8975f5c5SAndroid Build Coastguard Worker {
5243*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5244*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5245*8975f5c5SAndroid Build Coastguard Worker 
5246*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
5247*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
5248*8975f5c5SAndroid Build Coastguard Worker     {
5249*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
5250*8975f5c5SAndroid Build Coastguard Worker     }
5251*8975f5c5SAndroid Build Coastguard Worker 
5252*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
5253*8975f5c5SAndroid Build Coastguard Worker     {
5254*8975f5c5SAndroid Build Coastguard Worker         Texture *textureObject = getTexture(texture);
5255*8975f5c5SAndroid Build Coastguard Worker         ImageIndex index       = ImageIndex::MakeFromType(textureObject->getType(), level, layer);
5256*8975f5c5SAndroid Build Coastguard Worker         framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject);
5257*8975f5c5SAndroid Build Coastguard Worker     }
5258*8975f5c5SAndroid Build Coastguard Worker     else
5259*8975f5c5SAndroid Build Coastguard Worker     {
5260*8975f5c5SAndroid Build Coastguard Worker         framebuffer->resetAttachment(this, attachment);
5261*8975f5c5SAndroid Build Coastguard Worker     }
5262*8975f5c5SAndroid Build Coastguard Worker 
5263*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(target);
5264*8975f5c5SAndroid Build Coastguard Worker }
5265*8975f5c5SAndroid Build Coastguard Worker 
framebufferTextureMultiview(GLenum target,GLenum attachment,TextureID texture,GLint level,GLint baseViewIndex,GLsizei numViews)5266*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferTextureMultiview(GLenum target,
5267*8975f5c5SAndroid Build Coastguard Worker                                           GLenum attachment,
5268*8975f5c5SAndroid Build Coastguard Worker                                           TextureID texture,
5269*8975f5c5SAndroid Build Coastguard Worker                                           GLint level,
5270*8975f5c5SAndroid Build Coastguard Worker                                           GLint baseViewIndex,
5271*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei numViews)
5272*8975f5c5SAndroid Build Coastguard Worker {
5273*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5274*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5275*8975f5c5SAndroid Build Coastguard Worker 
5276*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
5277*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
5278*8975f5c5SAndroid Build Coastguard Worker     {
5279*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
5280*8975f5c5SAndroid Build Coastguard Worker     }
5281*8975f5c5SAndroid Build Coastguard Worker 
5282*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
5283*8975f5c5SAndroid Build Coastguard Worker     {
5284*8975f5c5SAndroid Build Coastguard Worker         Texture *textureObj = getTexture(texture);
5285*8975f5c5SAndroid Build Coastguard Worker 
5286*8975f5c5SAndroid Build Coastguard Worker         ImageIndex index;
5287*8975f5c5SAndroid Build Coastguard Worker         if (textureObj->getType() == TextureType::_2DArray)
5288*8975f5c5SAndroid Build Coastguard Worker         {
5289*8975f5c5SAndroid Build Coastguard Worker             index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews);
5290*8975f5c5SAndroid Build Coastguard Worker         }
5291*8975f5c5SAndroid Build Coastguard Worker         else
5292*8975f5c5SAndroid Build Coastguard Worker         {
5293*8975f5c5SAndroid Build Coastguard Worker             ASSERT(textureObj->getType() == TextureType::_2DMultisampleArray);
5294*8975f5c5SAndroid Build Coastguard Worker             ASSERT(level == 0);
5295*8975f5c5SAndroid Build Coastguard Worker             index = ImageIndex::Make2DMultisampleArrayRange(baseViewIndex, numViews);
5296*8975f5c5SAndroid Build Coastguard Worker         }
5297*8975f5c5SAndroid Build Coastguard Worker         framebuffer->setAttachmentMultiview(this, GL_TEXTURE, attachment, index, textureObj,
5298*8975f5c5SAndroid Build Coastguard Worker                                             numViews, baseViewIndex);
5299*8975f5c5SAndroid Build Coastguard Worker     }
5300*8975f5c5SAndroid Build Coastguard Worker     else
5301*8975f5c5SAndroid Build Coastguard Worker     {
5302*8975f5c5SAndroid Build Coastguard Worker         framebuffer->resetAttachment(this, attachment);
5303*8975f5c5SAndroid Build Coastguard Worker     }
5304*8975f5c5SAndroid Build Coastguard Worker 
5305*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(target);
5306*8975f5c5SAndroid Build Coastguard Worker }
5307*8975f5c5SAndroid Build Coastguard Worker 
framebufferTexture(GLenum target,GLenum attachment,TextureID texture,GLint level)5308*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferTexture(GLenum target, GLenum attachment, TextureID texture, GLint level)
5309*8975f5c5SAndroid Build Coastguard Worker {
5310*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5311*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5312*8975f5c5SAndroid Build Coastguard Worker 
5313*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
5314*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
5315*8975f5c5SAndroid Build Coastguard Worker     {
5316*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
5317*8975f5c5SAndroid Build Coastguard Worker     }
5318*8975f5c5SAndroid Build Coastguard Worker 
5319*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
5320*8975f5c5SAndroid Build Coastguard Worker     {
5321*8975f5c5SAndroid Build Coastguard Worker         Texture *textureObj = getTexture(texture);
5322*8975f5c5SAndroid Build Coastguard Worker 
5323*8975f5c5SAndroid Build Coastguard Worker         ImageIndex index = ImageIndex::MakeFromType(
5324*8975f5c5SAndroid Build Coastguard Worker             textureObj->getType(), level, ImageIndex::kEntireLevel, ImageIndex::kEntireLevel);
5325*8975f5c5SAndroid Build Coastguard Worker         framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj);
5326*8975f5c5SAndroid Build Coastguard Worker     }
5327*8975f5c5SAndroid Build Coastguard Worker     else
5328*8975f5c5SAndroid Build Coastguard Worker     {
5329*8975f5c5SAndroid Build Coastguard Worker         framebuffer->resetAttachment(this, attachment);
5330*8975f5c5SAndroid Build Coastguard Worker     }
5331*8975f5c5SAndroid Build Coastguard Worker 
5332*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(target);
5333*8975f5c5SAndroid Build Coastguard Worker }
5334*8975f5c5SAndroid Build Coastguard Worker 
drawBuffers(GLsizei n,const GLenum * bufs)5335*8975f5c5SAndroid Build Coastguard Worker void Context::drawBuffers(GLsizei n, const GLenum *bufs)
5336*8975f5c5SAndroid Build Coastguard Worker {
5337*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
5338*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5339*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0)
5340*8975f5c5SAndroid Build Coastguard Worker     {
5341*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
5342*8975f5c5SAndroid Build Coastguard Worker     }
5343*8975f5c5SAndroid Build Coastguard Worker     framebuffer->setDrawBuffers(n, bufs);
5344*8975f5c5SAndroid Build Coastguard Worker     mState.setDrawFramebufferDirty();
5345*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onDrawFramebufferChange(this);
5346*8975f5c5SAndroid Build Coastguard Worker }
5347*8975f5c5SAndroid Build Coastguard Worker 
readBuffer(GLenum mode)5348*8975f5c5SAndroid Build Coastguard Worker void Context::readBuffer(GLenum mode)
5349*8975f5c5SAndroid Build Coastguard Worker {
5350*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *readFBO = mState.getReadFramebuffer();
5351*8975f5c5SAndroid Build Coastguard Worker     readFBO->setReadBuffer(mode);
5352*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(GL_READ_FRAMEBUFFER);
5353*8975f5c5SAndroid Build Coastguard Worker }
5354*8975f5c5SAndroid Build Coastguard Worker 
discardFramebuffer(GLenum target,GLsizei numAttachments,const GLenum * attachments)5355*8975f5c5SAndroid Build Coastguard Worker void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
5356*8975f5c5SAndroid Build Coastguard Worker {
5357*8975f5c5SAndroid Build Coastguard Worker     // The specification isn't clear what should be done when the framebuffer isn't complete.
5358*8975f5c5SAndroid Build Coastguard Worker     // We threat it the same way as GLES3 glInvalidateFramebuffer.
5359*8975f5c5SAndroid Build Coastguard Worker     invalidateFramebuffer(target, numAttachments, attachments);
5360*8975f5c5SAndroid Build Coastguard Worker }
5361*8975f5c5SAndroid Build Coastguard Worker 
invalidateFramebuffer(GLenum target,GLsizei numAttachments,const GLenum * attachments)5362*8975f5c5SAndroid Build Coastguard Worker void Context::invalidateFramebuffer(GLenum target,
5363*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei numAttachments,
5364*8975f5c5SAndroid Build Coastguard Worker                                     const GLenum *attachments)
5365*8975f5c5SAndroid Build Coastguard Worker {
5366*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5367*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5368*8975f5c5SAndroid Build Coastguard Worker 
5369*8975f5c5SAndroid Build Coastguard Worker     // No-op incomplete FBOs.
5370*8975f5c5SAndroid Build Coastguard Worker     if (!framebuffer->isComplete(this))
5371*8975f5c5SAndroid Build Coastguard Worker     {
5372*8975f5c5SAndroid Build Coastguard Worker         return;
5373*8975f5c5SAndroid Build Coastguard Worker     }
5374*8975f5c5SAndroid Build Coastguard Worker 
5375*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForInvalidate(target));
5376*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments));
5377*8975f5c5SAndroid Build Coastguard Worker }
5378*8975f5c5SAndroid Build Coastguard Worker 
invalidateSubFramebuffer(GLenum target,GLsizei numAttachments,const GLenum * attachments,GLint x,GLint y,GLsizei width,GLsizei height)5379*8975f5c5SAndroid Build Coastguard Worker void Context::invalidateSubFramebuffer(GLenum target,
5380*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei numAttachments,
5381*8975f5c5SAndroid Build Coastguard Worker                                        const GLenum *attachments,
5382*8975f5c5SAndroid Build Coastguard Worker                                        GLint x,
5383*8975f5c5SAndroid Build Coastguard Worker                                        GLint y,
5384*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei width,
5385*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei height)
5386*8975f5c5SAndroid Build Coastguard Worker {
5387*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
5388*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
5389*8975f5c5SAndroid Build Coastguard Worker 
5390*8975f5c5SAndroid Build Coastguard Worker     if (!framebuffer->isComplete(this))
5391*8975f5c5SAndroid Build Coastguard Worker     {
5392*8975f5c5SAndroid Build Coastguard Worker         return;
5393*8975f5c5SAndroid Build Coastguard Worker     }
5394*8975f5c5SAndroid Build Coastguard Worker 
5395*8975f5c5SAndroid Build Coastguard Worker     Rectangle area(x, y, width, height);
5396*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForInvalidate(target));
5397*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area));
5398*8975f5c5SAndroid Build Coastguard Worker }
5399*8975f5c5SAndroid Build Coastguard Worker 
texImage2D(TextureTarget target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const void * pixels)5400*8975f5c5SAndroid Build Coastguard Worker void Context::texImage2D(TextureTarget target,
5401*8975f5c5SAndroid Build Coastguard Worker                          GLint level,
5402*8975f5c5SAndroid Build Coastguard Worker                          GLint internalformat,
5403*8975f5c5SAndroid Build Coastguard Worker                          GLsizei width,
5404*8975f5c5SAndroid Build Coastguard Worker                          GLsizei height,
5405*8975f5c5SAndroid Build Coastguard Worker                          GLint border,
5406*8975f5c5SAndroid Build Coastguard Worker                          GLenum format,
5407*8975f5c5SAndroid Build Coastguard Worker                          GLenum type,
5408*8975f5c5SAndroid Build Coastguard Worker                          const void *pixels)
5409*8975f5c5SAndroid Build Coastguard Worker {
5410*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5411*8975f5c5SAndroid Build Coastguard Worker 
5412*8975f5c5SAndroid Build Coastguard Worker     gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack);
5413*8975f5c5SAndroid Build Coastguard Worker 
5414*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, 1);
5415*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5416*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), unpackBuffer, target, level,
5417*8975f5c5SAndroid Build Coastguard Worker                                         internalformat, size, format, type,
5418*8975f5c5SAndroid Build Coastguard Worker                                         static_cast<const uint8_t *>(pixels)));
5419*8975f5c5SAndroid Build Coastguard Worker }
5420*8975f5c5SAndroid Build Coastguard Worker 
texImage2DRobust(TextureTarget target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,GLsizei bufSize,const void * pixels)5421*8975f5c5SAndroid Build Coastguard Worker void Context::texImage2DRobust(TextureTarget target,
5422*8975f5c5SAndroid Build Coastguard Worker                                GLint level,
5423*8975f5c5SAndroid Build Coastguard Worker                                GLint internalformat,
5424*8975f5c5SAndroid Build Coastguard Worker                                GLsizei width,
5425*8975f5c5SAndroid Build Coastguard Worker                                GLsizei height,
5426*8975f5c5SAndroid Build Coastguard Worker                                GLint border,
5427*8975f5c5SAndroid Build Coastguard Worker                                GLenum format,
5428*8975f5c5SAndroid Build Coastguard Worker                                GLenum type,
5429*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufSize,
5430*8975f5c5SAndroid Build Coastguard Worker                                const void *pixels)
5431*8975f5c5SAndroid Build Coastguard Worker {
5432*8975f5c5SAndroid Build Coastguard Worker     texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
5433*8975f5c5SAndroid Build Coastguard Worker }
5434*8975f5c5SAndroid Build Coastguard Worker 
texImage3D(TextureTarget target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const void * pixels)5435*8975f5c5SAndroid Build Coastguard Worker void Context::texImage3D(TextureTarget target,
5436*8975f5c5SAndroid Build Coastguard Worker                          GLint level,
5437*8975f5c5SAndroid Build Coastguard Worker                          GLint internalformat,
5438*8975f5c5SAndroid Build Coastguard Worker                          GLsizei width,
5439*8975f5c5SAndroid Build Coastguard Worker                          GLsizei height,
5440*8975f5c5SAndroid Build Coastguard Worker                          GLsizei depth,
5441*8975f5c5SAndroid Build Coastguard Worker                          GLint border,
5442*8975f5c5SAndroid Build Coastguard Worker                          GLenum format,
5443*8975f5c5SAndroid Build Coastguard Worker                          GLenum type,
5444*8975f5c5SAndroid Build Coastguard Worker                          const void *pixels)
5445*8975f5c5SAndroid Build Coastguard Worker {
5446*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5447*8975f5c5SAndroid Build Coastguard Worker 
5448*8975f5c5SAndroid Build Coastguard Worker     gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack);
5449*8975f5c5SAndroid Build Coastguard Worker 
5450*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, depth);
5451*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5452*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), unpackBuffer, target, level,
5453*8975f5c5SAndroid Build Coastguard Worker                                         internalformat, size, format, type,
5454*8975f5c5SAndroid Build Coastguard Worker                                         static_cast<const uint8_t *>(pixels)));
5455*8975f5c5SAndroid Build Coastguard Worker }
5456*8975f5c5SAndroid Build Coastguard Worker 
texImage3DRobust(TextureTarget target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,GLsizei bufSize,const void * pixels)5457*8975f5c5SAndroid Build Coastguard Worker void Context::texImage3DRobust(TextureTarget target,
5458*8975f5c5SAndroid Build Coastguard Worker                                GLint level,
5459*8975f5c5SAndroid Build Coastguard Worker                                GLint internalformat,
5460*8975f5c5SAndroid Build Coastguard Worker                                GLsizei width,
5461*8975f5c5SAndroid Build Coastguard Worker                                GLsizei height,
5462*8975f5c5SAndroid Build Coastguard Worker                                GLsizei depth,
5463*8975f5c5SAndroid Build Coastguard Worker                                GLint border,
5464*8975f5c5SAndroid Build Coastguard Worker                                GLenum format,
5465*8975f5c5SAndroid Build Coastguard Worker                                GLenum type,
5466*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufSize,
5467*8975f5c5SAndroid Build Coastguard Worker                                const void *pixels)
5468*8975f5c5SAndroid Build Coastguard Worker {
5469*8975f5c5SAndroid Build Coastguard Worker     texImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
5470*8975f5c5SAndroid Build Coastguard Worker }
5471*8975f5c5SAndroid Build Coastguard Worker 
texSubImage2D(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const void * pixels)5472*8975f5c5SAndroid Build Coastguard Worker void Context::texSubImage2D(TextureTarget target,
5473*8975f5c5SAndroid Build Coastguard Worker                             GLint level,
5474*8975f5c5SAndroid Build Coastguard Worker                             GLint xoffset,
5475*8975f5c5SAndroid Build Coastguard Worker                             GLint yoffset,
5476*8975f5c5SAndroid Build Coastguard Worker                             GLsizei width,
5477*8975f5c5SAndroid Build Coastguard Worker                             GLsizei height,
5478*8975f5c5SAndroid Build Coastguard Worker                             GLenum format,
5479*8975f5c5SAndroid Build Coastguard Worker                             GLenum type,
5480*8975f5c5SAndroid Build Coastguard Worker                             const void *pixels)
5481*8975f5c5SAndroid Build Coastguard Worker {
5482*8975f5c5SAndroid Build Coastguard Worker     // Zero sized uploads are valid but no-ops
5483*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0)
5484*8975f5c5SAndroid Build Coastguard Worker     {
5485*8975f5c5SAndroid Build Coastguard Worker         return;
5486*8975f5c5SAndroid Build Coastguard Worker     }
5487*8975f5c5SAndroid Build Coastguard Worker 
5488*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5489*8975f5c5SAndroid Build Coastguard Worker 
5490*8975f5c5SAndroid Build Coastguard Worker     Box area(xoffset, yoffset, 0, width, height, 1);
5491*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5492*8975f5c5SAndroid Build Coastguard Worker 
5493*8975f5c5SAndroid Build Coastguard Worker     gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack);
5494*8975f5c5SAndroid Build Coastguard Worker 
5495*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, target,
5496*8975f5c5SAndroid Build Coastguard Worker                                            level, area, format, type,
5497*8975f5c5SAndroid Build Coastguard Worker                                            static_cast<const uint8_t *>(pixels)));
5498*8975f5c5SAndroid Build Coastguard Worker }
5499*8975f5c5SAndroid Build Coastguard Worker 
texSubImage2DRobust(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,const void * pixels)5500*8975f5c5SAndroid Build Coastguard Worker void Context::texSubImage2DRobust(TextureTarget target,
5501*8975f5c5SAndroid Build Coastguard Worker                                   GLint level,
5502*8975f5c5SAndroid Build Coastguard Worker                                   GLint xoffset,
5503*8975f5c5SAndroid Build Coastguard Worker                                   GLint yoffset,
5504*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei width,
5505*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei height,
5506*8975f5c5SAndroid Build Coastguard Worker                                   GLenum format,
5507*8975f5c5SAndroid Build Coastguard Worker                                   GLenum type,
5508*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
5509*8975f5c5SAndroid Build Coastguard Worker                                   const void *pixels)
5510*8975f5c5SAndroid Build Coastguard Worker {
5511*8975f5c5SAndroid Build Coastguard Worker     texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
5512*8975f5c5SAndroid Build Coastguard Worker }
5513*8975f5c5SAndroid Build Coastguard Worker 
texSubImage3D(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const void * pixels)5514*8975f5c5SAndroid Build Coastguard Worker void Context::texSubImage3D(TextureTarget target,
5515*8975f5c5SAndroid Build Coastguard Worker                             GLint level,
5516*8975f5c5SAndroid Build Coastguard Worker                             GLint xoffset,
5517*8975f5c5SAndroid Build Coastguard Worker                             GLint yoffset,
5518*8975f5c5SAndroid Build Coastguard Worker                             GLint zoffset,
5519*8975f5c5SAndroid Build Coastguard Worker                             GLsizei width,
5520*8975f5c5SAndroid Build Coastguard Worker                             GLsizei height,
5521*8975f5c5SAndroid Build Coastguard Worker                             GLsizei depth,
5522*8975f5c5SAndroid Build Coastguard Worker                             GLenum format,
5523*8975f5c5SAndroid Build Coastguard Worker                             GLenum type,
5524*8975f5c5SAndroid Build Coastguard Worker                             const void *pixels)
5525*8975f5c5SAndroid Build Coastguard Worker {
5526*8975f5c5SAndroid Build Coastguard Worker     // Zero sized uploads are valid but no-ops
5527*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0 || depth == 0)
5528*8975f5c5SAndroid Build Coastguard Worker     {
5529*8975f5c5SAndroid Build Coastguard Worker         return;
5530*8975f5c5SAndroid Build Coastguard Worker     }
5531*8975f5c5SAndroid Build Coastguard Worker 
5532*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5533*8975f5c5SAndroid Build Coastguard Worker 
5534*8975f5c5SAndroid Build Coastguard Worker     Box area(xoffset, yoffset, zoffset, width, height, depth);
5535*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5536*8975f5c5SAndroid Build Coastguard Worker 
5537*8975f5c5SAndroid Build Coastguard Worker     gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack);
5538*8975f5c5SAndroid Build Coastguard Worker 
5539*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, target,
5540*8975f5c5SAndroid Build Coastguard Worker                                            level, area, format, type,
5541*8975f5c5SAndroid Build Coastguard Worker                                            static_cast<const uint8_t *>(pixels)));
5542*8975f5c5SAndroid Build Coastguard Worker }
5543*8975f5c5SAndroid Build Coastguard Worker 
texSubImage3DRobust(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,GLsizei bufSize,const void * pixels)5544*8975f5c5SAndroid Build Coastguard Worker void Context::texSubImage3DRobust(TextureTarget target,
5545*8975f5c5SAndroid Build Coastguard Worker                                   GLint level,
5546*8975f5c5SAndroid Build Coastguard Worker                                   GLint xoffset,
5547*8975f5c5SAndroid Build Coastguard Worker                                   GLint yoffset,
5548*8975f5c5SAndroid Build Coastguard Worker                                   GLint zoffset,
5549*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei width,
5550*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei height,
5551*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei depth,
5552*8975f5c5SAndroid Build Coastguard Worker                                   GLenum format,
5553*8975f5c5SAndroid Build Coastguard Worker                                   GLenum type,
5554*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
5555*8975f5c5SAndroid Build Coastguard Worker                                   const void *pixels)
5556*8975f5c5SAndroid Build Coastguard Worker {
5557*8975f5c5SAndroid Build Coastguard Worker     texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type,
5558*8975f5c5SAndroid Build Coastguard Worker                   pixels);
5559*8975f5c5SAndroid Build Coastguard Worker }
5560*8975f5c5SAndroid Build Coastguard Worker 
compressedTexImage2D(TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const void * data)5561*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexImage2D(TextureTarget target,
5562*8975f5c5SAndroid Build Coastguard Worker                                    GLint level,
5563*8975f5c5SAndroid Build Coastguard Worker                                    GLenum internalformat,
5564*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei width,
5565*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei height,
5566*8975f5c5SAndroid Build Coastguard Worker                                    GLint border,
5567*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei imageSize,
5568*8975f5c5SAndroid Build Coastguard Worker                                    const void *data)
5569*8975f5c5SAndroid Build Coastguard Worker {
5570*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5571*8975f5c5SAndroid Build Coastguard Worker 
5572*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, 1);
5573*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5574*8975f5c5SAndroid Build Coastguard Worker     // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture
5575*8975f5c5SAndroid Build Coastguard Worker     // image. So we use an empty PixelUnpackState.
5576*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, PixelUnpackState(), target, level,
5577*8975f5c5SAndroid Build Coastguard Worker                                                   internalformat, size, imageSize,
5578*8975f5c5SAndroid Build Coastguard Worker                                                   static_cast<const uint8_t *>(data)));
5579*8975f5c5SAndroid Build Coastguard Worker }
5580*8975f5c5SAndroid Build Coastguard Worker 
compressedTexImage2DRobust(TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,GLsizei dataSize,const GLvoid * data)5581*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexImage2DRobust(TextureTarget target,
5582*8975f5c5SAndroid Build Coastguard Worker                                          GLint level,
5583*8975f5c5SAndroid Build Coastguard Worker                                          GLenum internalformat,
5584*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei width,
5585*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei height,
5586*8975f5c5SAndroid Build Coastguard Worker                                          GLint border,
5587*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei imageSize,
5588*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei dataSize,
5589*8975f5c5SAndroid Build Coastguard Worker                                          const GLvoid *data)
5590*8975f5c5SAndroid Build Coastguard Worker {
5591*8975f5c5SAndroid Build Coastguard Worker     compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
5592*8975f5c5SAndroid Build Coastguard Worker }
5593*8975f5c5SAndroid Build Coastguard Worker 
compressedTexImage3D(TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const void * data)5594*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexImage3D(TextureTarget target,
5595*8975f5c5SAndroid Build Coastguard Worker                                    GLint level,
5596*8975f5c5SAndroid Build Coastguard Worker                                    GLenum internalformat,
5597*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei width,
5598*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei height,
5599*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei depth,
5600*8975f5c5SAndroid Build Coastguard Worker                                    GLint border,
5601*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei imageSize,
5602*8975f5c5SAndroid Build Coastguard Worker                                    const void *data)
5603*8975f5c5SAndroid Build Coastguard Worker {
5604*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5605*8975f5c5SAndroid Build Coastguard Worker 
5606*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, depth);
5607*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5608*8975f5c5SAndroid Build Coastguard Worker     // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture
5609*8975f5c5SAndroid Build Coastguard Worker     // image. So we use an empty PixelUnpackState.
5610*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, PixelUnpackState(), target, level,
5611*8975f5c5SAndroid Build Coastguard Worker                                                   internalformat, size, imageSize,
5612*8975f5c5SAndroid Build Coastguard Worker                                                   static_cast<const uint8_t *>(data)));
5613*8975f5c5SAndroid Build Coastguard Worker }
5614*8975f5c5SAndroid Build Coastguard Worker 
compressedTexImage3DRobust(TextureTarget target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,GLsizei dataSize,const GLvoid * data)5615*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexImage3DRobust(TextureTarget target,
5616*8975f5c5SAndroid Build Coastguard Worker                                          GLint level,
5617*8975f5c5SAndroid Build Coastguard Worker                                          GLenum internalformat,
5618*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei width,
5619*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei height,
5620*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei depth,
5621*8975f5c5SAndroid Build Coastguard Worker                                          GLint border,
5622*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei imageSize,
5623*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei dataSize,
5624*8975f5c5SAndroid Build Coastguard Worker                                          const GLvoid *data)
5625*8975f5c5SAndroid Build Coastguard Worker {
5626*8975f5c5SAndroid Build Coastguard Worker     compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize,
5627*8975f5c5SAndroid Build Coastguard Worker                          data);
5628*8975f5c5SAndroid Build Coastguard Worker }
5629*8975f5c5SAndroid Build Coastguard Worker 
compressedTexSubImage2D(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const void * data)5630*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexSubImage2D(TextureTarget target,
5631*8975f5c5SAndroid Build Coastguard Worker                                       GLint level,
5632*8975f5c5SAndroid Build Coastguard Worker                                       GLint xoffset,
5633*8975f5c5SAndroid Build Coastguard Worker                                       GLint yoffset,
5634*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei width,
5635*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei height,
5636*8975f5c5SAndroid Build Coastguard Worker                                       GLenum format,
5637*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei imageSize,
5638*8975f5c5SAndroid Build Coastguard Worker                                       const void *data)
5639*8975f5c5SAndroid Build Coastguard Worker {
5640*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5641*8975f5c5SAndroid Build Coastguard Worker 
5642*8975f5c5SAndroid Build Coastguard Worker     Box area(xoffset, yoffset, 0, width, height, 1);
5643*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5644*8975f5c5SAndroid Build Coastguard Worker     // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture
5645*8975f5c5SAndroid Build Coastguard Worker     // image. So we use an empty PixelUnpackState.
5646*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, PixelUnpackState(), target, level, area,
5647*8975f5c5SAndroid Build Coastguard Worker                                                      format, imageSize,
5648*8975f5c5SAndroid Build Coastguard Worker                                                      static_cast<const uint8_t *>(data)));
5649*8975f5c5SAndroid Build Coastguard Worker }
5650*8975f5c5SAndroid Build Coastguard Worker 
compressedTexSubImage2DRobust(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,GLsizei dataSize,const GLvoid * data)5651*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexSubImage2DRobust(TextureTarget target,
5652*8975f5c5SAndroid Build Coastguard Worker                                             GLint level,
5653*8975f5c5SAndroid Build Coastguard Worker                                             GLint xoffset,
5654*8975f5c5SAndroid Build Coastguard Worker                                             GLint yoffset,
5655*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei width,
5656*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei height,
5657*8975f5c5SAndroid Build Coastguard Worker                                             GLenum format,
5658*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei imageSize,
5659*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei dataSize,
5660*8975f5c5SAndroid Build Coastguard Worker                                             const GLvoid *data)
5661*8975f5c5SAndroid Build Coastguard Worker {
5662*8975f5c5SAndroid Build Coastguard Worker     compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize,
5663*8975f5c5SAndroid Build Coastguard Worker                             data);
5664*8975f5c5SAndroid Build Coastguard Worker }
5665*8975f5c5SAndroid Build Coastguard Worker 
compressedTexSubImage3D(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const void * data)5666*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexSubImage3D(TextureTarget target,
5667*8975f5c5SAndroid Build Coastguard Worker                                       GLint level,
5668*8975f5c5SAndroid Build Coastguard Worker                                       GLint xoffset,
5669*8975f5c5SAndroid Build Coastguard Worker                                       GLint yoffset,
5670*8975f5c5SAndroid Build Coastguard Worker                                       GLint zoffset,
5671*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei width,
5672*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei height,
5673*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei depth,
5674*8975f5c5SAndroid Build Coastguard Worker                                       GLenum format,
5675*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei imageSize,
5676*8975f5c5SAndroid Build Coastguard Worker                                       const void *data)
5677*8975f5c5SAndroid Build Coastguard Worker {
5678*8975f5c5SAndroid Build Coastguard Worker     // Zero sized uploads are valid but no-ops
5679*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0)
5680*8975f5c5SAndroid Build Coastguard Worker     {
5681*8975f5c5SAndroid Build Coastguard Worker         return;
5682*8975f5c5SAndroid Build Coastguard Worker     }
5683*8975f5c5SAndroid Build Coastguard Worker 
5684*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5685*8975f5c5SAndroid Build Coastguard Worker 
5686*8975f5c5SAndroid Build Coastguard Worker     Box area(xoffset, yoffset, zoffset, width, height, depth);
5687*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
5688*8975f5c5SAndroid Build Coastguard Worker     // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture
5689*8975f5c5SAndroid Build Coastguard Worker     // image. So we use an empty PixelUnpackState.
5690*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, PixelUnpackState(), target, level, area,
5691*8975f5c5SAndroid Build Coastguard Worker                                                      format, imageSize,
5692*8975f5c5SAndroid Build Coastguard Worker                                                      static_cast<const uint8_t *>(data)));
5693*8975f5c5SAndroid Build Coastguard Worker }
5694*8975f5c5SAndroid Build Coastguard Worker 
compressedTexSubImage3DRobust(TextureTarget target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,GLsizei dataSize,const GLvoid * data)5695*8975f5c5SAndroid Build Coastguard Worker void Context::compressedTexSubImage3DRobust(TextureTarget target,
5696*8975f5c5SAndroid Build Coastguard Worker                                             GLint level,
5697*8975f5c5SAndroid Build Coastguard Worker                                             GLint xoffset,
5698*8975f5c5SAndroid Build Coastguard Worker                                             GLint yoffset,
5699*8975f5c5SAndroid Build Coastguard Worker                                             GLint zoffset,
5700*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei width,
5701*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei height,
5702*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei depth,
5703*8975f5c5SAndroid Build Coastguard Worker                                             GLenum format,
5704*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei imageSize,
5705*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei dataSize,
5706*8975f5c5SAndroid Build Coastguard Worker                                             const GLvoid *data)
5707*8975f5c5SAndroid Build Coastguard Worker {
5708*8975f5c5SAndroid Build Coastguard Worker     compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format,
5709*8975f5c5SAndroid Build Coastguard Worker                             imageSize, data);
5710*8975f5c5SAndroid Build Coastguard Worker }
5711*8975f5c5SAndroid Build Coastguard Worker 
generateMipmap(TextureType target)5712*8975f5c5SAndroid Build Coastguard Worker void Context::generateMipmap(TextureType target)
5713*8975f5c5SAndroid Build Coastguard Worker {
5714*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByType(target);
5715*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->generateMipmap(this));
5716*8975f5c5SAndroid Build Coastguard Worker }
5717*8975f5c5SAndroid Build Coastguard Worker 
copyTexture(TextureID sourceId,GLint sourceLevel,TextureTarget destTarget,TextureID destId,GLint destLevel,GLint internalFormat,GLenum destType,GLboolean unpackFlipY,GLboolean unpackPremultiplyAlpha,GLboolean unpackUnmultiplyAlpha)5718*8975f5c5SAndroid Build Coastguard Worker void Context::copyTexture(TextureID sourceId,
5719*8975f5c5SAndroid Build Coastguard Worker                           GLint sourceLevel,
5720*8975f5c5SAndroid Build Coastguard Worker                           TextureTarget destTarget,
5721*8975f5c5SAndroid Build Coastguard Worker                           TextureID destId,
5722*8975f5c5SAndroid Build Coastguard Worker                           GLint destLevel,
5723*8975f5c5SAndroid Build Coastguard Worker                           GLint internalFormat,
5724*8975f5c5SAndroid Build Coastguard Worker                           GLenum destType,
5725*8975f5c5SAndroid Build Coastguard Worker                           GLboolean unpackFlipY,
5726*8975f5c5SAndroid Build Coastguard Worker                           GLboolean unpackPremultiplyAlpha,
5727*8975f5c5SAndroid Build Coastguard Worker                           GLboolean unpackUnmultiplyAlpha)
5728*8975f5c5SAndroid Build Coastguard Worker {
5729*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5730*8975f5c5SAndroid Build Coastguard Worker 
5731*8975f5c5SAndroid Build Coastguard Worker     gl::Texture *sourceTexture = getTexture(sourceId);
5732*8975f5c5SAndroid Build Coastguard Worker     gl::Texture *destTexture   = getTexture(destId);
5733*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
5734*8975f5c5SAndroid Build Coastguard Worker         destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel,
5735*8975f5c5SAndroid Build Coastguard Worker                                  ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha),
5736*8975f5c5SAndroid Build Coastguard Worker                                  ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
5737*8975f5c5SAndroid Build Coastguard Worker }
5738*8975f5c5SAndroid Build Coastguard Worker 
copySubTexture(TextureID sourceId,GLint sourceLevel,TextureTarget destTarget,TextureID destId,GLint destLevel,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height,GLboolean unpackFlipY,GLboolean unpackPremultiplyAlpha,GLboolean unpackUnmultiplyAlpha)5739*8975f5c5SAndroid Build Coastguard Worker void Context::copySubTexture(TextureID sourceId,
5740*8975f5c5SAndroid Build Coastguard Worker                              GLint sourceLevel,
5741*8975f5c5SAndroid Build Coastguard Worker                              TextureTarget destTarget,
5742*8975f5c5SAndroid Build Coastguard Worker                              TextureID destId,
5743*8975f5c5SAndroid Build Coastguard Worker                              GLint destLevel,
5744*8975f5c5SAndroid Build Coastguard Worker                              GLint xoffset,
5745*8975f5c5SAndroid Build Coastguard Worker                              GLint yoffset,
5746*8975f5c5SAndroid Build Coastguard Worker                              GLint x,
5747*8975f5c5SAndroid Build Coastguard Worker                              GLint y,
5748*8975f5c5SAndroid Build Coastguard Worker                              GLsizei width,
5749*8975f5c5SAndroid Build Coastguard Worker                              GLsizei height,
5750*8975f5c5SAndroid Build Coastguard Worker                              GLboolean unpackFlipY,
5751*8975f5c5SAndroid Build Coastguard Worker                              GLboolean unpackPremultiplyAlpha,
5752*8975f5c5SAndroid Build Coastguard Worker                              GLboolean unpackUnmultiplyAlpha)
5753*8975f5c5SAndroid Build Coastguard Worker {
5754*8975f5c5SAndroid Build Coastguard Worker     // Zero sized copies are valid but no-ops
5755*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0)
5756*8975f5c5SAndroid Build Coastguard Worker     {
5757*8975f5c5SAndroid Build Coastguard Worker         return;
5758*8975f5c5SAndroid Build Coastguard Worker     }
5759*8975f5c5SAndroid Build Coastguard Worker 
5760*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5761*8975f5c5SAndroid Build Coastguard Worker 
5762*8975f5c5SAndroid Build Coastguard Worker     gl::Texture *sourceTexture = getTexture(sourceId);
5763*8975f5c5SAndroid Build Coastguard Worker     gl::Texture *destTexture   = getTexture(destId);
5764*8975f5c5SAndroid Build Coastguard Worker     Offset offset(xoffset, yoffset, 0);
5765*8975f5c5SAndroid Build Coastguard Worker     Box box(x, y, 0, width, height, 1);
5766*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(destTexture->copySubTexture(
5767*8975f5c5SAndroid Build Coastguard Worker         this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY),
5768*8975f5c5SAndroid Build Coastguard Worker         ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha),
5769*8975f5c5SAndroid Build Coastguard Worker         sourceTexture));
5770*8975f5c5SAndroid Build Coastguard Worker }
5771*8975f5c5SAndroid Build Coastguard Worker 
copyTexture3D(TextureID sourceId,GLint sourceLevel,TextureTarget destTarget,TextureID destId,GLint destLevel,GLint internalFormat,GLenum destType,GLboolean unpackFlipY,GLboolean unpackPremultiplyAlpha,GLboolean unpackUnmultiplyAlpha)5772*8975f5c5SAndroid Build Coastguard Worker void Context::copyTexture3D(TextureID sourceId,
5773*8975f5c5SAndroid Build Coastguard Worker                             GLint sourceLevel,
5774*8975f5c5SAndroid Build Coastguard Worker                             TextureTarget destTarget,
5775*8975f5c5SAndroid Build Coastguard Worker                             TextureID destId,
5776*8975f5c5SAndroid Build Coastguard Worker                             GLint destLevel,
5777*8975f5c5SAndroid Build Coastguard Worker                             GLint internalFormat,
5778*8975f5c5SAndroid Build Coastguard Worker                             GLenum destType,
5779*8975f5c5SAndroid Build Coastguard Worker                             GLboolean unpackFlipY,
5780*8975f5c5SAndroid Build Coastguard Worker                             GLboolean unpackPremultiplyAlpha,
5781*8975f5c5SAndroid Build Coastguard Worker                             GLboolean unpackUnmultiplyAlpha)
5782*8975f5c5SAndroid Build Coastguard Worker {
5783*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5784*8975f5c5SAndroid Build Coastguard Worker 
5785*8975f5c5SAndroid Build Coastguard Worker     Texture *sourceTexture = getTexture(sourceId);
5786*8975f5c5SAndroid Build Coastguard Worker     Texture *destTexture   = getTexture(destId);
5787*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
5788*8975f5c5SAndroid Build Coastguard Worker         destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel,
5789*8975f5c5SAndroid Build Coastguard Worker                                  ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha),
5790*8975f5c5SAndroid Build Coastguard Worker                                  ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
5791*8975f5c5SAndroid Build Coastguard Worker }
5792*8975f5c5SAndroid Build Coastguard Worker 
copySubTexture3D(TextureID sourceId,GLint sourceLevel,TextureTarget destTarget,TextureID destId,GLint destLevel,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLint z,GLsizei width,GLsizei height,GLsizei depth,GLboolean unpackFlipY,GLboolean unpackPremultiplyAlpha,GLboolean unpackUnmultiplyAlpha)5793*8975f5c5SAndroid Build Coastguard Worker void Context::copySubTexture3D(TextureID sourceId,
5794*8975f5c5SAndroid Build Coastguard Worker                                GLint sourceLevel,
5795*8975f5c5SAndroid Build Coastguard Worker                                TextureTarget destTarget,
5796*8975f5c5SAndroid Build Coastguard Worker                                TextureID destId,
5797*8975f5c5SAndroid Build Coastguard Worker                                GLint destLevel,
5798*8975f5c5SAndroid Build Coastguard Worker                                GLint xoffset,
5799*8975f5c5SAndroid Build Coastguard Worker                                GLint yoffset,
5800*8975f5c5SAndroid Build Coastguard Worker                                GLint zoffset,
5801*8975f5c5SAndroid Build Coastguard Worker                                GLint x,
5802*8975f5c5SAndroid Build Coastguard Worker                                GLint y,
5803*8975f5c5SAndroid Build Coastguard Worker                                GLint z,
5804*8975f5c5SAndroid Build Coastguard Worker                                GLsizei width,
5805*8975f5c5SAndroid Build Coastguard Worker                                GLsizei height,
5806*8975f5c5SAndroid Build Coastguard Worker                                GLsizei depth,
5807*8975f5c5SAndroid Build Coastguard Worker                                GLboolean unpackFlipY,
5808*8975f5c5SAndroid Build Coastguard Worker                                GLboolean unpackPremultiplyAlpha,
5809*8975f5c5SAndroid Build Coastguard Worker                                GLboolean unpackUnmultiplyAlpha)
5810*8975f5c5SAndroid Build Coastguard Worker {
5811*8975f5c5SAndroid Build Coastguard Worker     // Zero sized copies are valid but no-ops
5812*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0 || depth == 0)
5813*8975f5c5SAndroid Build Coastguard Worker     {
5814*8975f5c5SAndroid Build Coastguard Worker         return;
5815*8975f5c5SAndroid Build Coastguard Worker     }
5816*8975f5c5SAndroid Build Coastguard Worker 
5817*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5818*8975f5c5SAndroid Build Coastguard Worker 
5819*8975f5c5SAndroid Build Coastguard Worker     Texture *sourceTexture = getTexture(sourceId);
5820*8975f5c5SAndroid Build Coastguard Worker     Texture *destTexture   = getTexture(destId);
5821*8975f5c5SAndroid Build Coastguard Worker     Offset offset(xoffset, yoffset, zoffset);
5822*8975f5c5SAndroid Build Coastguard Worker     Box box(x, y, z, width, height, depth);
5823*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(destTexture->copySubTexture(
5824*8975f5c5SAndroid Build Coastguard Worker         this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY),
5825*8975f5c5SAndroid Build Coastguard Worker         ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha),
5826*8975f5c5SAndroid Build Coastguard Worker         sourceTexture));
5827*8975f5c5SAndroid Build Coastguard Worker }
5828*8975f5c5SAndroid Build Coastguard Worker 
compressedCopyTexture(TextureID sourceId,TextureID destId)5829*8975f5c5SAndroid Build Coastguard Worker void Context::compressedCopyTexture(TextureID sourceId, TextureID destId)
5830*8975f5c5SAndroid Build Coastguard Worker {
5831*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncStateForTexImage());
5832*8975f5c5SAndroid Build Coastguard Worker 
5833*8975f5c5SAndroid Build Coastguard Worker     gl::Texture *sourceTexture = getTexture(sourceId);
5834*8975f5c5SAndroid Build Coastguard Worker     gl::Texture *destTexture   = getTexture(destId);
5835*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture));
5836*8975f5c5SAndroid Build Coastguard Worker }
5837*8975f5c5SAndroid Build Coastguard Worker 
getBufferPointerv(BufferBinding target,GLenum pname,void ** params)5838*8975f5c5SAndroid Build Coastguard Worker void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params)
5839*8975f5c5SAndroid Build Coastguard Worker {
5840*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
5841*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
5842*8975f5c5SAndroid Build Coastguard Worker 
5843*8975f5c5SAndroid Build Coastguard Worker     QueryBufferPointerv(buffer, pname, params);
5844*8975f5c5SAndroid Build Coastguard Worker }
5845*8975f5c5SAndroid Build Coastguard Worker 
getBufferPointervRobust(BufferBinding target,GLenum pname,GLsizei bufSize,GLsizei * length,void ** params)5846*8975f5c5SAndroid Build Coastguard Worker void Context::getBufferPointervRobust(BufferBinding target,
5847*8975f5c5SAndroid Build Coastguard Worker                                       GLenum pname,
5848*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei bufSize,
5849*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei *length,
5850*8975f5c5SAndroid Build Coastguard Worker                                       void **params)
5851*8975f5c5SAndroid Build Coastguard Worker {
5852*8975f5c5SAndroid Build Coastguard Worker     getBufferPointerv(target, pname, params);
5853*8975f5c5SAndroid Build Coastguard Worker }
5854*8975f5c5SAndroid Build Coastguard Worker 
mapBuffer(BufferBinding target,GLenum access)5855*8975f5c5SAndroid Build Coastguard Worker void *Context::mapBuffer(BufferBinding target, GLenum access)
5856*8975f5c5SAndroid Build Coastguard Worker {
5857*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
5858*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
5859*8975f5c5SAndroid Build Coastguard Worker 
5860*8975f5c5SAndroid Build Coastguard Worker     if (buffer->map(this, access) == angle::Result::Stop)
5861*8975f5c5SAndroid Build Coastguard Worker     {
5862*8975f5c5SAndroid Build Coastguard Worker         return nullptr;
5863*8975f5c5SAndroid Build Coastguard Worker     }
5864*8975f5c5SAndroid Build Coastguard Worker 
5865*8975f5c5SAndroid Build Coastguard Worker     return buffer->getMapPointer();
5866*8975f5c5SAndroid Build Coastguard Worker }
5867*8975f5c5SAndroid Build Coastguard Worker 
unmapBuffer(BufferBinding target)5868*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::unmapBuffer(BufferBinding target)
5869*8975f5c5SAndroid Build Coastguard Worker {
5870*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
5871*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
5872*8975f5c5SAndroid Build Coastguard Worker 
5873*8975f5c5SAndroid Build Coastguard Worker     GLboolean result;
5874*8975f5c5SAndroid Build Coastguard Worker     if (buffer->unmap(this, &result) == angle::Result::Stop)
5875*8975f5c5SAndroid Build Coastguard Worker     {
5876*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
5877*8975f5c5SAndroid Build Coastguard Worker     }
5878*8975f5c5SAndroid Build Coastguard Worker 
5879*8975f5c5SAndroid Build Coastguard Worker     return result;
5880*8975f5c5SAndroid Build Coastguard Worker }
5881*8975f5c5SAndroid Build Coastguard Worker 
mapBufferRange(BufferBinding target,GLintptr offset,GLsizeiptr length,GLbitfield access)5882*8975f5c5SAndroid Build Coastguard Worker void *Context::mapBufferRange(BufferBinding target,
5883*8975f5c5SAndroid Build Coastguard Worker                               GLintptr offset,
5884*8975f5c5SAndroid Build Coastguard Worker                               GLsizeiptr length,
5885*8975f5c5SAndroid Build Coastguard Worker                               GLbitfield access)
5886*8975f5c5SAndroid Build Coastguard Worker {
5887*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
5888*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
5889*8975f5c5SAndroid Build Coastguard Worker 
5890*8975f5c5SAndroid Build Coastguard Worker     if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop)
5891*8975f5c5SAndroid Build Coastguard Worker     {
5892*8975f5c5SAndroid Build Coastguard Worker         return nullptr;
5893*8975f5c5SAndroid Build Coastguard Worker     }
5894*8975f5c5SAndroid Build Coastguard Worker 
5895*8975f5c5SAndroid Build Coastguard Worker     // TODO: (anglebug.com/42266294): Modify return value in entry point layer
5896*8975f5c5SAndroid Build Coastguard Worker     angle::FrameCaptureShared *frameCaptureShared = getShareGroup()->getFrameCaptureShared();
5897*8975f5c5SAndroid Build Coastguard Worker     if (frameCaptureShared->enabled())
5898*8975f5c5SAndroid Build Coastguard Worker     {
5899*8975f5c5SAndroid Build Coastguard Worker         return frameCaptureShared->maybeGetShadowMemoryPointer(buffer, length, access);
5900*8975f5c5SAndroid Build Coastguard Worker     }
5901*8975f5c5SAndroid Build Coastguard Worker     else
5902*8975f5c5SAndroid Build Coastguard Worker     {
5903*8975f5c5SAndroid Build Coastguard Worker         return buffer->getMapPointer();
5904*8975f5c5SAndroid Build Coastguard Worker     }
5905*8975f5c5SAndroid Build Coastguard Worker }
5906*8975f5c5SAndroid Build Coastguard Worker 
flushMappedBufferRange(BufferBinding,GLintptr,GLsizeiptr)5907*8975f5c5SAndroid Build Coastguard Worker void Context::flushMappedBufferRange(BufferBinding /*target*/,
5908*8975f5c5SAndroid Build Coastguard Worker                                      GLintptr /*offset*/,
5909*8975f5c5SAndroid Build Coastguard Worker                                      GLsizeiptr /*length*/)
5910*8975f5c5SAndroid Build Coastguard Worker {
5911*8975f5c5SAndroid Build Coastguard Worker     // We do not currently support a non-trivial implementation of FlushMappedBufferRange
5912*8975f5c5SAndroid Build Coastguard Worker }
5913*8975f5c5SAndroid Build Coastguard Worker 
syncStateForReadPixels()5914*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::syncStateForReadPixels()
5915*8975f5c5SAndroid Build Coastguard Worker {
5916*8975f5c5SAndroid Build Coastguard Worker     return syncState(kReadPixelsDirtyBits, kReadPixelsExtendedDirtyBits, mReadPixelsDirtyObjects,
5917*8975f5c5SAndroid Build Coastguard Worker                      Command::ReadPixels);
5918*8975f5c5SAndroid Build Coastguard Worker }
5919*8975f5c5SAndroid Build Coastguard Worker 
syncStateForTexImage()5920*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::syncStateForTexImage()
5921*8975f5c5SAndroid Build Coastguard Worker {
5922*8975f5c5SAndroid Build Coastguard Worker     return syncState(kTexImageDirtyBits, kTexImageExtendedDirtyBits, mTexImageDirtyObjects,
5923*8975f5c5SAndroid Build Coastguard Worker                      Command::TexImage);
5924*8975f5c5SAndroid Build Coastguard Worker }
5925*8975f5c5SAndroid Build Coastguard Worker 
syncStateForBlit(GLbitfield mask)5926*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::syncStateForBlit(GLbitfield mask)
5927*8975f5c5SAndroid Build Coastguard Worker {
5928*8975f5c5SAndroid Build Coastguard Worker     uint32_t commandMask = 0;
5929*8975f5c5SAndroid Build Coastguard Worker     if ((mask & GL_COLOR_BUFFER_BIT) != 0)
5930*8975f5c5SAndroid Build Coastguard Worker     {
5931*8975f5c5SAndroid Build Coastguard Worker         commandMask |= CommandBlitBufferColor;
5932*8975f5c5SAndroid Build Coastguard Worker     }
5933*8975f5c5SAndroid Build Coastguard Worker     if ((mask & GL_DEPTH_BUFFER_BIT) != 0)
5934*8975f5c5SAndroid Build Coastguard Worker     {
5935*8975f5c5SAndroid Build Coastguard Worker         commandMask |= CommandBlitBufferDepth;
5936*8975f5c5SAndroid Build Coastguard Worker     }
5937*8975f5c5SAndroid Build Coastguard Worker     if ((mask & GL_STENCIL_BUFFER_BIT) != 0)
5938*8975f5c5SAndroid Build Coastguard Worker     {
5939*8975f5c5SAndroid Build Coastguard Worker         commandMask |= CommandBlitBufferStencil;
5940*8975f5c5SAndroid Build Coastguard Worker     }
5941*8975f5c5SAndroid Build Coastguard Worker 
5942*8975f5c5SAndroid Build Coastguard Worker     Command command = static_cast<Command>(static_cast<uint32_t>(Command::Blit) + commandMask);
5943*8975f5c5SAndroid Build Coastguard Worker 
5944*8975f5c5SAndroid Build Coastguard Worker     return syncState(kBlitDirtyBits, kBlitExtendedDirtyBits, mBlitDirtyObjects, command);
5945*8975f5c5SAndroid Build Coastguard Worker }
5946*8975f5c5SAndroid Build Coastguard Worker 
syncStateForClear()5947*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::syncStateForClear()
5948*8975f5c5SAndroid Build Coastguard Worker {
5949*8975f5c5SAndroid Build Coastguard Worker     return syncState(kClearDirtyBits, kClearExtendedDirtyBits, mClearDirtyObjects, Command::Clear);
5950*8975f5c5SAndroid Build Coastguard Worker }
5951*8975f5c5SAndroid Build Coastguard Worker 
syncTextureForCopy(Texture * texture)5952*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::syncTextureForCopy(Texture *texture)
5953*8975f5c5SAndroid Build Coastguard Worker {
5954*8975f5c5SAndroid Build Coastguard Worker     ASSERT(texture);
5955*8975f5c5SAndroid Build Coastguard Worker     // Sync texture not active but scheduled for a copy
5956*8975f5c5SAndroid Build Coastguard Worker     if (texture->hasAnyDirtyBit())
5957*8975f5c5SAndroid Build Coastguard Worker     {
5958*8975f5c5SAndroid Build Coastguard Worker         return texture->syncState(this, Command::Other);
5959*8975f5c5SAndroid Build Coastguard Worker     }
5960*8975f5c5SAndroid Build Coastguard Worker 
5961*8975f5c5SAndroid Build Coastguard Worker     return angle::Result::Continue;
5962*8975f5c5SAndroid Build Coastguard Worker }
5963*8975f5c5SAndroid Build Coastguard Worker 
activeShaderProgram(ProgramPipelineID pipeline,ShaderProgramID program)5964*8975f5c5SAndroid Build Coastguard Worker void Context::activeShaderProgram(ProgramPipelineID pipeline, ShaderProgramID program)
5965*8975f5c5SAndroid Build Coastguard Worker {
5966*8975f5c5SAndroid Build Coastguard Worker     Program *shaderProgram = getProgramNoResolveLink(program);
5967*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *programPipeline =
5968*8975f5c5SAndroid Build Coastguard Worker         mState.mProgramPipelineManager->checkProgramPipelineAllocation(mImplementation.get(),
5969*8975f5c5SAndroid Build Coastguard Worker                                                                        pipeline);
5970*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programPipeline);
5971*8975f5c5SAndroid Build Coastguard Worker 
5972*8975f5c5SAndroid Build Coastguard Worker     programPipeline->activeShaderProgram(shaderProgram);
5973*8975f5c5SAndroid Build Coastguard Worker }
5974*8975f5c5SAndroid Build Coastguard Worker 
blendBarrier()5975*8975f5c5SAndroid Build Coastguard Worker void Context::blendBarrier()
5976*8975f5c5SAndroid Build Coastguard Worker {
5977*8975f5c5SAndroid Build Coastguard Worker     mImplementation->blendBarrier();
5978*8975f5c5SAndroid Build Coastguard Worker }
5979*8975f5c5SAndroid Build Coastguard Worker 
disableVertexAttribArray(GLuint index)5980*8975f5c5SAndroid Build Coastguard Worker void Context::disableVertexAttribArray(GLuint index)
5981*8975f5c5SAndroid Build Coastguard Worker {
5982*8975f5c5SAndroid Build Coastguard Worker     mState.setEnableVertexAttribArray(index, false);
5983*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayStateChange(this);
5984*8975f5c5SAndroid Build Coastguard Worker }
5985*8975f5c5SAndroid Build Coastguard Worker 
enableVertexAttribArray(GLuint index)5986*8975f5c5SAndroid Build Coastguard Worker void Context::enableVertexAttribArray(GLuint index)
5987*8975f5c5SAndroid Build Coastguard Worker {
5988*8975f5c5SAndroid Build Coastguard Worker     mState.setEnableVertexAttribArray(index, true);
5989*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayStateChange(this);
5990*8975f5c5SAndroid Build Coastguard Worker }
5991*8975f5c5SAndroid Build Coastguard Worker 
vertexAttribPointer(GLuint index,GLint size,VertexAttribType type,GLboolean normalized,GLsizei stride,const void * ptr)5992*8975f5c5SAndroid Build Coastguard Worker void Context::vertexAttribPointer(GLuint index,
5993*8975f5c5SAndroid Build Coastguard Worker                                   GLint size,
5994*8975f5c5SAndroid Build Coastguard Worker                                   VertexAttribType type,
5995*8975f5c5SAndroid Build Coastguard Worker                                   GLboolean normalized,
5996*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei stride,
5997*8975f5c5SAndroid Build Coastguard Worker                                   const void *ptr)
5998*8975f5c5SAndroid Build Coastguard Worker {
5999*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexAttribPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size,
6000*8975f5c5SAndroid Build Coastguard Worker                                   type, ConvertToBool(normalized), stride, ptr);
6001*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayStateChange(this);
6002*8975f5c5SAndroid Build Coastguard Worker }
6003*8975f5c5SAndroid Build Coastguard Worker 
vertexAttribFormat(GLuint attribIndex,GLint size,VertexAttribType type,GLboolean normalized,GLuint relativeOffset)6004*8975f5c5SAndroid Build Coastguard Worker void Context::vertexAttribFormat(GLuint attribIndex,
6005*8975f5c5SAndroid Build Coastguard Worker                                  GLint size,
6006*8975f5c5SAndroid Build Coastguard Worker                                  VertexAttribType type,
6007*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean normalized,
6008*8975f5c5SAndroid Build Coastguard Worker                                  GLuint relativeOffset)
6009*8975f5c5SAndroid Build Coastguard Worker {
6010*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexAttribFormat(attribIndex, size, type, ConvertToBool(normalized), false,
6011*8975f5c5SAndroid Build Coastguard Worker                                  relativeOffset);
6012*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayFormatChange(this);
6013*8975f5c5SAndroid Build Coastguard Worker }
6014*8975f5c5SAndroid Build Coastguard Worker 
vertexAttribIFormat(GLuint attribIndex,GLint size,VertexAttribType type,GLuint relativeOffset)6015*8975f5c5SAndroid Build Coastguard Worker void Context::vertexAttribIFormat(GLuint attribIndex,
6016*8975f5c5SAndroid Build Coastguard Worker                                   GLint size,
6017*8975f5c5SAndroid Build Coastguard Worker                                   VertexAttribType type,
6018*8975f5c5SAndroid Build Coastguard Worker                                   GLuint relativeOffset)
6019*8975f5c5SAndroid Build Coastguard Worker {
6020*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset);
6021*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayFormatChange(this);
6022*8975f5c5SAndroid Build Coastguard Worker }
6023*8975f5c5SAndroid Build Coastguard Worker 
vertexAttribBinding(GLuint attribIndex,GLuint bindingIndex)6024*8975f5c5SAndroid Build Coastguard Worker void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
6025*8975f5c5SAndroid Build Coastguard Worker {
6026*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexAttribBinding(this, attribIndex, bindingIndex);
6027*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayStateChange(this);
6028*8975f5c5SAndroid Build Coastguard Worker }
6029*8975f5c5SAndroid Build Coastguard Worker 
vertexBindingDivisor(GLuint bindingIndex,GLuint divisor)6030*8975f5c5SAndroid Build Coastguard Worker void Context::vertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
6031*8975f5c5SAndroid Build Coastguard Worker {
6032*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexBindingDivisor(this, bindingIndex, divisor);
6033*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayFormatChange(this);
6034*8975f5c5SAndroid Build Coastguard Worker }
6035*8975f5c5SAndroid Build Coastguard Worker 
vertexAttribIPointer(GLuint index,GLint size,VertexAttribType type,GLsizei stride,const void * pointer)6036*8975f5c5SAndroid Build Coastguard Worker void Context::vertexAttribIPointer(GLuint index,
6037*8975f5c5SAndroid Build Coastguard Worker                                    GLint size,
6038*8975f5c5SAndroid Build Coastguard Worker                                    VertexAttribType type,
6039*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei stride,
6040*8975f5c5SAndroid Build Coastguard Worker                                    const void *pointer)
6041*8975f5c5SAndroid Build Coastguard Worker {
6042*8975f5c5SAndroid Build Coastguard Worker     mState.setVertexAttribIPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size,
6043*8975f5c5SAndroid Build Coastguard Worker                                    type, stride, pointer);
6044*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onVertexArrayStateChange(this);
6045*8975f5c5SAndroid Build Coastguard Worker }
6046*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribivImpl(GLuint index,GLenum pname,GLint * params) const6047*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribivImpl(GLuint index, GLenum pname, GLint *params) const
6048*8975f5c5SAndroid Build Coastguard Worker {
6049*8975f5c5SAndroid Build Coastguard Worker     const VertexAttribCurrentValueData &currentValues =
6050*8975f5c5SAndroid Build Coastguard Worker         getState().getVertexAttribCurrentValue(index);
6051*8975f5c5SAndroid Build Coastguard Worker     const VertexArray *vao = getState().getVertexArray();
6052*8975f5c5SAndroid Build Coastguard Worker     QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6053*8975f5c5SAndroid Build Coastguard Worker                         currentValues, pname, params);
6054*8975f5c5SAndroid Build Coastguard Worker }
6055*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribiv(GLuint index,GLenum pname,GLint * params)6056*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params)
6057*8975f5c5SAndroid Build Coastguard Worker {
6058*8975f5c5SAndroid Build Coastguard Worker     return getVertexAttribivImpl(index, pname, params);
6059*8975f5c5SAndroid Build Coastguard Worker }
6060*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribivRobust(GLuint index,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)6061*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribivRobust(GLuint index,
6062*8975f5c5SAndroid Build Coastguard Worker                                       GLenum pname,
6063*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei bufSize,
6064*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei *length,
6065*8975f5c5SAndroid Build Coastguard Worker                                       GLint *params)
6066*8975f5c5SAndroid Build Coastguard Worker {
6067*8975f5c5SAndroid Build Coastguard Worker     getVertexAttribiv(index, pname, params);
6068*8975f5c5SAndroid Build Coastguard Worker }
6069*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribfv(GLuint index,GLenum pname,GLfloat * params)6070*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
6071*8975f5c5SAndroid Build Coastguard Worker {
6072*8975f5c5SAndroid Build Coastguard Worker     const VertexAttribCurrentValueData &currentValues =
6073*8975f5c5SAndroid Build Coastguard Worker         getState().getVertexAttribCurrentValue(index);
6074*8975f5c5SAndroid Build Coastguard Worker     const VertexArray *vao = getState().getVertexArray();
6075*8975f5c5SAndroid Build Coastguard Worker     QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6076*8975f5c5SAndroid Build Coastguard Worker                         currentValues, pname, params);
6077*8975f5c5SAndroid Build Coastguard Worker }
6078*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribfvRobust(GLuint index,GLenum pname,GLsizei bufSize,GLsizei * length,GLfloat * params)6079*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribfvRobust(GLuint index,
6080*8975f5c5SAndroid Build Coastguard Worker                                       GLenum pname,
6081*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei bufSize,
6082*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei *length,
6083*8975f5c5SAndroid Build Coastguard Worker                                       GLfloat *params)
6084*8975f5c5SAndroid Build Coastguard Worker {
6085*8975f5c5SAndroid Build Coastguard Worker     getVertexAttribfv(index, pname, params);
6086*8975f5c5SAndroid Build Coastguard Worker }
6087*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribIiv(GLuint index,GLenum pname,GLint * params)6088*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
6089*8975f5c5SAndroid Build Coastguard Worker {
6090*8975f5c5SAndroid Build Coastguard Worker     const VertexAttribCurrentValueData &currentValues =
6091*8975f5c5SAndroid Build Coastguard Worker         getState().getVertexAttribCurrentValue(index);
6092*8975f5c5SAndroid Build Coastguard Worker     const VertexArray *vao = getState().getVertexArray();
6093*8975f5c5SAndroid Build Coastguard Worker     QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6094*8975f5c5SAndroid Build Coastguard Worker                          currentValues, pname, params);
6095*8975f5c5SAndroid Build Coastguard Worker }
6096*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribIivRobust(GLuint index,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)6097*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribIivRobust(GLuint index,
6098*8975f5c5SAndroid Build Coastguard Worker                                        GLenum pname,
6099*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei bufSize,
6100*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei *length,
6101*8975f5c5SAndroid Build Coastguard Worker                                        GLint *params)
6102*8975f5c5SAndroid Build Coastguard Worker {
6103*8975f5c5SAndroid Build Coastguard Worker     getVertexAttribIiv(index, pname, params);
6104*8975f5c5SAndroid Build Coastguard Worker }
6105*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribIuiv(GLuint index,GLenum pname,GLuint * params)6106*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
6107*8975f5c5SAndroid Build Coastguard Worker {
6108*8975f5c5SAndroid Build Coastguard Worker     const VertexAttribCurrentValueData &currentValues =
6109*8975f5c5SAndroid Build Coastguard Worker         getState().getVertexAttribCurrentValue(index);
6110*8975f5c5SAndroid Build Coastguard Worker     const VertexArray *vao = getState().getVertexArray();
6111*8975f5c5SAndroid Build Coastguard Worker     QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6112*8975f5c5SAndroid Build Coastguard Worker                           currentValues, pname, params);
6113*8975f5c5SAndroid Build Coastguard Worker }
6114*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribIuivRobust(GLuint index,GLenum pname,GLsizei bufSize,GLsizei * length,GLuint * params)6115*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribIuivRobust(GLuint index,
6116*8975f5c5SAndroid Build Coastguard Worker                                         GLenum pname,
6117*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
6118*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
6119*8975f5c5SAndroid Build Coastguard Worker                                         GLuint *params)
6120*8975f5c5SAndroid Build Coastguard Worker {
6121*8975f5c5SAndroid Build Coastguard Worker     getVertexAttribIuiv(index, pname, params);
6122*8975f5c5SAndroid Build Coastguard Worker }
6123*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribPointerv(GLuint index,GLenum pname,void ** pointer)6124*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer)
6125*8975f5c5SAndroid Build Coastguard Worker {
6126*8975f5c5SAndroid Build Coastguard Worker     const VertexAttribute &attrib = getState().getVertexArray()->getVertexAttribute(index);
6127*8975f5c5SAndroid Build Coastguard Worker     QueryVertexAttribPointerv(attrib, pname, pointer);
6128*8975f5c5SAndroid Build Coastguard Worker }
6129*8975f5c5SAndroid Build Coastguard Worker 
getVertexAttribPointervRobust(GLuint index,GLenum pname,GLsizei bufSize,GLsizei * length,void ** pointer)6130*8975f5c5SAndroid Build Coastguard Worker void Context::getVertexAttribPointervRobust(GLuint index,
6131*8975f5c5SAndroid Build Coastguard Worker                                             GLenum pname,
6132*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei bufSize,
6133*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei *length,
6134*8975f5c5SAndroid Build Coastguard Worker                                             void **pointer)
6135*8975f5c5SAndroid Build Coastguard Worker {
6136*8975f5c5SAndroid Build Coastguard Worker     getVertexAttribPointerv(index, pname, pointer);
6137*8975f5c5SAndroid Build Coastguard Worker }
6138*8975f5c5SAndroid Build Coastguard Worker 
debugMessageControl(GLenum source,GLenum type,GLenum severity,GLsizei count,const GLuint * ids,GLboolean enabled)6139*8975f5c5SAndroid Build Coastguard Worker void Context::debugMessageControl(GLenum source,
6140*8975f5c5SAndroid Build Coastguard Worker                                   GLenum type,
6141*8975f5c5SAndroid Build Coastguard Worker                                   GLenum severity,
6142*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei count,
6143*8975f5c5SAndroid Build Coastguard Worker                                   const GLuint *ids,
6144*8975f5c5SAndroid Build Coastguard Worker                                   GLboolean enabled)
6145*8975f5c5SAndroid Build Coastguard Worker {
6146*8975f5c5SAndroid Build Coastguard Worker     std::vector<GLuint> idVector(ids, ids + count);
6147*8975f5c5SAndroid Build Coastguard Worker     mState.getDebug().setMessageControl(source, type, severity, std::move(idVector),
6148*8975f5c5SAndroid Build Coastguard Worker                                         ConvertToBool(enabled));
6149*8975f5c5SAndroid Build Coastguard Worker }
6150*8975f5c5SAndroid Build Coastguard Worker 
debugMessageInsert(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar * buf)6151*8975f5c5SAndroid Build Coastguard Worker void Context::debugMessageInsert(GLenum source,
6152*8975f5c5SAndroid Build Coastguard Worker                                  GLenum type,
6153*8975f5c5SAndroid Build Coastguard Worker                                  GLuint id,
6154*8975f5c5SAndroid Build Coastguard Worker                                  GLenum severity,
6155*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei length,
6156*8975f5c5SAndroid Build Coastguard Worker                                  const GLchar *buf)
6157*8975f5c5SAndroid Build Coastguard Worker {
6158*8975f5c5SAndroid Build Coastguard Worker     std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf));
6159*8975f5c5SAndroid Build Coastguard Worker     mState.getDebug().insertMessage(source, type, id, severity, std::move(msg), gl::LOG_INFO,
6160*8975f5c5SAndroid Build Coastguard Worker                                     angle::EntryPoint::GLDebugMessageInsert);
6161*8975f5c5SAndroid Build Coastguard Worker }
6162*8975f5c5SAndroid Build Coastguard Worker 
debugMessageCallback(GLDEBUGPROCKHR callback,const void * userParam)6163*8975f5c5SAndroid Build Coastguard Worker void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam)
6164*8975f5c5SAndroid Build Coastguard Worker {
6165*8975f5c5SAndroid Build Coastguard Worker     mState.getDebug().setCallback(callback, userParam);
6166*8975f5c5SAndroid Build Coastguard Worker }
6167*8975f5c5SAndroid Build Coastguard Worker 
getDebugMessageLog(GLuint count,GLsizei bufSize,GLenum * sources,GLenum * types,GLuint * ids,GLenum * severities,GLsizei * lengths,GLchar * messageLog)6168*8975f5c5SAndroid Build Coastguard Worker GLuint Context::getDebugMessageLog(GLuint count,
6169*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
6170*8975f5c5SAndroid Build Coastguard Worker                                    GLenum *sources,
6171*8975f5c5SAndroid Build Coastguard Worker                                    GLenum *types,
6172*8975f5c5SAndroid Build Coastguard Worker                                    GLuint *ids,
6173*8975f5c5SAndroid Build Coastguard Worker                                    GLenum *severities,
6174*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei *lengths,
6175*8975f5c5SAndroid Build Coastguard Worker                                    GLchar *messageLog)
6176*8975f5c5SAndroid Build Coastguard Worker {
6177*8975f5c5SAndroid Build Coastguard Worker     return static_cast<GLuint>(mState.getDebug().getMessages(count, bufSize, sources, types, ids,
6178*8975f5c5SAndroid Build Coastguard Worker                                                              severities, lengths, messageLog));
6179*8975f5c5SAndroid Build Coastguard Worker }
6180*8975f5c5SAndroid Build Coastguard Worker 
pushDebugGroup(GLenum source,GLuint id,GLsizei length,const GLchar * message)6181*8975f5c5SAndroid Build Coastguard Worker void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message)
6182*8975f5c5SAndroid Build Coastguard Worker {
6183*8975f5c5SAndroid Build Coastguard Worker     std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message));
6184*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->pushDebugGroup(this, source, id, msg));
6185*8975f5c5SAndroid Build Coastguard Worker     mState.getDebug().pushGroup(source, id, std::move(msg));
6186*8975f5c5SAndroid Build Coastguard Worker }
6187*8975f5c5SAndroid Build Coastguard Worker 
handleNoopDrawEvent()6188*8975f5c5SAndroid Build Coastguard Worker angle::Result Context::handleNoopDrawEvent()
6189*8975f5c5SAndroid Build Coastguard Worker {
6190*8975f5c5SAndroid Build Coastguard Worker     return (mImplementation->handleNoopDrawEvent());
6191*8975f5c5SAndroid Build Coastguard Worker }
6192*8975f5c5SAndroid Build Coastguard Worker 
popDebugGroup()6193*8975f5c5SAndroid Build Coastguard Worker void Context::popDebugGroup()
6194*8975f5c5SAndroid Build Coastguard Worker {
6195*8975f5c5SAndroid Build Coastguard Worker     mState.getDebug().popGroup();
6196*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->popDebugGroup(this));
6197*8975f5c5SAndroid Build Coastguard Worker }
6198*8975f5c5SAndroid Build Coastguard Worker 
bufferStorage(BufferBinding target,GLsizeiptr size,const void * data,GLbitfield flags)6199*8975f5c5SAndroid Build Coastguard Worker void Context::bufferStorage(BufferBinding target,
6200*8975f5c5SAndroid Build Coastguard Worker                             GLsizeiptr size,
6201*8975f5c5SAndroid Build Coastguard Worker                             const void *data,
6202*8975f5c5SAndroid Build Coastguard Worker                             GLbitfield flags)
6203*8975f5c5SAndroid Build Coastguard Worker {
6204*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
6205*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
6206*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(buffer->bufferStorage(this, target, size, data, flags));
6207*8975f5c5SAndroid Build Coastguard Worker }
6208*8975f5c5SAndroid Build Coastguard Worker 
bufferStorageExternal(BufferBinding target,GLintptr offset,GLsizeiptr size,GLeglClientBufferEXT clientBuffer,GLbitfield flags)6209*8975f5c5SAndroid Build Coastguard Worker void Context::bufferStorageExternal(BufferBinding target,
6210*8975f5c5SAndroid Build Coastguard Worker                                     GLintptr offset,
6211*8975f5c5SAndroid Build Coastguard Worker                                     GLsizeiptr size,
6212*8975f5c5SAndroid Build Coastguard Worker                                     GLeglClientBufferEXT clientBuffer,
6213*8975f5c5SAndroid Build Coastguard Worker                                     GLbitfield flags)
6214*8975f5c5SAndroid Build Coastguard Worker {
6215*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
6216*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
6217*8975f5c5SAndroid Build Coastguard Worker 
6218*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(buffer->bufferStorageExternal(this, target, size, clientBuffer, flags));
6219*8975f5c5SAndroid Build Coastguard Worker }
6220*8975f5c5SAndroid Build Coastguard Worker 
namedBufferStorageExternal(GLuint buffer,GLintptr offset,GLsizeiptr size,GLeglClientBufferEXT clientBuffer,GLbitfield flags)6221*8975f5c5SAndroid Build Coastguard Worker void Context::namedBufferStorageExternal(GLuint buffer,
6222*8975f5c5SAndroid Build Coastguard Worker                                          GLintptr offset,
6223*8975f5c5SAndroid Build Coastguard Worker                                          GLsizeiptr size,
6224*8975f5c5SAndroid Build Coastguard Worker                                          GLeglClientBufferEXT clientBuffer,
6225*8975f5c5SAndroid Build Coastguard Worker                                          GLbitfield flags)
6226*8975f5c5SAndroid Build Coastguard Worker {
6227*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
6228*8975f5c5SAndroid Build Coastguard Worker }
6229*8975f5c5SAndroid Build Coastguard Worker 
bufferData(BufferBinding target,GLsizeiptr size,const void * data,BufferUsage usage)6230*8975f5c5SAndroid Build Coastguard Worker void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage)
6231*8975f5c5SAndroid Build Coastguard Worker {
6232*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
6233*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
6234*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage));
6235*8975f5c5SAndroid Build Coastguard Worker }
6236*8975f5c5SAndroid Build Coastguard Worker 
bufferSubData(BufferBinding target,GLintptr offset,GLsizeiptr size,const void * data)6237*8975f5c5SAndroid Build Coastguard Worker void Context::bufferSubData(BufferBinding target,
6238*8975f5c5SAndroid Build Coastguard Worker                             GLintptr offset,
6239*8975f5c5SAndroid Build Coastguard Worker                             GLsizeiptr size,
6240*8975f5c5SAndroid Build Coastguard Worker                             const void *data)
6241*8975f5c5SAndroid Build Coastguard Worker {
6242*8975f5c5SAndroid Build Coastguard Worker     if (data == nullptr || size == 0)
6243*8975f5c5SAndroid Build Coastguard Worker     {
6244*8975f5c5SAndroid Build Coastguard Worker         return;
6245*8975f5c5SAndroid Build Coastguard Worker     }
6246*8975f5c5SAndroid Build Coastguard Worker 
6247*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
6248*8975f5c5SAndroid Build Coastguard Worker     ASSERT(buffer);
6249*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset));
6250*8975f5c5SAndroid Build Coastguard Worker }
6251*8975f5c5SAndroid Build Coastguard Worker 
attachShader(ShaderProgramID program,ShaderProgramID shader)6252*8975f5c5SAndroid Build Coastguard Worker void Context::attachShader(ShaderProgramID program, ShaderProgramID shader)
6253*8975f5c5SAndroid Build Coastguard Worker {
6254*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = mState.mShaderProgramManager->getProgram(program);
6255*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject   = mState.mShaderProgramManager->getShader(shader);
6256*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject && shaderObject);
6257*8975f5c5SAndroid Build Coastguard Worker     programObject->attachShader(this, shaderObject);
6258*8975f5c5SAndroid Build Coastguard Worker }
6259*8975f5c5SAndroid Build Coastguard Worker 
copyBufferSubData(BufferBinding readTarget,BufferBinding writeTarget,GLintptr readOffset,GLintptr writeOffset,GLsizeiptr size)6260*8975f5c5SAndroid Build Coastguard Worker void Context::copyBufferSubData(BufferBinding readTarget,
6261*8975f5c5SAndroid Build Coastguard Worker                                 BufferBinding writeTarget,
6262*8975f5c5SAndroid Build Coastguard Worker                                 GLintptr readOffset,
6263*8975f5c5SAndroid Build Coastguard Worker                                 GLintptr writeOffset,
6264*8975f5c5SAndroid Build Coastguard Worker                                 GLsizeiptr size)
6265*8975f5c5SAndroid Build Coastguard Worker {
6266*8975f5c5SAndroid Build Coastguard Worker     // if size is zero, the copy is a successful no-op
6267*8975f5c5SAndroid Build Coastguard Worker     if (size == 0)
6268*8975f5c5SAndroid Build Coastguard Worker     {
6269*8975f5c5SAndroid Build Coastguard Worker         return;
6270*8975f5c5SAndroid Build Coastguard Worker     }
6271*8975f5c5SAndroid Build Coastguard Worker 
6272*8975f5c5SAndroid Build Coastguard Worker     // TODO(jmadill): cache these.
6273*8975f5c5SAndroid Build Coastguard Worker     Buffer *readBuffer  = mState.getTargetBuffer(readTarget);
6274*8975f5c5SAndroid Build Coastguard Worker     Buffer *writeBuffer = mState.getTargetBuffer(writeTarget);
6275*8975f5c5SAndroid Build Coastguard Worker 
6276*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
6277*8975f5c5SAndroid Build Coastguard Worker         writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size));
6278*8975f5c5SAndroid Build Coastguard Worker }
6279*8975f5c5SAndroid Build Coastguard Worker 
bindAttribLocation(ShaderProgramID program,GLuint index,const GLchar * name)6280*8975f5c5SAndroid Build Coastguard Worker void Context::bindAttribLocation(ShaderProgramID program, GLuint index, const GLchar *name)
6281*8975f5c5SAndroid Build Coastguard Worker {
6282*8975f5c5SAndroid Build Coastguard Worker     // Ideally we could share the program query with the validation layer if possible.
6283*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
6284*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
6285*8975f5c5SAndroid Build Coastguard Worker     programObject->bindAttributeLocation(this, index, name);
6286*8975f5c5SAndroid Build Coastguard Worker }
6287*8975f5c5SAndroid Build Coastguard Worker 
bindBufferBase(BufferBinding target,GLuint index,BufferID buffer)6288*8975f5c5SAndroid Build Coastguard Worker void Context::bindBufferBase(BufferBinding target, GLuint index, BufferID buffer)
6289*8975f5c5SAndroid Build Coastguard Worker {
6290*8975f5c5SAndroid Build Coastguard Worker     bindBufferRange(target, index, buffer, 0, 0);
6291*8975f5c5SAndroid Build Coastguard Worker }
6292*8975f5c5SAndroid Build Coastguard Worker 
bindBufferRange(BufferBinding target,GLuint index,BufferID buffer,GLintptr offset,GLsizeiptr size)6293*8975f5c5SAndroid Build Coastguard Worker void Context::bindBufferRange(BufferBinding target,
6294*8975f5c5SAndroid Build Coastguard Worker                               GLuint index,
6295*8975f5c5SAndroid Build Coastguard Worker                               BufferID buffer,
6296*8975f5c5SAndroid Build Coastguard Worker                               GLintptr offset,
6297*8975f5c5SAndroid Build Coastguard Worker                               GLsizeiptr size)
6298*8975f5c5SAndroid Build Coastguard Worker {
6299*8975f5c5SAndroid Build Coastguard Worker     Buffer *object = mState.mBufferManager->checkBufferAllocation(mImplementation.get(), buffer);
6300*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mState.setIndexedBufferBinding(this, target, index, object, offset, size));
6301*8975f5c5SAndroid Build Coastguard Worker     if (target == BufferBinding::Uniform)
6302*8975f5c5SAndroid Build Coastguard Worker     {
6303*8975f5c5SAndroid Build Coastguard Worker         mUniformBufferObserverBindings[index].bind(object);
6304*8975f5c5SAndroid Build Coastguard Worker         mState.onUniformBufferStateChange(index);
6305*8975f5c5SAndroid Build Coastguard Worker         mStateCache.onUniformBufferStateChange(this);
6306*8975f5c5SAndroid Build Coastguard Worker     }
6307*8975f5c5SAndroid Build Coastguard Worker     else if (target == BufferBinding::AtomicCounter)
6308*8975f5c5SAndroid Build Coastguard Worker     {
6309*8975f5c5SAndroid Build Coastguard Worker         mAtomicCounterBufferObserverBindings[index].bind(object);
6310*8975f5c5SAndroid Build Coastguard Worker         mStateCache.onAtomicCounterBufferStateChange(this);
6311*8975f5c5SAndroid Build Coastguard Worker     }
6312*8975f5c5SAndroid Build Coastguard Worker     else if (target == BufferBinding::ShaderStorage)
6313*8975f5c5SAndroid Build Coastguard Worker     {
6314*8975f5c5SAndroid Build Coastguard Worker         mShaderStorageBufferObserverBindings[index].bind(object);
6315*8975f5c5SAndroid Build Coastguard Worker         mStateCache.onShaderStorageBufferStateChange(this);
6316*8975f5c5SAndroid Build Coastguard Worker     }
6317*8975f5c5SAndroid Build Coastguard Worker     else
6318*8975f5c5SAndroid Build Coastguard Worker     {
6319*8975f5c5SAndroid Build Coastguard Worker         mStateCache.onBufferBindingChange(this);
6320*8975f5c5SAndroid Build Coastguard Worker     }
6321*8975f5c5SAndroid Build Coastguard Worker 
6322*8975f5c5SAndroid Build Coastguard Worker     if (object)
6323*8975f5c5SAndroid Build Coastguard Worker     {
6324*8975f5c5SAndroid Build Coastguard Worker         object->onBind(this, target);
6325*8975f5c5SAndroid Build Coastguard Worker     }
6326*8975f5c5SAndroid Build Coastguard Worker }
6327*8975f5c5SAndroid Build Coastguard Worker 
bindFramebuffer(GLenum target,FramebufferID framebuffer)6328*8975f5c5SAndroid Build Coastguard Worker void Context::bindFramebuffer(GLenum target, FramebufferID framebuffer)
6329*8975f5c5SAndroid Build Coastguard Worker {
6330*8975f5c5SAndroid Build Coastguard Worker     if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER)
6331*8975f5c5SAndroid Build Coastguard Worker     {
6332*8975f5c5SAndroid Build Coastguard Worker         bindReadFramebuffer(framebuffer);
6333*8975f5c5SAndroid Build Coastguard Worker     }
6334*8975f5c5SAndroid Build Coastguard Worker 
6335*8975f5c5SAndroid Build Coastguard Worker     if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER)
6336*8975f5c5SAndroid Build Coastguard Worker     {
6337*8975f5c5SAndroid Build Coastguard Worker         bindDrawFramebuffer(framebuffer);
6338*8975f5c5SAndroid Build Coastguard Worker     }
6339*8975f5c5SAndroid Build Coastguard Worker }
6340*8975f5c5SAndroid Build Coastguard Worker 
bindRenderbuffer(GLenum target,RenderbufferID renderbuffer)6341*8975f5c5SAndroid Build Coastguard Worker void Context::bindRenderbuffer(GLenum target, RenderbufferID renderbuffer)
6342*8975f5c5SAndroid Build Coastguard Worker {
6343*8975f5c5SAndroid Build Coastguard Worker     ASSERT(target == GL_RENDERBUFFER);
6344*8975f5c5SAndroid Build Coastguard Worker     Renderbuffer *object = mState.mRenderbufferManager->checkRenderbufferAllocation(
6345*8975f5c5SAndroid Build Coastguard Worker         mImplementation.get(), renderbuffer);
6346*8975f5c5SAndroid Build Coastguard Worker     mState.setRenderbufferBinding(this, object);
6347*8975f5c5SAndroid Build Coastguard Worker }
6348*8975f5c5SAndroid Build Coastguard Worker 
texStorage2DMultisample(TextureType target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height,GLboolean fixedsamplelocations)6349*8975f5c5SAndroid Build Coastguard Worker void Context::texStorage2DMultisample(TextureType target,
6350*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei samples,
6351*8975f5c5SAndroid Build Coastguard Worker                                       GLenum internalformat,
6352*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei width,
6353*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei height,
6354*8975f5c5SAndroid Build Coastguard Worker                                       GLboolean fixedsamplelocations)
6355*8975f5c5SAndroid Build Coastguard Worker {
6356*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, 1);
6357*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByType(target);
6358*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size,
6359*8975f5c5SAndroid Build Coastguard Worker                                                      ConvertToBool(fixedsamplelocations)));
6360*8975f5c5SAndroid Build Coastguard Worker }
6361*8975f5c5SAndroid Build Coastguard Worker 
texStorage3DMultisample(TextureType target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLboolean fixedsamplelocations)6362*8975f5c5SAndroid Build Coastguard Worker void Context::texStorage3DMultisample(TextureType target,
6363*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei samples,
6364*8975f5c5SAndroid Build Coastguard Worker                                       GLenum internalformat,
6365*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei width,
6366*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei height,
6367*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei depth,
6368*8975f5c5SAndroid Build Coastguard Worker                                       GLboolean fixedsamplelocations)
6369*8975f5c5SAndroid Build Coastguard Worker {
6370*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, depth);
6371*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByType(target);
6372*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size,
6373*8975f5c5SAndroid Build Coastguard Worker                                                      ConvertToBool(fixedsamplelocations)));
6374*8975f5c5SAndroid Build Coastguard Worker }
6375*8975f5c5SAndroid Build Coastguard Worker 
texImage2DExternal(TextureTarget target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type)6376*8975f5c5SAndroid Build Coastguard Worker void Context::texImage2DExternal(TextureTarget target,
6377*8975f5c5SAndroid Build Coastguard Worker                                  GLint level,
6378*8975f5c5SAndroid Build Coastguard Worker                                  GLint internalformat,
6379*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei width,
6380*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei height,
6381*8975f5c5SAndroid Build Coastguard Worker                                  GLint border,
6382*8975f5c5SAndroid Build Coastguard Worker                                  GLenum format,
6383*8975f5c5SAndroid Build Coastguard Worker                                  GLenum type)
6384*8975f5c5SAndroid Build Coastguard Worker {
6385*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, 1);
6386*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByTarget(target);
6387*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
6388*8975f5c5SAndroid Build Coastguard Worker         texture->setImageExternal(this, target, level, internalformat, size, format, type));
6389*8975f5c5SAndroid Build Coastguard Worker }
6390*8975f5c5SAndroid Build Coastguard Worker 
invalidateTexture(TextureType target)6391*8975f5c5SAndroid Build Coastguard Worker void Context::invalidateTexture(TextureType target)
6392*8975f5c5SAndroid Build Coastguard Worker {
6393*8975f5c5SAndroid Build Coastguard Worker     mImplementation->invalidateTexture(target);
6394*8975f5c5SAndroid Build Coastguard Worker     mState.invalidateTextureBindings(target);
6395*8975f5c5SAndroid Build Coastguard Worker }
6396*8975f5c5SAndroid Build Coastguard Worker 
getMultisamplefv(GLenum pname,GLuint index,GLfloat * val)6397*8975f5c5SAndroid Build Coastguard Worker void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val)
6398*8975f5c5SAndroid Build Coastguard Worker {
6399*8975f5c5SAndroid Build Coastguard Worker     // According to spec 3.1 Table 20.49: Framebuffer Dependent Values,
6400*8975f5c5SAndroid Build Coastguard Worker     // the sample position should be queried by DRAW_FRAMEBUFFER.
6401*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_DRAW_FRAMEBUFFER));
6402*8975f5c5SAndroid Build Coastguard Worker     const Framebuffer *framebuffer = mState.getDrawFramebuffer();
6403*8975f5c5SAndroid Build Coastguard Worker 
6404*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
6405*8975f5c5SAndroid Build Coastguard Worker     {
6406*8975f5c5SAndroid Build Coastguard Worker         case GL_SAMPLE_POSITION:
6407*8975f5c5SAndroid Build Coastguard Worker             ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val));
6408*8975f5c5SAndroid Build Coastguard Worker             break;
6409*8975f5c5SAndroid Build Coastguard Worker         default:
6410*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
6411*8975f5c5SAndroid Build Coastguard Worker     }
6412*8975f5c5SAndroid Build Coastguard Worker }
6413*8975f5c5SAndroid Build Coastguard Worker 
getMultisamplefvRobust(GLenum pname,GLuint index,GLsizei bufSize,GLsizei * length,GLfloat * val)6414*8975f5c5SAndroid Build Coastguard Worker void Context::getMultisamplefvRobust(GLenum pname,
6415*8975f5c5SAndroid Build Coastguard Worker                                      GLuint index,
6416*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei bufSize,
6417*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei *length,
6418*8975f5c5SAndroid Build Coastguard Worker                                      GLfloat *val)
6419*8975f5c5SAndroid Build Coastguard Worker {
6420*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
6421*8975f5c5SAndroid Build Coastguard Worker }
6422*8975f5c5SAndroid Build Coastguard Worker 
renderbufferStorage(GLenum target,GLenum internalformat,GLsizei width,GLsizei height)6423*8975f5c5SAndroid Build Coastguard Worker void Context::renderbufferStorage(GLenum target,
6424*8975f5c5SAndroid Build Coastguard Worker                                   GLenum internalformat,
6425*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei width,
6426*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei height)
6427*8975f5c5SAndroid Build Coastguard Worker {
6428*8975f5c5SAndroid Build Coastguard Worker     // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format.
6429*8975f5c5SAndroid Build Coastguard Worker     GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat);
6430*8975f5c5SAndroid Build Coastguard Worker 
6431*8975f5c5SAndroid Build Coastguard Worker     Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer();
6432*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height));
6433*8975f5c5SAndroid Build Coastguard Worker }
6434*8975f5c5SAndroid Build Coastguard Worker 
renderbufferStorageMultisample(GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height)6435*8975f5c5SAndroid Build Coastguard Worker void Context::renderbufferStorageMultisample(GLenum target,
6436*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei samples,
6437*8975f5c5SAndroid Build Coastguard Worker                                              GLenum internalformat,
6438*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei width,
6439*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei height)
6440*8975f5c5SAndroid Build Coastguard Worker {
6441*8975f5c5SAndroid Build Coastguard Worker     renderbufferStorageMultisampleImpl(target, samples, internalformat, width, height,
6442*8975f5c5SAndroid Build Coastguard Worker                                        MultisamplingMode::Regular);
6443*8975f5c5SAndroid Build Coastguard Worker }
6444*8975f5c5SAndroid Build Coastguard Worker 
renderbufferStorageMultisampleEXT(GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height)6445*8975f5c5SAndroid Build Coastguard Worker void Context::renderbufferStorageMultisampleEXT(GLenum target,
6446*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei samples,
6447*8975f5c5SAndroid Build Coastguard Worker                                                 GLenum internalformat,
6448*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei width,
6449*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei height)
6450*8975f5c5SAndroid Build Coastguard Worker {
6451*8975f5c5SAndroid Build Coastguard Worker     renderbufferStorageMultisampleImpl(target, samples, internalformat, width, height,
6452*8975f5c5SAndroid Build Coastguard Worker                                        MultisamplingMode::MultisampledRenderToTexture);
6453*8975f5c5SAndroid Build Coastguard Worker }
6454*8975f5c5SAndroid Build Coastguard Worker 
renderbufferStorageMultisampleImpl(GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height,MultisamplingMode mode)6455*8975f5c5SAndroid Build Coastguard Worker void Context::renderbufferStorageMultisampleImpl(GLenum target,
6456*8975f5c5SAndroid Build Coastguard Worker                                                  GLsizei samples,
6457*8975f5c5SAndroid Build Coastguard Worker                                                  GLenum internalformat,
6458*8975f5c5SAndroid Build Coastguard Worker                                                  GLsizei width,
6459*8975f5c5SAndroid Build Coastguard Worker                                                  GLsizei height,
6460*8975f5c5SAndroid Build Coastguard Worker                                                  MultisamplingMode mode)
6461*8975f5c5SAndroid Build Coastguard Worker {
6462*8975f5c5SAndroid Build Coastguard Worker     // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format.
6463*8975f5c5SAndroid Build Coastguard Worker     GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat);
6464*8975f5c5SAndroid Build Coastguard Worker 
6465*8975f5c5SAndroid Build Coastguard Worker     Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer();
6466*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat,
6467*8975f5c5SAndroid Build Coastguard Worker                                                           width, height, mode));
6468*8975f5c5SAndroid Build Coastguard Worker }
6469*8975f5c5SAndroid Build Coastguard Worker 
framebufferTexture2DMultisample(GLenum target,GLenum attachment,TextureTarget textarget,TextureID texture,GLint level,GLsizei samples)6470*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferTexture2DMultisample(GLenum target,
6471*8975f5c5SAndroid Build Coastguard Worker                                               GLenum attachment,
6472*8975f5c5SAndroid Build Coastguard Worker                                               TextureTarget textarget,
6473*8975f5c5SAndroid Build Coastguard Worker                                               TextureID texture,
6474*8975f5c5SAndroid Build Coastguard Worker                                               GLint level,
6475*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei samples)
6476*8975f5c5SAndroid Build Coastguard Worker {
6477*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
6478*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
6479*8975f5c5SAndroid Build Coastguard Worker 
6480*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
6481*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
6482*8975f5c5SAndroid Build Coastguard Worker     {
6483*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
6484*8975f5c5SAndroid Build Coastguard Worker     }
6485*8975f5c5SAndroid Build Coastguard Worker 
6486*8975f5c5SAndroid Build Coastguard Worker     if (texture.value != 0)
6487*8975f5c5SAndroid Build Coastguard Worker     {
6488*8975f5c5SAndroid Build Coastguard Worker         Texture *textureObj = getTexture(texture);
6489*8975f5c5SAndroid Build Coastguard Worker         ImageIndex index    = ImageIndex::MakeFromTarget(textarget, level, 1);
6490*8975f5c5SAndroid Build Coastguard Worker         framebuffer->setAttachmentMultisample(this, GL_TEXTURE, attachment, index, textureObj,
6491*8975f5c5SAndroid Build Coastguard Worker                                               samples);
6492*8975f5c5SAndroid Build Coastguard Worker         textureObj->onBindToMSRTTFramebuffer();
6493*8975f5c5SAndroid Build Coastguard Worker     }
6494*8975f5c5SAndroid Build Coastguard Worker     else
6495*8975f5c5SAndroid Build Coastguard Worker     {
6496*8975f5c5SAndroid Build Coastguard Worker         framebuffer->resetAttachment(this, attachment);
6497*8975f5c5SAndroid Build Coastguard Worker     }
6498*8975f5c5SAndroid Build Coastguard Worker 
6499*8975f5c5SAndroid Build Coastguard Worker     mState.setObjectDirty(target);
6500*8975f5c5SAndroid Build Coastguard Worker }
6501*8975f5c5SAndroid Build Coastguard Worker 
getSynciv(SyncID syncPacked,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * values)6502*8975f5c5SAndroid Build Coastguard Worker void Context::getSynciv(SyncID syncPacked,
6503*8975f5c5SAndroid Build Coastguard Worker                         GLenum pname,
6504*8975f5c5SAndroid Build Coastguard Worker                         GLsizei bufSize,
6505*8975f5c5SAndroid Build Coastguard Worker                         GLsizei *length,
6506*8975f5c5SAndroid Build Coastguard Worker                         GLint *values)
6507*8975f5c5SAndroid Build Coastguard Worker {
6508*8975f5c5SAndroid Build Coastguard Worker     const Sync *syncObject = nullptr;
6509*8975f5c5SAndroid Build Coastguard Worker     if (!isContextLost())
6510*8975f5c5SAndroid Build Coastguard Worker     {
6511*8975f5c5SAndroid Build Coastguard Worker         syncObject = getSync(syncPacked);
6512*8975f5c5SAndroid Build Coastguard Worker     }
6513*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values));
6514*8975f5c5SAndroid Build Coastguard Worker }
6515*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferParameteriv(GLenum target,GLenum pname,GLint * params)6516*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
6517*8975f5c5SAndroid Build Coastguard Worker {
6518*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
6519*8975f5c5SAndroid Build Coastguard Worker     QueryFramebufferParameteriv(framebuffer, pname, params);
6520*8975f5c5SAndroid Build Coastguard Worker }
6521*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferParameterivRobust(GLenum target,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)6522*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferParameterivRobust(GLenum target,
6523*8975f5c5SAndroid Build Coastguard Worker                                               GLenum pname,
6524*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei bufSize,
6525*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei *length,
6526*8975f5c5SAndroid Build Coastguard Worker                                               GLint *params)
6527*8975f5c5SAndroid Build Coastguard Worker {
6528*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
6529*8975f5c5SAndroid Build Coastguard Worker }
6530*8975f5c5SAndroid Build Coastguard Worker 
framebufferParameteri(GLenum target,GLenum pname,GLint param)6531*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferParameteri(GLenum target, GLenum pname, GLint param)
6532*8975f5c5SAndroid Build Coastguard Worker {
6533*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
6534*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0 &&
6535*8975f5c5SAndroid Build Coastguard Worker         framebuffer == mState.getDrawFramebuffer())
6536*8975f5c5SAndroid Build Coastguard Worker     {
6537*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
6538*8975f5c5SAndroid Build Coastguard Worker     }
6539*8975f5c5SAndroid Build Coastguard Worker     SetFramebufferParameteri(this, framebuffer, pname, param);
6540*8975f5c5SAndroid Build Coastguard Worker }
6541*8975f5c5SAndroid Build Coastguard Worker 
getScratchBuffer(size_t requstedSizeBytes,angle::MemoryBuffer ** scratchBufferOut) const6542*8975f5c5SAndroid Build Coastguard Worker bool Context::getScratchBuffer(size_t requstedSizeBytes,
6543*8975f5c5SAndroid Build Coastguard Worker                                angle::MemoryBuffer **scratchBufferOut) const
6544*8975f5c5SAndroid Build Coastguard Worker {
6545*8975f5c5SAndroid Build Coastguard Worker     if (!mScratchBuffer.valid())
6546*8975f5c5SAndroid Build Coastguard Worker     {
6547*8975f5c5SAndroid Build Coastguard Worker         mScratchBuffer = mDisplay->requestScratchBuffer();
6548*8975f5c5SAndroid Build Coastguard Worker     }
6549*8975f5c5SAndroid Build Coastguard Worker 
6550*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mScratchBuffer.valid());
6551*8975f5c5SAndroid Build Coastguard Worker     return mScratchBuffer.value().get(requstedSizeBytes, scratchBufferOut);
6552*8975f5c5SAndroid Build Coastguard Worker }
6553*8975f5c5SAndroid Build Coastguard Worker 
getScratchBuffer() const6554*8975f5c5SAndroid Build Coastguard Worker angle::ScratchBuffer *Context::getScratchBuffer() const
6555*8975f5c5SAndroid Build Coastguard Worker {
6556*8975f5c5SAndroid Build Coastguard Worker     if (!mScratchBuffer.valid())
6557*8975f5c5SAndroid Build Coastguard Worker     {
6558*8975f5c5SAndroid Build Coastguard Worker         mScratchBuffer = mDisplay->requestScratchBuffer();
6559*8975f5c5SAndroid Build Coastguard Worker     }
6560*8975f5c5SAndroid Build Coastguard Worker 
6561*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mScratchBuffer.valid());
6562*8975f5c5SAndroid Build Coastguard Worker     return &mScratchBuffer.value();
6563*8975f5c5SAndroid Build Coastguard Worker }
6564*8975f5c5SAndroid Build Coastguard Worker 
getZeroFilledBuffer(size_t requstedSizeBytes,angle::MemoryBuffer ** zeroBufferOut) const6565*8975f5c5SAndroid Build Coastguard Worker bool Context::getZeroFilledBuffer(size_t requstedSizeBytes,
6566*8975f5c5SAndroid Build Coastguard Worker                                   angle::MemoryBuffer **zeroBufferOut) const
6567*8975f5c5SAndroid Build Coastguard Worker {
6568*8975f5c5SAndroid Build Coastguard Worker     if (!mZeroFilledBuffer.valid())
6569*8975f5c5SAndroid Build Coastguard Worker     {
6570*8975f5c5SAndroid Build Coastguard Worker         mZeroFilledBuffer = mDisplay->requestZeroFilledBuffer();
6571*8975f5c5SAndroid Build Coastguard Worker     }
6572*8975f5c5SAndroid Build Coastguard Worker 
6573*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mZeroFilledBuffer.valid());
6574*8975f5c5SAndroid Build Coastguard Worker     return mZeroFilledBuffer.value().getInitialized(requstedSizeBytes, zeroBufferOut, 0);
6575*8975f5c5SAndroid Build Coastguard Worker }
6576*8975f5c5SAndroid Build Coastguard Worker 
dispatchCompute(GLuint numGroupsX,GLuint numGroupsY,GLuint numGroupsZ)6577*8975f5c5SAndroid Build Coastguard Worker void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ)
6578*8975f5c5SAndroid Build Coastguard Worker {
6579*8975f5c5SAndroid Build Coastguard Worker     if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u)
6580*8975f5c5SAndroid Build Coastguard Worker     {
6581*8975f5c5SAndroid Build Coastguard Worker         return;
6582*8975f5c5SAndroid Build Coastguard Worker     }
6583*8975f5c5SAndroid Build Coastguard Worker 
6584*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDispatch());
6585*8975f5c5SAndroid Build Coastguard Worker 
6586*8975f5c5SAndroid Build Coastguard Worker     angle::Result result =
6587*8975f5c5SAndroid Build Coastguard Worker         mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ);
6588*8975f5c5SAndroid Build Coastguard Worker 
6589*8975f5c5SAndroid Build Coastguard Worker     // This must be called before convertPpoToComputeOrDraw() so it uses the PPO's compute values
6590*8975f5c5SAndroid Build Coastguard Worker     // before convertPpoToComputeOrDraw() reverts the PPO back to graphics.
6591*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
6592*8975f5c5SAndroid Build Coastguard Worker 
6593*8975f5c5SAndroid Build Coastguard Worker     if (ANGLE_UNLIKELY(IsError(result)))
6594*8975f5c5SAndroid Build Coastguard Worker     {
6595*8975f5c5SAndroid Build Coastguard Worker         return;
6596*8975f5c5SAndroid Build Coastguard Worker     }
6597*8975f5c5SAndroid Build Coastguard Worker }
6598*8975f5c5SAndroid Build Coastguard Worker 
dispatchComputeIndirect(GLintptr indirect)6599*8975f5c5SAndroid Build Coastguard Worker void Context::dispatchComputeIndirect(GLintptr indirect)
6600*8975f5c5SAndroid Build Coastguard Worker {
6601*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDispatch());
6602*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->dispatchComputeIndirect(this, indirect));
6603*8975f5c5SAndroid Build Coastguard Worker 
6604*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
6605*8975f5c5SAndroid Build Coastguard Worker }
6606*8975f5c5SAndroid Build Coastguard Worker 
texStorage2D(TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height)6607*8975f5c5SAndroid Build Coastguard Worker void Context::texStorage2D(TextureType target,
6608*8975f5c5SAndroid Build Coastguard Worker                            GLsizei levels,
6609*8975f5c5SAndroid Build Coastguard Worker                            GLenum internalFormat,
6610*8975f5c5SAndroid Build Coastguard Worker                            GLsizei width,
6611*8975f5c5SAndroid Build Coastguard Worker                            GLsizei height)
6612*8975f5c5SAndroid Build Coastguard Worker {
6613*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, 1);
6614*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByType(target);
6615*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size));
6616*8975f5c5SAndroid Build Coastguard Worker }
6617*8975f5c5SAndroid Build Coastguard Worker 
texStorage3D(TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth)6618*8975f5c5SAndroid Build Coastguard Worker void Context::texStorage3D(TextureType target,
6619*8975f5c5SAndroid Build Coastguard Worker                            GLsizei levels,
6620*8975f5c5SAndroid Build Coastguard Worker                            GLenum internalFormat,
6621*8975f5c5SAndroid Build Coastguard Worker                            GLsizei width,
6622*8975f5c5SAndroid Build Coastguard Worker                            GLsizei height,
6623*8975f5c5SAndroid Build Coastguard Worker                            GLsizei depth)
6624*8975f5c5SAndroid Build Coastguard Worker {
6625*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, depth);
6626*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByType(target);
6627*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size));
6628*8975f5c5SAndroid Build Coastguard Worker }
6629*8975f5c5SAndroid Build Coastguard Worker 
memoryBarrier(GLbitfield barriers)6630*8975f5c5SAndroid Build Coastguard Worker void Context::memoryBarrier(GLbitfield barriers)
6631*8975f5c5SAndroid Build Coastguard Worker {
6632*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers));
6633*8975f5c5SAndroid Build Coastguard Worker }
6634*8975f5c5SAndroid Build Coastguard Worker 
memoryBarrierByRegion(GLbitfield barriers)6635*8975f5c5SAndroid Build Coastguard Worker void Context::memoryBarrierByRegion(GLbitfield barriers)
6636*8975f5c5SAndroid Build Coastguard Worker {
6637*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers));
6638*8975f5c5SAndroid Build Coastguard Worker }
6639*8975f5c5SAndroid Build Coastguard Worker 
multiDrawArrays(PrimitiveMode mode,const GLint * firsts,const GLsizei * counts,GLsizei drawcount)6640*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawArrays(PrimitiveMode mode,
6641*8975f5c5SAndroid Build Coastguard Worker                               const GLint *firsts,
6642*8975f5c5SAndroid Build Coastguard Worker                               const GLsizei *counts,
6643*8975f5c5SAndroid Build Coastguard Worker                               GLsizei drawcount)
6644*8975f5c5SAndroid Build Coastguard Worker {
6645*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6646*8975f5c5SAndroid Build Coastguard Worker     {
6647*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6648*8975f5c5SAndroid Build Coastguard Worker         return;
6649*8975f5c5SAndroid Build Coastguard Worker     }
6650*8975f5c5SAndroid Build Coastguard Worker 
6651*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6652*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->multiDrawArrays(this, mode, firsts, counts, drawcount));
6653*8975f5c5SAndroid Build Coastguard Worker }
6654*8975f5c5SAndroid Build Coastguard Worker 
multiDrawArraysInstanced(PrimitiveMode mode,const GLint * firsts,const GLsizei * counts,const GLsizei * instanceCounts,GLsizei drawcount)6655*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawArraysInstanced(PrimitiveMode mode,
6656*8975f5c5SAndroid Build Coastguard Worker                                        const GLint *firsts,
6657*8975f5c5SAndroid Build Coastguard Worker                                        const GLsizei *counts,
6658*8975f5c5SAndroid Build Coastguard Worker                                        const GLsizei *instanceCounts,
6659*8975f5c5SAndroid Build Coastguard Worker                                        GLsizei drawcount)
6660*8975f5c5SAndroid Build Coastguard Worker {
6661*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6662*8975f5c5SAndroid Build Coastguard Worker     {
6663*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6664*8975f5c5SAndroid Build Coastguard Worker         return;
6665*8975f5c5SAndroid Build Coastguard Worker     }
6666*8975f5c5SAndroid Build Coastguard Worker 
6667*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6668*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->multiDrawArraysInstanced(this, mode, firsts, counts,
6669*8975f5c5SAndroid Build Coastguard Worker                                                                 instanceCounts, drawcount));
6670*8975f5c5SAndroid Build Coastguard Worker }
6671*8975f5c5SAndroid Build Coastguard Worker 
multiDrawArraysIndirect(PrimitiveMode mode,const void * indirect,GLsizei drawcount,GLsizei stride)6672*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawArraysIndirect(PrimitiveMode mode,
6673*8975f5c5SAndroid Build Coastguard Worker                                       const void *indirect,
6674*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei drawcount,
6675*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei stride)
6676*8975f5c5SAndroid Build Coastguard Worker {
6677*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6678*8975f5c5SAndroid Build Coastguard Worker     {
6679*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6680*8975f5c5SAndroid Build Coastguard Worker         return;
6681*8975f5c5SAndroid Build Coastguard Worker     }
6682*8975f5c5SAndroid Build Coastguard Worker 
6683*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6684*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
6685*8975f5c5SAndroid Build Coastguard Worker         mImplementation->multiDrawArraysIndirect(this, mode, indirect, drawcount, stride));
6686*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
6687*8975f5c5SAndroid Build Coastguard Worker }
6688*8975f5c5SAndroid Build Coastguard Worker 
multiDrawElements(PrimitiveMode mode,const GLsizei * counts,DrawElementsType type,const GLvoid * const * indices,GLsizei drawcount)6689*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawElements(PrimitiveMode mode,
6690*8975f5c5SAndroid Build Coastguard Worker                                 const GLsizei *counts,
6691*8975f5c5SAndroid Build Coastguard Worker                                 DrawElementsType type,
6692*8975f5c5SAndroid Build Coastguard Worker                                 const GLvoid *const *indices,
6693*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei drawcount)
6694*8975f5c5SAndroid Build Coastguard Worker {
6695*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6696*8975f5c5SAndroid Build Coastguard Worker     {
6697*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6698*8975f5c5SAndroid Build Coastguard Worker         return;
6699*8975f5c5SAndroid Build Coastguard Worker     }
6700*8975f5c5SAndroid Build Coastguard Worker 
6701*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6702*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
6703*8975f5c5SAndroid Build Coastguard Worker         mImplementation->multiDrawElements(this, mode, counts, type, indices, drawcount));
6704*8975f5c5SAndroid Build Coastguard Worker }
6705*8975f5c5SAndroid Build Coastguard Worker 
multiDrawElementsInstanced(PrimitiveMode mode,const GLsizei * counts,DrawElementsType type,const GLvoid * const * indices,const GLsizei * instanceCounts,GLsizei drawcount)6706*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawElementsInstanced(PrimitiveMode mode,
6707*8975f5c5SAndroid Build Coastguard Worker                                          const GLsizei *counts,
6708*8975f5c5SAndroid Build Coastguard Worker                                          DrawElementsType type,
6709*8975f5c5SAndroid Build Coastguard Worker                                          const GLvoid *const *indices,
6710*8975f5c5SAndroid Build Coastguard Worker                                          const GLsizei *instanceCounts,
6711*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei drawcount)
6712*8975f5c5SAndroid Build Coastguard Worker {
6713*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6714*8975f5c5SAndroid Build Coastguard Worker     {
6715*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6716*8975f5c5SAndroid Build Coastguard Worker         return;
6717*8975f5c5SAndroid Build Coastguard Worker     }
6718*8975f5c5SAndroid Build Coastguard Worker 
6719*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6720*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->multiDrawElementsInstanced(this, mode, counts, type, indices,
6721*8975f5c5SAndroid Build Coastguard Worker                                                                   instanceCounts, drawcount));
6722*8975f5c5SAndroid Build Coastguard Worker }
6723*8975f5c5SAndroid Build Coastguard Worker 
multiDrawElementsIndirect(PrimitiveMode mode,DrawElementsType type,const void * indirect,GLsizei drawcount,GLsizei stride)6724*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawElementsIndirect(PrimitiveMode mode,
6725*8975f5c5SAndroid Build Coastguard Worker                                         DrawElementsType type,
6726*8975f5c5SAndroid Build Coastguard Worker                                         const void *indirect,
6727*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei drawcount,
6728*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei stride)
6729*8975f5c5SAndroid Build Coastguard Worker {
6730*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6731*8975f5c5SAndroid Build Coastguard Worker     {
6732*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6733*8975f5c5SAndroid Build Coastguard Worker         return;
6734*8975f5c5SAndroid Build Coastguard Worker     }
6735*8975f5c5SAndroid Build Coastguard Worker 
6736*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6737*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
6738*8975f5c5SAndroid Build Coastguard Worker         mImplementation->multiDrawElementsIndirect(this, mode, type, indirect, drawcount, stride));
6739*8975f5c5SAndroid Build Coastguard Worker     MarkShaderStorageUsage(this);
6740*8975f5c5SAndroid Build Coastguard Worker }
6741*8975f5c5SAndroid Build Coastguard Worker 
drawArraysInstancedBaseInstance(PrimitiveMode mode,GLint first,GLsizei count,GLsizei instanceCount,GLuint baseInstance)6742*8975f5c5SAndroid Build Coastguard Worker void Context::drawArraysInstancedBaseInstance(PrimitiveMode mode,
6743*8975f5c5SAndroid Build Coastguard Worker                                               GLint first,
6744*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei count,
6745*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei instanceCount,
6746*8975f5c5SAndroid Build Coastguard Worker                                               GLuint baseInstance)
6747*8975f5c5SAndroid Build Coastguard Worker {
6748*8975f5c5SAndroid Build Coastguard Worker     if (noopDrawInstanced(mode, count, instanceCount))
6749*8975f5c5SAndroid Build Coastguard Worker     {
6750*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6751*8975f5c5SAndroid Build Coastguard Worker         return;
6752*8975f5c5SAndroid Build Coastguard Worker     }
6753*8975f5c5SAndroid Build Coastguard Worker 
6754*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6755*8975f5c5SAndroid Build Coastguard Worker     ProgramExecutable *executable = mState.getLinkedProgramExecutable(this);
6756*8975f5c5SAndroid Build Coastguard Worker 
6757*8975f5c5SAndroid Build Coastguard Worker     const bool hasBaseInstance = executable->hasBaseInstanceUniform();
6758*8975f5c5SAndroid Build Coastguard Worker     if (hasBaseInstance)
6759*8975f5c5SAndroid Build Coastguard Worker     {
6760*8975f5c5SAndroid Build Coastguard Worker         executable->setBaseInstanceUniform(baseInstance);
6761*8975f5c5SAndroid Build Coastguard Worker     }
6762*8975f5c5SAndroid Build Coastguard Worker 
6763*8975f5c5SAndroid Build Coastguard Worker     rx::ResetBaseVertexBaseInstance resetUniforms(executable, false, hasBaseInstance);
6764*8975f5c5SAndroid Build Coastguard Worker 
6765*8975f5c5SAndroid Build Coastguard Worker     // The input gl_InstanceID does not follow the baseinstance. gl_InstanceID always falls on
6766*8975f5c5SAndroid Build Coastguard Worker     // the half-open range [0, instancecount). No need to set other stuff. Except for Vulkan.
6767*8975f5c5SAndroid Build Coastguard Worker 
6768*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstancedBaseInstance(
6769*8975f5c5SAndroid Build Coastguard Worker         this, mode, first, count, instanceCount, baseInstance));
6770*8975f5c5SAndroid Build Coastguard Worker     MarkTransformFeedbackBufferUsage(this, count, 1);
6771*8975f5c5SAndroid Build Coastguard Worker }
6772*8975f5c5SAndroid Build Coastguard Worker 
drawArraysInstancedBaseInstanceANGLE(PrimitiveMode mode,GLint first,GLsizei count,GLsizei instanceCount,GLuint baseInstance)6773*8975f5c5SAndroid Build Coastguard Worker void Context::drawArraysInstancedBaseInstanceANGLE(PrimitiveMode mode,
6774*8975f5c5SAndroid Build Coastguard Worker                                                    GLint first,
6775*8975f5c5SAndroid Build Coastguard Worker                                                    GLsizei count,
6776*8975f5c5SAndroid Build Coastguard Worker                                                    GLsizei instanceCount,
6777*8975f5c5SAndroid Build Coastguard Worker                                                    GLuint baseInstance)
6778*8975f5c5SAndroid Build Coastguard Worker {
6779*8975f5c5SAndroid Build Coastguard Worker     drawArraysInstancedBaseInstance(mode, first, count, instanceCount, baseInstance);
6780*8975f5c5SAndroid Build Coastguard Worker }
6781*8975f5c5SAndroid Build Coastguard Worker 
drawElementsInstancedBaseInstance(PrimitiveMode mode,GLsizei count,DrawElementsType type,const void * indices,GLsizei instanceCount,GLuint baseInstance)6782*8975f5c5SAndroid Build Coastguard Worker void Context::drawElementsInstancedBaseInstance(PrimitiveMode mode,
6783*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei count,
6784*8975f5c5SAndroid Build Coastguard Worker                                                 DrawElementsType type,
6785*8975f5c5SAndroid Build Coastguard Worker                                                 const void *indices,
6786*8975f5c5SAndroid Build Coastguard Worker                                                 GLsizei instanceCount,
6787*8975f5c5SAndroid Build Coastguard Worker                                                 GLuint baseInstance)
6788*8975f5c5SAndroid Build Coastguard Worker {
6789*8975f5c5SAndroid Build Coastguard Worker     drawElementsInstancedBaseVertexBaseInstance(mode, count, type, indices, instanceCount, 0,
6790*8975f5c5SAndroid Build Coastguard Worker                                                 baseInstance);
6791*8975f5c5SAndroid Build Coastguard Worker }
6792*8975f5c5SAndroid Build Coastguard Worker 
drawElementsInstancedBaseVertexBaseInstance(PrimitiveMode mode,GLsizei count,DrawElementsType type,const GLvoid * indices,GLsizei instanceCount,GLint baseVertex,GLuint baseInstance)6793*8975f5c5SAndroid Build Coastguard Worker void Context::drawElementsInstancedBaseVertexBaseInstance(PrimitiveMode mode,
6794*8975f5c5SAndroid Build Coastguard Worker                                                           GLsizei count,
6795*8975f5c5SAndroid Build Coastguard Worker                                                           DrawElementsType type,
6796*8975f5c5SAndroid Build Coastguard Worker                                                           const GLvoid *indices,
6797*8975f5c5SAndroid Build Coastguard Worker                                                           GLsizei instanceCount,
6798*8975f5c5SAndroid Build Coastguard Worker                                                           GLint baseVertex,
6799*8975f5c5SAndroid Build Coastguard Worker                                                           GLuint baseInstance)
6800*8975f5c5SAndroid Build Coastguard Worker {
6801*8975f5c5SAndroid Build Coastguard Worker     if (noopDrawInstanced(mode, count, instanceCount))
6802*8975f5c5SAndroid Build Coastguard Worker     {
6803*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6804*8975f5c5SAndroid Build Coastguard Worker         return;
6805*8975f5c5SAndroid Build Coastguard Worker     }
6806*8975f5c5SAndroid Build Coastguard Worker 
6807*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6808*8975f5c5SAndroid Build Coastguard Worker     ProgramExecutable *executable = mState.getLinkedProgramExecutable(this);
6809*8975f5c5SAndroid Build Coastguard Worker 
6810*8975f5c5SAndroid Build Coastguard Worker     const bool hasBaseVertex   = executable->hasBaseVertexUniform();
6811*8975f5c5SAndroid Build Coastguard Worker     const bool hasBaseInstance = executable->hasBaseInstanceUniform();
6812*8975f5c5SAndroid Build Coastguard Worker 
6813*8975f5c5SAndroid Build Coastguard Worker     if (hasBaseVertex)
6814*8975f5c5SAndroid Build Coastguard Worker     {
6815*8975f5c5SAndroid Build Coastguard Worker         executable->setBaseVertexUniform(baseVertex);
6816*8975f5c5SAndroid Build Coastguard Worker     }
6817*8975f5c5SAndroid Build Coastguard Worker 
6818*8975f5c5SAndroid Build Coastguard Worker     if (hasBaseInstance)
6819*8975f5c5SAndroid Build Coastguard Worker     {
6820*8975f5c5SAndroid Build Coastguard Worker         executable->setBaseInstanceUniform(baseInstance);
6821*8975f5c5SAndroid Build Coastguard Worker     }
6822*8975f5c5SAndroid Build Coastguard Worker 
6823*8975f5c5SAndroid Build Coastguard Worker     rx::ResetBaseVertexBaseInstance resetUniforms(executable, hasBaseVertex, hasBaseInstance);
6824*8975f5c5SAndroid Build Coastguard Worker 
6825*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstancedBaseVertexBaseInstance(
6826*8975f5c5SAndroid Build Coastguard Worker         this, mode, count, type, indices, instanceCount, baseVertex, baseInstance));
6827*8975f5c5SAndroid Build Coastguard Worker }
6828*8975f5c5SAndroid Build Coastguard Worker 
drawElementsInstancedBaseVertexBaseInstanceANGLE(PrimitiveMode mode,GLsizei count,DrawElementsType type,const GLvoid * indices,GLsizei instanceCount,GLint baseVertex,GLuint baseInstance)6829*8975f5c5SAndroid Build Coastguard Worker void Context::drawElementsInstancedBaseVertexBaseInstanceANGLE(PrimitiveMode mode,
6830*8975f5c5SAndroid Build Coastguard Worker                                                                GLsizei count,
6831*8975f5c5SAndroid Build Coastguard Worker                                                                DrawElementsType type,
6832*8975f5c5SAndroid Build Coastguard Worker                                                                const GLvoid *indices,
6833*8975f5c5SAndroid Build Coastguard Worker                                                                GLsizei instanceCount,
6834*8975f5c5SAndroid Build Coastguard Worker                                                                GLint baseVertex,
6835*8975f5c5SAndroid Build Coastguard Worker                                                                GLuint baseInstance)
6836*8975f5c5SAndroid Build Coastguard Worker {
6837*8975f5c5SAndroid Build Coastguard Worker     drawElementsInstancedBaseVertexBaseInstance(mode, count, type, indices, instanceCount,
6838*8975f5c5SAndroid Build Coastguard Worker                                                 baseVertex, baseInstance);
6839*8975f5c5SAndroid Build Coastguard Worker }
6840*8975f5c5SAndroid Build Coastguard Worker 
multiDrawArraysInstancedBaseInstance(PrimitiveMode mode,const GLint * firsts,const GLsizei * counts,const GLsizei * instanceCounts,const GLuint * baseInstances,GLsizei drawcount)6841*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawArraysInstancedBaseInstance(PrimitiveMode mode,
6842*8975f5c5SAndroid Build Coastguard Worker                                                    const GLint *firsts,
6843*8975f5c5SAndroid Build Coastguard Worker                                                    const GLsizei *counts,
6844*8975f5c5SAndroid Build Coastguard Worker                                                    const GLsizei *instanceCounts,
6845*8975f5c5SAndroid Build Coastguard Worker                                                    const GLuint *baseInstances,
6846*8975f5c5SAndroid Build Coastguard Worker                                                    GLsizei drawcount)
6847*8975f5c5SAndroid Build Coastguard Worker {
6848*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6849*8975f5c5SAndroid Build Coastguard Worker     {
6850*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6851*8975f5c5SAndroid Build Coastguard Worker         return;
6852*8975f5c5SAndroid Build Coastguard Worker     }
6853*8975f5c5SAndroid Build Coastguard Worker 
6854*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6855*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->multiDrawArraysInstancedBaseInstance(
6856*8975f5c5SAndroid Build Coastguard Worker         this, mode, firsts, counts, instanceCounts, baseInstances, drawcount));
6857*8975f5c5SAndroid Build Coastguard Worker }
6858*8975f5c5SAndroid Build Coastguard Worker 
multiDrawElementsBaseVertex(PrimitiveMode mode,const GLsizei * count,DrawElementsType type,const void * const * indices,GLsizei drawcount,const GLint * basevertex)6859*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawElementsBaseVertex(PrimitiveMode mode,
6860*8975f5c5SAndroid Build Coastguard Worker                                           const GLsizei *count,
6861*8975f5c5SAndroid Build Coastguard Worker                                           DrawElementsType type,
6862*8975f5c5SAndroid Build Coastguard Worker                                           const void *const *indices,
6863*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei drawcount,
6864*8975f5c5SAndroid Build Coastguard Worker                                           const GLint *basevertex)
6865*8975f5c5SAndroid Build Coastguard Worker {
6866*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
6867*8975f5c5SAndroid Build Coastguard Worker }
6868*8975f5c5SAndroid Build Coastguard Worker 
multiDrawElementsInstancedBaseVertexBaseInstance(PrimitiveMode mode,const GLsizei * counts,DrawElementsType type,const GLvoid * const * indices,const GLsizei * instanceCounts,const GLint * baseVertices,const GLuint * baseInstances,GLsizei drawcount)6869*8975f5c5SAndroid Build Coastguard Worker void Context::multiDrawElementsInstancedBaseVertexBaseInstance(PrimitiveMode mode,
6870*8975f5c5SAndroid Build Coastguard Worker                                                                const GLsizei *counts,
6871*8975f5c5SAndroid Build Coastguard Worker                                                                DrawElementsType type,
6872*8975f5c5SAndroid Build Coastguard Worker                                                                const GLvoid *const *indices,
6873*8975f5c5SAndroid Build Coastguard Worker                                                                const GLsizei *instanceCounts,
6874*8975f5c5SAndroid Build Coastguard Worker                                                                const GLint *baseVertices,
6875*8975f5c5SAndroid Build Coastguard Worker                                                                const GLuint *baseInstances,
6876*8975f5c5SAndroid Build Coastguard Worker                                                                GLsizei drawcount)
6877*8975f5c5SAndroid Build Coastguard Worker {
6878*8975f5c5SAndroid Build Coastguard Worker     if (noopMultiDraw(drawcount))
6879*8975f5c5SAndroid Build Coastguard Worker     {
6880*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(mImplementation->handleNoopDrawEvent());
6881*8975f5c5SAndroid Build Coastguard Worker         return;
6882*8975f5c5SAndroid Build Coastguard Worker     }
6883*8975f5c5SAndroid Build Coastguard Worker 
6884*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(prepareForDraw(mode));
6885*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->multiDrawElementsInstancedBaseVertexBaseInstance(
6886*8975f5c5SAndroid Build Coastguard Worker         this, mode, counts, type, indices, instanceCounts, baseVertices, baseInstances, drawcount));
6887*8975f5c5SAndroid Build Coastguard Worker }
6888*8975f5c5SAndroid Build Coastguard Worker 
checkFramebufferStatus(GLenum target)6889*8975f5c5SAndroid Build Coastguard Worker GLenum Context::checkFramebufferStatus(GLenum target)
6890*8975f5c5SAndroid Build Coastguard Worker {
6891*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
6892*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
6893*8975f5c5SAndroid Build Coastguard Worker     return framebuffer->checkStatus(this).status;
6894*8975f5c5SAndroid Build Coastguard Worker }
6895*8975f5c5SAndroid Build Coastguard Worker 
compileShader(ShaderProgramID shader)6896*8975f5c5SAndroid Build Coastguard Worker void Context::compileShader(ShaderProgramID shader)
6897*8975f5c5SAndroid Build Coastguard Worker {
6898*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = GetValidShader(this, angle::EntryPoint::GLCompileShader, shader);
6899*8975f5c5SAndroid Build Coastguard Worker     if (!shaderObject)
6900*8975f5c5SAndroid Build Coastguard Worker     {
6901*8975f5c5SAndroid Build Coastguard Worker         return;
6902*8975f5c5SAndroid Build Coastguard Worker     }
6903*8975f5c5SAndroid Build Coastguard Worker     shaderObject->compile(this, angle::JobResultExpectancy::Future);
6904*8975f5c5SAndroid Build Coastguard Worker }
6905*8975f5c5SAndroid Build Coastguard Worker 
deleteBuffers(GLsizei n,const BufferID * buffers)6906*8975f5c5SAndroid Build Coastguard Worker void Context::deleteBuffers(GLsizei n, const BufferID *buffers)
6907*8975f5c5SAndroid Build Coastguard Worker {
6908*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6909*8975f5c5SAndroid Build Coastguard Worker     {
6910*8975f5c5SAndroid Build Coastguard Worker         deleteBuffer(buffers[i]);
6911*8975f5c5SAndroid Build Coastguard Worker     }
6912*8975f5c5SAndroid Build Coastguard Worker }
6913*8975f5c5SAndroid Build Coastguard Worker 
deleteFramebuffers(GLsizei n,const FramebufferID * framebuffers)6914*8975f5c5SAndroid Build Coastguard Worker void Context::deleteFramebuffers(GLsizei n, const FramebufferID *framebuffers)
6915*8975f5c5SAndroid Build Coastguard Worker {
6916*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6917*8975f5c5SAndroid Build Coastguard Worker     {
6918*8975f5c5SAndroid Build Coastguard Worker         if (framebuffers[i].value != 0)
6919*8975f5c5SAndroid Build Coastguard Worker         {
6920*8975f5c5SAndroid Build Coastguard Worker             deleteFramebuffer(framebuffers[i]);
6921*8975f5c5SAndroid Build Coastguard Worker         }
6922*8975f5c5SAndroid Build Coastguard Worker     }
6923*8975f5c5SAndroid Build Coastguard Worker }
6924*8975f5c5SAndroid Build Coastguard Worker 
deleteRenderbuffers(GLsizei n,const RenderbufferID * renderbuffers)6925*8975f5c5SAndroid Build Coastguard Worker void Context::deleteRenderbuffers(GLsizei n, const RenderbufferID *renderbuffers)
6926*8975f5c5SAndroid Build Coastguard Worker {
6927*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6928*8975f5c5SAndroid Build Coastguard Worker     {
6929*8975f5c5SAndroid Build Coastguard Worker         deleteRenderbuffer(renderbuffers[i]);
6930*8975f5c5SAndroid Build Coastguard Worker     }
6931*8975f5c5SAndroid Build Coastguard Worker }
6932*8975f5c5SAndroid Build Coastguard Worker 
deleteTextures(GLsizei n,const TextureID * textures)6933*8975f5c5SAndroid Build Coastguard Worker void Context::deleteTextures(GLsizei n, const TextureID *textures)
6934*8975f5c5SAndroid Build Coastguard Worker {
6935*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6936*8975f5c5SAndroid Build Coastguard Worker     {
6937*8975f5c5SAndroid Build Coastguard Worker         if (textures[i].value != 0)
6938*8975f5c5SAndroid Build Coastguard Worker         {
6939*8975f5c5SAndroid Build Coastguard Worker             deleteTexture(textures[i]);
6940*8975f5c5SAndroid Build Coastguard Worker         }
6941*8975f5c5SAndroid Build Coastguard Worker     }
6942*8975f5c5SAndroid Build Coastguard Worker }
6943*8975f5c5SAndroid Build Coastguard Worker 
detachShader(ShaderProgramID program,ShaderProgramID shader)6944*8975f5c5SAndroid Build Coastguard Worker void Context::detachShader(ShaderProgramID program, ShaderProgramID shader)
6945*8975f5c5SAndroid Build Coastguard Worker {
6946*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramNoResolveLink(program);
6947*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
6948*8975f5c5SAndroid Build Coastguard Worker 
6949*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = getShaderNoResolveCompile(shader);
6950*8975f5c5SAndroid Build Coastguard Worker     ASSERT(shaderObject);
6951*8975f5c5SAndroid Build Coastguard Worker 
6952*8975f5c5SAndroid Build Coastguard Worker     programObject->detachShader(this, shaderObject);
6953*8975f5c5SAndroid Build Coastguard Worker }
6954*8975f5c5SAndroid Build Coastguard Worker 
genBuffers(GLsizei n,BufferID * buffers)6955*8975f5c5SAndroid Build Coastguard Worker void Context::genBuffers(GLsizei n, BufferID *buffers)
6956*8975f5c5SAndroid Build Coastguard Worker {
6957*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6958*8975f5c5SAndroid Build Coastguard Worker     {
6959*8975f5c5SAndroid Build Coastguard Worker         buffers[i] = createBuffer();
6960*8975f5c5SAndroid Build Coastguard Worker     }
6961*8975f5c5SAndroid Build Coastguard Worker }
6962*8975f5c5SAndroid Build Coastguard Worker 
genFramebuffers(GLsizei n,FramebufferID * framebuffers)6963*8975f5c5SAndroid Build Coastguard Worker void Context::genFramebuffers(GLsizei n, FramebufferID *framebuffers)
6964*8975f5c5SAndroid Build Coastguard Worker {
6965*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6966*8975f5c5SAndroid Build Coastguard Worker     {
6967*8975f5c5SAndroid Build Coastguard Worker         framebuffers[i] = createFramebuffer();
6968*8975f5c5SAndroid Build Coastguard Worker     }
6969*8975f5c5SAndroid Build Coastguard Worker }
6970*8975f5c5SAndroid Build Coastguard Worker 
genRenderbuffers(GLsizei n,RenderbufferID * renderbuffers)6971*8975f5c5SAndroid Build Coastguard Worker void Context::genRenderbuffers(GLsizei n, RenderbufferID *renderbuffers)
6972*8975f5c5SAndroid Build Coastguard Worker {
6973*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6974*8975f5c5SAndroid Build Coastguard Worker     {
6975*8975f5c5SAndroid Build Coastguard Worker         renderbuffers[i] = createRenderbuffer();
6976*8975f5c5SAndroid Build Coastguard Worker     }
6977*8975f5c5SAndroid Build Coastguard Worker }
6978*8975f5c5SAndroid Build Coastguard Worker 
genTextures(GLsizei n,TextureID * textures)6979*8975f5c5SAndroid Build Coastguard Worker void Context::genTextures(GLsizei n, TextureID *textures)
6980*8975f5c5SAndroid Build Coastguard Worker {
6981*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
6982*8975f5c5SAndroid Build Coastguard Worker     {
6983*8975f5c5SAndroid Build Coastguard Worker         textures[i] = createTexture();
6984*8975f5c5SAndroid Build Coastguard Worker     }
6985*8975f5c5SAndroid Build Coastguard Worker }
6986*8975f5c5SAndroid Build Coastguard Worker 
getActiveAttrib(ShaderProgramID program,GLuint index,GLsizei bufsize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)6987*8975f5c5SAndroid Build Coastguard Worker void Context::getActiveAttrib(ShaderProgramID program,
6988*8975f5c5SAndroid Build Coastguard Worker                               GLuint index,
6989*8975f5c5SAndroid Build Coastguard Worker                               GLsizei bufsize,
6990*8975f5c5SAndroid Build Coastguard Worker                               GLsizei *length,
6991*8975f5c5SAndroid Build Coastguard Worker                               GLint *size,
6992*8975f5c5SAndroid Build Coastguard Worker                               GLenum *type,
6993*8975f5c5SAndroid Build Coastguard Worker                               GLchar *name)
6994*8975f5c5SAndroid Build Coastguard Worker {
6995*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
6996*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
6997*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getActiveAttribute(index, bufsize, length, size, type, name);
6998*8975f5c5SAndroid Build Coastguard Worker }
6999*8975f5c5SAndroid Build Coastguard Worker 
getActiveUniform(ShaderProgramID program,GLuint index,GLsizei bufsize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)7000*8975f5c5SAndroid Build Coastguard Worker void Context::getActiveUniform(ShaderProgramID program,
7001*8975f5c5SAndroid Build Coastguard Worker                                GLuint index,
7002*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufsize,
7003*8975f5c5SAndroid Build Coastguard Worker                                GLsizei *length,
7004*8975f5c5SAndroid Build Coastguard Worker                                GLint *size,
7005*8975f5c5SAndroid Build Coastguard Worker                                GLenum *type,
7006*8975f5c5SAndroid Build Coastguard Worker                                GLchar *name)
7007*8975f5c5SAndroid Build Coastguard Worker {
7008*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7009*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7010*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getActiveUniform(index, bufsize, length, size, type, name);
7011*8975f5c5SAndroid Build Coastguard Worker }
7012*8975f5c5SAndroid Build Coastguard Worker 
getAttachedShaders(ShaderProgramID program,GLsizei maxcount,GLsizei * count,ShaderProgramID * shaders)7013*8975f5c5SAndroid Build Coastguard Worker void Context::getAttachedShaders(ShaderProgramID program,
7014*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei maxcount,
7015*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei *count,
7016*8975f5c5SAndroid Build Coastguard Worker                                  ShaderProgramID *shaders)
7017*8975f5c5SAndroid Build Coastguard Worker {
7018*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramNoResolveLink(program);
7019*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7020*8975f5c5SAndroid Build Coastguard Worker     programObject->getAttachedShaders(maxcount, count, shaders);
7021*8975f5c5SAndroid Build Coastguard Worker }
7022*8975f5c5SAndroid Build Coastguard Worker 
getAttribLocation(ShaderProgramID program,const GLchar * name)7023*8975f5c5SAndroid Build Coastguard Worker GLint Context::getAttribLocation(ShaderProgramID program, const GLchar *name)
7024*8975f5c5SAndroid Build Coastguard Worker {
7025*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7026*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7027*8975f5c5SAndroid Build Coastguard Worker     return programObject->getExecutable().getAttributeLocation(name);
7028*8975f5c5SAndroid Build Coastguard Worker }
7029*8975f5c5SAndroid Build Coastguard Worker 
getBooleanv(GLenum pname,GLboolean * params)7030*8975f5c5SAndroid Build Coastguard Worker void Context::getBooleanv(GLenum pname, GLboolean *params)
7031*8975f5c5SAndroid Build Coastguard Worker {
7032*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
7033*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams = 0;
7034*8975f5c5SAndroid Build Coastguard Worker     getQueryParameterInfo(pname, &nativeType, &numParams);
7035*8975f5c5SAndroid Build Coastguard Worker 
7036*8975f5c5SAndroid Build Coastguard Worker     if (nativeType == GL_BOOL)
7037*8975f5c5SAndroid Build Coastguard Worker     {
7038*8975f5c5SAndroid Build Coastguard Worker         getBooleanvImpl(pname, params);
7039*8975f5c5SAndroid Build Coastguard Worker     }
7040*8975f5c5SAndroid Build Coastguard Worker     else
7041*8975f5c5SAndroid Build Coastguard Worker     {
7042*8975f5c5SAndroid Build Coastguard Worker         CastStateValues(this, nativeType, pname, numParams, params);
7043*8975f5c5SAndroid Build Coastguard Worker     }
7044*8975f5c5SAndroid Build Coastguard Worker }
7045*8975f5c5SAndroid Build Coastguard Worker 
getBooleanvRobust(GLenum pname,GLsizei bufSize,GLsizei * length,GLboolean * params)7046*8975f5c5SAndroid Build Coastguard Worker void Context::getBooleanvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLboolean *params)
7047*8975f5c5SAndroid Build Coastguard Worker {
7048*8975f5c5SAndroid Build Coastguard Worker     getBooleanv(pname, params);
7049*8975f5c5SAndroid Build Coastguard Worker }
7050*8975f5c5SAndroid Build Coastguard Worker 
getFloatv(GLenum pname,GLfloat * params)7051*8975f5c5SAndroid Build Coastguard Worker void Context::getFloatv(GLenum pname, GLfloat *params)
7052*8975f5c5SAndroid Build Coastguard Worker {
7053*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType;
7054*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams = 0;
7055*8975f5c5SAndroid Build Coastguard Worker     getQueryParameterInfo(pname, &nativeType, &numParams);
7056*8975f5c5SAndroid Build Coastguard Worker 
7057*8975f5c5SAndroid Build Coastguard Worker     if (nativeType == GL_FLOAT)
7058*8975f5c5SAndroid Build Coastguard Worker     {
7059*8975f5c5SAndroid Build Coastguard Worker         getFloatvImpl(pname, params);
7060*8975f5c5SAndroid Build Coastguard Worker     }
7061*8975f5c5SAndroid Build Coastguard Worker     else
7062*8975f5c5SAndroid Build Coastguard Worker     {
7063*8975f5c5SAndroid Build Coastguard Worker         CastStateValues(this, nativeType, pname, numParams, params);
7064*8975f5c5SAndroid Build Coastguard Worker     }
7065*8975f5c5SAndroid Build Coastguard Worker }
7066*8975f5c5SAndroid Build Coastguard Worker 
getFloatvRobust(GLenum pname,GLsizei bufSize,GLsizei * length,GLfloat * params)7067*8975f5c5SAndroid Build Coastguard Worker void Context::getFloatvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLfloat *params)
7068*8975f5c5SAndroid Build Coastguard Worker {
7069*8975f5c5SAndroid Build Coastguard Worker     getFloatv(pname, params);
7070*8975f5c5SAndroid Build Coastguard Worker }
7071*8975f5c5SAndroid Build Coastguard Worker 
getIntegerv(GLenum pname,GLint * params)7072*8975f5c5SAndroid Build Coastguard Worker void Context::getIntegerv(GLenum pname, GLint *params)
7073*8975f5c5SAndroid Build Coastguard Worker {
7074*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType      = GL_NONE;
7075*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams = 0;
7076*8975f5c5SAndroid Build Coastguard Worker     getQueryParameterInfo(pname, &nativeType, &numParams);
7077*8975f5c5SAndroid Build Coastguard Worker 
7078*8975f5c5SAndroid Build Coastguard Worker     if (nativeType == GL_INT)
7079*8975f5c5SAndroid Build Coastguard Worker     {
7080*8975f5c5SAndroid Build Coastguard Worker         getIntegervImpl(pname, params);
7081*8975f5c5SAndroid Build Coastguard Worker     }
7082*8975f5c5SAndroid Build Coastguard Worker     else
7083*8975f5c5SAndroid Build Coastguard Worker     {
7084*8975f5c5SAndroid Build Coastguard Worker         CastStateValues(this, nativeType, pname, numParams, params);
7085*8975f5c5SAndroid Build Coastguard Worker     }
7086*8975f5c5SAndroid Build Coastguard Worker }
7087*8975f5c5SAndroid Build Coastguard Worker 
getIntegervRobust(GLenum pname,GLsizei bufSize,GLsizei * length,GLint * data)7088*8975f5c5SAndroid Build Coastguard Worker void Context::getIntegervRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint *data)
7089*8975f5c5SAndroid Build Coastguard Worker {
7090*8975f5c5SAndroid Build Coastguard Worker     getIntegerv(pname, data);
7091*8975f5c5SAndroid Build Coastguard Worker }
7092*8975f5c5SAndroid Build Coastguard Worker 
getProgramiv(ShaderProgramID program,GLenum pname,GLint * params)7093*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramiv(ShaderProgramID program, GLenum pname, GLint *params)
7094*8975f5c5SAndroid Build Coastguard Worker {
7095*8975f5c5SAndroid Build Coastguard Worker     // Don't resolve link if checking the link completion status.
7096*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramNoResolveLink(program);
7097*8975f5c5SAndroid Build Coastguard Worker     if (!isContextLost() && pname != GL_COMPLETION_STATUS_KHR)
7098*8975f5c5SAndroid Build Coastguard Worker     {
7099*8975f5c5SAndroid Build Coastguard Worker         programObject = getProgramResolveLink(program);
7100*8975f5c5SAndroid Build Coastguard Worker     }
7101*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7102*8975f5c5SAndroid Build Coastguard Worker     QueryProgramiv(this, programObject, pname, params);
7103*8975f5c5SAndroid Build Coastguard Worker }
7104*8975f5c5SAndroid Build Coastguard Worker 
getProgramivRobust(ShaderProgramID program,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)7105*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramivRobust(ShaderProgramID program,
7106*8975f5c5SAndroid Build Coastguard Worker                                  GLenum pname,
7107*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei bufSize,
7108*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei *length,
7109*8975f5c5SAndroid Build Coastguard Worker                                  GLint *params)
7110*8975f5c5SAndroid Build Coastguard Worker {
7111*8975f5c5SAndroid Build Coastguard Worker     getProgramiv(program, pname, params);
7112*8975f5c5SAndroid Build Coastguard Worker }
7113*8975f5c5SAndroid Build Coastguard Worker 
getProgramPipelineiv(ProgramPipelineID pipeline,GLenum pname,GLint * params)7114*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramPipelineiv(ProgramPipelineID pipeline, GLenum pname, GLint *params)
7115*8975f5c5SAndroid Build Coastguard Worker {
7116*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *programPipeline = nullptr;
7117*8975f5c5SAndroid Build Coastguard Worker     if (!isContextLost())
7118*8975f5c5SAndroid Build Coastguard Worker     {
7119*8975f5c5SAndroid Build Coastguard Worker         programPipeline = getProgramPipeline(pipeline);
7120*8975f5c5SAndroid Build Coastguard Worker     }
7121*8975f5c5SAndroid Build Coastguard Worker     QueryProgramPipelineiv(this, programPipeline, pname, params);
7122*8975f5c5SAndroid Build Coastguard Worker }
7123*8975f5c5SAndroid Build Coastguard Worker 
getMemoryObject(MemoryObjectID handle) const7124*8975f5c5SAndroid Build Coastguard Worker MemoryObject *Context::getMemoryObject(MemoryObjectID handle) const
7125*8975f5c5SAndroid Build Coastguard Worker {
7126*8975f5c5SAndroid Build Coastguard Worker     return mState.mMemoryObjectManager->getMemoryObject(handle);
7127*8975f5c5SAndroid Build Coastguard Worker }
7128*8975f5c5SAndroid Build Coastguard Worker 
getSemaphore(SemaphoreID handle) const7129*8975f5c5SAndroid Build Coastguard Worker Semaphore *Context::getSemaphore(SemaphoreID handle) const
7130*8975f5c5SAndroid Build Coastguard Worker {
7131*8975f5c5SAndroid Build Coastguard Worker     return mState.mSemaphoreManager->getSemaphore(handle);
7132*8975f5c5SAndroid Build Coastguard Worker }
7133*8975f5c5SAndroid Build Coastguard Worker 
getProgramInfoLog(ShaderProgramID program,GLsizei bufsize,GLsizei * length,GLchar * infolog)7134*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramInfoLog(ShaderProgramID program,
7135*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei bufsize,
7136*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei *length,
7137*8975f5c5SAndroid Build Coastguard Worker                                 GLchar *infolog)
7138*8975f5c5SAndroid Build Coastguard Worker {
7139*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7140*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7141*8975f5c5SAndroid Build Coastguard Worker     programObject->getInfoLog(bufsize, length, infolog);
7142*8975f5c5SAndroid Build Coastguard Worker }
7143*8975f5c5SAndroid Build Coastguard Worker 
getProgramPipelineInfoLog(ProgramPipelineID pipeline,GLsizei bufSize,GLsizei * length,GLchar * infoLog)7144*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramPipelineInfoLog(ProgramPipelineID pipeline,
7145*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
7146*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
7147*8975f5c5SAndroid Build Coastguard Worker                                         GLchar *infoLog)
7148*8975f5c5SAndroid Build Coastguard Worker {
7149*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *programPipeline = getProgramPipeline(pipeline);
7150*8975f5c5SAndroid Build Coastguard Worker     if (programPipeline)
7151*8975f5c5SAndroid Build Coastguard Worker     {
7152*8975f5c5SAndroid Build Coastguard Worker         programPipeline->getInfoLog(bufSize, length, infoLog);
7153*8975f5c5SAndroid Build Coastguard Worker     }
7154*8975f5c5SAndroid Build Coastguard Worker     else
7155*8975f5c5SAndroid Build Coastguard Worker     {
7156*8975f5c5SAndroid Build Coastguard Worker         *length  = 0;
7157*8975f5c5SAndroid Build Coastguard Worker         *infoLog = '\0';
7158*8975f5c5SAndroid Build Coastguard Worker     }
7159*8975f5c5SAndroid Build Coastguard Worker }
7160*8975f5c5SAndroid Build Coastguard Worker 
getShaderiv(ShaderProgramID shader,GLenum pname,GLint * params)7161*8975f5c5SAndroid Build Coastguard Worker void Context::getShaderiv(ShaderProgramID shader, GLenum pname, GLint *params)
7162*8975f5c5SAndroid Build Coastguard Worker {
7163*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = nullptr;
7164*8975f5c5SAndroid Build Coastguard Worker     if (!isContextLost())
7165*8975f5c5SAndroid Build Coastguard Worker     {
7166*8975f5c5SAndroid Build Coastguard Worker         shaderObject = getShaderNoResolveCompile(shader);
7167*8975f5c5SAndroid Build Coastguard Worker         ASSERT(shaderObject);
7168*8975f5c5SAndroid Build Coastguard Worker     }
7169*8975f5c5SAndroid Build Coastguard Worker     QueryShaderiv(this, shaderObject, pname, params);
7170*8975f5c5SAndroid Build Coastguard Worker }
7171*8975f5c5SAndroid Build Coastguard Worker 
getShaderivRobust(ShaderProgramID shader,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)7172*8975f5c5SAndroid Build Coastguard Worker void Context::getShaderivRobust(ShaderProgramID shader,
7173*8975f5c5SAndroid Build Coastguard Worker                                 GLenum pname,
7174*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei bufSize,
7175*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei *length,
7176*8975f5c5SAndroid Build Coastguard Worker                                 GLint *params)
7177*8975f5c5SAndroid Build Coastguard Worker {
7178*8975f5c5SAndroid Build Coastguard Worker     getShaderiv(shader, pname, params);
7179*8975f5c5SAndroid Build Coastguard Worker }
7180*8975f5c5SAndroid Build Coastguard Worker 
getShaderInfoLog(ShaderProgramID shader,GLsizei bufsize,GLsizei * length,GLchar * infolog)7181*8975f5c5SAndroid Build Coastguard Worker void Context::getShaderInfoLog(ShaderProgramID shader,
7182*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufsize,
7183*8975f5c5SAndroid Build Coastguard Worker                                GLsizei *length,
7184*8975f5c5SAndroid Build Coastguard Worker                                GLchar *infolog)
7185*8975f5c5SAndroid Build Coastguard Worker {
7186*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = getShaderNoResolveCompile(shader);
7187*8975f5c5SAndroid Build Coastguard Worker     ASSERT(shaderObject);
7188*8975f5c5SAndroid Build Coastguard Worker     shaderObject->getInfoLog(this, bufsize, length, infolog);
7189*8975f5c5SAndroid Build Coastguard Worker }
7190*8975f5c5SAndroid Build Coastguard Worker 
getShaderPrecisionFormat(GLenum shadertype,GLenum precisiontype,GLint * range,GLint * precision)7191*8975f5c5SAndroid Build Coastguard Worker void Context::getShaderPrecisionFormat(GLenum shadertype,
7192*8975f5c5SAndroid Build Coastguard Worker                                        GLenum precisiontype,
7193*8975f5c5SAndroid Build Coastguard Worker                                        GLint *range,
7194*8975f5c5SAndroid Build Coastguard Worker                                        GLint *precision)
7195*8975f5c5SAndroid Build Coastguard Worker {
7196*8975f5c5SAndroid Build Coastguard Worker     switch (shadertype)
7197*8975f5c5SAndroid Build Coastguard Worker     {
7198*8975f5c5SAndroid Build Coastguard Worker         case GL_VERTEX_SHADER:
7199*8975f5c5SAndroid Build Coastguard Worker             switch (precisiontype)
7200*8975f5c5SAndroid Build Coastguard Worker             {
7201*8975f5c5SAndroid Build Coastguard Worker                 case GL_LOW_FLOAT:
7202*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().vertexLowpFloat.get(range, precision);
7203*8975f5c5SAndroid Build Coastguard Worker                     break;
7204*8975f5c5SAndroid Build Coastguard Worker                 case GL_MEDIUM_FLOAT:
7205*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().vertexMediumpFloat.get(range, precision);
7206*8975f5c5SAndroid Build Coastguard Worker                     break;
7207*8975f5c5SAndroid Build Coastguard Worker                 case GL_HIGH_FLOAT:
7208*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().vertexHighpFloat.get(range, precision);
7209*8975f5c5SAndroid Build Coastguard Worker                     break;
7210*8975f5c5SAndroid Build Coastguard Worker 
7211*8975f5c5SAndroid Build Coastguard Worker                 case GL_LOW_INT:
7212*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().vertexLowpInt.get(range, precision);
7213*8975f5c5SAndroid Build Coastguard Worker                     break;
7214*8975f5c5SAndroid Build Coastguard Worker                 case GL_MEDIUM_INT:
7215*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().vertexMediumpInt.get(range, precision);
7216*8975f5c5SAndroid Build Coastguard Worker                     break;
7217*8975f5c5SAndroid Build Coastguard Worker                 case GL_HIGH_INT:
7218*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().vertexHighpInt.get(range, precision);
7219*8975f5c5SAndroid Build Coastguard Worker                     break;
7220*8975f5c5SAndroid Build Coastguard Worker 
7221*8975f5c5SAndroid Build Coastguard Worker                 default:
7222*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
7223*8975f5c5SAndroid Build Coastguard Worker                     return;
7224*8975f5c5SAndroid Build Coastguard Worker             }
7225*8975f5c5SAndroid Build Coastguard Worker             break;
7226*8975f5c5SAndroid Build Coastguard Worker 
7227*8975f5c5SAndroid Build Coastguard Worker         case GL_FRAGMENT_SHADER:
7228*8975f5c5SAndroid Build Coastguard Worker             switch (precisiontype)
7229*8975f5c5SAndroid Build Coastguard Worker             {
7230*8975f5c5SAndroid Build Coastguard Worker                 case GL_LOW_FLOAT:
7231*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().fragmentLowpFloat.get(range, precision);
7232*8975f5c5SAndroid Build Coastguard Worker                     break;
7233*8975f5c5SAndroid Build Coastguard Worker                 case GL_MEDIUM_FLOAT:
7234*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().fragmentMediumpFloat.get(range, precision);
7235*8975f5c5SAndroid Build Coastguard Worker                     break;
7236*8975f5c5SAndroid Build Coastguard Worker                 case GL_HIGH_FLOAT:
7237*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().fragmentHighpFloat.get(range, precision);
7238*8975f5c5SAndroid Build Coastguard Worker                     break;
7239*8975f5c5SAndroid Build Coastguard Worker 
7240*8975f5c5SAndroid Build Coastguard Worker                 case GL_LOW_INT:
7241*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().fragmentLowpInt.get(range, precision);
7242*8975f5c5SAndroid Build Coastguard Worker                     break;
7243*8975f5c5SAndroid Build Coastguard Worker                 case GL_MEDIUM_INT:
7244*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().fragmentMediumpInt.get(range, precision);
7245*8975f5c5SAndroid Build Coastguard Worker                     break;
7246*8975f5c5SAndroid Build Coastguard Worker                 case GL_HIGH_INT:
7247*8975f5c5SAndroid Build Coastguard Worker                     mState.getCaps().fragmentHighpInt.get(range, precision);
7248*8975f5c5SAndroid Build Coastguard Worker                     break;
7249*8975f5c5SAndroid Build Coastguard Worker 
7250*8975f5c5SAndroid Build Coastguard Worker                 default:
7251*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
7252*8975f5c5SAndroid Build Coastguard Worker                     return;
7253*8975f5c5SAndroid Build Coastguard Worker             }
7254*8975f5c5SAndroid Build Coastguard Worker             break;
7255*8975f5c5SAndroid Build Coastguard Worker 
7256*8975f5c5SAndroid Build Coastguard Worker         default:
7257*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
7258*8975f5c5SAndroid Build Coastguard Worker             return;
7259*8975f5c5SAndroid Build Coastguard Worker     }
7260*8975f5c5SAndroid Build Coastguard Worker }
7261*8975f5c5SAndroid Build Coastguard Worker 
getShaderSource(ShaderProgramID shader,GLsizei bufsize,GLsizei * length,GLchar * source)7262*8975f5c5SAndroid Build Coastguard Worker void Context::getShaderSource(ShaderProgramID shader,
7263*8975f5c5SAndroid Build Coastguard Worker                               GLsizei bufsize,
7264*8975f5c5SAndroid Build Coastguard Worker                               GLsizei *length,
7265*8975f5c5SAndroid Build Coastguard Worker                               GLchar *source)
7266*8975f5c5SAndroid Build Coastguard Worker {
7267*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = getShaderNoResolveCompile(shader);
7268*8975f5c5SAndroid Build Coastguard Worker     ASSERT(shaderObject);
7269*8975f5c5SAndroid Build Coastguard Worker     shaderObject->getSource(bufsize, length, source);
7270*8975f5c5SAndroid Build Coastguard Worker }
7271*8975f5c5SAndroid Build Coastguard Worker 
getUniformfv(ShaderProgramID program,UniformLocation location,GLfloat * params)7272*8975f5c5SAndroid Build Coastguard Worker void Context::getUniformfv(ShaderProgramID program, UniformLocation location, GLfloat *params)
7273*8975f5c5SAndroid Build Coastguard Worker {
7274*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7275*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7276*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getUniformfv(this, location, params);
7277*8975f5c5SAndroid Build Coastguard Worker }
7278*8975f5c5SAndroid Build Coastguard Worker 
getUniformfvRobust(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLsizei * length,GLfloat * params)7279*8975f5c5SAndroid Build Coastguard Worker void Context::getUniformfvRobust(ShaderProgramID program,
7280*8975f5c5SAndroid Build Coastguard Worker                                  UniformLocation location,
7281*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei bufSize,
7282*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei *length,
7283*8975f5c5SAndroid Build Coastguard Worker                                  GLfloat *params)
7284*8975f5c5SAndroid Build Coastguard Worker {
7285*8975f5c5SAndroid Build Coastguard Worker     getUniformfv(program, location, params);
7286*8975f5c5SAndroid Build Coastguard Worker }
7287*8975f5c5SAndroid Build Coastguard Worker 
getUniformiv(ShaderProgramID program,UniformLocation location,GLint * params)7288*8975f5c5SAndroid Build Coastguard Worker void Context::getUniformiv(ShaderProgramID program, UniformLocation location, GLint *params)
7289*8975f5c5SAndroid Build Coastguard Worker {
7290*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7291*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7292*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getUniformiv(this, location, params);
7293*8975f5c5SAndroid Build Coastguard Worker }
7294*8975f5c5SAndroid Build Coastguard Worker 
getUniformivRobust(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLsizei * length,GLint * params)7295*8975f5c5SAndroid Build Coastguard Worker void Context::getUniformivRobust(ShaderProgramID program,
7296*8975f5c5SAndroid Build Coastguard Worker                                  UniformLocation location,
7297*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei bufSize,
7298*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei *length,
7299*8975f5c5SAndroid Build Coastguard Worker                                  GLint *params)
7300*8975f5c5SAndroid Build Coastguard Worker {
7301*8975f5c5SAndroid Build Coastguard Worker     getUniformiv(program, location, params);
7302*8975f5c5SAndroid Build Coastguard Worker }
7303*8975f5c5SAndroid Build Coastguard Worker 
getUniformLocation(ShaderProgramID program,const GLchar * name)7304*8975f5c5SAndroid Build Coastguard Worker GLint Context::getUniformLocation(ShaderProgramID program, const GLchar *name)
7305*8975f5c5SAndroid Build Coastguard Worker {
7306*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7307*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7308*8975f5c5SAndroid Build Coastguard Worker     return programObject->getExecutable().getUniformLocation(name).value;
7309*8975f5c5SAndroid Build Coastguard Worker }
7310*8975f5c5SAndroid Build Coastguard Worker 
isBuffer(BufferID buffer) const7311*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isBuffer(BufferID buffer) const
7312*8975f5c5SAndroid Build Coastguard Worker {
7313*8975f5c5SAndroid Build Coastguard Worker     if (buffer.value == 0)
7314*8975f5c5SAndroid Build Coastguard Worker     {
7315*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7316*8975f5c5SAndroid Build Coastguard Worker     }
7317*8975f5c5SAndroid Build Coastguard Worker 
7318*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getBuffer(buffer));
7319*8975f5c5SAndroid Build Coastguard Worker }
7320*8975f5c5SAndroid Build Coastguard Worker 
isFramebuffer(FramebufferID framebuffer) const7321*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isFramebuffer(FramebufferID framebuffer) const
7322*8975f5c5SAndroid Build Coastguard Worker {
7323*8975f5c5SAndroid Build Coastguard Worker     if (framebuffer.value == 0)
7324*8975f5c5SAndroid Build Coastguard Worker     {
7325*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7326*8975f5c5SAndroid Build Coastguard Worker     }
7327*8975f5c5SAndroid Build Coastguard Worker 
7328*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getFramebuffer(framebuffer));
7329*8975f5c5SAndroid Build Coastguard Worker }
7330*8975f5c5SAndroid Build Coastguard Worker 
isProgram(ShaderProgramID program) const7331*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isProgram(ShaderProgramID program) const
7332*8975f5c5SAndroid Build Coastguard Worker {
7333*8975f5c5SAndroid Build Coastguard Worker     if (program.value == 0)
7334*8975f5c5SAndroid Build Coastguard Worker     {
7335*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7336*8975f5c5SAndroid Build Coastguard Worker     }
7337*8975f5c5SAndroid Build Coastguard Worker 
7338*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getProgramNoResolveLink(program));
7339*8975f5c5SAndroid Build Coastguard Worker }
7340*8975f5c5SAndroid Build Coastguard Worker 
isRenderbuffer(RenderbufferID renderbuffer) const7341*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isRenderbuffer(RenderbufferID renderbuffer) const
7342*8975f5c5SAndroid Build Coastguard Worker {
7343*8975f5c5SAndroid Build Coastguard Worker     if (renderbuffer.value == 0)
7344*8975f5c5SAndroid Build Coastguard Worker     {
7345*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7346*8975f5c5SAndroid Build Coastguard Worker     }
7347*8975f5c5SAndroid Build Coastguard Worker 
7348*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getRenderbuffer(renderbuffer));
7349*8975f5c5SAndroid Build Coastguard Worker }
7350*8975f5c5SAndroid Build Coastguard Worker 
isShader(ShaderProgramID shader) const7351*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isShader(ShaderProgramID shader) const
7352*8975f5c5SAndroid Build Coastguard Worker {
7353*8975f5c5SAndroid Build Coastguard Worker     if (shader.value == 0)
7354*8975f5c5SAndroid Build Coastguard Worker     {
7355*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7356*8975f5c5SAndroid Build Coastguard Worker     }
7357*8975f5c5SAndroid Build Coastguard Worker 
7358*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getShaderNoResolveCompile(shader));
7359*8975f5c5SAndroid Build Coastguard Worker }
7360*8975f5c5SAndroid Build Coastguard Worker 
isTexture(TextureID texture) const7361*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isTexture(TextureID texture) const
7362*8975f5c5SAndroid Build Coastguard Worker {
7363*8975f5c5SAndroid Build Coastguard Worker     if (texture.value == 0)
7364*8975f5c5SAndroid Build Coastguard Worker     {
7365*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7366*8975f5c5SAndroid Build Coastguard Worker     }
7367*8975f5c5SAndroid Build Coastguard Worker 
7368*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getTexture(texture));
7369*8975f5c5SAndroid Build Coastguard Worker }
7370*8975f5c5SAndroid Build Coastguard Worker 
linkProgram(ShaderProgramID program)7371*8975f5c5SAndroid Build Coastguard Worker void Context::linkProgram(ShaderProgramID program)
7372*8975f5c5SAndroid Build Coastguard Worker {
7373*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramNoResolveLink(program);
7374*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7375*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(programObject->link(this, angle::JobResultExpectancy::Future));
7376*8975f5c5SAndroid Build Coastguard Worker }
7377*8975f5c5SAndroid Build Coastguard Worker 
releaseShaderCompiler()7378*8975f5c5SAndroid Build Coastguard Worker void Context::releaseShaderCompiler()
7379*8975f5c5SAndroid Build Coastguard Worker {
7380*8975f5c5SAndroid Build Coastguard Worker     mCompiler.set(this, nullptr);
7381*8975f5c5SAndroid Build Coastguard Worker }
7382*8975f5c5SAndroid Build Coastguard Worker 
shaderBinary(GLsizei n,const ShaderProgramID * shaders,GLenum binaryformat,const void * binary,GLsizei length)7383*8975f5c5SAndroid Build Coastguard Worker void Context::shaderBinary(GLsizei n,
7384*8975f5c5SAndroid Build Coastguard Worker                            const ShaderProgramID *shaders,
7385*8975f5c5SAndroid Build Coastguard Worker                            GLenum binaryformat,
7386*8975f5c5SAndroid Build Coastguard Worker                            const void *binary,
7387*8975f5c5SAndroid Build Coastguard Worker                            GLsizei length)
7388*8975f5c5SAndroid Build Coastguard Worker {
7389*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = getShaderNoResolveCompile(*shaders);
7390*8975f5c5SAndroid Build Coastguard Worker     ASSERT(shaderObject != nullptr);
7391*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
7392*8975f5c5SAndroid Build Coastguard Worker         shaderObject->loadShaderBinary(this, binary, length, angle::JobResultExpectancy::Future));
7393*8975f5c5SAndroid Build Coastguard Worker }
7394*8975f5c5SAndroid Build Coastguard Worker 
bindFragDataLocationIndexed(ShaderProgramID program,GLuint colorNumber,GLuint index,const char * name)7395*8975f5c5SAndroid Build Coastguard Worker void Context::bindFragDataLocationIndexed(ShaderProgramID program,
7396*8975f5c5SAndroid Build Coastguard Worker                                           GLuint colorNumber,
7397*8975f5c5SAndroid Build Coastguard Worker                                           GLuint index,
7398*8975f5c5SAndroid Build Coastguard Worker                                           const char *name)
7399*8975f5c5SAndroid Build Coastguard Worker {
7400*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramNoResolveLink(program);
7401*8975f5c5SAndroid Build Coastguard Worker     programObject->bindFragmentOutputLocation(this, colorNumber, name);
7402*8975f5c5SAndroid Build Coastguard Worker     programObject->bindFragmentOutputIndex(this, index, name);
7403*8975f5c5SAndroid Build Coastguard Worker }
7404*8975f5c5SAndroid Build Coastguard Worker 
bindFragDataLocation(ShaderProgramID program,GLuint colorNumber,const char * name)7405*8975f5c5SAndroid Build Coastguard Worker void Context::bindFragDataLocation(ShaderProgramID program, GLuint colorNumber, const char *name)
7406*8975f5c5SAndroid Build Coastguard Worker {
7407*8975f5c5SAndroid Build Coastguard Worker     bindFragDataLocationIndexed(program, colorNumber, 0u, name);
7408*8975f5c5SAndroid Build Coastguard Worker }
7409*8975f5c5SAndroid Build Coastguard Worker 
getFragDataIndex(ShaderProgramID program,const char * name)7410*8975f5c5SAndroid Build Coastguard Worker int Context::getFragDataIndex(ShaderProgramID program, const char *name)
7411*8975f5c5SAndroid Build Coastguard Worker {
7412*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7413*8975f5c5SAndroid Build Coastguard Worker     return programObject->getExecutable().getFragDataIndex(name);
7414*8975f5c5SAndroid Build Coastguard Worker }
7415*8975f5c5SAndroid Build Coastguard Worker 
getProgramResourceLocationIndex(ShaderProgramID program,GLenum programInterface,const char * name)7416*8975f5c5SAndroid Build Coastguard Worker int Context::getProgramResourceLocationIndex(ShaderProgramID program,
7417*8975f5c5SAndroid Build Coastguard Worker                                              GLenum programInterface,
7418*8975f5c5SAndroid Build Coastguard Worker                                              const char *name)
7419*8975f5c5SAndroid Build Coastguard Worker {
7420*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7421*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programInterface == GL_PROGRAM_OUTPUT);
7422*8975f5c5SAndroid Build Coastguard Worker     return programObject->getExecutable().getFragDataIndex(name);
7423*8975f5c5SAndroid Build Coastguard Worker }
7424*8975f5c5SAndroid Build Coastguard Worker 
shaderSource(ShaderProgramID shader,GLsizei count,const GLchar * const * string,const GLint * length)7425*8975f5c5SAndroid Build Coastguard Worker void Context::shaderSource(ShaderProgramID shader,
7426*8975f5c5SAndroid Build Coastguard Worker                            GLsizei count,
7427*8975f5c5SAndroid Build Coastguard Worker                            const GLchar *const *string,
7428*8975f5c5SAndroid Build Coastguard Worker                            const GLint *length)
7429*8975f5c5SAndroid Build Coastguard Worker {
7430*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = getShaderNoResolveCompile(shader);
7431*8975f5c5SAndroid Build Coastguard Worker     ASSERT(shaderObject);
7432*8975f5c5SAndroid Build Coastguard Worker     shaderObject->setSource(this, count, string, length);
7433*8975f5c5SAndroid Build Coastguard Worker }
7434*8975f5c5SAndroid Build Coastguard Worker 
getActiveLinkedProgram() const7435*8975f5c5SAndroid Build Coastguard Worker Program *Context::getActiveLinkedProgram() const
7436*8975f5c5SAndroid Build Coastguard Worker {
7437*8975f5c5SAndroid Build Coastguard Worker     Program *program = mState.getLinkedProgram(this);
7438*8975f5c5SAndroid Build Coastguard Worker     if (!program)
7439*8975f5c5SAndroid Build Coastguard Worker     {
7440*8975f5c5SAndroid Build Coastguard Worker         ProgramPipeline *programPipelineObject = mState.getProgramPipeline();
7441*8975f5c5SAndroid Build Coastguard Worker         if (programPipelineObject)
7442*8975f5c5SAndroid Build Coastguard Worker         {
7443*8975f5c5SAndroid Build Coastguard Worker             program = programPipelineObject->getLinkedActiveShaderProgram(this);
7444*8975f5c5SAndroid Build Coastguard Worker         }
7445*8975f5c5SAndroid Build Coastguard Worker     }
7446*8975f5c5SAndroid Build Coastguard Worker 
7447*8975f5c5SAndroid Build Coastguard Worker     return program;
7448*8975f5c5SAndroid Build Coastguard Worker }
7449*8975f5c5SAndroid Build Coastguard Worker 
uniform1f(UniformLocation location,GLfloat x)7450*8975f5c5SAndroid Build Coastguard Worker void Context::uniform1f(UniformLocation location, GLfloat x)
7451*8975f5c5SAndroid Build Coastguard Worker {
7452*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7453*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform1fv(location, 1, &x);
7454*8975f5c5SAndroid Build Coastguard Worker }
7455*8975f5c5SAndroid Build Coastguard Worker 
uniform1fv(UniformLocation location,GLsizei count,const GLfloat * v)7456*8975f5c5SAndroid Build Coastguard Worker void Context::uniform1fv(UniformLocation location, GLsizei count, const GLfloat *v)
7457*8975f5c5SAndroid Build Coastguard Worker {
7458*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7459*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform1fv(location, count, v);
7460*8975f5c5SAndroid Build Coastguard Worker }
7461*8975f5c5SAndroid Build Coastguard Worker 
setUniform1iImpl(Program * program,UniformLocation location,GLsizei count,const GLint * v)7462*8975f5c5SAndroid Build Coastguard Worker void Context::setUniform1iImpl(Program *program,
7463*8975f5c5SAndroid Build Coastguard Worker                                UniformLocation location,
7464*8975f5c5SAndroid Build Coastguard Worker                                GLsizei count,
7465*8975f5c5SAndroid Build Coastguard Worker                                const GLint *v)
7466*8975f5c5SAndroid Build Coastguard Worker {
7467*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform1iv(this, location, count, v);
7468*8975f5c5SAndroid Build Coastguard Worker }
7469*8975f5c5SAndroid Build Coastguard Worker 
onSamplerUniformChange(size_t textureUnitIndex)7470*8975f5c5SAndroid Build Coastguard Worker void Context::onSamplerUniformChange(size_t textureUnitIndex)
7471*8975f5c5SAndroid Build Coastguard Worker {
7472*8975f5c5SAndroid Build Coastguard Worker     mState.onActiveTextureChange(this, textureUnitIndex);
7473*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTextureChange(this);
7474*8975f5c5SAndroid Build Coastguard Worker }
7475*8975f5c5SAndroid Build Coastguard Worker 
uniform1i(UniformLocation location,GLint x)7476*8975f5c5SAndroid Build Coastguard Worker void Context::uniform1i(UniformLocation location, GLint x)
7477*8975f5c5SAndroid Build Coastguard Worker {
7478*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7479*8975f5c5SAndroid Build Coastguard Worker     setUniform1iImpl(program, location, 1, &x);
7480*8975f5c5SAndroid Build Coastguard Worker }
7481*8975f5c5SAndroid Build Coastguard Worker 
uniform1iv(UniformLocation location,GLsizei count,const GLint * v)7482*8975f5c5SAndroid Build Coastguard Worker void Context::uniform1iv(UniformLocation location, GLsizei count, const GLint *v)
7483*8975f5c5SAndroid Build Coastguard Worker {
7484*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7485*8975f5c5SAndroid Build Coastguard Worker     setUniform1iImpl(program, location, count, v);
7486*8975f5c5SAndroid Build Coastguard Worker }
7487*8975f5c5SAndroid Build Coastguard Worker 
uniform2f(UniformLocation location,GLfloat x,GLfloat y)7488*8975f5c5SAndroid Build Coastguard Worker void Context::uniform2f(UniformLocation location, GLfloat x, GLfloat y)
7489*8975f5c5SAndroid Build Coastguard Worker {
7490*8975f5c5SAndroid Build Coastguard Worker     GLfloat xy[2]    = {x, y};
7491*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7492*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform2fv(location, 1, xy);
7493*8975f5c5SAndroid Build Coastguard Worker }
7494*8975f5c5SAndroid Build Coastguard Worker 
uniform2fv(UniformLocation location,GLsizei count,const GLfloat * v)7495*8975f5c5SAndroid Build Coastguard Worker void Context::uniform2fv(UniformLocation location, GLsizei count, const GLfloat *v)
7496*8975f5c5SAndroid Build Coastguard Worker {
7497*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7498*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform2fv(location, count, v);
7499*8975f5c5SAndroid Build Coastguard Worker }
7500*8975f5c5SAndroid Build Coastguard Worker 
uniform2i(UniformLocation location,GLint x,GLint y)7501*8975f5c5SAndroid Build Coastguard Worker void Context::uniform2i(UniformLocation location, GLint x, GLint y)
7502*8975f5c5SAndroid Build Coastguard Worker {
7503*8975f5c5SAndroid Build Coastguard Worker     GLint xy[2]      = {x, y};
7504*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7505*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform2iv(location, 1, xy);
7506*8975f5c5SAndroid Build Coastguard Worker }
7507*8975f5c5SAndroid Build Coastguard Worker 
uniform2iv(UniformLocation location,GLsizei count,const GLint * v)7508*8975f5c5SAndroid Build Coastguard Worker void Context::uniform2iv(UniformLocation location, GLsizei count, const GLint *v)
7509*8975f5c5SAndroid Build Coastguard Worker {
7510*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7511*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform2iv(location, count, v);
7512*8975f5c5SAndroid Build Coastguard Worker }
7513*8975f5c5SAndroid Build Coastguard Worker 
uniform3f(UniformLocation location,GLfloat x,GLfloat y,GLfloat z)7514*8975f5c5SAndroid Build Coastguard Worker void Context::uniform3f(UniformLocation location, GLfloat x, GLfloat y, GLfloat z)
7515*8975f5c5SAndroid Build Coastguard Worker {
7516*8975f5c5SAndroid Build Coastguard Worker     GLfloat xyz[3]   = {x, y, z};
7517*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7518*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform3fv(location, 1, xyz);
7519*8975f5c5SAndroid Build Coastguard Worker }
7520*8975f5c5SAndroid Build Coastguard Worker 
uniform3fv(UniformLocation location,GLsizei count,const GLfloat * v)7521*8975f5c5SAndroid Build Coastguard Worker void Context::uniform3fv(UniformLocation location, GLsizei count, const GLfloat *v)
7522*8975f5c5SAndroid Build Coastguard Worker {
7523*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7524*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform3fv(location, count, v);
7525*8975f5c5SAndroid Build Coastguard Worker }
7526*8975f5c5SAndroid Build Coastguard Worker 
uniform3i(UniformLocation location,GLint x,GLint y,GLint z)7527*8975f5c5SAndroid Build Coastguard Worker void Context::uniform3i(UniformLocation location, GLint x, GLint y, GLint z)
7528*8975f5c5SAndroid Build Coastguard Worker {
7529*8975f5c5SAndroid Build Coastguard Worker     GLint xyz[3]     = {x, y, z};
7530*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7531*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform3iv(location, 1, xyz);
7532*8975f5c5SAndroid Build Coastguard Worker }
7533*8975f5c5SAndroid Build Coastguard Worker 
uniform3iv(UniformLocation location,GLsizei count,const GLint * v)7534*8975f5c5SAndroid Build Coastguard Worker void Context::uniform3iv(UniformLocation location, GLsizei count, const GLint *v)
7535*8975f5c5SAndroid Build Coastguard Worker {
7536*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7537*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform3iv(location, count, v);
7538*8975f5c5SAndroid Build Coastguard Worker }
7539*8975f5c5SAndroid Build Coastguard Worker 
uniform4f(UniformLocation location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)7540*8975f5c5SAndroid Build Coastguard Worker void Context::uniform4f(UniformLocation location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7541*8975f5c5SAndroid Build Coastguard Worker {
7542*8975f5c5SAndroid Build Coastguard Worker     GLfloat xyzw[4]  = {x, y, z, w};
7543*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7544*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform4fv(location, 1, xyzw);
7545*8975f5c5SAndroid Build Coastguard Worker }
7546*8975f5c5SAndroid Build Coastguard Worker 
uniform4fv(UniformLocation location,GLsizei count,const GLfloat * v)7547*8975f5c5SAndroid Build Coastguard Worker void Context::uniform4fv(UniformLocation location, GLsizei count, const GLfloat *v)
7548*8975f5c5SAndroid Build Coastguard Worker {
7549*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7550*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform4fv(location, count, v);
7551*8975f5c5SAndroid Build Coastguard Worker }
7552*8975f5c5SAndroid Build Coastguard Worker 
uniform4i(UniformLocation location,GLint x,GLint y,GLint z,GLint w)7553*8975f5c5SAndroid Build Coastguard Worker void Context::uniform4i(UniformLocation location, GLint x, GLint y, GLint z, GLint w)
7554*8975f5c5SAndroid Build Coastguard Worker {
7555*8975f5c5SAndroid Build Coastguard Worker     GLint xyzw[4]    = {x, y, z, w};
7556*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7557*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform4iv(location, 1, xyzw);
7558*8975f5c5SAndroid Build Coastguard Worker }
7559*8975f5c5SAndroid Build Coastguard Worker 
uniform4iv(UniformLocation location,GLsizei count,const GLint * v)7560*8975f5c5SAndroid Build Coastguard Worker void Context::uniform4iv(UniformLocation location, GLsizei count, const GLint *v)
7561*8975f5c5SAndroid Build Coastguard Worker {
7562*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7563*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform4iv(location, count, v);
7564*8975f5c5SAndroid Build Coastguard Worker }
7565*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix2fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7566*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix2fv(UniformLocation location,
7567*8975f5c5SAndroid Build Coastguard Worker                                GLsizei count,
7568*8975f5c5SAndroid Build Coastguard Worker                                GLboolean transpose,
7569*8975f5c5SAndroid Build Coastguard Worker                                const GLfloat *value)
7570*8975f5c5SAndroid Build Coastguard Worker {
7571*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7572*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix2fv(location, count, transpose, value);
7573*8975f5c5SAndroid Build Coastguard Worker }
7574*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix3fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7575*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix3fv(UniformLocation location,
7576*8975f5c5SAndroid Build Coastguard Worker                                GLsizei count,
7577*8975f5c5SAndroid Build Coastguard Worker                                GLboolean transpose,
7578*8975f5c5SAndroid Build Coastguard Worker                                const GLfloat *value)
7579*8975f5c5SAndroid Build Coastguard Worker {
7580*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7581*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix3fv(location, count, transpose, value);
7582*8975f5c5SAndroid Build Coastguard Worker }
7583*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix4fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7584*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix4fv(UniformLocation location,
7585*8975f5c5SAndroid Build Coastguard Worker                                GLsizei count,
7586*8975f5c5SAndroid Build Coastguard Worker                                GLboolean transpose,
7587*8975f5c5SAndroid Build Coastguard Worker                                const GLfloat *value)
7588*8975f5c5SAndroid Build Coastguard Worker {
7589*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7590*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix4fv(location, count, transpose, value);
7591*8975f5c5SAndroid Build Coastguard Worker }
7592*8975f5c5SAndroid Build Coastguard Worker 
validateProgram(ShaderProgramID program)7593*8975f5c5SAndroid Build Coastguard Worker void Context::validateProgram(ShaderProgramID program)
7594*8975f5c5SAndroid Build Coastguard Worker {
7595*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7596*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7597*8975f5c5SAndroid Build Coastguard Worker     programObject->validate(mState.getCaps());
7598*8975f5c5SAndroid Build Coastguard Worker }
7599*8975f5c5SAndroid Build Coastguard Worker 
validateProgramPipeline(ProgramPipelineID pipeline)7600*8975f5c5SAndroid Build Coastguard Worker void Context::validateProgramPipeline(ProgramPipelineID pipeline)
7601*8975f5c5SAndroid Build Coastguard Worker {
7602*8975f5c5SAndroid Build Coastguard Worker     // GLES spec 3.2, Section 7.4 "Program Pipeline Objects"
7603*8975f5c5SAndroid Build Coastguard Worker     // If pipeline is a name that has been generated (without subsequent deletion) by
7604*8975f5c5SAndroid Build Coastguard Worker     // GenProgramPipelines, but refers to a program pipeline object that has not been
7605*8975f5c5SAndroid Build Coastguard Worker     // previously bound, the GL first creates a new state vector in the same manner as
7606*8975f5c5SAndroid Build Coastguard Worker     // when BindProgramPipeline creates a new program pipeline object.
7607*8975f5c5SAndroid Build Coastguard Worker     //
7608*8975f5c5SAndroid Build Coastguard Worker     // void BindProgramPipeline( uint pipeline );
7609*8975f5c5SAndroid Build Coastguard Worker     // pipeline is the program pipeline object name. The resulting program pipeline
7610*8975f5c5SAndroid Build Coastguard Worker     // object is a new state vector, comprising all the state and with the same initial values
7611*8975f5c5SAndroid Build Coastguard Worker     // listed in table 21.20.
7612*8975f5c5SAndroid Build Coastguard Worker     //
7613*8975f5c5SAndroid Build Coastguard Worker     // If we do not have a pipeline object that's been created with glBindProgramPipeline, we leave
7614*8975f5c5SAndroid Build Coastguard Worker     // VALIDATE_STATUS at it's default false value without generating a pipeline object.
7615*8975f5c5SAndroid Build Coastguard Worker     if (!getProgramPipeline(pipeline))
7616*8975f5c5SAndroid Build Coastguard Worker     {
7617*8975f5c5SAndroid Build Coastguard Worker         return;
7618*8975f5c5SAndroid Build Coastguard Worker     }
7619*8975f5c5SAndroid Build Coastguard Worker 
7620*8975f5c5SAndroid Build Coastguard Worker     ProgramPipeline *programPipeline =
7621*8975f5c5SAndroid Build Coastguard Worker         mState.mProgramPipelineManager->checkProgramPipelineAllocation(mImplementation.get(),
7622*8975f5c5SAndroid Build Coastguard Worker                                                                        pipeline);
7623*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programPipeline);
7624*8975f5c5SAndroid Build Coastguard Worker 
7625*8975f5c5SAndroid Build Coastguard Worker     programPipeline->validate(this);
7626*8975f5c5SAndroid Build Coastguard Worker }
7627*8975f5c5SAndroid Build Coastguard Worker 
getProgramBinary(ShaderProgramID program,GLsizei bufSize,GLsizei * length,GLenum * binaryFormat,void * binary)7628*8975f5c5SAndroid Build Coastguard Worker void Context::getProgramBinary(ShaderProgramID program,
7629*8975f5c5SAndroid Build Coastguard Worker                                GLsizei bufSize,
7630*8975f5c5SAndroid Build Coastguard Worker                                GLsizei *length,
7631*8975f5c5SAndroid Build Coastguard Worker                                GLenum *binaryFormat,
7632*8975f5c5SAndroid Build Coastguard Worker                                void *binary)
7633*8975f5c5SAndroid Build Coastguard Worker {
7634*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7635*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject != nullptr);
7636*8975f5c5SAndroid Build Coastguard Worker 
7637*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(programObject->getBinary(this, binaryFormat, binary, bufSize, length));
7638*8975f5c5SAndroid Build Coastguard Worker }
7639*8975f5c5SAndroid Build Coastguard Worker 
programBinary(ShaderProgramID program,GLenum binaryFormat,const void * binary,GLsizei length)7640*8975f5c5SAndroid Build Coastguard Worker void Context::programBinary(ShaderProgramID program,
7641*8975f5c5SAndroid Build Coastguard Worker                             GLenum binaryFormat,
7642*8975f5c5SAndroid Build Coastguard Worker                             const void *binary,
7643*8975f5c5SAndroid Build Coastguard Worker                             GLsizei length)
7644*8975f5c5SAndroid Build Coastguard Worker {
7645*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7646*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject != nullptr);
7647*8975f5c5SAndroid Build Coastguard Worker 
7648*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(programObject->setBinary(this, binaryFormat, binary, length));
7649*8975f5c5SAndroid Build Coastguard Worker }
7650*8975f5c5SAndroid Build Coastguard Worker 
uniform1ui(UniformLocation location,GLuint v0)7651*8975f5c5SAndroid Build Coastguard Worker void Context::uniform1ui(UniformLocation location, GLuint v0)
7652*8975f5c5SAndroid Build Coastguard Worker {
7653*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7654*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform1uiv(location, 1, &v0);
7655*8975f5c5SAndroid Build Coastguard Worker }
7656*8975f5c5SAndroid Build Coastguard Worker 
uniform2ui(UniformLocation location,GLuint v0,GLuint v1)7657*8975f5c5SAndroid Build Coastguard Worker void Context::uniform2ui(UniformLocation location, GLuint v0, GLuint v1)
7658*8975f5c5SAndroid Build Coastguard Worker {
7659*8975f5c5SAndroid Build Coastguard Worker     Program *program  = getActiveLinkedProgram();
7660*8975f5c5SAndroid Build Coastguard Worker     const GLuint xy[] = {v0, v1};
7661*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform2uiv(location, 1, xy);
7662*8975f5c5SAndroid Build Coastguard Worker }
7663*8975f5c5SAndroid Build Coastguard Worker 
uniform3ui(UniformLocation location,GLuint v0,GLuint v1,GLuint v2)7664*8975f5c5SAndroid Build Coastguard Worker void Context::uniform3ui(UniformLocation location, GLuint v0, GLuint v1, GLuint v2)
7665*8975f5c5SAndroid Build Coastguard Worker {
7666*8975f5c5SAndroid Build Coastguard Worker     Program *program   = getActiveLinkedProgram();
7667*8975f5c5SAndroid Build Coastguard Worker     const GLuint xyz[] = {v0, v1, v2};
7668*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform3uiv(location, 1, xyz);
7669*8975f5c5SAndroid Build Coastguard Worker }
7670*8975f5c5SAndroid Build Coastguard Worker 
uniform4ui(UniformLocation location,GLuint v0,GLuint v1,GLuint v2,GLuint v3)7671*8975f5c5SAndroid Build Coastguard Worker void Context::uniform4ui(UniformLocation location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
7672*8975f5c5SAndroid Build Coastguard Worker {
7673*8975f5c5SAndroid Build Coastguard Worker     Program *program    = getActiveLinkedProgram();
7674*8975f5c5SAndroid Build Coastguard Worker     const GLuint xyzw[] = {v0, v1, v2, v3};
7675*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform4uiv(location, 1, xyzw);
7676*8975f5c5SAndroid Build Coastguard Worker }
7677*8975f5c5SAndroid Build Coastguard Worker 
uniform1uiv(UniformLocation location,GLsizei count,const GLuint * value)7678*8975f5c5SAndroid Build Coastguard Worker void Context::uniform1uiv(UniformLocation location, GLsizei count, const GLuint *value)
7679*8975f5c5SAndroid Build Coastguard Worker {
7680*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7681*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform1uiv(location, count, value);
7682*8975f5c5SAndroid Build Coastguard Worker }
uniform2uiv(UniformLocation location,GLsizei count,const GLuint * value)7683*8975f5c5SAndroid Build Coastguard Worker void Context::uniform2uiv(UniformLocation location, GLsizei count, const GLuint *value)
7684*8975f5c5SAndroid Build Coastguard Worker {
7685*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7686*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform2uiv(location, count, value);
7687*8975f5c5SAndroid Build Coastguard Worker }
7688*8975f5c5SAndroid Build Coastguard Worker 
uniform3uiv(UniformLocation location,GLsizei count,const GLuint * value)7689*8975f5c5SAndroid Build Coastguard Worker void Context::uniform3uiv(UniformLocation location, GLsizei count, const GLuint *value)
7690*8975f5c5SAndroid Build Coastguard Worker {
7691*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7692*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform3uiv(location, count, value);
7693*8975f5c5SAndroid Build Coastguard Worker }
7694*8975f5c5SAndroid Build Coastguard Worker 
uniform4uiv(UniformLocation location,GLsizei count,const GLuint * value)7695*8975f5c5SAndroid Build Coastguard Worker void Context::uniform4uiv(UniformLocation location, GLsizei count, const GLuint *value)
7696*8975f5c5SAndroid Build Coastguard Worker {
7697*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7698*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniform4uiv(location, count, value);
7699*8975f5c5SAndroid Build Coastguard Worker }
7700*8975f5c5SAndroid Build Coastguard Worker 
genQueries(GLsizei n,QueryID * ids)7701*8975f5c5SAndroid Build Coastguard Worker void Context::genQueries(GLsizei n, QueryID *ids)
7702*8975f5c5SAndroid Build Coastguard Worker {
7703*8975f5c5SAndroid Build Coastguard Worker     for (GLsizei i = 0; i < n; i++)
7704*8975f5c5SAndroid Build Coastguard Worker     {
7705*8975f5c5SAndroid Build Coastguard Worker         QueryID handle = QueryID{mQueryHandleAllocator.allocate()};
7706*8975f5c5SAndroid Build Coastguard Worker         mQueryMap.assign(handle, nullptr);
7707*8975f5c5SAndroid Build Coastguard Worker         ids[i] = handle;
7708*8975f5c5SAndroid Build Coastguard Worker     }
7709*8975f5c5SAndroid Build Coastguard Worker }
7710*8975f5c5SAndroid Build Coastguard Worker 
deleteQueries(GLsizei n,const QueryID * ids)7711*8975f5c5SAndroid Build Coastguard Worker void Context::deleteQueries(GLsizei n, const QueryID *ids)
7712*8975f5c5SAndroid Build Coastguard Worker {
7713*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
7714*8975f5c5SAndroid Build Coastguard Worker     {
7715*8975f5c5SAndroid Build Coastguard Worker         QueryID query = ids[i];
7716*8975f5c5SAndroid Build Coastguard Worker 
7717*8975f5c5SAndroid Build Coastguard Worker         Query *queryObject = nullptr;
7718*8975f5c5SAndroid Build Coastguard Worker         if (mQueryMap.erase(query, &queryObject))
7719*8975f5c5SAndroid Build Coastguard Worker         {
7720*8975f5c5SAndroid Build Coastguard Worker             mQueryHandleAllocator.release(query.value);
7721*8975f5c5SAndroid Build Coastguard Worker             if (queryObject)
7722*8975f5c5SAndroid Build Coastguard Worker             {
7723*8975f5c5SAndroid Build Coastguard Worker                 queryObject->release(this);
7724*8975f5c5SAndroid Build Coastguard Worker             }
7725*8975f5c5SAndroid Build Coastguard Worker         }
7726*8975f5c5SAndroid Build Coastguard Worker     }
7727*8975f5c5SAndroid Build Coastguard Worker }
7728*8975f5c5SAndroid Build Coastguard Worker 
isQueryGenerated(QueryID query) const7729*8975f5c5SAndroid Build Coastguard Worker bool Context::isQueryGenerated(QueryID query) const
7730*8975f5c5SAndroid Build Coastguard Worker {
7731*8975f5c5SAndroid Build Coastguard Worker     return mQueryMap.contains(query);
7732*8975f5c5SAndroid Build Coastguard Worker }
7733*8975f5c5SAndroid Build Coastguard Worker 
isQuery(QueryID id) const7734*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isQuery(QueryID id) const
7735*8975f5c5SAndroid Build Coastguard Worker {
7736*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getQuery(id) != nullptr);
7737*8975f5c5SAndroid Build Coastguard Worker }
7738*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix2x3fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7739*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix2x3fv(UniformLocation location,
7740*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
7741*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean transpose,
7742*8975f5c5SAndroid Build Coastguard Worker                                  const GLfloat *value)
7743*8975f5c5SAndroid Build Coastguard Worker {
7744*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7745*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix2x3fv(location, count, transpose, value);
7746*8975f5c5SAndroid Build Coastguard Worker }
7747*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix3x2fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7748*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix3x2fv(UniformLocation location,
7749*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
7750*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean transpose,
7751*8975f5c5SAndroid Build Coastguard Worker                                  const GLfloat *value)
7752*8975f5c5SAndroid Build Coastguard Worker {
7753*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7754*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix3x2fv(location, count, transpose, value);
7755*8975f5c5SAndroid Build Coastguard Worker }
7756*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix2x4fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7757*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix2x4fv(UniformLocation location,
7758*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
7759*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean transpose,
7760*8975f5c5SAndroid Build Coastguard Worker                                  const GLfloat *value)
7761*8975f5c5SAndroid Build Coastguard Worker {
7762*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7763*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix2x4fv(location, count, transpose, value);
7764*8975f5c5SAndroid Build Coastguard Worker }
7765*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix4x2fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7766*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix4x2fv(UniformLocation location,
7767*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
7768*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean transpose,
7769*8975f5c5SAndroid Build Coastguard Worker                                  const GLfloat *value)
7770*8975f5c5SAndroid Build Coastguard Worker {
7771*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7772*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix4x2fv(location, count, transpose, value);
7773*8975f5c5SAndroid Build Coastguard Worker }
7774*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix3x4fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7775*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix3x4fv(UniformLocation location,
7776*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
7777*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean transpose,
7778*8975f5c5SAndroid Build Coastguard Worker                                  const GLfloat *value)
7779*8975f5c5SAndroid Build Coastguard Worker {
7780*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7781*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix3x4fv(location, count, transpose, value);
7782*8975f5c5SAndroid Build Coastguard Worker }
7783*8975f5c5SAndroid Build Coastguard Worker 
uniformMatrix4x3fv(UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)7784*8975f5c5SAndroid Build Coastguard Worker void Context::uniformMatrix4x3fv(UniformLocation location,
7785*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
7786*8975f5c5SAndroid Build Coastguard Worker                                  GLboolean transpose,
7787*8975f5c5SAndroid Build Coastguard Worker                                  const GLfloat *value)
7788*8975f5c5SAndroid Build Coastguard Worker {
7789*8975f5c5SAndroid Build Coastguard Worker     Program *program = getActiveLinkedProgram();
7790*8975f5c5SAndroid Build Coastguard Worker     program->getExecutable().setUniformMatrix4x3fv(location, count, transpose, value);
7791*8975f5c5SAndroid Build Coastguard Worker }
7792*8975f5c5SAndroid Build Coastguard Worker 
deleteVertexArrays(GLsizei n,const VertexArrayID * arrays)7793*8975f5c5SAndroid Build Coastguard Worker void Context::deleteVertexArrays(GLsizei n, const VertexArrayID *arrays)
7794*8975f5c5SAndroid Build Coastguard Worker {
7795*8975f5c5SAndroid Build Coastguard Worker     for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
7796*8975f5c5SAndroid Build Coastguard Worker     {
7797*8975f5c5SAndroid Build Coastguard Worker         VertexArrayID vertexArray = arrays[arrayIndex];
7798*8975f5c5SAndroid Build Coastguard Worker 
7799*8975f5c5SAndroid Build Coastguard Worker         if (arrays[arrayIndex].value != 0)
7800*8975f5c5SAndroid Build Coastguard Worker         {
7801*8975f5c5SAndroid Build Coastguard Worker             VertexArray *vertexArrayObject = nullptr;
7802*8975f5c5SAndroid Build Coastguard Worker             if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject))
7803*8975f5c5SAndroid Build Coastguard Worker             {
7804*8975f5c5SAndroid Build Coastguard Worker                 if (vertexArrayObject != nullptr)
7805*8975f5c5SAndroid Build Coastguard Worker                 {
7806*8975f5c5SAndroid Build Coastguard Worker                     detachVertexArray(vertexArray);
7807*8975f5c5SAndroid Build Coastguard Worker                     vertexArrayObject->onDestroy(this);
7808*8975f5c5SAndroid Build Coastguard Worker                 }
7809*8975f5c5SAndroid Build Coastguard Worker 
7810*8975f5c5SAndroid Build Coastguard Worker                 mVertexArrayHandleAllocator.release(vertexArray.value);
7811*8975f5c5SAndroid Build Coastguard Worker             }
7812*8975f5c5SAndroid Build Coastguard Worker         }
7813*8975f5c5SAndroid Build Coastguard Worker     }
7814*8975f5c5SAndroid Build Coastguard Worker }
7815*8975f5c5SAndroid Build Coastguard Worker 
genVertexArrays(GLsizei n,VertexArrayID * arrays)7816*8975f5c5SAndroid Build Coastguard Worker void Context::genVertexArrays(GLsizei n, VertexArrayID *arrays)
7817*8975f5c5SAndroid Build Coastguard Worker {
7818*8975f5c5SAndroid Build Coastguard Worker     for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
7819*8975f5c5SAndroid Build Coastguard Worker     {
7820*8975f5c5SAndroid Build Coastguard Worker         VertexArrayID vertexArray = {mVertexArrayHandleAllocator.allocate()};
7821*8975f5c5SAndroid Build Coastguard Worker         mVertexArrayMap.assign(vertexArray, nullptr);
7822*8975f5c5SAndroid Build Coastguard Worker         arrays[arrayIndex] = vertexArray;
7823*8975f5c5SAndroid Build Coastguard Worker     }
7824*8975f5c5SAndroid Build Coastguard Worker }
7825*8975f5c5SAndroid Build Coastguard Worker 
isVertexArray(VertexArrayID array) const7826*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isVertexArray(VertexArrayID array) const
7827*8975f5c5SAndroid Build Coastguard Worker {
7828*8975f5c5SAndroid Build Coastguard Worker     if (array.value == 0)
7829*8975f5c5SAndroid Build Coastguard Worker     {
7830*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7831*8975f5c5SAndroid Build Coastguard Worker     }
7832*8975f5c5SAndroid Build Coastguard Worker 
7833*8975f5c5SAndroid Build Coastguard Worker     VertexArray *vao = getVertexArray(array);
7834*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(vao != nullptr);
7835*8975f5c5SAndroid Build Coastguard Worker }
7836*8975f5c5SAndroid Build Coastguard Worker 
endTransformFeedback()7837*8975f5c5SAndroid Build Coastguard Worker void Context::endTransformFeedback()
7838*8975f5c5SAndroid Build Coastguard Worker {
7839*8975f5c5SAndroid Build Coastguard Worker     TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback();
7840*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(transformFeedback->end(this));
7841*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTransformFeedbackChange(this);
7842*8975f5c5SAndroid Build Coastguard Worker }
7843*8975f5c5SAndroid Build Coastguard Worker 
transformFeedbackVaryings(ShaderProgramID program,GLsizei count,const GLchar * const * varyings,GLenum bufferMode)7844*8975f5c5SAndroid Build Coastguard Worker void Context::transformFeedbackVaryings(ShaderProgramID program,
7845*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei count,
7846*8975f5c5SAndroid Build Coastguard Worker                                         const GLchar *const *varyings,
7847*8975f5c5SAndroid Build Coastguard Worker                                         GLenum bufferMode)
7848*8975f5c5SAndroid Build Coastguard Worker {
7849*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7850*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7851*8975f5c5SAndroid Build Coastguard Worker     programObject->setTransformFeedbackVaryings(this, count, varyings, bufferMode);
7852*8975f5c5SAndroid Build Coastguard Worker }
7853*8975f5c5SAndroid Build Coastguard Worker 
getTransformFeedbackVarying(ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLsizei * size,GLenum * type,GLchar * name)7854*8975f5c5SAndroid Build Coastguard Worker void Context::getTransformFeedbackVarying(ShaderProgramID program,
7855*8975f5c5SAndroid Build Coastguard Worker                                           GLuint index,
7856*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei bufSize,
7857*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei *length,
7858*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei *size,
7859*8975f5c5SAndroid Build Coastguard Worker                                           GLenum *type,
7860*8975f5c5SAndroid Build Coastguard Worker                                           GLchar *name)
7861*8975f5c5SAndroid Build Coastguard Worker {
7862*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
7863*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
7864*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getTransformFeedbackVarying(index, bufSize, length, size, type,
7865*8975f5c5SAndroid Build Coastguard Worker                                                                name);
7866*8975f5c5SAndroid Build Coastguard Worker }
7867*8975f5c5SAndroid Build Coastguard Worker 
deleteTransformFeedbacks(GLsizei n,const TransformFeedbackID * ids)7868*8975f5c5SAndroid Build Coastguard Worker void Context::deleteTransformFeedbacks(GLsizei n, const TransformFeedbackID *ids)
7869*8975f5c5SAndroid Build Coastguard Worker {
7870*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
7871*8975f5c5SAndroid Build Coastguard Worker     {
7872*8975f5c5SAndroid Build Coastguard Worker         TransformFeedbackID transformFeedback = ids[i];
7873*8975f5c5SAndroid Build Coastguard Worker         if (transformFeedback.value == 0)
7874*8975f5c5SAndroid Build Coastguard Worker         {
7875*8975f5c5SAndroid Build Coastguard Worker             continue;
7876*8975f5c5SAndroid Build Coastguard Worker         }
7877*8975f5c5SAndroid Build Coastguard Worker 
7878*8975f5c5SAndroid Build Coastguard Worker         TransformFeedback *transformFeedbackObject = nullptr;
7879*8975f5c5SAndroid Build Coastguard Worker         if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject))
7880*8975f5c5SAndroid Build Coastguard Worker         {
7881*8975f5c5SAndroid Build Coastguard Worker             if (transformFeedbackObject != nullptr)
7882*8975f5c5SAndroid Build Coastguard Worker             {
7883*8975f5c5SAndroid Build Coastguard Worker                 detachTransformFeedback(transformFeedback);
7884*8975f5c5SAndroid Build Coastguard Worker                 transformFeedbackObject->release(this);
7885*8975f5c5SAndroid Build Coastguard Worker             }
7886*8975f5c5SAndroid Build Coastguard Worker 
7887*8975f5c5SAndroid Build Coastguard Worker             mTransformFeedbackHandleAllocator.release(transformFeedback.value);
7888*8975f5c5SAndroid Build Coastguard Worker         }
7889*8975f5c5SAndroid Build Coastguard Worker     }
7890*8975f5c5SAndroid Build Coastguard Worker }
7891*8975f5c5SAndroid Build Coastguard Worker 
genTransformFeedbacks(GLsizei n,TransformFeedbackID * ids)7892*8975f5c5SAndroid Build Coastguard Worker void Context::genTransformFeedbacks(GLsizei n, TransformFeedbackID *ids)
7893*8975f5c5SAndroid Build Coastguard Worker {
7894*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
7895*8975f5c5SAndroid Build Coastguard Worker     {
7896*8975f5c5SAndroid Build Coastguard Worker         TransformFeedbackID transformFeedback = {mTransformFeedbackHandleAllocator.allocate()};
7897*8975f5c5SAndroid Build Coastguard Worker         mTransformFeedbackMap.assign(transformFeedback, nullptr);
7898*8975f5c5SAndroid Build Coastguard Worker         ids[i] = transformFeedback;
7899*8975f5c5SAndroid Build Coastguard Worker     }
7900*8975f5c5SAndroid Build Coastguard Worker }
7901*8975f5c5SAndroid Build Coastguard Worker 
isTransformFeedback(TransformFeedbackID id) const7902*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isTransformFeedback(TransformFeedbackID id) const
7903*8975f5c5SAndroid Build Coastguard Worker {
7904*8975f5c5SAndroid Build Coastguard Worker     if (id.value == 0)
7905*8975f5c5SAndroid Build Coastguard Worker     {
7906*8975f5c5SAndroid Build Coastguard Worker         // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback
7907*8975f5c5SAndroid Build Coastguard Worker         // returns FALSE
7908*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
7909*8975f5c5SAndroid Build Coastguard Worker     }
7910*8975f5c5SAndroid Build Coastguard Worker 
7911*8975f5c5SAndroid Build Coastguard Worker     const TransformFeedback *transformFeedback = getTransformFeedback(id);
7912*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(transformFeedback != nullptr);
7913*8975f5c5SAndroid Build Coastguard Worker }
7914*8975f5c5SAndroid Build Coastguard Worker 
pauseTransformFeedback()7915*8975f5c5SAndroid Build Coastguard Worker void Context::pauseTransformFeedback()
7916*8975f5c5SAndroid Build Coastguard Worker {
7917*8975f5c5SAndroid Build Coastguard Worker     TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback();
7918*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(transformFeedback->pause(this));
7919*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTransformFeedbackChange(this);
7920*8975f5c5SAndroid Build Coastguard Worker }
7921*8975f5c5SAndroid Build Coastguard Worker 
resumeTransformFeedback()7922*8975f5c5SAndroid Build Coastguard Worker void Context::resumeTransformFeedback()
7923*8975f5c5SAndroid Build Coastguard Worker {
7924*8975f5c5SAndroid Build Coastguard Worker     TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback();
7925*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(transformFeedback->resume(this));
7926*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onActiveTransformFeedbackChange(this);
7927*8975f5c5SAndroid Build Coastguard Worker }
7928*8975f5c5SAndroid Build Coastguard Worker 
getUniformuiv(ShaderProgramID program,UniformLocation location,GLuint * params)7929*8975f5c5SAndroid Build Coastguard Worker void Context::getUniformuiv(ShaderProgramID program, UniformLocation location, GLuint *params)
7930*8975f5c5SAndroid Build Coastguard Worker {
7931*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
7932*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getUniformuiv(this, location, params);
7933*8975f5c5SAndroid Build Coastguard Worker }
7934*8975f5c5SAndroid Build Coastguard Worker 
getUniformuivRobust(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLsizei * length,GLuint * params)7935*8975f5c5SAndroid Build Coastguard Worker void Context::getUniformuivRobust(ShaderProgramID program,
7936*8975f5c5SAndroid Build Coastguard Worker                                   UniformLocation location,
7937*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
7938*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei *length,
7939*8975f5c5SAndroid Build Coastguard Worker                                   GLuint *params)
7940*8975f5c5SAndroid Build Coastguard Worker {
7941*8975f5c5SAndroid Build Coastguard Worker     getUniformuiv(program, location, params);
7942*8975f5c5SAndroid Build Coastguard Worker }
7943*8975f5c5SAndroid Build Coastguard Worker 
getFragDataLocation(ShaderProgramID program,const GLchar * name)7944*8975f5c5SAndroid Build Coastguard Worker GLint Context::getFragDataLocation(ShaderProgramID program, const GLchar *name)
7945*8975f5c5SAndroid Build Coastguard Worker {
7946*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
7947*8975f5c5SAndroid Build Coastguard Worker     return programObject->getExecutable().getFragDataLocation(name);
7948*8975f5c5SAndroid Build Coastguard Worker }
7949*8975f5c5SAndroid Build Coastguard Worker 
getUniformIndices(ShaderProgramID program,GLsizei uniformCount,const GLchar * const * uniformNames,GLuint * uniformIndices)7950*8975f5c5SAndroid Build Coastguard Worker void Context::getUniformIndices(ShaderProgramID program,
7951*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei uniformCount,
7952*8975f5c5SAndroid Build Coastguard Worker                                 const GLchar *const *uniformNames,
7953*8975f5c5SAndroid Build Coastguard Worker                                 GLuint *uniformIndices)
7954*8975f5c5SAndroid Build Coastguard Worker {
7955*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
7956*8975f5c5SAndroid Build Coastguard Worker     if (!programObject->isLinked())
7957*8975f5c5SAndroid Build Coastguard Worker     {
7958*8975f5c5SAndroid Build Coastguard Worker         for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7959*8975f5c5SAndroid Build Coastguard Worker         {
7960*8975f5c5SAndroid Build Coastguard Worker             uniformIndices[uniformId] = GL_INVALID_INDEX;
7961*8975f5c5SAndroid Build Coastguard Worker         }
7962*8975f5c5SAndroid Build Coastguard Worker     }
7963*8975f5c5SAndroid Build Coastguard Worker     else
7964*8975f5c5SAndroid Build Coastguard Worker     {
7965*8975f5c5SAndroid Build Coastguard Worker         for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7966*8975f5c5SAndroid Build Coastguard Worker         {
7967*8975f5c5SAndroid Build Coastguard Worker             uniformIndices[uniformId] =
7968*8975f5c5SAndroid Build Coastguard Worker                 programObject->getExecutable().getUniformIndex(uniformNames[uniformId]);
7969*8975f5c5SAndroid Build Coastguard Worker         }
7970*8975f5c5SAndroid Build Coastguard Worker     }
7971*8975f5c5SAndroid Build Coastguard Worker }
7972*8975f5c5SAndroid Build Coastguard Worker 
getActiveUniformsiv(ShaderProgramID program,GLsizei uniformCount,const GLuint * uniformIndices,GLenum pname,GLint * params)7973*8975f5c5SAndroid Build Coastguard Worker void Context::getActiveUniformsiv(ShaderProgramID program,
7974*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei uniformCount,
7975*8975f5c5SAndroid Build Coastguard Worker                                   const GLuint *uniformIndices,
7976*8975f5c5SAndroid Build Coastguard Worker                                   GLenum pname,
7977*8975f5c5SAndroid Build Coastguard Worker                                   GLint *params)
7978*8975f5c5SAndroid Build Coastguard Worker {
7979*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
7980*8975f5c5SAndroid Build Coastguard Worker     for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7981*8975f5c5SAndroid Build Coastguard Worker     {
7982*8975f5c5SAndroid Build Coastguard Worker         const GLuint index = uniformIndices[uniformId];
7983*8975f5c5SAndroid Build Coastguard Worker         params[uniformId]  = GetUniformResourceProperty(programObject, index, pname);
7984*8975f5c5SAndroid Build Coastguard Worker     }
7985*8975f5c5SAndroid Build Coastguard Worker }
7986*8975f5c5SAndroid Build Coastguard Worker 
getUniformBlockIndex(ShaderProgramID program,const GLchar * uniformBlockName)7987*8975f5c5SAndroid Build Coastguard Worker GLuint Context::getUniformBlockIndex(ShaderProgramID program, const GLchar *uniformBlockName)
7988*8975f5c5SAndroid Build Coastguard Worker {
7989*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
7990*8975f5c5SAndroid Build Coastguard Worker     return programObject->getExecutable().getUniformBlockIndex(uniformBlockName);
7991*8975f5c5SAndroid Build Coastguard Worker }
7992*8975f5c5SAndroid Build Coastguard Worker 
getActiveUniformBlockiv(ShaderProgramID program,UniformBlockIndex uniformBlockIndex,GLenum pname,GLint * params)7993*8975f5c5SAndroid Build Coastguard Worker void Context::getActiveUniformBlockiv(ShaderProgramID program,
7994*8975f5c5SAndroid Build Coastguard Worker                                       UniformBlockIndex uniformBlockIndex,
7995*8975f5c5SAndroid Build Coastguard Worker                                       GLenum pname,
7996*8975f5c5SAndroid Build Coastguard Worker                                       GLint *params)
7997*8975f5c5SAndroid Build Coastguard Worker {
7998*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
7999*8975f5c5SAndroid Build Coastguard Worker     QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params);
8000*8975f5c5SAndroid Build Coastguard Worker }
8001*8975f5c5SAndroid Build Coastguard Worker 
getActiveUniformBlockivRobust(ShaderProgramID program,UniformBlockIndex uniformBlockIndex,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)8002*8975f5c5SAndroid Build Coastguard Worker void Context::getActiveUniformBlockivRobust(ShaderProgramID program,
8003*8975f5c5SAndroid Build Coastguard Worker                                             UniformBlockIndex uniformBlockIndex,
8004*8975f5c5SAndroid Build Coastguard Worker                                             GLenum pname,
8005*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei bufSize,
8006*8975f5c5SAndroid Build Coastguard Worker                                             GLsizei *length,
8007*8975f5c5SAndroid Build Coastguard Worker                                             GLint *params)
8008*8975f5c5SAndroid Build Coastguard Worker {
8009*8975f5c5SAndroid Build Coastguard Worker     getActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
8010*8975f5c5SAndroid Build Coastguard Worker }
8011*8975f5c5SAndroid Build Coastguard Worker 
getActiveUniformBlockName(ShaderProgramID program,UniformBlockIndex uniformBlockIndex,GLsizei bufSize,GLsizei * length,GLchar * uniformBlockName)8012*8975f5c5SAndroid Build Coastguard Worker void Context::getActiveUniformBlockName(ShaderProgramID program,
8013*8975f5c5SAndroid Build Coastguard Worker                                         UniformBlockIndex uniformBlockIndex,
8014*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
8015*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
8016*8975f5c5SAndroid Build Coastguard Worker                                         GLchar *uniformBlockName)
8017*8975f5c5SAndroid Build Coastguard Worker {
8018*8975f5c5SAndroid Build Coastguard Worker     const Program *programObject = getProgramResolveLink(program);
8019*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getActiveUniformBlockName(this, uniformBlockIndex, bufSize,
8020*8975f5c5SAndroid Build Coastguard Worker                                                              length, uniformBlockName);
8021*8975f5c5SAndroid Build Coastguard Worker }
8022*8975f5c5SAndroid Build Coastguard Worker 
uniformBlockBinding(ShaderProgramID program,UniformBlockIndex uniformBlockIndex,GLuint uniformBlockBinding)8023*8975f5c5SAndroid Build Coastguard Worker void Context::uniformBlockBinding(ShaderProgramID program,
8024*8975f5c5SAndroid Build Coastguard Worker                                   UniformBlockIndex uniformBlockIndex,
8025*8975f5c5SAndroid Build Coastguard Worker                                   GLuint uniformBlockBinding)
8026*8975f5c5SAndroid Build Coastguard Worker {
8027*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8028*8975f5c5SAndroid Build Coastguard Worker     programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
8029*8975f5c5SAndroid Build Coastguard Worker }
8030*8975f5c5SAndroid Build Coastguard Worker 
fenceSync(GLenum condition,GLbitfield flags)8031*8975f5c5SAndroid Build Coastguard Worker GLsync Context::fenceSync(GLenum condition, GLbitfield flags)
8032*8975f5c5SAndroid Build Coastguard Worker {
8033*8975f5c5SAndroid Build Coastguard Worker     SyncID syncHandle = mState.mSyncManager->createSync(mImplementation.get());
8034*8975f5c5SAndroid Build Coastguard Worker     Sync *syncObject  = getSync(syncHandle);
8035*8975f5c5SAndroid Build Coastguard Worker     if (syncObject->set(this, condition, flags) == angle::Result::Stop)
8036*8975f5c5SAndroid Build Coastguard Worker     {
8037*8975f5c5SAndroid Build Coastguard Worker         deleteSync(syncHandle);
8038*8975f5c5SAndroid Build Coastguard Worker         return nullptr;
8039*8975f5c5SAndroid Build Coastguard Worker     }
8040*8975f5c5SAndroid Build Coastguard Worker 
8041*8975f5c5SAndroid Build Coastguard Worker     return unsafe_int_to_pointer_cast<GLsync>(syncHandle.value);
8042*8975f5c5SAndroid Build Coastguard Worker }
8043*8975f5c5SAndroid Build Coastguard Worker 
isSync(SyncID syncPacked) const8044*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isSync(SyncID syncPacked) const
8045*8975f5c5SAndroid Build Coastguard Worker {
8046*8975f5c5SAndroid Build Coastguard Worker     return (getSync(syncPacked) != nullptr);
8047*8975f5c5SAndroid Build Coastguard Worker }
8048*8975f5c5SAndroid Build Coastguard Worker 
clientWaitSync(SyncID syncPacked,GLbitfield flags,GLuint64 timeout)8049*8975f5c5SAndroid Build Coastguard Worker GLenum Context::clientWaitSync(SyncID syncPacked, GLbitfield flags, GLuint64 timeout)
8050*8975f5c5SAndroid Build Coastguard Worker {
8051*8975f5c5SAndroid Build Coastguard Worker     Sync *syncObject = getSync(syncPacked);
8052*8975f5c5SAndroid Build Coastguard Worker 
8053*8975f5c5SAndroid Build Coastguard Worker     GLenum result = GL_WAIT_FAILED;
8054*8975f5c5SAndroid Build Coastguard Worker     if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop)
8055*8975f5c5SAndroid Build Coastguard Worker     {
8056*8975f5c5SAndroid Build Coastguard Worker         return GL_WAIT_FAILED;
8057*8975f5c5SAndroid Build Coastguard Worker     }
8058*8975f5c5SAndroid Build Coastguard Worker     return result;
8059*8975f5c5SAndroid Build Coastguard Worker }
8060*8975f5c5SAndroid Build Coastguard Worker 
waitSync(SyncID syncPacked,GLbitfield flags,GLuint64 timeout)8061*8975f5c5SAndroid Build Coastguard Worker void Context::waitSync(SyncID syncPacked, GLbitfield flags, GLuint64 timeout)
8062*8975f5c5SAndroid Build Coastguard Worker {
8063*8975f5c5SAndroid Build Coastguard Worker     Sync *syncObject = getSync(syncPacked);
8064*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout));
8065*8975f5c5SAndroid Build Coastguard Worker }
8066*8975f5c5SAndroid Build Coastguard Worker 
getInteger64v(GLenum pname,GLint64 * params)8067*8975f5c5SAndroid Build Coastguard Worker void Context::getInteger64v(GLenum pname, GLint64 *params)
8068*8975f5c5SAndroid Build Coastguard Worker {
8069*8975f5c5SAndroid Build Coastguard Worker     GLenum nativeType      = GL_NONE;
8070*8975f5c5SAndroid Build Coastguard Worker     unsigned int numParams = 0;
8071*8975f5c5SAndroid Build Coastguard Worker     getQueryParameterInfo(pname, &nativeType, &numParams);
8072*8975f5c5SAndroid Build Coastguard Worker 
8073*8975f5c5SAndroid Build Coastguard Worker     if (nativeType == GL_INT_64_ANGLEX)
8074*8975f5c5SAndroid Build Coastguard Worker     {
8075*8975f5c5SAndroid Build Coastguard Worker         getInteger64vImpl(pname, params);
8076*8975f5c5SAndroid Build Coastguard Worker     }
8077*8975f5c5SAndroid Build Coastguard Worker     else
8078*8975f5c5SAndroid Build Coastguard Worker     {
8079*8975f5c5SAndroid Build Coastguard Worker         CastStateValues(this, nativeType, pname, numParams, params);
8080*8975f5c5SAndroid Build Coastguard Worker     }
8081*8975f5c5SAndroid Build Coastguard Worker }
8082*8975f5c5SAndroid Build Coastguard Worker 
getInteger64vRobust(GLenum pname,GLsizei bufSize,GLsizei * length,GLint64 * data)8083*8975f5c5SAndroid Build Coastguard Worker void Context::getInteger64vRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint64 *data)
8084*8975f5c5SAndroid Build Coastguard Worker {
8085*8975f5c5SAndroid Build Coastguard Worker     getInteger64v(pname, data);
8086*8975f5c5SAndroid Build Coastguard Worker }
8087*8975f5c5SAndroid Build Coastguard Worker 
getBufferParameteri64v(BufferBinding target,GLenum pname,GLint64 * params)8088*8975f5c5SAndroid Build Coastguard Worker void Context::getBufferParameteri64v(BufferBinding target, GLenum pname, GLint64 *params)
8089*8975f5c5SAndroid Build Coastguard Worker {
8090*8975f5c5SAndroid Build Coastguard Worker     Buffer *buffer = mState.getTargetBuffer(target);
8091*8975f5c5SAndroid Build Coastguard Worker     QueryBufferParameteri64v(buffer, pname, params);
8092*8975f5c5SAndroid Build Coastguard Worker }
8093*8975f5c5SAndroid Build Coastguard Worker 
getBufferParameteri64vRobust(BufferBinding target,GLenum pname,GLsizei bufSize,GLsizei * length,GLint64 * params)8094*8975f5c5SAndroid Build Coastguard Worker void Context::getBufferParameteri64vRobust(BufferBinding target,
8095*8975f5c5SAndroid Build Coastguard Worker                                            GLenum pname,
8096*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei bufSize,
8097*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei *length,
8098*8975f5c5SAndroid Build Coastguard Worker                                            GLint64 *params)
8099*8975f5c5SAndroid Build Coastguard Worker {
8100*8975f5c5SAndroid Build Coastguard Worker     getBufferParameteri64v(target, pname, params);
8101*8975f5c5SAndroid Build Coastguard Worker }
8102*8975f5c5SAndroid Build Coastguard Worker 
genSamplers(GLsizei count,SamplerID * samplers)8103*8975f5c5SAndroid Build Coastguard Worker void Context::genSamplers(GLsizei count, SamplerID *samplers)
8104*8975f5c5SAndroid Build Coastguard Worker {
8105*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < count; i++)
8106*8975f5c5SAndroid Build Coastguard Worker     {
8107*8975f5c5SAndroid Build Coastguard Worker         samplers[i] = mState.mSamplerManager->createSampler();
8108*8975f5c5SAndroid Build Coastguard Worker     }
8109*8975f5c5SAndroid Build Coastguard Worker }
8110*8975f5c5SAndroid Build Coastguard Worker 
deleteSamplers(GLsizei count,const SamplerID * samplers)8111*8975f5c5SAndroid Build Coastguard Worker void Context::deleteSamplers(GLsizei count, const SamplerID *samplers)
8112*8975f5c5SAndroid Build Coastguard Worker {
8113*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < count; i++)
8114*8975f5c5SAndroid Build Coastguard Worker     {
8115*8975f5c5SAndroid Build Coastguard Worker         SamplerID sampler = samplers[i];
8116*8975f5c5SAndroid Build Coastguard Worker 
8117*8975f5c5SAndroid Build Coastguard Worker         if (mState.mSamplerManager->getSampler(sampler))
8118*8975f5c5SAndroid Build Coastguard Worker         {
8119*8975f5c5SAndroid Build Coastguard Worker             detachSampler(sampler);
8120*8975f5c5SAndroid Build Coastguard Worker         }
8121*8975f5c5SAndroid Build Coastguard Worker 
8122*8975f5c5SAndroid Build Coastguard Worker         mState.mSamplerManager->deleteObject(this, sampler);
8123*8975f5c5SAndroid Build Coastguard Worker     }
8124*8975f5c5SAndroid Build Coastguard Worker }
8125*8975f5c5SAndroid Build Coastguard Worker 
getInternalformativ(GLenum target,GLenum internalformat,GLenum pname,GLsizei bufSize,GLint * params)8126*8975f5c5SAndroid Build Coastguard Worker void Context::getInternalformativ(GLenum target,
8127*8975f5c5SAndroid Build Coastguard Worker                                   GLenum internalformat,
8128*8975f5c5SAndroid Build Coastguard Worker                                   GLenum pname,
8129*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
8130*8975f5c5SAndroid Build Coastguard Worker                                   GLint *params)
8131*8975f5c5SAndroid Build Coastguard Worker {
8132*8975f5c5SAndroid Build Coastguard Worker     Texture *texture    = nullptr;
8133*8975f5c5SAndroid Build Coastguard Worker     TextureType textype = FromGLenum<TextureType>(target);
8134*8975f5c5SAndroid Build Coastguard Worker     if (textype != TextureType::InvalidEnum)
8135*8975f5c5SAndroid Build Coastguard Worker     {
8136*8975f5c5SAndroid Build Coastguard Worker         texture = getTextureByType(textype);
8137*8975f5c5SAndroid Build Coastguard Worker     }
8138*8975f5c5SAndroid Build Coastguard Worker     const TextureCaps &formatCaps = mState.getTextureCap(internalformat);
8139*8975f5c5SAndroid Build Coastguard Worker     QueryInternalFormativ(this, texture, internalformat, formatCaps, pname, bufSize, params);
8140*8975f5c5SAndroid Build Coastguard Worker }
8141*8975f5c5SAndroid Build Coastguard Worker 
getInternalformativRobust(GLenum target,GLenum internalformat,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)8142*8975f5c5SAndroid Build Coastguard Worker void Context::getInternalformativRobust(GLenum target,
8143*8975f5c5SAndroid Build Coastguard Worker                                         GLenum internalformat,
8144*8975f5c5SAndroid Build Coastguard Worker                                         GLenum pname,
8145*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
8146*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
8147*8975f5c5SAndroid Build Coastguard Worker                                         GLint *params)
8148*8975f5c5SAndroid Build Coastguard Worker {
8149*8975f5c5SAndroid Build Coastguard Worker     getInternalformativ(target, internalformat, pname, bufSize, params);
8150*8975f5c5SAndroid Build Coastguard Worker }
8151*8975f5c5SAndroid Build Coastguard Worker 
programUniform1i(ShaderProgramID program,UniformLocation location,GLint v0)8152*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform1i(ShaderProgramID program, UniformLocation location, GLint v0)
8153*8975f5c5SAndroid Build Coastguard Worker {
8154*8975f5c5SAndroid Build Coastguard Worker     programUniform1iv(program, location, 1, &v0);
8155*8975f5c5SAndroid Build Coastguard Worker }
8156*8975f5c5SAndroid Build Coastguard Worker 
programUniform2i(ShaderProgramID program,UniformLocation location,GLint v0,GLint v1)8157*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform2i(ShaderProgramID program,
8158*8975f5c5SAndroid Build Coastguard Worker                                UniformLocation location,
8159*8975f5c5SAndroid Build Coastguard Worker                                GLint v0,
8160*8975f5c5SAndroid Build Coastguard Worker                                GLint v1)
8161*8975f5c5SAndroid Build Coastguard Worker {
8162*8975f5c5SAndroid Build Coastguard Worker     GLint xy[2] = {v0, v1};
8163*8975f5c5SAndroid Build Coastguard Worker     programUniform2iv(program, location, 1, xy);
8164*8975f5c5SAndroid Build Coastguard Worker }
8165*8975f5c5SAndroid Build Coastguard Worker 
programUniform3i(ShaderProgramID program,UniformLocation location,GLint v0,GLint v1,GLint v2)8166*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform3i(ShaderProgramID program,
8167*8975f5c5SAndroid Build Coastguard Worker                                UniformLocation location,
8168*8975f5c5SAndroid Build Coastguard Worker                                GLint v0,
8169*8975f5c5SAndroid Build Coastguard Worker                                GLint v1,
8170*8975f5c5SAndroid Build Coastguard Worker                                GLint v2)
8171*8975f5c5SAndroid Build Coastguard Worker {
8172*8975f5c5SAndroid Build Coastguard Worker     GLint xyz[3] = {v0, v1, v2};
8173*8975f5c5SAndroid Build Coastguard Worker     programUniform3iv(program, location, 1, xyz);
8174*8975f5c5SAndroid Build Coastguard Worker }
8175*8975f5c5SAndroid Build Coastguard Worker 
programUniform4i(ShaderProgramID program,UniformLocation location,GLint v0,GLint v1,GLint v2,GLint v3)8176*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform4i(ShaderProgramID program,
8177*8975f5c5SAndroid Build Coastguard Worker                                UniformLocation location,
8178*8975f5c5SAndroid Build Coastguard Worker                                GLint v0,
8179*8975f5c5SAndroid Build Coastguard Worker                                GLint v1,
8180*8975f5c5SAndroid Build Coastguard Worker                                GLint v2,
8181*8975f5c5SAndroid Build Coastguard Worker                                GLint v3)
8182*8975f5c5SAndroid Build Coastguard Worker {
8183*8975f5c5SAndroid Build Coastguard Worker     GLint xyzw[4] = {v0, v1, v2, v3};
8184*8975f5c5SAndroid Build Coastguard Worker     programUniform4iv(program, location, 1, xyzw);
8185*8975f5c5SAndroid Build Coastguard Worker }
8186*8975f5c5SAndroid Build Coastguard Worker 
programUniform1ui(ShaderProgramID program,UniformLocation location,GLuint v0)8187*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform1ui(ShaderProgramID program, UniformLocation location, GLuint v0)
8188*8975f5c5SAndroid Build Coastguard Worker {
8189*8975f5c5SAndroid Build Coastguard Worker     programUniform1uiv(program, location, 1, &v0);
8190*8975f5c5SAndroid Build Coastguard Worker }
8191*8975f5c5SAndroid Build Coastguard Worker 
programUniform2ui(ShaderProgramID program,UniformLocation location,GLuint v0,GLuint v1)8192*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform2ui(ShaderProgramID program,
8193*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8194*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v0,
8195*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v1)
8196*8975f5c5SAndroid Build Coastguard Worker {
8197*8975f5c5SAndroid Build Coastguard Worker     GLuint xy[2] = {v0, v1};
8198*8975f5c5SAndroid Build Coastguard Worker     programUniform2uiv(program, location, 1, xy);
8199*8975f5c5SAndroid Build Coastguard Worker }
8200*8975f5c5SAndroid Build Coastguard Worker 
programUniform3ui(ShaderProgramID program,UniformLocation location,GLuint v0,GLuint v1,GLuint v2)8201*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform3ui(ShaderProgramID program,
8202*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8203*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v0,
8204*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v1,
8205*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v2)
8206*8975f5c5SAndroid Build Coastguard Worker {
8207*8975f5c5SAndroid Build Coastguard Worker     GLuint xyz[3] = {v0, v1, v2};
8208*8975f5c5SAndroid Build Coastguard Worker     programUniform3uiv(program, location, 1, xyz);
8209*8975f5c5SAndroid Build Coastguard Worker }
8210*8975f5c5SAndroid Build Coastguard Worker 
programUniform4ui(ShaderProgramID program,UniformLocation location,GLuint v0,GLuint v1,GLuint v2,GLuint v3)8211*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform4ui(ShaderProgramID program,
8212*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8213*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v0,
8214*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v1,
8215*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v2,
8216*8975f5c5SAndroid Build Coastguard Worker                                 GLuint v3)
8217*8975f5c5SAndroid Build Coastguard Worker {
8218*8975f5c5SAndroid Build Coastguard Worker     GLuint xyzw[4] = {v0, v1, v2, v3};
8219*8975f5c5SAndroid Build Coastguard Worker     programUniform4uiv(program, location, 1, xyzw);
8220*8975f5c5SAndroid Build Coastguard Worker }
8221*8975f5c5SAndroid Build Coastguard Worker 
programUniform1f(ShaderProgramID program,UniformLocation location,GLfloat v0)8222*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform1f(ShaderProgramID program, UniformLocation location, GLfloat v0)
8223*8975f5c5SAndroid Build Coastguard Worker {
8224*8975f5c5SAndroid Build Coastguard Worker     programUniform1fv(program, location, 1, &v0);
8225*8975f5c5SAndroid Build Coastguard Worker }
8226*8975f5c5SAndroid Build Coastguard Worker 
programUniform2f(ShaderProgramID program,UniformLocation location,GLfloat v0,GLfloat v1)8227*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform2f(ShaderProgramID program,
8228*8975f5c5SAndroid Build Coastguard Worker                                UniformLocation location,
8229*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v0,
8230*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v1)
8231*8975f5c5SAndroid Build Coastguard Worker {
8232*8975f5c5SAndroid Build Coastguard Worker     GLfloat xy[2] = {v0, v1};
8233*8975f5c5SAndroid Build Coastguard Worker     programUniform2fv(program, location, 1, xy);
8234*8975f5c5SAndroid Build Coastguard Worker }
8235*8975f5c5SAndroid Build Coastguard Worker 
programUniform3f(ShaderProgramID program,UniformLocation location,GLfloat v0,GLfloat v1,GLfloat v2)8236*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform3f(ShaderProgramID program,
8237*8975f5c5SAndroid Build Coastguard Worker                                UniformLocation location,
8238*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v0,
8239*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v1,
8240*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v2)
8241*8975f5c5SAndroid Build Coastguard Worker {
8242*8975f5c5SAndroid Build Coastguard Worker     GLfloat xyz[3] = {v0, v1, v2};
8243*8975f5c5SAndroid Build Coastguard Worker     programUniform3fv(program, location, 1, xyz);
8244*8975f5c5SAndroid Build Coastguard Worker }
8245*8975f5c5SAndroid Build Coastguard Worker 
programUniform4f(ShaderProgramID program,UniformLocation location,GLfloat v0,GLfloat v1,GLfloat v2,GLfloat v3)8246*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform4f(ShaderProgramID program,
8247*8975f5c5SAndroid Build Coastguard Worker                                UniformLocation location,
8248*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v0,
8249*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v1,
8250*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v2,
8251*8975f5c5SAndroid Build Coastguard Worker                                GLfloat v3)
8252*8975f5c5SAndroid Build Coastguard Worker {
8253*8975f5c5SAndroid Build Coastguard Worker     GLfloat xyzw[4] = {v0, v1, v2, v3};
8254*8975f5c5SAndroid Build Coastguard Worker     programUniform4fv(program, location, 1, xyzw);
8255*8975f5c5SAndroid Build Coastguard Worker }
8256*8975f5c5SAndroid Build Coastguard Worker 
programUniform1iv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLint * value)8257*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform1iv(ShaderProgramID program,
8258*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8259*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8260*8975f5c5SAndroid Build Coastguard Worker                                 const GLint *value)
8261*8975f5c5SAndroid Build Coastguard Worker {
8262*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8263*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8264*8975f5c5SAndroid Build Coastguard Worker     setUniform1iImpl(programObject, location, count, value);
8265*8975f5c5SAndroid Build Coastguard Worker }
8266*8975f5c5SAndroid Build Coastguard Worker 
programUniform2iv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLint * value)8267*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform2iv(ShaderProgramID program,
8268*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8269*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8270*8975f5c5SAndroid Build Coastguard Worker                                 const GLint *value)
8271*8975f5c5SAndroid Build Coastguard Worker {
8272*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8273*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8274*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform2iv(location, count, value);
8275*8975f5c5SAndroid Build Coastguard Worker }
8276*8975f5c5SAndroid Build Coastguard Worker 
programUniform3iv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLint * value)8277*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform3iv(ShaderProgramID program,
8278*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8279*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8280*8975f5c5SAndroid Build Coastguard Worker                                 const GLint *value)
8281*8975f5c5SAndroid Build Coastguard Worker {
8282*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8283*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8284*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform3iv(location, count, value);
8285*8975f5c5SAndroid Build Coastguard Worker }
8286*8975f5c5SAndroid Build Coastguard Worker 
programUniform4iv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLint * value)8287*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform4iv(ShaderProgramID program,
8288*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8289*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8290*8975f5c5SAndroid Build Coastguard Worker                                 const GLint *value)
8291*8975f5c5SAndroid Build Coastguard Worker {
8292*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8293*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8294*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform4iv(location, count, value);
8295*8975f5c5SAndroid Build Coastguard Worker }
8296*8975f5c5SAndroid Build Coastguard Worker 
programUniform1uiv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLuint * value)8297*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform1uiv(ShaderProgramID program,
8298*8975f5c5SAndroid Build Coastguard Worker                                  UniformLocation location,
8299*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
8300*8975f5c5SAndroid Build Coastguard Worker                                  const GLuint *value)
8301*8975f5c5SAndroid Build Coastguard Worker {
8302*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8303*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8304*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform1uiv(location, count, value);
8305*8975f5c5SAndroid Build Coastguard Worker }
8306*8975f5c5SAndroid Build Coastguard Worker 
programUniform2uiv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLuint * value)8307*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform2uiv(ShaderProgramID program,
8308*8975f5c5SAndroid Build Coastguard Worker                                  UniformLocation location,
8309*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
8310*8975f5c5SAndroid Build Coastguard Worker                                  const GLuint *value)
8311*8975f5c5SAndroid Build Coastguard Worker {
8312*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8313*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8314*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform2uiv(location, count, value);
8315*8975f5c5SAndroid Build Coastguard Worker }
8316*8975f5c5SAndroid Build Coastguard Worker 
programUniform3uiv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLuint * value)8317*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform3uiv(ShaderProgramID program,
8318*8975f5c5SAndroid Build Coastguard Worker                                  UniformLocation location,
8319*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
8320*8975f5c5SAndroid Build Coastguard Worker                                  const GLuint *value)
8321*8975f5c5SAndroid Build Coastguard Worker {
8322*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8323*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8324*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform3uiv(location, count, value);
8325*8975f5c5SAndroid Build Coastguard Worker }
8326*8975f5c5SAndroid Build Coastguard Worker 
programUniform4uiv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLuint * value)8327*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform4uiv(ShaderProgramID program,
8328*8975f5c5SAndroid Build Coastguard Worker                                  UniformLocation location,
8329*8975f5c5SAndroid Build Coastguard Worker                                  GLsizei count,
8330*8975f5c5SAndroid Build Coastguard Worker                                  const GLuint *value)
8331*8975f5c5SAndroid Build Coastguard Worker {
8332*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8333*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8334*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform4uiv(location, count, value);
8335*8975f5c5SAndroid Build Coastguard Worker }
8336*8975f5c5SAndroid Build Coastguard Worker 
programUniform1fv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLfloat * value)8337*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform1fv(ShaderProgramID program,
8338*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8339*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8340*8975f5c5SAndroid Build Coastguard Worker                                 const GLfloat *value)
8341*8975f5c5SAndroid Build Coastguard Worker {
8342*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8343*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8344*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform1fv(location, count, value);
8345*8975f5c5SAndroid Build Coastguard Worker }
8346*8975f5c5SAndroid Build Coastguard Worker 
programUniform2fv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLfloat * value)8347*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform2fv(ShaderProgramID program,
8348*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8349*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8350*8975f5c5SAndroid Build Coastguard Worker                                 const GLfloat *value)
8351*8975f5c5SAndroid Build Coastguard Worker {
8352*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8353*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8354*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform2fv(location, count, value);
8355*8975f5c5SAndroid Build Coastguard Worker }
8356*8975f5c5SAndroid Build Coastguard Worker 
programUniform3fv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLfloat * value)8357*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform3fv(ShaderProgramID program,
8358*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8359*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8360*8975f5c5SAndroid Build Coastguard Worker                                 const GLfloat *value)
8361*8975f5c5SAndroid Build Coastguard Worker {
8362*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8363*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8364*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform3fv(location, count, value);
8365*8975f5c5SAndroid Build Coastguard Worker }
8366*8975f5c5SAndroid Build Coastguard Worker 
programUniform4fv(ShaderProgramID program,UniformLocation location,GLsizei count,const GLfloat * value)8367*8975f5c5SAndroid Build Coastguard Worker void Context::programUniform4fv(ShaderProgramID program,
8368*8975f5c5SAndroid Build Coastguard Worker                                 UniformLocation location,
8369*8975f5c5SAndroid Build Coastguard Worker                                 GLsizei count,
8370*8975f5c5SAndroid Build Coastguard Worker                                 const GLfloat *value)
8371*8975f5c5SAndroid Build Coastguard Worker {
8372*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8373*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8374*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniform4fv(location, count, value);
8375*8975f5c5SAndroid Build Coastguard Worker }
8376*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix2fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8377*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix2fv(ShaderProgramID program,
8378*8975f5c5SAndroid Build Coastguard Worker                                       UniformLocation location,
8379*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei count,
8380*8975f5c5SAndroid Build Coastguard Worker                                       GLboolean transpose,
8381*8975f5c5SAndroid Build Coastguard Worker                                       const GLfloat *value)
8382*8975f5c5SAndroid Build Coastguard Worker {
8383*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8384*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8385*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix2fv(location, count, transpose, value);
8386*8975f5c5SAndroid Build Coastguard Worker }
8387*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix3fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8388*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix3fv(ShaderProgramID program,
8389*8975f5c5SAndroid Build Coastguard Worker                                       UniformLocation location,
8390*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei count,
8391*8975f5c5SAndroid Build Coastguard Worker                                       GLboolean transpose,
8392*8975f5c5SAndroid Build Coastguard Worker                                       const GLfloat *value)
8393*8975f5c5SAndroid Build Coastguard Worker {
8394*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8395*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8396*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix3fv(location, count, transpose, value);
8397*8975f5c5SAndroid Build Coastguard Worker }
8398*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix4fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8399*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix4fv(ShaderProgramID program,
8400*8975f5c5SAndroid Build Coastguard Worker                                       UniformLocation location,
8401*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei count,
8402*8975f5c5SAndroid Build Coastguard Worker                                       GLboolean transpose,
8403*8975f5c5SAndroid Build Coastguard Worker                                       const GLfloat *value)
8404*8975f5c5SAndroid Build Coastguard Worker {
8405*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8406*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8407*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix4fv(location, count, transpose, value);
8408*8975f5c5SAndroid Build Coastguard Worker }
8409*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix2x3fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8410*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix2x3fv(ShaderProgramID program,
8411*8975f5c5SAndroid Build Coastguard Worker                                         UniformLocation location,
8412*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei count,
8413*8975f5c5SAndroid Build Coastguard Worker                                         GLboolean transpose,
8414*8975f5c5SAndroid Build Coastguard Worker                                         const GLfloat *value)
8415*8975f5c5SAndroid Build Coastguard Worker {
8416*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8417*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8418*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix2x3fv(location, count, transpose, value);
8419*8975f5c5SAndroid Build Coastguard Worker }
8420*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix3x2fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8421*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix3x2fv(ShaderProgramID program,
8422*8975f5c5SAndroid Build Coastguard Worker                                         UniformLocation location,
8423*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei count,
8424*8975f5c5SAndroid Build Coastguard Worker                                         GLboolean transpose,
8425*8975f5c5SAndroid Build Coastguard Worker                                         const GLfloat *value)
8426*8975f5c5SAndroid Build Coastguard Worker {
8427*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8428*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8429*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix3x2fv(location, count, transpose, value);
8430*8975f5c5SAndroid Build Coastguard Worker }
8431*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix2x4fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8432*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix2x4fv(ShaderProgramID program,
8433*8975f5c5SAndroid Build Coastguard Worker                                         UniformLocation location,
8434*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei count,
8435*8975f5c5SAndroid Build Coastguard Worker                                         GLboolean transpose,
8436*8975f5c5SAndroid Build Coastguard Worker                                         const GLfloat *value)
8437*8975f5c5SAndroid Build Coastguard Worker {
8438*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8439*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8440*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix2x4fv(location, count, transpose, value);
8441*8975f5c5SAndroid Build Coastguard Worker }
8442*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix4x2fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8443*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix4x2fv(ShaderProgramID program,
8444*8975f5c5SAndroid Build Coastguard Worker                                         UniformLocation location,
8445*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei count,
8446*8975f5c5SAndroid Build Coastguard Worker                                         GLboolean transpose,
8447*8975f5c5SAndroid Build Coastguard Worker                                         const GLfloat *value)
8448*8975f5c5SAndroid Build Coastguard Worker {
8449*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8450*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8451*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix4x2fv(location, count, transpose, value);
8452*8975f5c5SAndroid Build Coastguard Worker }
8453*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix3x4fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8454*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix3x4fv(ShaderProgramID program,
8455*8975f5c5SAndroid Build Coastguard Worker                                         UniformLocation location,
8456*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei count,
8457*8975f5c5SAndroid Build Coastguard Worker                                         GLboolean transpose,
8458*8975f5c5SAndroid Build Coastguard Worker                                         const GLfloat *value)
8459*8975f5c5SAndroid Build Coastguard Worker {
8460*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8461*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8462*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix3x4fv(location, count, transpose, value);
8463*8975f5c5SAndroid Build Coastguard Worker }
8464*8975f5c5SAndroid Build Coastguard Worker 
programUniformMatrix4x3fv(ShaderProgramID program,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value)8465*8975f5c5SAndroid Build Coastguard Worker void Context::programUniformMatrix4x3fv(ShaderProgramID program,
8466*8975f5c5SAndroid Build Coastguard Worker                                         UniformLocation location,
8467*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei count,
8468*8975f5c5SAndroid Build Coastguard Worker                                         GLboolean transpose,
8469*8975f5c5SAndroid Build Coastguard Worker                                         const GLfloat *value)
8470*8975f5c5SAndroid Build Coastguard Worker {
8471*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8472*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8473*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().setUniformMatrix4x3fv(location, count, transpose, value);
8474*8975f5c5SAndroid Build Coastguard Worker }
8475*8975f5c5SAndroid Build Coastguard Worker 
isCurrentTransformFeedback(const TransformFeedback * tf) const8476*8975f5c5SAndroid Build Coastguard Worker bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const
8477*8975f5c5SAndroid Build Coastguard Worker {
8478*8975f5c5SAndroid Build Coastguard Worker     return mState.isCurrentTransformFeedback(tf);
8479*8975f5c5SAndroid Build Coastguard Worker }
8480*8975f5c5SAndroid Build Coastguard Worker 
genProgramPipelines(GLsizei count,ProgramPipelineID * pipelines)8481*8975f5c5SAndroid Build Coastguard Worker void Context::genProgramPipelines(GLsizei count, ProgramPipelineID *pipelines)
8482*8975f5c5SAndroid Build Coastguard Worker {
8483*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < count; i++)
8484*8975f5c5SAndroid Build Coastguard Worker     {
8485*8975f5c5SAndroid Build Coastguard Worker         pipelines[i] = createProgramPipeline();
8486*8975f5c5SAndroid Build Coastguard Worker     }
8487*8975f5c5SAndroid Build Coastguard Worker }
8488*8975f5c5SAndroid Build Coastguard Worker 
deleteProgramPipelines(GLsizei count,const ProgramPipelineID * pipelines)8489*8975f5c5SAndroid Build Coastguard Worker void Context::deleteProgramPipelines(GLsizei count, const ProgramPipelineID *pipelines)
8490*8975f5c5SAndroid Build Coastguard Worker {
8491*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < count; i++)
8492*8975f5c5SAndroid Build Coastguard Worker     {
8493*8975f5c5SAndroid Build Coastguard Worker         if (pipelines[i].value != 0)
8494*8975f5c5SAndroid Build Coastguard Worker         {
8495*8975f5c5SAndroid Build Coastguard Worker             deleteProgramPipeline(pipelines[i]);
8496*8975f5c5SAndroid Build Coastguard Worker         }
8497*8975f5c5SAndroid Build Coastguard Worker     }
8498*8975f5c5SAndroid Build Coastguard Worker }
8499*8975f5c5SAndroid Build Coastguard Worker 
isProgramPipeline(ProgramPipelineID pipeline) const8500*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isProgramPipeline(ProgramPipelineID pipeline) const
8501*8975f5c5SAndroid Build Coastguard Worker {
8502*8975f5c5SAndroid Build Coastguard Worker     if (pipeline.value == 0)
8503*8975f5c5SAndroid Build Coastguard Worker     {
8504*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
8505*8975f5c5SAndroid Build Coastguard Worker     }
8506*8975f5c5SAndroid Build Coastguard Worker 
8507*8975f5c5SAndroid Build Coastguard Worker     if (getProgramPipeline(pipeline))
8508*8975f5c5SAndroid Build Coastguard Worker     {
8509*8975f5c5SAndroid Build Coastguard Worker         return GL_TRUE;
8510*8975f5c5SAndroid Build Coastguard Worker     }
8511*8975f5c5SAndroid Build Coastguard Worker 
8512*8975f5c5SAndroid Build Coastguard Worker     return GL_FALSE;
8513*8975f5c5SAndroid Build Coastguard Worker }
8514*8975f5c5SAndroid Build Coastguard Worker 
finishFenceNV(FenceNVID fence)8515*8975f5c5SAndroid Build Coastguard Worker void Context::finishFenceNV(FenceNVID fence)
8516*8975f5c5SAndroid Build Coastguard Worker {
8517*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = getFenceNV(fence);
8518*8975f5c5SAndroid Build Coastguard Worker 
8519*8975f5c5SAndroid Build Coastguard Worker     ASSERT(fenceObject && fenceObject->isSet());
8520*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(fenceObject->finish(this));
8521*8975f5c5SAndroid Build Coastguard Worker }
8522*8975f5c5SAndroid Build Coastguard Worker 
getFenceivNV(FenceNVID fence,GLenum pname,GLint * params)8523*8975f5c5SAndroid Build Coastguard Worker void Context::getFenceivNV(FenceNVID fence, GLenum pname, GLint *params)
8524*8975f5c5SAndroid Build Coastguard Worker {
8525*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = getFenceNV(fence);
8526*8975f5c5SAndroid Build Coastguard Worker 
8527*8975f5c5SAndroid Build Coastguard Worker     ASSERT(fenceObject && fenceObject->isSet());
8528*8975f5c5SAndroid Build Coastguard Worker 
8529*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
8530*8975f5c5SAndroid Build Coastguard Worker     {
8531*8975f5c5SAndroid Build Coastguard Worker         case GL_FENCE_STATUS_NV:
8532*8975f5c5SAndroid Build Coastguard Worker         {
8533*8975f5c5SAndroid Build Coastguard Worker             // GL_NV_fence spec:
8534*8975f5c5SAndroid Build Coastguard Worker             // Once the status of a fence has been finished (via FinishFenceNV) or tested and
8535*8975f5c5SAndroid Build Coastguard Worker             // the returned status is TRUE (via either TestFenceNV or GetFenceivNV querying the
8536*8975f5c5SAndroid Build Coastguard Worker             // FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
8537*8975f5c5SAndroid Build Coastguard Worker             GLboolean status = GL_TRUE;
8538*8975f5c5SAndroid Build Coastguard Worker             if (fenceObject->getStatus() != GL_TRUE)
8539*8975f5c5SAndroid Build Coastguard Worker             {
8540*8975f5c5SAndroid Build Coastguard Worker                 ANGLE_CONTEXT_TRY(fenceObject->test(this, &status));
8541*8975f5c5SAndroid Build Coastguard Worker             }
8542*8975f5c5SAndroid Build Coastguard Worker             *params = status;
8543*8975f5c5SAndroid Build Coastguard Worker             break;
8544*8975f5c5SAndroid Build Coastguard Worker         }
8545*8975f5c5SAndroid Build Coastguard Worker 
8546*8975f5c5SAndroid Build Coastguard Worker         case GL_FENCE_CONDITION_NV:
8547*8975f5c5SAndroid Build Coastguard Worker         {
8548*8975f5c5SAndroid Build Coastguard Worker             *params = static_cast<GLint>(fenceObject->getCondition());
8549*8975f5c5SAndroid Build Coastguard Worker             break;
8550*8975f5c5SAndroid Build Coastguard Worker         }
8551*8975f5c5SAndroid Build Coastguard Worker 
8552*8975f5c5SAndroid Build Coastguard Worker         default:
8553*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
8554*8975f5c5SAndroid Build Coastguard Worker     }
8555*8975f5c5SAndroid Build Coastguard Worker }
8556*8975f5c5SAndroid Build Coastguard Worker 
getTranslatedShaderSource(ShaderProgramID shader,GLsizei bufsize,GLsizei * length,GLchar * source)8557*8975f5c5SAndroid Build Coastguard Worker void Context::getTranslatedShaderSource(ShaderProgramID shader,
8558*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufsize,
8559*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
8560*8975f5c5SAndroid Build Coastguard Worker                                         GLchar *source)
8561*8975f5c5SAndroid Build Coastguard Worker {
8562*8975f5c5SAndroid Build Coastguard Worker     Shader *shaderObject = getShaderNoResolveCompile(shader);
8563*8975f5c5SAndroid Build Coastguard Worker     ASSERT(shaderObject);
8564*8975f5c5SAndroid Build Coastguard Worker     shaderObject->getTranslatedSourceWithDebugInfo(this, bufsize, length, source);
8565*8975f5c5SAndroid Build Coastguard Worker }
8566*8975f5c5SAndroid Build Coastguard Worker 
getnUniformfv(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLfloat * params)8567*8975f5c5SAndroid Build Coastguard Worker void Context::getnUniformfv(ShaderProgramID program,
8568*8975f5c5SAndroid Build Coastguard Worker                             UniformLocation location,
8569*8975f5c5SAndroid Build Coastguard Worker                             GLsizei bufSize,
8570*8975f5c5SAndroid Build Coastguard Worker                             GLfloat *params)
8571*8975f5c5SAndroid Build Coastguard Worker {
8572*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8573*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8574*8975f5c5SAndroid Build Coastguard Worker 
8575*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getUniformfv(this, location, params);
8576*8975f5c5SAndroid Build Coastguard Worker }
8577*8975f5c5SAndroid Build Coastguard Worker 
getnUniformfvRobust(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLsizei * length,GLfloat * params)8578*8975f5c5SAndroid Build Coastguard Worker void Context::getnUniformfvRobust(ShaderProgramID program,
8579*8975f5c5SAndroid Build Coastguard Worker                                   UniformLocation location,
8580*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
8581*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei *length,
8582*8975f5c5SAndroid Build Coastguard Worker                                   GLfloat *params)
8583*8975f5c5SAndroid Build Coastguard Worker {
8584*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8585*8975f5c5SAndroid Build Coastguard Worker }
8586*8975f5c5SAndroid Build Coastguard Worker 
getnUniformiv(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLint * params)8587*8975f5c5SAndroid Build Coastguard Worker void Context::getnUniformiv(ShaderProgramID program,
8588*8975f5c5SAndroid Build Coastguard Worker                             UniformLocation location,
8589*8975f5c5SAndroid Build Coastguard Worker                             GLsizei bufSize,
8590*8975f5c5SAndroid Build Coastguard Worker                             GLint *params)
8591*8975f5c5SAndroid Build Coastguard Worker {
8592*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8593*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8594*8975f5c5SAndroid Build Coastguard Worker 
8595*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getUniformiv(this, location, params);
8596*8975f5c5SAndroid Build Coastguard Worker }
8597*8975f5c5SAndroid Build Coastguard Worker 
getnUniformuiv(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLuint * params)8598*8975f5c5SAndroid Build Coastguard Worker void Context::getnUniformuiv(ShaderProgramID program,
8599*8975f5c5SAndroid Build Coastguard Worker                              UniformLocation location,
8600*8975f5c5SAndroid Build Coastguard Worker                              GLsizei bufSize,
8601*8975f5c5SAndroid Build Coastguard Worker                              GLuint *params)
8602*8975f5c5SAndroid Build Coastguard Worker {
8603*8975f5c5SAndroid Build Coastguard Worker     Program *programObject = getProgramResolveLink(program);
8604*8975f5c5SAndroid Build Coastguard Worker     ASSERT(programObject);
8605*8975f5c5SAndroid Build Coastguard Worker 
8606*8975f5c5SAndroid Build Coastguard Worker     programObject->getExecutable().getUniformuiv(this, location, params);
8607*8975f5c5SAndroid Build Coastguard Worker }
8608*8975f5c5SAndroid Build Coastguard Worker 
getnUniformivRobust(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLsizei * length,GLint * params)8609*8975f5c5SAndroid Build Coastguard Worker void Context::getnUniformivRobust(ShaderProgramID program,
8610*8975f5c5SAndroid Build Coastguard Worker                                   UniformLocation location,
8611*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei bufSize,
8612*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei *length,
8613*8975f5c5SAndroid Build Coastguard Worker                                   GLint *params)
8614*8975f5c5SAndroid Build Coastguard Worker {
8615*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8616*8975f5c5SAndroid Build Coastguard Worker }
8617*8975f5c5SAndroid Build Coastguard Worker 
getnUniformuivRobust(ShaderProgramID program,UniformLocation location,GLsizei bufSize,GLsizei * length,GLuint * params)8618*8975f5c5SAndroid Build Coastguard Worker void Context::getnUniformuivRobust(ShaderProgramID program,
8619*8975f5c5SAndroid Build Coastguard Worker                                    UniformLocation location,
8620*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei bufSize,
8621*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei *length,
8622*8975f5c5SAndroid Build Coastguard Worker                                    GLuint *params)
8623*8975f5c5SAndroid Build Coastguard Worker {
8624*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8625*8975f5c5SAndroid Build Coastguard Worker }
8626*8975f5c5SAndroid Build Coastguard Worker 
isFenceNV(FenceNVID fence) const8627*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isFenceNV(FenceNVID fence) const
8628*8975f5c5SAndroid Build Coastguard Worker {
8629*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = getFenceNV(fence);
8630*8975f5c5SAndroid Build Coastguard Worker 
8631*8975f5c5SAndroid Build Coastguard Worker     if (fenceObject == nullptr)
8632*8975f5c5SAndroid Build Coastguard Worker     {
8633*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
8634*8975f5c5SAndroid Build Coastguard Worker     }
8635*8975f5c5SAndroid Build Coastguard Worker 
8636*8975f5c5SAndroid Build Coastguard Worker     // GL_NV_fence spec:
8637*8975f5c5SAndroid Build Coastguard Worker     // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an
8638*8975f5c5SAndroid Build Coastguard Worker     // existing fence.
8639*8975f5c5SAndroid Build Coastguard Worker     return fenceObject->isSet();
8640*8975f5c5SAndroid Build Coastguard Worker }
8641*8975f5c5SAndroid Build Coastguard Worker 
readnPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,void * data)8642*8975f5c5SAndroid Build Coastguard Worker void Context::readnPixels(GLint x,
8643*8975f5c5SAndroid Build Coastguard Worker                           GLint y,
8644*8975f5c5SAndroid Build Coastguard Worker                           GLsizei width,
8645*8975f5c5SAndroid Build Coastguard Worker                           GLsizei height,
8646*8975f5c5SAndroid Build Coastguard Worker                           GLenum format,
8647*8975f5c5SAndroid Build Coastguard Worker                           GLenum type,
8648*8975f5c5SAndroid Build Coastguard Worker                           GLsizei bufSize,
8649*8975f5c5SAndroid Build Coastguard Worker                           void *data)
8650*8975f5c5SAndroid Build Coastguard Worker {
8651*8975f5c5SAndroid Build Coastguard Worker     return readPixels(x, y, width, height, format, type, data);
8652*8975f5c5SAndroid Build Coastguard Worker }
8653*8975f5c5SAndroid Build Coastguard Worker 
setFenceNV(FenceNVID fence,GLenum condition)8654*8975f5c5SAndroid Build Coastguard Worker void Context::setFenceNV(FenceNVID fence, GLenum condition)
8655*8975f5c5SAndroid Build Coastguard Worker {
8656*8975f5c5SAndroid Build Coastguard Worker     ASSERT(condition == GL_ALL_COMPLETED_NV);
8657*8975f5c5SAndroid Build Coastguard Worker 
8658*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = getFenceNV(fence);
8659*8975f5c5SAndroid Build Coastguard Worker     ASSERT(fenceObject != nullptr);
8660*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(fenceObject->set(this, condition));
8661*8975f5c5SAndroid Build Coastguard Worker }
8662*8975f5c5SAndroid Build Coastguard Worker 
testFenceNV(FenceNVID fence)8663*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::testFenceNV(FenceNVID fence)
8664*8975f5c5SAndroid Build Coastguard Worker {
8665*8975f5c5SAndroid Build Coastguard Worker     FenceNV *fenceObject = getFenceNV(fence);
8666*8975f5c5SAndroid Build Coastguard Worker 
8667*8975f5c5SAndroid Build Coastguard Worker     ASSERT(fenceObject != nullptr);
8668*8975f5c5SAndroid Build Coastguard Worker     ASSERT(fenceObject->isSet() == GL_TRUE);
8669*8975f5c5SAndroid Build Coastguard Worker 
8670*8975f5c5SAndroid Build Coastguard Worker     GLboolean result = GL_TRUE;
8671*8975f5c5SAndroid Build Coastguard Worker     if (fenceObject->test(this, &result) == angle::Result::Stop)
8672*8975f5c5SAndroid Build Coastguard Worker     {
8673*8975f5c5SAndroid Build Coastguard Worker         return GL_TRUE;
8674*8975f5c5SAndroid Build Coastguard Worker     }
8675*8975f5c5SAndroid Build Coastguard Worker 
8676*8975f5c5SAndroid Build Coastguard Worker     return result;
8677*8975f5c5SAndroid Build Coastguard Worker }
8678*8975f5c5SAndroid Build Coastguard Worker 
deleteMemoryObjects(GLsizei n,const MemoryObjectID * memoryObjects)8679*8975f5c5SAndroid Build Coastguard Worker void Context::deleteMemoryObjects(GLsizei n, const MemoryObjectID *memoryObjects)
8680*8975f5c5SAndroid Build Coastguard Worker {
8681*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
8682*8975f5c5SAndroid Build Coastguard Worker     {
8683*8975f5c5SAndroid Build Coastguard Worker         deleteMemoryObject(memoryObjects[i]);
8684*8975f5c5SAndroid Build Coastguard Worker     }
8685*8975f5c5SAndroid Build Coastguard Worker }
8686*8975f5c5SAndroid Build Coastguard Worker 
isMemoryObject(MemoryObjectID memoryObject) const8687*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isMemoryObject(MemoryObjectID memoryObject) const
8688*8975f5c5SAndroid Build Coastguard Worker {
8689*8975f5c5SAndroid Build Coastguard Worker     if (memoryObject.value == 0)
8690*8975f5c5SAndroid Build Coastguard Worker     {
8691*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
8692*8975f5c5SAndroid Build Coastguard Worker     }
8693*8975f5c5SAndroid Build Coastguard Worker 
8694*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getMemoryObject(memoryObject));
8695*8975f5c5SAndroid Build Coastguard Worker }
8696*8975f5c5SAndroid Build Coastguard Worker 
createMemoryObjects(GLsizei n,MemoryObjectID * memoryObjects)8697*8975f5c5SAndroid Build Coastguard Worker void Context::createMemoryObjects(GLsizei n, MemoryObjectID *memoryObjects)
8698*8975f5c5SAndroid Build Coastguard Worker {
8699*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
8700*8975f5c5SAndroid Build Coastguard Worker     {
8701*8975f5c5SAndroid Build Coastguard Worker         memoryObjects[i] = createMemoryObject();
8702*8975f5c5SAndroid Build Coastguard Worker     }
8703*8975f5c5SAndroid Build Coastguard Worker }
8704*8975f5c5SAndroid Build Coastguard Worker 
memoryObjectParameteriv(MemoryObjectID memory,GLenum pname,const GLint * params)8705*8975f5c5SAndroid Build Coastguard Worker void Context::memoryObjectParameteriv(MemoryObjectID memory, GLenum pname, const GLint *params)
8706*8975f5c5SAndroid Build Coastguard Worker {
8707*8975f5c5SAndroid Build Coastguard Worker     MemoryObject *memoryObject = getMemoryObject(memory);
8708*8975f5c5SAndroid Build Coastguard Worker     ASSERT(memoryObject);
8709*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(SetMemoryObjectParameteriv(this, memoryObject, pname, params));
8710*8975f5c5SAndroid Build Coastguard Worker }
8711*8975f5c5SAndroid Build Coastguard Worker 
getMemoryObjectParameteriv(MemoryObjectID memory,GLenum pname,GLint * params)8712*8975f5c5SAndroid Build Coastguard Worker void Context::getMemoryObjectParameteriv(MemoryObjectID memory, GLenum pname, GLint *params)
8713*8975f5c5SAndroid Build Coastguard Worker {
8714*8975f5c5SAndroid Build Coastguard Worker     const MemoryObject *memoryObject = getMemoryObject(memory);
8715*8975f5c5SAndroid Build Coastguard Worker     ASSERT(memoryObject);
8716*8975f5c5SAndroid Build Coastguard Worker     QueryMemoryObjectParameteriv(memoryObject, pname, params);
8717*8975f5c5SAndroid Build Coastguard Worker }
8718*8975f5c5SAndroid Build Coastguard Worker 
texStorageMem2D(TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,MemoryObjectID memory,GLuint64 offset)8719*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMem2D(TextureType target,
8720*8975f5c5SAndroid Build Coastguard Worker                               GLsizei levels,
8721*8975f5c5SAndroid Build Coastguard Worker                               GLenum internalFormat,
8722*8975f5c5SAndroid Build Coastguard Worker                               GLsizei width,
8723*8975f5c5SAndroid Build Coastguard Worker                               GLsizei height,
8724*8975f5c5SAndroid Build Coastguard Worker                               MemoryObjectID memory,
8725*8975f5c5SAndroid Build Coastguard Worker                               GLuint64 offset)
8726*8975f5c5SAndroid Build Coastguard Worker {
8727*8975f5c5SAndroid Build Coastguard Worker     texStorageMemFlags2D(target, levels, internalFormat, width, height, memory, offset,
8728*8975f5c5SAndroid Build Coastguard Worker                          std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(),
8729*8975f5c5SAndroid Build Coastguard Worker                          nullptr);
8730*8975f5c5SAndroid Build Coastguard Worker }
8731*8975f5c5SAndroid Build Coastguard Worker 
texStorageMem2DMultisample(TextureType target,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLboolean fixedSampleLocations,MemoryObjectID memory,GLuint64 offset)8732*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMem2DMultisample(TextureType target,
8733*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei samples,
8734*8975f5c5SAndroid Build Coastguard Worker                                          GLenum internalFormat,
8735*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei width,
8736*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei height,
8737*8975f5c5SAndroid Build Coastguard Worker                                          GLboolean fixedSampleLocations,
8738*8975f5c5SAndroid Build Coastguard Worker                                          MemoryObjectID memory,
8739*8975f5c5SAndroid Build Coastguard Worker                                          GLuint64 offset)
8740*8975f5c5SAndroid Build Coastguard Worker {
8741*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8742*8975f5c5SAndroid Build Coastguard Worker }
8743*8975f5c5SAndroid Build Coastguard Worker 
texStorageMem3D(TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,MemoryObjectID memory,GLuint64 offset)8744*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMem3D(TextureType target,
8745*8975f5c5SAndroid Build Coastguard Worker                               GLsizei levels,
8746*8975f5c5SAndroid Build Coastguard Worker                               GLenum internalFormat,
8747*8975f5c5SAndroid Build Coastguard Worker                               GLsizei width,
8748*8975f5c5SAndroid Build Coastguard Worker                               GLsizei height,
8749*8975f5c5SAndroid Build Coastguard Worker                               GLsizei depth,
8750*8975f5c5SAndroid Build Coastguard Worker                               MemoryObjectID memory,
8751*8975f5c5SAndroid Build Coastguard Worker                               GLuint64 offset)
8752*8975f5c5SAndroid Build Coastguard Worker {
8753*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8754*8975f5c5SAndroid Build Coastguard Worker }
8755*8975f5c5SAndroid Build Coastguard Worker 
texStorageMem3DMultisample(TextureType target,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLboolean fixedSampleLocations,MemoryObjectID memory,GLuint64 offset)8756*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMem3DMultisample(TextureType target,
8757*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei samples,
8758*8975f5c5SAndroid Build Coastguard Worker                                          GLenum internalFormat,
8759*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei width,
8760*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei height,
8761*8975f5c5SAndroid Build Coastguard Worker                                          GLsizei depth,
8762*8975f5c5SAndroid Build Coastguard Worker                                          GLboolean fixedSampleLocations,
8763*8975f5c5SAndroid Build Coastguard Worker                                          MemoryObjectID memory,
8764*8975f5c5SAndroid Build Coastguard Worker                                          GLuint64 offset)
8765*8975f5c5SAndroid Build Coastguard Worker {
8766*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8767*8975f5c5SAndroid Build Coastguard Worker }
8768*8975f5c5SAndroid Build Coastguard Worker 
bufferStorageMem(TextureType target,GLsizeiptr size,MemoryObjectID memory,GLuint64 offset)8769*8975f5c5SAndroid Build Coastguard Worker void Context::bufferStorageMem(TextureType target,
8770*8975f5c5SAndroid Build Coastguard Worker                                GLsizeiptr size,
8771*8975f5c5SAndroid Build Coastguard Worker                                MemoryObjectID memory,
8772*8975f5c5SAndroid Build Coastguard Worker                                GLuint64 offset)
8773*8975f5c5SAndroid Build Coastguard Worker {
8774*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8775*8975f5c5SAndroid Build Coastguard Worker }
8776*8975f5c5SAndroid Build Coastguard Worker 
importMemoryFd(MemoryObjectID memory,GLuint64 size,HandleType handleType,GLint fd)8777*8975f5c5SAndroid Build Coastguard Worker void Context::importMemoryFd(MemoryObjectID memory, GLuint64 size, HandleType handleType, GLint fd)
8778*8975f5c5SAndroid Build Coastguard Worker {
8779*8975f5c5SAndroid Build Coastguard Worker     MemoryObject *memoryObject = getMemoryObject(memory);
8780*8975f5c5SAndroid Build Coastguard Worker     ASSERT(memoryObject != nullptr);
8781*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(memoryObject->importFd(this, size, handleType, fd));
8782*8975f5c5SAndroid Build Coastguard Worker }
8783*8975f5c5SAndroid Build Coastguard Worker 
texStorageMemFlags2D(TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,MemoryObjectID memory,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)8784*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMemFlags2D(TextureType target,
8785*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei levels,
8786*8975f5c5SAndroid Build Coastguard Worker                                    GLenum internalFormat,
8787*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei width,
8788*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei height,
8789*8975f5c5SAndroid Build Coastguard Worker                                    MemoryObjectID memory,
8790*8975f5c5SAndroid Build Coastguard Worker                                    GLuint64 offset,
8791*8975f5c5SAndroid Build Coastguard Worker                                    GLbitfield createFlags,
8792*8975f5c5SAndroid Build Coastguard Worker                                    GLbitfield usageFlags,
8793*8975f5c5SAndroid Build Coastguard Worker                                    const void *imageCreateInfoPNext)
8794*8975f5c5SAndroid Build Coastguard Worker {
8795*8975f5c5SAndroid Build Coastguard Worker     MemoryObject *memoryObject = getMemoryObject(memory);
8796*8975f5c5SAndroid Build Coastguard Worker     ASSERT(memoryObject);
8797*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, 1);
8798*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTextureByType(target);
8799*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setStorageExternalMemory(this, target, levels, internalFormat, size,
8800*8975f5c5SAndroid Build Coastguard Worker                                                         memoryObject, offset, createFlags,
8801*8975f5c5SAndroid Build Coastguard Worker                                                         usageFlags, imageCreateInfoPNext));
8802*8975f5c5SAndroid Build Coastguard Worker }
8803*8975f5c5SAndroid Build Coastguard Worker 
texStorageMemFlags2DMultisample(TextureType target,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLboolean fixedSampleLocations,MemoryObjectID memory,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)8804*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMemFlags2DMultisample(TextureType target,
8805*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei samples,
8806*8975f5c5SAndroid Build Coastguard Worker                                               GLenum internalFormat,
8807*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei width,
8808*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei height,
8809*8975f5c5SAndroid Build Coastguard Worker                                               GLboolean fixedSampleLocations,
8810*8975f5c5SAndroid Build Coastguard Worker                                               MemoryObjectID memory,
8811*8975f5c5SAndroid Build Coastguard Worker                                               GLuint64 offset,
8812*8975f5c5SAndroid Build Coastguard Worker                                               GLbitfield createFlags,
8813*8975f5c5SAndroid Build Coastguard Worker                                               GLbitfield usageFlags,
8814*8975f5c5SAndroid Build Coastguard Worker                                               const void *imageCreateInfoPNext)
8815*8975f5c5SAndroid Build Coastguard Worker {
8816*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8817*8975f5c5SAndroid Build Coastguard Worker }
8818*8975f5c5SAndroid Build Coastguard Worker 
texStorageMemFlags3D(TextureType target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,MemoryObjectID memory,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)8819*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMemFlags3D(TextureType target,
8820*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei levels,
8821*8975f5c5SAndroid Build Coastguard Worker                                    GLenum internalFormat,
8822*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei width,
8823*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei height,
8824*8975f5c5SAndroid Build Coastguard Worker                                    GLsizei depth,
8825*8975f5c5SAndroid Build Coastguard Worker                                    MemoryObjectID memory,
8826*8975f5c5SAndroid Build Coastguard Worker                                    GLuint64 offset,
8827*8975f5c5SAndroid Build Coastguard Worker                                    GLbitfield createFlags,
8828*8975f5c5SAndroid Build Coastguard Worker                                    GLbitfield usageFlags,
8829*8975f5c5SAndroid Build Coastguard Worker                                    const void *imageCreateInfoPNext)
8830*8975f5c5SAndroid Build Coastguard Worker {
8831*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8832*8975f5c5SAndroid Build Coastguard Worker }
8833*8975f5c5SAndroid Build Coastguard Worker 
texStorageMemFlags3DMultisample(TextureType target,GLsizei samples,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLboolean fixedSampleLocations,MemoryObjectID memory,GLuint64 offset,GLbitfield createFlags,GLbitfield usageFlags,const void * imageCreateInfoPNext)8834*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageMemFlags3DMultisample(TextureType target,
8835*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei samples,
8836*8975f5c5SAndroid Build Coastguard Worker                                               GLenum internalFormat,
8837*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei width,
8838*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei height,
8839*8975f5c5SAndroid Build Coastguard Worker                                               GLsizei depth,
8840*8975f5c5SAndroid Build Coastguard Worker                                               GLboolean fixedSampleLocations,
8841*8975f5c5SAndroid Build Coastguard Worker                                               MemoryObjectID memory,
8842*8975f5c5SAndroid Build Coastguard Worker                                               GLuint64 offset,
8843*8975f5c5SAndroid Build Coastguard Worker                                               GLbitfield createFlags,
8844*8975f5c5SAndroid Build Coastguard Worker                                               GLbitfield usageFlags,
8845*8975f5c5SAndroid Build Coastguard Worker                                               const void *imageCreateInfoPNext)
8846*8975f5c5SAndroid Build Coastguard Worker {
8847*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8848*8975f5c5SAndroid Build Coastguard Worker }
8849*8975f5c5SAndroid Build Coastguard Worker 
importMemoryZirconHandle(MemoryObjectID memory,GLuint64 size,HandleType handleType,GLuint handle)8850*8975f5c5SAndroid Build Coastguard Worker void Context::importMemoryZirconHandle(MemoryObjectID memory,
8851*8975f5c5SAndroid Build Coastguard Worker                                        GLuint64 size,
8852*8975f5c5SAndroid Build Coastguard Worker                                        HandleType handleType,
8853*8975f5c5SAndroid Build Coastguard Worker                                        GLuint handle)
8854*8975f5c5SAndroid Build Coastguard Worker {
8855*8975f5c5SAndroid Build Coastguard Worker     MemoryObject *memoryObject = getMemoryObject(memory);
8856*8975f5c5SAndroid Build Coastguard Worker     ASSERT(memoryObject != nullptr);
8857*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(memoryObject->importZirconHandle(this, size, handleType, handle));
8858*8975f5c5SAndroid Build Coastguard Worker }
8859*8975f5c5SAndroid Build Coastguard Worker 
genSemaphores(GLsizei n,SemaphoreID * semaphores)8860*8975f5c5SAndroid Build Coastguard Worker void Context::genSemaphores(GLsizei n, SemaphoreID *semaphores)
8861*8975f5c5SAndroid Build Coastguard Worker {
8862*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
8863*8975f5c5SAndroid Build Coastguard Worker     {
8864*8975f5c5SAndroid Build Coastguard Worker         semaphores[i] = createSemaphore();
8865*8975f5c5SAndroid Build Coastguard Worker     }
8866*8975f5c5SAndroid Build Coastguard Worker }
8867*8975f5c5SAndroid Build Coastguard Worker 
deleteSemaphores(GLsizei n,const SemaphoreID * semaphores)8868*8975f5c5SAndroid Build Coastguard Worker void Context::deleteSemaphores(GLsizei n, const SemaphoreID *semaphores)
8869*8975f5c5SAndroid Build Coastguard Worker {
8870*8975f5c5SAndroid Build Coastguard Worker     for (int i = 0; i < n; i++)
8871*8975f5c5SAndroid Build Coastguard Worker     {
8872*8975f5c5SAndroid Build Coastguard Worker         deleteSemaphore(semaphores[i]);
8873*8975f5c5SAndroid Build Coastguard Worker     }
8874*8975f5c5SAndroid Build Coastguard Worker }
8875*8975f5c5SAndroid Build Coastguard Worker 
isSemaphore(SemaphoreID semaphore) const8876*8975f5c5SAndroid Build Coastguard Worker GLboolean Context::isSemaphore(SemaphoreID semaphore) const
8877*8975f5c5SAndroid Build Coastguard Worker {
8878*8975f5c5SAndroid Build Coastguard Worker     if (semaphore.value == 0)
8879*8975f5c5SAndroid Build Coastguard Worker     {
8880*8975f5c5SAndroid Build Coastguard Worker         return GL_FALSE;
8881*8975f5c5SAndroid Build Coastguard Worker     }
8882*8975f5c5SAndroid Build Coastguard Worker 
8883*8975f5c5SAndroid Build Coastguard Worker     return ConvertToGLBoolean(getSemaphore(semaphore));
8884*8975f5c5SAndroid Build Coastguard Worker }
8885*8975f5c5SAndroid Build Coastguard Worker 
semaphoreParameterui64v(SemaphoreID semaphore,GLenum pname,const GLuint64 * params)8886*8975f5c5SAndroid Build Coastguard Worker void Context::semaphoreParameterui64v(SemaphoreID semaphore, GLenum pname, const GLuint64 *params)
8887*8975f5c5SAndroid Build Coastguard Worker {
8888*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8889*8975f5c5SAndroid Build Coastguard Worker }
8890*8975f5c5SAndroid Build Coastguard Worker 
getSemaphoreParameterui64v(SemaphoreID semaphore,GLenum pname,GLuint64 * params)8891*8975f5c5SAndroid Build Coastguard Worker void Context::getSemaphoreParameterui64v(SemaphoreID semaphore, GLenum pname, GLuint64 *params)
8892*8975f5c5SAndroid Build Coastguard Worker {
8893*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
8894*8975f5c5SAndroid Build Coastguard Worker }
8895*8975f5c5SAndroid Build Coastguard Worker 
acquireTextures(GLuint numTextures,const TextureID * textureIds,const GLenum * layouts)8896*8975f5c5SAndroid Build Coastguard Worker void Context::acquireTextures(GLuint numTextures,
8897*8975f5c5SAndroid Build Coastguard Worker                               const TextureID *textureIds,
8898*8975f5c5SAndroid Build Coastguard Worker                               const GLenum *layouts)
8899*8975f5c5SAndroid Build Coastguard Worker {
8900*8975f5c5SAndroid Build Coastguard Worker     TextureBarrierVector textureBarriers(numTextures);
8901*8975f5c5SAndroid Build Coastguard Worker     for (size_t i = 0; i < numTextures; i++)
8902*8975f5c5SAndroid Build Coastguard Worker     {
8903*8975f5c5SAndroid Build Coastguard Worker         textureBarriers[i].texture = getTexture(textureIds[i]);
8904*8975f5c5SAndroid Build Coastguard Worker         textureBarriers[i].layout  = layouts[i];
8905*8975f5c5SAndroid Build Coastguard Worker     }
8906*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->acquireTextures(this, textureBarriers));
8907*8975f5c5SAndroid Build Coastguard Worker }
8908*8975f5c5SAndroid Build Coastguard Worker 
releaseTextures(GLuint numTextures,const TextureID * textureIds,GLenum * layouts)8909*8975f5c5SAndroid Build Coastguard Worker void Context::releaseTextures(GLuint numTextures, const TextureID *textureIds, GLenum *layouts)
8910*8975f5c5SAndroid Build Coastguard Worker {
8911*8975f5c5SAndroid Build Coastguard Worker     TextureBarrierVector textureBarriers(numTextures);
8912*8975f5c5SAndroid Build Coastguard Worker     for (size_t i = 0; i < numTextures; i++)
8913*8975f5c5SAndroid Build Coastguard Worker     {
8914*8975f5c5SAndroid Build Coastguard Worker         textureBarriers[i].texture = getTexture(textureIds[i]);
8915*8975f5c5SAndroid Build Coastguard Worker     }
8916*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->releaseTextures(this, &textureBarriers));
8917*8975f5c5SAndroid Build Coastguard Worker     for (size_t i = 0; i < numTextures; i++)
8918*8975f5c5SAndroid Build Coastguard Worker     {
8919*8975f5c5SAndroid Build Coastguard Worker         layouts[i] = textureBarriers[i].layout;
8920*8975f5c5SAndroid Build Coastguard Worker     }
8921*8975f5c5SAndroid Build Coastguard Worker }
8922*8975f5c5SAndroid Build Coastguard Worker 
waitSemaphore(SemaphoreID semaphoreHandle,GLuint numBufferBarriers,const BufferID * buffers,GLuint numTextureBarriers,const TextureID * textures,const GLenum * srcLayouts)8923*8975f5c5SAndroid Build Coastguard Worker void Context::waitSemaphore(SemaphoreID semaphoreHandle,
8924*8975f5c5SAndroid Build Coastguard Worker                             GLuint numBufferBarriers,
8925*8975f5c5SAndroid Build Coastguard Worker                             const BufferID *buffers,
8926*8975f5c5SAndroid Build Coastguard Worker                             GLuint numTextureBarriers,
8927*8975f5c5SAndroid Build Coastguard Worker                             const TextureID *textures,
8928*8975f5c5SAndroid Build Coastguard Worker                             const GLenum *srcLayouts)
8929*8975f5c5SAndroid Build Coastguard Worker {
8930*8975f5c5SAndroid Build Coastguard Worker     Semaphore *semaphore = getSemaphore(semaphoreHandle);
8931*8975f5c5SAndroid Build Coastguard Worker     ASSERT(semaphore);
8932*8975f5c5SAndroid Build Coastguard Worker 
8933*8975f5c5SAndroid Build Coastguard Worker     BufferBarrierVector bufferBarriers(numBufferBarriers);
8934*8975f5c5SAndroid Build Coastguard Worker     for (GLuint bufferBarrierIdx = 0; bufferBarrierIdx < numBufferBarriers; bufferBarrierIdx++)
8935*8975f5c5SAndroid Build Coastguard Worker     {
8936*8975f5c5SAndroid Build Coastguard Worker         bufferBarriers[bufferBarrierIdx] = getBuffer(buffers[bufferBarrierIdx]);
8937*8975f5c5SAndroid Build Coastguard Worker     }
8938*8975f5c5SAndroid Build Coastguard Worker 
8939*8975f5c5SAndroid Build Coastguard Worker     TextureBarrierVector textureBarriers(numTextureBarriers);
8940*8975f5c5SAndroid Build Coastguard Worker     for (GLuint textureBarrierIdx = 0; textureBarrierIdx < numTextureBarriers; textureBarrierIdx++)
8941*8975f5c5SAndroid Build Coastguard Worker     {
8942*8975f5c5SAndroid Build Coastguard Worker         textureBarriers[textureBarrierIdx].texture = getTexture(textures[textureBarrierIdx]);
8943*8975f5c5SAndroid Build Coastguard Worker         textureBarriers[textureBarrierIdx].layout  = srcLayouts[textureBarrierIdx];
8944*8975f5c5SAndroid Build Coastguard Worker     }
8945*8975f5c5SAndroid Build Coastguard Worker 
8946*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(semaphore->wait(this, bufferBarriers, textureBarriers));
8947*8975f5c5SAndroid Build Coastguard Worker }
8948*8975f5c5SAndroid Build Coastguard Worker 
signalSemaphore(SemaphoreID semaphoreHandle,GLuint numBufferBarriers,const BufferID * buffers,GLuint numTextureBarriers,const TextureID * textures,const GLenum * dstLayouts)8949*8975f5c5SAndroid Build Coastguard Worker void Context::signalSemaphore(SemaphoreID semaphoreHandle,
8950*8975f5c5SAndroid Build Coastguard Worker                               GLuint numBufferBarriers,
8951*8975f5c5SAndroid Build Coastguard Worker                               const BufferID *buffers,
8952*8975f5c5SAndroid Build Coastguard Worker                               GLuint numTextureBarriers,
8953*8975f5c5SAndroid Build Coastguard Worker                               const TextureID *textures,
8954*8975f5c5SAndroid Build Coastguard Worker                               const GLenum *dstLayouts)
8955*8975f5c5SAndroid Build Coastguard Worker {
8956*8975f5c5SAndroid Build Coastguard Worker     Semaphore *semaphore = getSemaphore(semaphoreHandle);
8957*8975f5c5SAndroid Build Coastguard Worker     ASSERT(semaphore);
8958*8975f5c5SAndroid Build Coastguard Worker 
8959*8975f5c5SAndroid Build Coastguard Worker     BufferBarrierVector bufferBarriers(numBufferBarriers);
8960*8975f5c5SAndroid Build Coastguard Worker     for (GLuint bufferBarrierIdx = 0; bufferBarrierIdx < numBufferBarriers; bufferBarrierIdx++)
8961*8975f5c5SAndroid Build Coastguard Worker     {
8962*8975f5c5SAndroid Build Coastguard Worker         bufferBarriers[bufferBarrierIdx] = getBuffer(buffers[bufferBarrierIdx]);
8963*8975f5c5SAndroid Build Coastguard Worker     }
8964*8975f5c5SAndroid Build Coastguard Worker 
8965*8975f5c5SAndroid Build Coastguard Worker     TextureBarrierVector textureBarriers(numTextureBarriers);
8966*8975f5c5SAndroid Build Coastguard Worker     for (GLuint textureBarrierIdx = 0; textureBarrierIdx < numTextureBarriers; textureBarrierIdx++)
8967*8975f5c5SAndroid Build Coastguard Worker     {
8968*8975f5c5SAndroid Build Coastguard Worker         textureBarriers[textureBarrierIdx].texture = getTexture(textures[textureBarrierIdx]);
8969*8975f5c5SAndroid Build Coastguard Worker         textureBarriers[textureBarrierIdx].layout  = dstLayouts[textureBarrierIdx];
8970*8975f5c5SAndroid Build Coastguard Worker     }
8971*8975f5c5SAndroid Build Coastguard Worker 
8972*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(semaphore->signal(this, bufferBarriers, textureBarriers));
8973*8975f5c5SAndroid Build Coastguard Worker }
8974*8975f5c5SAndroid Build Coastguard Worker 
importSemaphoreFd(SemaphoreID semaphore,HandleType handleType,GLint fd)8975*8975f5c5SAndroid Build Coastguard Worker void Context::importSemaphoreFd(SemaphoreID semaphore, HandleType handleType, GLint fd)
8976*8975f5c5SAndroid Build Coastguard Worker {
8977*8975f5c5SAndroid Build Coastguard Worker     Semaphore *semaphoreObject = getSemaphore(semaphore);
8978*8975f5c5SAndroid Build Coastguard Worker     ASSERT(semaphoreObject != nullptr);
8979*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(semaphoreObject->importFd(this, handleType, fd));
8980*8975f5c5SAndroid Build Coastguard Worker }
8981*8975f5c5SAndroid Build Coastguard Worker 
importSemaphoreZirconHandle(SemaphoreID semaphore,HandleType handleType,GLuint handle)8982*8975f5c5SAndroid Build Coastguard Worker void Context::importSemaphoreZirconHandle(SemaphoreID semaphore,
8983*8975f5c5SAndroid Build Coastguard Worker                                           HandleType handleType,
8984*8975f5c5SAndroid Build Coastguard Worker                                           GLuint handle)
8985*8975f5c5SAndroid Build Coastguard Worker {
8986*8975f5c5SAndroid Build Coastguard Worker     Semaphore *semaphoreObject = getSemaphore(semaphore);
8987*8975f5c5SAndroid Build Coastguard Worker     ASSERT(semaphoreObject != nullptr);
8988*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(semaphoreObject->importZirconHandle(this, handleType, handle));
8989*8975f5c5SAndroid Build Coastguard Worker }
8990*8975f5c5SAndroid Build Coastguard Worker 
framebufferMemorylessPixelLocalStorage(GLint plane,GLenum internalformat)8991*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferMemorylessPixelLocalStorage(GLint plane, GLenum internalformat)
8992*8975f5c5SAndroid Build Coastguard Worker {
8993*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
8994*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
8995*8975f5c5SAndroid Build Coastguard Worker 
8996*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0)
8997*8975f5c5SAndroid Build Coastguard Worker     {
8998*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
8999*8975f5c5SAndroid Build Coastguard Worker     }
9000*8975f5c5SAndroid Build Coastguard Worker 
9001*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9002*8975f5c5SAndroid Build Coastguard Worker 
9003*8975f5c5SAndroid Build Coastguard Worker     if (internalformat == GL_NONE)
9004*8975f5c5SAndroid Build Coastguard Worker     {
9005*8975f5c5SAndroid Build Coastguard Worker         pls.deinitialize(this, plane);
9006*8975f5c5SAndroid Build Coastguard Worker     }
9007*8975f5c5SAndroid Build Coastguard Worker     else
9008*8975f5c5SAndroid Build Coastguard Worker     {
9009*8975f5c5SAndroid Build Coastguard Worker         pls.setMemoryless(this, plane, internalformat);
9010*8975f5c5SAndroid Build Coastguard Worker     }
9011*8975f5c5SAndroid Build Coastguard Worker }
9012*8975f5c5SAndroid Build Coastguard Worker 
framebufferTexturePixelLocalStorage(GLint plane,TextureID backingtexture,GLint level,GLint layer)9013*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferTexturePixelLocalStorage(GLint plane,
9014*8975f5c5SAndroid Build Coastguard Worker                                                   TextureID backingtexture,
9015*8975f5c5SAndroid Build Coastguard Worker                                                   GLint level,
9016*8975f5c5SAndroid Build Coastguard Worker                                                   GLint layer)
9017*8975f5c5SAndroid Build Coastguard Worker {
9018*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9019*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9020*8975f5c5SAndroid Build Coastguard Worker 
9021*8975f5c5SAndroid Build Coastguard Worker     if (mState.getPixelLocalStorageActivePlanes() != 0)
9022*8975f5c5SAndroid Build Coastguard Worker     {
9023*8975f5c5SAndroid Build Coastguard Worker         endPixelLocalStorageImplicit();
9024*8975f5c5SAndroid Build Coastguard Worker     }
9025*8975f5c5SAndroid Build Coastguard Worker 
9026*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9027*8975f5c5SAndroid Build Coastguard Worker 
9028*8975f5c5SAndroid Build Coastguard Worker     if (backingtexture.value == 0)
9029*8975f5c5SAndroid Build Coastguard Worker     {
9030*8975f5c5SAndroid Build Coastguard Worker         pls.deinitialize(this, plane);
9031*8975f5c5SAndroid Build Coastguard Worker     }
9032*8975f5c5SAndroid Build Coastguard Worker     else
9033*8975f5c5SAndroid Build Coastguard Worker     {
9034*8975f5c5SAndroid Build Coastguard Worker         Texture *tex = getTexture(backingtexture);
9035*8975f5c5SAndroid Build Coastguard Worker         ASSERT(tex);  // Validation guarantees this.
9036*8975f5c5SAndroid Build Coastguard Worker         pls.setTextureBacked(this, plane, tex, level, layer);
9037*8975f5c5SAndroid Build Coastguard Worker     }
9038*8975f5c5SAndroid Build Coastguard Worker }
9039*8975f5c5SAndroid Build Coastguard Worker 
framebufferPixelLocalClearValuefv(GLint plane,const GLfloat value[])9040*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferPixelLocalClearValuefv(GLint plane, const GLfloat value[])
9041*8975f5c5SAndroid Build Coastguard Worker {
9042*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9043*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9044*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9045*8975f5c5SAndroid Build Coastguard Worker     pls.setClearValuef(plane, value);
9046*8975f5c5SAndroid Build Coastguard Worker }
9047*8975f5c5SAndroid Build Coastguard Worker 
framebufferPixelLocalClearValueiv(GLint plane,const GLint value[])9048*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferPixelLocalClearValueiv(GLint plane, const GLint value[])
9049*8975f5c5SAndroid Build Coastguard Worker {
9050*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9051*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9052*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9053*8975f5c5SAndroid Build Coastguard Worker     pls.setClearValuei(plane, value);
9054*8975f5c5SAndroid Build Coastguard Worker }
9055*8975f5c5SAndroid Build Coastguard Worker 
framebufferPixelLocalClearValueuiv(GLint plane,const GLuint value[])9056*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferPixelLocalClearValueuiv(GLint plane, const GLuint value[])
9057*8975f5c5SAndroid Build Coastguard Worker {
9058*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9059*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9060*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9061*8975f5c5SAndroid Build Coastguard Worker     pls.setClearValueui(plane, value);
9062*8975f5c5SAndroid Build Coastguard Worker }
9063*8975f5c5SAndroid Build Coastguard Worker 
beginPixelLocalStorage(GLsizei n,const GLenum loadops[])9064*8975f5c5SAndroid Build Coastguard Worker void Context::beginPixelLocalStorage(GLsizei n, const GLenum loadops[])
9065*8975f5c5SAndroid Build Coastguard Worker {
9066*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9067*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9068*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9069*8975f5c5SAndroid Build Coastguard Worker 
9070*8975f5c5SAndroid Build Coastguard Worker     pls.begin(this, n, loadops);
9071*8975f5c5SAndroid Build Coastguard Worker     mState.setPixelLocalStorageActivePlanes(n);
9072*8975f5c5SAndroid Build Coastguard Worker }
9073*8975f5c5SAndroid Build Coastguard Worker 
endPixelLocalStorage(GLsizei n,const GLenum storeops[])9074*8975f5c5SAndroid Build Coastguard Worker void Context::endPixelLocalStorage(GLsizei n, const GLenum storeops[])
9075*8975f5c5SAndroid Build Coastguard Worker {
9076*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9077*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9078*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9079*8975f5c5SAndroid Build Coastguard Worker 
9080*8975f5c5SAndroid Build Coastguard Worker     ASSERT(n == mState.getPixelLocalStorageActivePlanes());
9081*8975f5c5SAndroid Build Coastguard Worker     mState.setPixelLocalStorageActivePlanes(0);
9082*8975f5c5SAndroid Build Coastguard Worker     pls.end(this, n, storeops);
9083*8975f5c5SAndroid Build Coastguard Worker }
9084*8975f5c5SAndroid Build Coastguard Worker 
endPixelLocalStorageImplicit()9085*8975f5c5SAndroid Build Coastguard Worker void Context::endPixelLocalStorageImplicit()
9086*8975f5c5SAndroid Build Coastguard Worker {
9087*8975f5c5SAndroid Build Coastguard Worker     GLsizei n = mState.getPixelLocalStorageActivePlanes();
9088*8975f5c5SAndroid Build Coastguard Worker     ASSERT(n != 0);
9089*8975f5c5SAndroid Build Coastguard Worker     angle::FixedVector<GLenum, IMPLEMENTATION_MAX_PIXEL_LOCAL_STORAGE_PLANES> storeops(
9090*8975f5c5SAndroid Build Coastguard Worker         n, GL_STORE_OP_STORE_ANGLE);
9091*8975f5c5SAndroid Build Coastguard Worker     endPixelLocalStorage(n, storeops.data());
9092*8975f5c5SAndroid Build Coastguard Worker }
9093*8975f5c5SAndroid Build Coastguard Worker 
areBlobCacheFuncsSet() const9094*8975f5c5SAndroid Build Coastguard Worker bool Context::areBlobCacheFuncsSet() const
9095*8975f5c5SAndroid Build Coastguard Worker {
9096*8975f5c5SAndroid Build Coastguard Worker     return mState.getBlobCacheCallbacks().getFunction && mState.getBlobCacheCallbacks().setFunction;
9097*8975f5c5SAndroid Build Coastguard Worker }
9098*8975f5c5SAndroid Build Coastguard Worker 
pixelLocalStorageBarrier()9099*8975f5c5SAndroid Build Coastguard Worker void Context::pixelLocalStorageBarrier()
9100*8975f5c5SAndroid Build Coastguard Worker {
9101*8975f5c5SAndroid Build Coastguard Worker     if (getExtensions().shaderPixelLocalStorageCoherentANGLE)
9102*8975f5c5SAndroid Build Coastguard Worker     {
9103*8975f5c5SAndroid Build Coastguard Worker         return;
9104*8975f5c5SAndroid Build Coastguard Worker     }
9105*8975f5c5SAndroid Build Coastguard Worker 
9106*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9107*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9108*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9109*8975f5c5SAndroid Build Coastguard Worker 
9110*8975f5c5SAndroid Build Coastguard Worker     pls.barrier(this);
9111*8975f5c5SAndroid Build Coastguard Worker }
9112*8975f5c5SAndroid Build Coastguard Worker 
framebufferPixelLocalStorageInterrupt()9113*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferPixelLocalStorageInterrupt()
9114*8975f5c5SAndroid Build Coastguard Worker {
9115*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9116*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9117*8975f5c5SAndroid Build Coastguard Worker     if (framebuffer->id().value != 0)
9118*8975f5c5SAndroid Build Coastguard Worker     {
9119*8975f5c5SAndroid Build Coastguard Worker         PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9120*8975f5c5SAndroid Build Coastguard Worker         pls.interrupt(this);
9121*8975f5c5SAndroid Build Coastguard Worker     }
9122*8975f5c5SAndroid Build Coastguard Worker }
9123*8975f5c5SAndroid Build Coastguard Worker 
framebufferPixelLocalStorageRestore()9124*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferPixelLocalStorageRestore()
9125*8975f5c5SAndroid Build Coastguard Worker {
9126*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9127*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9128*8975f5c5SAndroid Build Coastguard Worker     if (framebuffer->id().value != 0)
9129*8975f5c5SAndroid Build Coastguard Worker     {
9130*8975f5c5SAndroid Build Coastguard Worker         PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9131*8975f5c5SAndroid Build Coastguard Worker         pls.restore(this);
9132*8975f5c5SAndroid Build Coastguard Worker     }
9133*8975f5c5SAndroid Build Coastguard Worker }
9134*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferPixelLocalStorageParameterfv(GLint plane,GLenum pname,GLfloat * params)9135*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferPixelLocalStorageParameterfv(GLint plane, GLenum pname, GLfloat *params)
9136*8975f5c5SAndroid Build Coastguard Worker {
9137*8975f5c5SAndroid Build Coastguard Worker     getFramebufferPixelLocalStorageParameterfvRobust(
9138*8975f5c5SAndroid Build Coastguard Worker         plane, pname, std::numeric_limits<GLsizei>::max(), nullptr, params);
9139*8975f5c5SAndroid Build Coastguard Worker }
9140*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferPixelLocalStorageParameteriv(GLint plane,GLenum pname,GLint * params)9141*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferPixelLocalStorageParameteriv(GLint plane, GLenum pname, GLint *params)
9142*8975f5c5SAndroid Build Coastguard Worker {
9143*8975f5c5SAndroid Build Coastguard Worker     getFramebufferPixelLocalStorageParameterivRobust(
9144*8975f5c5SAndroid Build Coastguard Worker         plane, pname, std::numeric_limits<GLsizei>::max(), nullptr, params);
9145*8975f5c5SAndroid Build Coastguard Worker }
9146*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferPixelLocalStorageParameterfvRobust(GLint plane,GLenum pname,GLsizei bufSize,GLsizei * length,GLfloat * params)9147*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferPixelLocalStorageParameterfvRobust(GLint plane,
9148*8975f5c5SAndroid Build Coastguard Worker                                                                GLenum pname,
9149*8975f5c5SAndroid Build Coastguard Worker                                                                GLsizei bufSize,
9150*8975f5c5SAndroid Build Coastguard Worker                                                                GLsizei *length,
9151*8975f5c5SAndroid Build Coastguard Worker                                                                GLfloat *params)
9152*8975f5c5SAndroid Build Coastguard Worker {
9153*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9154*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9155*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9156*8975f5c5SAndroid Build Coastguard Worker 
9157*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
9158*8975f5c5SAndroid Build Coastguard Worker     {
9159*8975f5c5SAndroid Build Coastguard Worker         case GL_PIXEL_LOCAL_CLEAR_VALUE_FLOAT_ANGLE:
9160*8975f5c5SAndroid Build Coastguard Worker             if (length != nullptr)
9161*8975f5c5SAndroid Build Coastguard Worker             {
9162*8975f5c5SAndroid Build Coastguard Worker                 *length = 4;
9163*8975f5c5SAndroid Build Coastguard Worker             }
9164*8975f5c5SAndroid Build Coastguard Worker             pls.getPlane(plane).getClearValuef(params);
9165*8975f5c5SAndroid Build Coastguard Worker             break;
9166*8975f5c5SAndroid Build Coastguard Worker     }
9167*8975f5c5SAndroid Build Coastguard Worker }
9168*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferPixelLocalStorageParameterivRobust(GLint plane,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * params)9169*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferPixelLocalStorageParameterivRobust(GLint plane,
9170*8975f5c5SAndroid Build Coastguard Worker                                                                GLenum pname,
9171*8975f5c5SAndroid Build Coastguard Worker                                                                GLsizei bufSize,
9172*8975f5c5SAndroid Build Coastguard Worker                                                                GLsizei *length,
9173*8975f5c5SAndroid Build Coastguard Worker                                                                GLint *params)
9174*8975f5c5SAndroid Build Coastguard Worker {
9175*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = mState.getDrawFramebuffer();
9176*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9177*8975f5c5SAndroid Build Coastguard Worker     PixelLocalStorage &pls = framebuffer->getPixelLocalStorage(this);
9178*8975f5c5SAndroid Build Coastguard Worker 
9179*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
9180*8975f5c5SAndroid Build Coastguard Worker     {
9181*8975f5c5SAndroid Build Coastguard Worker         // GL_ANGLE_shader_pixel_local_storage.
9182*8975f5c5SAndroid Build Coastguard Worker         case GL_PIXEL_LOCAL_FORMAT_ANGLE:
9183*8975f5c5SAndroid Build Coastguard Worker         case GL_PIXEL_LOCAL_TEXTURE_NAME_ANGLE:
9184*8975f5c5SAndroid Build Coastguard Worker         case GL_PIXEL_LOCAL_TEXTURE_LEVEL_ANGLE:
9185*8975f5c5SAndroid Build Coastguard Worker         case GL_PIXEL_LOCAL_TEXTURE_LAYER_ANGLE:
9186*8975f5c5SAndroid Build Coastguard Worker             if (length != nullptr)
9187*8975f5c5SAndroid Build Coastguard Worker             {
9188*8975f5c5SAndroid Build Coastguard Worker                 *length = 1;
9189*8975f5c5SAndroid Build Coastguard Worker             }
9190*8975f5c5SAndroid Build Coastguard Worker             *params = pls.getPlane(plane).getIntegeri(pname);
9191*8975f5c5SAndroid Build Coastguard Worker             break;
9192*8975f5c5SAndroid Build Coastguard Worker         case GL_PIXEL_LOCAL_CLEAR_VALUE_INT_ANGLE:
9193*8975f5c5SAndroid Build Coastguard Worker             if (length != nullptr)
9194*8975f5c5SAndroid Build Coastguard Worker             {
9195*8975f5c5SAndroid Build Coastguard Worker                 *length = 4;
9196*8975f5c5SAndroid Build Coastguard Worker             }
9197*8975f5c5SAndroid Build Coastguard Worker             pls.getPlane(plane).getClearValuei(params);
9198*8975f5c5SAndroid Build Coastguard Worker             break;
9199*8975f5c5SAndroid Build Coastguard Worker         case GL_PIXEL_LOCAL_CLEAR_VALUE_UNSIGNED_INT_ANGLE:
9200*8975f5c5SAndroid Build Coastguard Worker         {
9201*8975f5c5SAndroid Build Coastguard Worker             if (length != nullptr)
9202*8975f5c5SAndroid Build Coastguard Worker             {
9203*8975f5c5SAndroid Build Coastguard Worker                 *length = 4;
9204*8975f5c5SAndroid Build Coastguard Worker             }
9205*8975f5c5SAndroid Build Coastguard Worker             GLuint valueui[4];
9206*8975f5c5SAndroid Build Coastguard Worker             pls.getPlane(plane).getClearValueui(valueui);
9207*8975f5c5SAndroid Build Coastguard Worker             memcpy(params, valueui, sizeof(valueui));
9208*8975f5c5SAndroid Build Coastguard Worker             break;
9209*8975f5c5SAndroid Build Coastguard Worker         }
9210*8975f5c5SAndroid Build Coastguard Worker     }
9211*8975f5c5SAndroid Build Coastguard Worker }
9212*8975f5c5SAndroid Build Coastguard Worker 
eGLImageTargetTexStorage(GLenum target,egl::ImageID image,const GLint * attrib_list)9213*8975f5c5SAndroid Build Coastguard Worker void Context::eGLImageTargetTexStorage(GLenum target, egl::ImageID image, const GLint *attrib_list)
9214*8975f5c5SAndroid Build Coastguard Worker {
9215*8975f5c5SAndroid Build Coastguard Worker     Texture *texture        = getTextureByType(FromGLenum<TextureType>(target));
9216*8975f5c5SAndroid Build Coastguard Worker     egl::Image *imageObject = mDisplay->getImage(image);
9217*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setStorageEGLImageTarget(this, FromGLenum<TextureType>(target),
9218*8975f5c5SAndroid Build Coastguard Worker                                                         imageObject, attrib_list));
9219*8975f5c5SAndroid Build Coastguard Worker }
9220*8975f5c5SAndroid Build Coastguard Worker 
eGLImageTargetTextureStorage(GLuint texture,egl::ImageID image,const GLint * attrib_list)9221*8975f5c5SAndroid Build Coastguard Worker void Context::eGLImageTargetTextureStorage(GLuint texture,
9222*8975f5c5SAndroid Build Coastguard Worker                                            egl::ImageID image,
9223*8975f5c5SAndroid Build Coastguard Worker                                            const GLint *attrib_list)
9224*8975f5c5SAndroid Build Coastguard Worker {}
9225*8975f5c5SAndroid Build Coastguard Worker 
eGLImageTargetTexture2D(TextureType target,egl::ImageID image)9226*8975f5c5SAndroid Build Coastguard Worker void Context::eGLImageTargetTexture2D(TextureType target, egl::ImageID image)
9227*8975f5c5SAndroid Build Coastguard Worker {
9228*8975f5c5SAndroid Build Coastguard Worker     Texture *texture        = getTextureByType(target);
9229*8975f5c5SAndroid Build Coastguard Worker     egl::Image *imageObject = mDisplay->getImage(image);
9230*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject));
9231*8975f5c5SAndroid Build Coastguard Worker }
9232*8975f5c5SAndroid Build Coastguard Worker 
eGLImageTargetRenderbufferStorage(GLenum target,egl::ImageID image)9233*8975f5c5SAndroid Build Coastguard Worker void Context::eGLImageTargetRenderbufferStorage(GLenum target, egl::ImageID image)
9234*8975f5c5SAndroid Build Coastguard Worker {
9235*8975f5c5SAndroid Build Coastguard Worker     Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer();
9236*8975f5c5SAndroid Build Coastguard Worker     egl::Image *imageObject    = mDisplay->getImage(image);
9237*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject));
9238*8975f5c5SAndroid Build Coastguard Worker }
9239*8975f5c5SAndroid Build Coastguard Worker 
framebufferFetchBarrier()9240*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferFetchBarrier()
9241*8975f5c5SAndroid Build Coastguard Worker {
9242*8975f5c5SAndroid Build Coastguard Worker     mImplementation->framebufferFetchBarrier();
9243*8975f5c5SAndroid Build Coastguard Worker }
9244*8975f5c5SAndroid Build Coastguard Worker 
texStorage1D(GLenum target,GLsizei levels,GLenum internalformat,GLsizei width)9245*8975f5c5SAndroid Build Coastguard Worker void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width)
9246*8975f5c5SAndroid Build Coastguard Worker {
9247*8975f5c5SAndroid Build Coastguard Worker     UNIMPLEMENTED();
9248*8975f5c5SAndroid Build Coastguard Worker }
9249*8975f5c5SAndroid Build Coastguard Worker 
getQueryParameterInfo(GLenum pname,GLenum * type,unsigned int * numParams) const9250*8975f5c5SAndroid Build Coastguard Worker bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) const
9251*8975f5c5SAndroid Build Coastguard Worker {
9252*8975f5c5SAndroid Build Coastguard Worker     return GetQueryParameterInfo(mState, pname, type, numParams);
9253*8975f5c5SAndroid Build Coastguard Worker }
9254*8975f5c5SAndroid Build Coastguard Worker 
getIndexedQueryParameterInfo(GLenum target,GLenum * type,unsigned int * numParams) const9255*8975f5c5SAndroid Build Coastguard Worker bool Context::getIndexedQueryParameterInfo(GLenum target,
9256*8975f5c5SAndroid Build Coastguard Worker                                            GLenum *type,
9257*8975f5c5SAndroid Build Coastguard Worker                                            unsigned int *numParams) const
9258*8975f5c5SAndroid Build Coastguard Worker {
9259*8975f5c5SAndroid Build Coastguard Worker     return GetIndexedQueryParameterInfo(mState, target, type, numParams);
9260*8975f5c5SAndroid Build Coastguard Worker }
9261*8975f5c5SAndroid Build Coastguard Worker 
getProgramNoResolveLink(ShaderProgramID handle) const9262*8975f5c5SAndroid Build Coastguard Worker Program *Context::getProgramNoResolveLink(ShaderProgramID handle) const
9263*8975f5c5SAndroid Build Coastguard Worker {
9264*8975f5c5SAndroid Build Coastguard Worker     return mState.mShaderProgramManager->getProgram(handle);
9265*8975f5c5SAndroid Build Coastguard Worker }
9266*8975f5c5SAndroid Build Coastguard Worker 
getShaderResolveCompile(ShaderProgramID handle) const9267*8975f5c5SAndroid Build Coastguard Worker Shader *Context::getShaderResolveCompile(ShaderProgramID handle) const
9268*8975f5c5SAndroid Build Coastguard Worker {
9269*8975f5c5SAndroid Build Coastguard Worker     Shader *shader = getShaderNoResolveCompile(handle);
9270*8975f5c5SAndroid Build Coastguard Worker     if (shader)
9271*8975f5c5SAndroid Build Coastguard Worker     {
9272*8975f5c5SAndroid Build Coastguard Worker         shader->resolveCompile(this);
9273*8975f5c5SAndroid Build Coastguard Worker     }
9274*8975f5c5SAndroid Build Coastguard Worker     return shader;
9275*8975f5c5SAndroid Build Coastguard Worker }
9276*8975f5c5SAndroid Build Coastguard Worker 
getShaderNoResolveCompile(ShaderProgramID handle) const9277*8975f5c5SAndroid Build Coastguard Worker Shader *Context::getShaderNoResolveCompile(ShaderProgramID handle) const
9278*8975f5c5SAndroid Build Coastguard Worker {
9279*8975f5c5SAndroid Build Coastguard Worker     return mState.mShaderProgramManager->getShader(handle);
9280*8975f5c5SAndroid Build Coastguard Worker }
9281*8975f5c5SAndroid Build Coastguard Worker 
getFrontendFeatures() const9282*8975f5c5SAndroid Build Coastguard Worker const angle::FrontendFeatures &Context::getFrontendFeatures() const
9283*8975f5c5SAndroid Build Coastguard Worker {
9284*8975f5c5SAndroid Build Coastguard Worker     return mDisplay->getFrontendFeatures();
9285*8975f5c5SAndroid Build Coastguard Worker }
9286*8975f5c5SAndroid Build Coastguard Worker 
isRenderbufferGenerated(RenderbufferID renderbuffer) const9287*8975f5c5SAndroid Build Coastguard Worker bool Context::isRenderbufferGenerated(RenderbufferID renderbuffer) const
9288*8975f5c5SAndroid Build Coastguard Worker {
9289*8975f5c5SAndroid Build Coastguard Worker     return mState.mRenderbufferManager->isHandleGenerated(renderbuffer);
9290*8975f5c5SAndroid Build Coastguard Worker }
9291*8975f5c5SAndroid Build Coastguard Worker 
isFramebufferGenerated(FramebufferID framebuffer) const9292*8975f5c5SAndroid Build Coastguard Worker bool Context::isFramebufferGenerated(FramebufferID framebuffer) const
9293*8975f5c5SAndroid Build Coastguard Worker {
9294*8975f5c5SAndroid Build Coastguard Worker     return mState.mFramebufferManager->isHandleGenerated(framebuffer);
9295*8975f5c5SAndroid Build Coastguard Worker }
9296*8975f5c5SAndroid Build Coastguard Worker 
isProgramPipelineGenerated(ProgramPipelineID pipeline) const9297*8975f5c5SAndroid Build Coastguard Worker bool Context::isProgramPipelineGenerated(ProgramPipelineID pipeline) const
9298*8975f5c5SAndroid Build Coastguard Worker {
9299*8975f5c5SAndroid Build Coastguard Worker     return mState.mProgramPipelineManager->isHandleGenerated(pipeline);
9300*8975f5c5SAndroid Build Coastguard Worker }
9301*8975f5c5SAndroid Build Coastguard Worker 
usingDisplayTextureShareGroup() const9302*8975f5c5SAndroid Build Coastguard Worker bool Context::usingDisplayTextureShareGroup() const
9303*8975f5c5SAndroid Build Coastguard Worker {
9304*8975f5c5SAndroid Build Coastguard Worker     return mDisplayTextureShareGroup;
9305*8975f5c5SAndroid Build Coastguard Worker }
9306*8975f5c5SAndroid Build Coastguard Worker 
usingDisplaySemaphoreShareGroup() const9307*8975f5c5SAndroid Build Coastguard Worker bool Context::usingDisplaySemaphoreShareGroup() const
9308*8975f5c5SAndroid Build Coastguard Worker {
9309*8975f5c5SAndroid Build Coastguard Worker     return mDisplaySemaphoreShareGroup;
9310*8975f5c5SAndroid Build Coastguard Worker }
9311*8975f5c5SAndroid Build Coastguard Worker 
getConvertedRenderbufferFormat(GLenum internalformat) const9312*8975f5c5SAndroid Build Coastguard Worker GLenum Context::getConvertedRenderbufferFormat(GLenum internalformat) const
9313*8975f5c5SAndroid Build Coastguard Worker {
9314*8975f5c5SAndroid Build Coastguard Worker     if (isWebGL() && mState.getClientMajorVersion() == 2 && internalformat == GL_DEPTH_STENCIL)
9315*8975f5c5SAndroid Build Coastguard Worker     {
9316*8975f5c5SAndroid Build Coastguard Worker         return GL_DEPTH24_STENCIL8;
9317*8975f5c5SAndroid Build Coastguard Worker     }
9318*8975f5c5SAndroid Build Coastguard Worker     return internalformat;
9319*8975f5c5SAndroid Build Coastguard Worker }
9320*8975f5c5SAndroid Build Coastguard Worker 
maxShaderCompilerThreads(GLuint count)9321*8975f5c5SAndroid Build Coastguard Worker void Context::maxShaderCompilerThreads(GLuint count)
9322*8975f5c5SAndroid Build Coastguard Worker {
9323*8975f5c5SAndroid Build Coastguard Worker     // A count of zero specifies a request for no parallel compiling or linking.  This is handled in
9324*8975f5c5SAndroid Build Coastguard Worker     // getShaderCompileThreadPool.  Otherwise the count itself has no effect as the pool is shared
9325*8975f5c5SAndroid Build Coastguard Worker     // between contexts.
9326*8975f5c5SAndroid Build Coastguard Worker     mState.setMaxShaderCompilerThreads(count);
9327*8975f5c5SAndroid Build Coastguard Worker     mImplementation->setMaxShaderCompilerThreads(count);
9328*8975f5c5SAndroid Build Coastguard Worker }
9329*8975f5c5SAndroid Build Coastguard Worker 
framebufferParameteriMESA(GLenum target,GLenum pname,GLint param)9330*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferParameteriMESA(GLenum target, GLenum pname, GLint param)
9331*8975f5c5SAndroid Build Coastguard Worker {
9332*8975f5c5SAndroid Build Coastguard Worker     framebufferParameteri(target, pname, param);
9333*8975f5c5SAndroid Build Coastguard Worker }
9334*8975f5c5SAndroid Build Coastguard Worker 
getFramebufferParameterivMESA(GLenum target,GLenum pname,GLint * params)9335*8975f5c5SAndroid Build Coastguard Worker void Context::getFramebufferParameterivMESA(GLenum target, GLenum pname, GLint *params)
9336*8975f5c5SAndroid Build Coastguard Worker {
9337*8975f5c5SAndroid Build Coastguard Worker     getFramebufferParameteriv(target, pname, params);
9338*8975f5c5SAndroid Build Coastguard Worker }
9339*8975f5c5SAndroid Build Coastguard Worker 
isGLES1() const9340*8975f5c5SAndroid Build Coastguard Worker bool Context::isGLES1() const
9341*8975f5c5SAndroid Build Coastguard Worker {
9342*8975f5c5SAndroid Build Coastguard Worker     return mState.isGLES1();
9343*8975f5c5SAndroid Build Coastguard Worker }
9344*8975f5c5SAndroid Build Coastguard Worker 
getShaderCompileThreadPool() const9345*8975f5c5SAndroid Build Coastguard Worker std::shared_ptr<angle::WorkerThreadPool> Context::getShaderCompileThreadPool() const
9346*8975f5c5SAndroid Build Coastguard Worker {
9347*8975f5c5SAndroid Build Coastguard Worker     if (mState.getExtensions().parallelShaderCompileKHR && mState.getMaxShaderCompilerThreads() > 0)
9348*8975f5c5SAndroid Build Coastguard Worker     {
9349*8975f5c5SAndroid Build Coastguard Worker         return mDisplay->getMultiThreadPool();
9350*8975f5c5SAndroid Build Coastguard Worker     }
9351*8975f5c5SAndroid Build Coastguard Worker     return mDisplay->getSingleThreadPool();
9352*8975f5c5SAndroid Build Coastguard Worker }
9353*8975f5c5SAndroid Build Coastguard Worker 
getLinkSubTaskThreadPool() const9354*8975f5c5SAndroid Build Coastguard Worker std::shared_ptr<angle::WorkerThreadPool> Context::getLinkSubTaskThreadPool() const
9355*8975f5c5SAndroid Build Coastguard Worker {
9356*8975f5c5SAndroid Build Coastguard Worker     return getFrontendFeatures().alwaysRunLinkSubJobsThreaded.enabled
9357*8975f5c5SAndroid Build Coastguard Worker                ? getWorkerThreadPool()
9358*8975f5c5SAndroid Build Coastguard Worker                : getShaderCompileThreadPool();
9359*8975f5c5SAndroid Build Coastguard Worker }
9360*8975f5c5SAndroid Build Coastguard Worker 
postCompileLinkTask(const std::shared_ptr<angle::Closure> & task,angle::JobThreadSafety safety,angle::JobResultExpectancy resultExpectancy) const9361*8975f5c5SAndroid Build Coastguard Worker std::shared_ptr<angle::WaitableEvent> Context::postCompileLinkTask(
9362*8975f5c5SAndroid Build Coastguard Worker     const std::shared_ptr<angle::Closure> &task,
9363*8975f5c5SAndroid Build Coastguard Worker     angle::JobThreadSafety safety,
9364*8975f5c5SAndroid Build Coastguard Worker     angle::JobResultExpectancy resultExpectancy) const
9365*8975f5c5SAndroid Build Coastguard Worker {
9366*8975f5c5SAndroid Build Coastguard Worker     // If the compile/link job is not thread safe, use the single-thread pool.  Otherwise, the pool
9367*8975f5c5SAndroid Build Coastguard Worker     // that is configured by the application (through GL_KHR_parallel_shader_compile) is used.
9368*8975f5c5SAndroid Build Coastguard Worker     const bool isThreadSafe = safety == angle::JobThreadSafety::Safe;
9369*8975f5c5SAndroid Build Coastguard Worker     std::shared_ptr<angle::WorkerThreadPool> workerPool =
9370*8975f5c5SAndroid Build Coastguard Worker         isThreadSafe ? getShaderCompileThreadPool() : getSingleThreadPool();
9371*8975f5c5SAndroid Build Coastguard Worker 
9372*8975f5c5SAndroid Build Coastguard Worker     // If the job is thread-safe, but it's still not going to be threaded, then it's performed as an
9373*8975f5c5SAndroid Build Coastguard Worker     // unlocked tail call to allow other threads to proceed.  This is only possible if the results
9374*8975f5c5SAndroid Build Coastguard Worker     // of the call are not immediately needed in the same entry point call.
9375*8975f5c5SAndroid Build Coastguard Worker     if (isThreadSafe && !workerPool->isAsync() &&
9376*8975f5c5SAndroid Build Coastguard Worker         resultExpectancy == angle::JobResultExpectancy::Future &&
9377*8975f5c5SAndroid Build Coastguard Worker         !getShareGroup()->getFrameCaptureShared()->enabled())
9378*8975f5c5SAndroid Build Coastguard Worker     {
9379*8975f5c5SAndroid Build Coastguard Worker         std::shared_ptr<angle::AsyncWaitableEvent> event =
9380*8975f5c5SAndroid Build Coastguard Worker             std::make_shared<angle::AsyncWaitableEvent>();
9381*8975f5c5SAndroid Build Coastguard Worker         auto unlockedTask = [task, event](void *resultOut) {
9382*8975f5c5SAndroid Build Coastguard Worker             ANGLE_TRACE_EVENT0("gpu.angle", "Compile/Link (unlocked)");
9383*8975f5c5SAndroid Build Coastguard Worker             (*task)();
9384*8975f5c5SAndroid Build Coastguard Worker             event->markAsReady();
9385*8975f5c5SAndroid Build Coastguard Worker         };
9386*8975f5c5SAndroid Build Coastguard Worker         egl::Display::GetCurrentThreadUnlockedTailCall()->add(unlockedTask);
9387*8975f5c5SAndroid Build Coastguard Worker         return event;
9388*8975f5c5SAndroid Build Coastguard Worker     }
9389*8975f5c5SAndroid Build Coastguard Worker 
9390*8975f5c5SAndroid Build Coastguard Worker     // Otherwise, just schedule the task on the pool
9391*8975f5c5SAndroid Build Coastguard Worker     return workerPool->postWorkerTask(task);
9392*8975f5c5SAndroid Build Coastguard Worker }
9393*8975f5c5SAndroid Build Coastguard Worker 
getSingleThreadPool() const9394*8975f5c5SAndroid Build Coastguard Worker std::shared_ptr<angle::WorkerThreadPool> Context::getSingleThreadPool() const
9395*8975f5c5SAndroid Build Coastguard Worker {
9396*8975f5c5SAndroid Build Coastguard Worker     return mDisplay->getSingleThreadPool();
9397*8975f5c5SAndroid Build Coastguard Worker }
9398*8975f5c5SAndroid Build Coastguard Worker 
getWorkerThreadPool() const9399*8975f5c5SAndroid Build Coastguard Worker std::shared_ptr<angle::WorkerThreadPool> Context::getWorkerThreadPool() const
9400*8975f5c5SAndroid Build Coastguard Worker {
9401*8975f5c5SAndroid Build Coastguard Worker     return mDisplay->getMultiThreadPool();
9402*8975f5c5SAndroid Build Coastguard Worker }
9403*8975f5c5SAndroid Build Coastguard Worker 
onUniformBlockBindingUpdated(GLuint uniformBlockIndex)9404*8975f5c5SAndroid Build Coastguard Worker void Context::onUniformBlockBindingUpdated(GLuint uniformBlockIndex)
9405*8975f5c5SAndroid Build Coastguard Worker {
9406*8975f5c5SAndroid Build Coastguard Worker     mState.mDirtyBits.set(state::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS);
9407*8975f5c5SAndroid Build Coastguard Worker     mState.mDirtyUniformBlocks.set(uniformBlockIndex);
9408*8975f5c5SAndroid Build Coastguard Worker     mStateCache.onUniformBufferStateChange(this);
9409*8975f5c5SAndroid Build Coastguard Worker }
9410*8975f5c5SAndroid Build Coastguard Worker 
endTilingImplicit()9411*8975f5c5SAndroid Build Coastguard Worker void Context::endTilingImplicit()
9412*8975f5c5SAndroid Build Coastguard Worker {
9413*8975f5c5SAndroid Build Coastguard Worker     if (getMutablePrivateState()->isTiledRendering())
9414*8975f5c5SAndroid Build Coastguard Worker     {
9415*8975f5c5SAndroid Build Coastguard Worker         ANGLE_PERF_WARNING(getState().getDebug(), GL_DEBUG_SEVERITY_LOW,
9416*8975f5c5SAndroid Build Coastguard Worker                            "Implicitly ending tiled rendering due to framebuffer state change");
9417*8975f5c5SAndroid Build Coastguard Worker         getMutablePrivateState()->setTiledRendering(false);
9418*8975f5c5SAndroid Build Coastguard Worker     }
9419*8975f5c5SAndroid Build Coastguard Worker }
9420*8975f5c5SAndroid Build Coastguard Worker 
onSubjectStateChange(angle::SubjectIndex index,angle::SubjectMessage message)9421*8975f5c5SAndroid Build Coastguard Worker void Context::onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message)
9422*8975f5c5SAndroid Build Coastguard Worker {
9423*8975f5c5SAndroid Build Coastguard Worker     switch (index)
9424*8975f5c5SAndroid Build Coastguard Worker     {
9425*8975f5c5SAndroid Build Coastguard Worker         case kVertexArraySubjectIndex:
9426*8975f5c5SAndroid Build Coastguard Worker             switch (message)
9427*8975f5c5SAndroid Build Coastguard Worker             {
9428*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::ContentsChanged:
9429*8975f5c5SAndroid Build Coastguard Worker                     mState.setObjectDirty(GL_VERTEX_ARRAY);
9430*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onVertexArrayBufferContentsChange(this);
9431*8975f5c5SAndroid Build Coastguard Worker                     break;
9432*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::SubjectMapped:
9433*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::SubjectUnmapped:
9434*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::BindingChanged:
9435*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onVertexArrayBufferStateChange(this);
9436*8975f5c5SAndroid Build Coastguard Worker                     break;
9437*8975f5c5SAndroid Build Coastguard Worker                 default:
9438*8975f5c5SAndroid Build Coastguard Worker                     break;
9439*8975f5c5SAndroid Build Coastguard Worker             }
9440*8975f5c5SAndroid Build Coastguard Worker             break;
9441*8975f5c5SAndroid Build Coastguard Worker 
9442*8975f5c5SAndroid Build Coastguard Worker         case kReadFramebufferSubjectIndex:
9443*8975f5c5SAndroid Build Coastguard Worker             switch (message)
9444*8975f5c5SAndroid Build Coastguard Worker             {
9445*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::DirtyBitsFlagged:
9446*8975f5c5SAndroid Build Coastguard Worker                     mState.setReadFramebufferDirty();
9447*8975f5c5SAndroid Build Coastguard Worker                     break;
9448*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::SurfaceChanged:
9449*8975f5c5SAndroid Build Coastguard Worker                     mState.setReadFramebufferBindingDirty();
9450*8975f5c5SAndroid Build Coastguard Worker                     break;
9451*8975f5c5SAndroid Build Coastguard Worker                 default:
9452*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
9453*8975f5c5SAndroid Build Coastguard Worker                     break;
9454*8975f5c5SAndroid Build Coastguard Worker             }
9455*8975f5c5SAndroid Build Coastguard Worker             break;
9456*8975f5c5SAndroid Build Coastguard Worker 
9457*8975f5c5SAndroid Build Coastguard Worker         case kDrawFramebufferSubjectIndex:
9458*8975f5c5SAndroid Build Coastguard Worker             switch (message)
9459*8975f5c5SAndroid Build Coastguard Worker             {
9460*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::DirtyBitsFlagged:
9461*8975f5c5SAndroid Build Coastguard Worker                     mState.setDrawFramebufferDirty();
9462*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onDrawFramebufferChange(this);
9463*8975f5c5SAndroid Build Coastguard Worker                     break;
9464*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::SurfaceChanged:
9465*8975f5c5SAndroid Build Coastguard Worker                     mState.setDrawFramebufferBindingDirty();
9466*8975f5c5SAndroid Build Coastguard Worker                     break;
9467*8975f5c5SAndroid Build Coastguard Worker                 default:
9468*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
9469*8975f5c5SAndroid Build Coastguard Worker                     break;
9470*8975f5c5SAndroid Build Coastguard Worker             }
9471*8975f5c5SAndroid Build Coastguard Worker             break;
9472*8975f5c5SAndroid Build Coastguard Worker 
9473*8975f5c5SAndroid Build Coastguard Worker         case kProgramSubjectIndex:
9474*8975f5c5SAndroid Build Coastguard Worker             switch (message)
9475*8975f5c5SAndroid Build Coastguard Worker             {
9476*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::ProgramUnlinked:
9477*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onProgramExecutableChange(this);
9478*8975f5c5SAndroid Build Coastguard Worker                     break;
9479*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::ProgramRelinked:
9480*8975f5c5SAndroid Build Coastguard Worker                 {
9481*8975f5c5SAndroid Build Coastguard Worker                     Program *program = mState.getProgram();
9482*8975f5c5SAndroid Build Coastguard Worker                     ASSERT(program->isLinked());
9483*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_CONTEXT_TRY(mState.installProgramExecutable(this));
9484*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onProgramExecutableChange(this);
9485*8975f5c5SAndroid Build Coastguard Worker                     break;
9486*8975f5c5SAndroid Build Coastguard Worker                 }
9487*8975f5c5SAndroid Build Coastguard Worker                 default:
9488*8975f5c5SAndroid Build Coastguard Worker                     if (angle::IsProgramUniformBlockBindingUpdatedMessage(message))
9489*8975f5c5SAndroid Build Coastguard Worker                     {
9490*8975f5c5SAndroid Build Coastguard Worker                         onUniformBlockBindingUpdated(
9491*8975f5c5SAndroid Build Coastguard Worker                             angle::ProgramUniformBlockBindingUpdatedMessageToIndex(message));
9492*8975f5c5SAndroid Build Coastguard Worker                         break;
9493*8975f5c5SAndroid Build Coastguard Worker                     }
9494*8975f5c5SAndroid Build Coastguard Worker                     // Ignore all the other notifications
9495*8975f5c5SAndroid Build Coastguard Worker                     break;
9496*8975f5c5SAndroid Build Coastguard Worker             }
9497*8975f5c5SAndroid Build Coastguard Worker             break;
9498*8975f5c5SAndroid Build Coastguard Worker 
9499*8975f5c5SAndroid Build Coastguard Worker         case kProgramPipelineSubjectIndex:
9500*8975f5c5SAndroid Build Coastguard Worker             switch (message)
9501*8975f5c5SAndroid Build Coastguard Worker             {
9502*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::ProgramUnlinked:
9503*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onProgramExecutableChange(this);
9504*8975f5c5SAndroid Build Coastguard Worker                     break;
9505*8975f5c5SAndroid Build Coastguard Worker                 case angle::SubjectMessage::ProgramRelinked:
9506*8975f5c5SAndroid Build Coastguard Worker                     ANGLE_CONTEXT_TRY(mState.installProgramPipelineExecutable(this));
9507*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onProgramExecutableChange(this);
9508*8975f5c5SAndroid Build Coastguard Worker                     break;
9509*8975f5c5SAndroid Build Coastguard Worker                 default:
9510*8975f5c5SAndroid Build Coastguard Worker                     if (angle::IsProgramUniformBlockBindingUpdatedMessage(message))
9511*8975f5c5SAndroid Build Coastguard Worker                     {
9512*8975f5c5SAndroid Build Coastguard Worker                         // Note: if there's a program bound, its executable is used (and not the
9513*8975f5c5SAndroid Build Coastguard Worker                         // PPO's)
9514*8975f5c5SAndroid Build Coastguard Worker                         if (mState.getProgram() == nullptr)
9515*8975f5c5SAndroid Build Coastguard Worker                         {
9516*8975f5c5SAndroid Build Coastguard Worker                             onUniformBlockBindingUpdated(
9517*8975f5c5SAndroid Build Coastguard Worker                                 angle::ProgramUniformBlockBindingUpdatedMessageToIndex(message));
9518*8975f5c5SAndroid Build Coastguard Worker                         }
9519*8975f5c5SAndroid Build Coastguard Worker                         break;
9520*8975f5c5SAndroid Build Coastguard Worker                     }
9521*8975f5c5SAndroid Build Coastguard Worker                     UNREACHABLE();
9522*8975f5c5SAndroid Build Coastguard Worker                     break;
9523*8975f5c5SAndroid Build Coastguard Worker             }
9524*8975f5c5SAndroid Build Coastguard Worker             break;
9525*8975f5c5SAndroid Build Coastguard Worker 
9526*8975f5c5SAndroid Build Coastguard Worker         default:
9527*8975f5c5SAndroid Build Coastguard Worker             if (index < kTextureMaxSubjectIndex)
9528*8975f5c5SAndroid Build Coastguard Worker             {
9529*8975f5c5SAndroid Build Coastguard Worker                 if (message != angle::SubjectMessage::ContentsChanged &&
9530*8975f5c5SAndroid Build Coastguard Worker                     message != angle::SubjectMessage::BindingChanged)
9531*8975f5c5SAndroid Build Coastguard Worker                 {
9532*8975f5c5SAndroid Build Coastguard Worker                     mState.onActiveTextureStateChange(this, index);
9533*8975f5c5SAndroid Build Coastguard Worker                     mStateCache.onActiveTextureChange(this);
9534*8975f5c5SAndroid Build Coastguard Worker                 }
9535*8975f5c5SAndroid Build Coastguard Worker             }
9536*8975f5c5SAndroid Build Coastguard Worker             else if (index < kImageMaxSubjectIndex)
9537*8975f5c5SAndroid Build Coastguard Worker             {
9538*8975f5c5SAndroid Build Coastguard Worker                 mState.onImageStateChange(this, index - kImage0SubjectIndex);
9539*8975f5c5SAndroid Build Coastguard Worker                 if (message == angle::SubjectMessage::ContentsChanged)
9540*8975f5c5SAndroid Build Coastguard Worker                 {
9541*8975f5c5SAndroid Build Coastguard Worker                     mState.mDirtyBits.set(state::DirtyBitType::DIRTY_BIT_IMAGE_BINDINGS);
9542*8975f5c5SAndroid Build Coastguard Worker                 }
9543*8975f5c5SAndroid Build Coastguard Worker             }
9544*8975f5c5SAndroid Build Coastguard Worker             else if (index < kUniformBufferMaxSubjectIndex)
9545*8975f5c5SAndroid Build Coastguard Worker             {
9546*8975f5c5SAndroid Build Coastguard Worker                 mState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex);
9547*8975f5c5SAndroid Build Coastguard Worker                 mStateCache.onUniformBufferStateChange(this);
9548*8975f5c5SAndroid Build Coastguard Worker             }
9549*8975f5c5SAndroid Build Coastguard Worker             else if (index < kAtomicCounterBufferMaxSubjectIndex)
9550*8975f5c5SAndroid Build Coastguard Worker             {
9551*8975f5c5SAndroid Build Coastguard Worker                 mState.onAtomicCounterBufferStateChange(index - kAtomicCounterBuffer0SubjectIndex);
9552*8975f5c5SAndroid Build Coastguard Worker                 mStateCache.onAtomicCounterBufferStateChange(this);
9553*8975f5c5SAndroid Build Coastguard Worker             }
9554*8975f5c5SAndroid Build Coastguard Worker             else if (index < kShaderStorageBufferMaxSubjectIndex)
9555*8975f5c5SAndroid Build Coastguard Worker             {
9556*8975f5c5SAndroid Build Coastguard Worker                 mState.onShaderStorageBufferStateChange(index - kShaderStorageBuffer0SubjectIndex);
9557*8975f5c5SAndroid Build Coastguard Worker                 mStateCache.onShaderStorageBufferStateChange(this);
9558*8975f5c5SAndroid Build Coastguard Worker             }
9559*8975f5c5SAndroid Build Coastguard Worker             else
9560*8975f5c5SAndroid Build Coastguard Worker             {
9561*8975f5c5SAndroid Build Coastguard Worker                 ASSERT(index < kSamplerMaxSubjectIndex);
9562*8975f5c5SAndroid Build Coastguard Worker                 mState.setSamplerDirty(index - kSampler0SubjectIndex);
9563*8975f5c5SAndroid Build Coastguard Worker                 mState.onActiveTextureStateChange(this, index - kSampler0SubjectIndex);
9564*8975f5c5SAndroid Build Coastguard Worker             }
9565*8975f5c5SAndroid Build Coastguard Worker             break;
9566*8975f5c5SAndroid Build Coastguard Worker     }
9567*8975f5c5SAndroid Build Coastguard Worker }
9568*8975f5c5SAndroid Build Coastguard Worker 
setDefaultFramebuffer(egl::Surface * drawSurface,egl::Surface * readSurface)9569*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::setDefaultFramebuffer(egl::Surface *drawSurface, egl::Surface *readSurface)
9570*8975f5c5SAndroid Build Coastguard Worker {
9571*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mCurrentDrawSurface == nullptr);
9572*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mCurrentReadSurface == nullptr);
9573*8975f5c5SAndroid Build Coastguard Worker 
9574*8975f5c5SAndroid Build Coastguard Worker     mCurrentDrawSurface = drawSurface;
9575*8975f5c5SAndroid Build Coastguard Worker     mCurrentReadSurface = readSurface;
9576*8975f5c5SAndroid Build Coastguard Worker 
9577*8975f5c5SAndroid Build Coastguard Worker     if (drawSurface != nullptr)
9578*8975f5c5SAndroid Build Coastguard Worker     {
9579*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(drawSurface->makeCurrent(this));
9580*8975f5c5SAndroid Build Coastguard Worker     }
9581*8975f5c5SAndroid Build Coastguard Worker 
9582*8975f5c5SAndroid Build Coastguard Worker     ANGLE_TRY(mDefaultFramebuffer->setSurfaces(this, drawSurface, readSurface));
9583*8975f5c5SAndroid Build Coastguard Worker 
9584*8975f5c5SAndroid Build Coastguard Worker     if (readSurface && (drawSurface != readSurface))
9585*8975f5c5SAndroid Build Coastguard Worker     {
9586*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(readSurface->makeCurrent(this));
9587*8975f5c5SAndroid Build Coastguard Worker     }
9588*8975f5c5SAndroid Build Coastguard Worker 
9589*8975f5c5SAndroid Build Coastguard Worker     // Update default framebuffer, the binding of the previous default
9590*8975f5c5SAndroid Build Coastguard Worker     // framebuffer (or lack of) will have a nullptr.
9591*8975f5c5SAndroid Build Coastguard Worker     mState.mFramebufferManager->setDefaultFramebuffer(mDefaultFramebuffer.get());
9592*8975f5c5SAndroid Build Coastguard Worker     if (mState.getDrawFramebuffer() == nullptr)
9593*8975f5c5SAndroid Build Coastguard Worker     {
9594*8975f5c5SAndroid Build Coastguard Worker         bindDrawFramebuffer(mDefaultFramebuffer->id());
9595*8975f5c5SAndroid Build Coastguard Worker     }
9596*8975f5c5SAndroid Build Coastguard Worker     if (mState.getReadFramebuffer() == nullptr)
9597*8975f5c5SAndroid Build Coastguard Worker     {
9598*8975f5c5SAndroid Build Coastguard Worker         bindReadFramebuffer(mDefaultFramebuffer->id());
9599*8975f5c5SAndroid Build Coastguard Worker     }
9600*8975f5c5SAndroid Build Coastguard Worker 
9601*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
9602*8975f5c5SAndroid Build Coastguard Worker }
9603*8975f5c5SAndroid Build Coastguard Worker 
unsetDefaultFramebuffer()9604*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::unsetDefaultFramebuffer()
9605*8975f5c5SAndroid Build Coastguard Worker {
9606*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *defaultFramebuffer =
9607*8975f5c5SAndroid Build Coastguard Worker         mState.mFramebufferManager->getFramebuffer(Framebuffer::kDefaultDrawFramebufferHandle);
9608*8975f5c5SAndroid Build Coastguard Worker 
9609*8975f5c5SAndroid Build Coastguard Worker     if (defaultFramebuffer)
9610*8975f5c5SAndroid Build Coastguard Worker     {
9611*8975f5c5SAndroid Build Coastguard Worker         // Remove the default framebuffer
9612*8975f5c5SAndroid Build Coastguard Worker         if (defaultFramebuffer == mState.getReadFramebuffer())
9613*8975f5c5SAndroid Build Coastguard Worker         {
9614*8975f5c5SAndroid Build Coastguard Worker             mState.setReadFramebufferBinding(nullptr);
9615*8975f5c5SAndroid Build Coastguard Worker             mReadFramebufferObserverBinding.bind(nullptr);
9616*8975f5c5SAndroid Build Coastguard Worker         }
9617*8975f5c5SAndroid Build Coastguard Worker 
9618*8975f5c5SAndroid Build Coastguard Worker         if (defaultFramebuffer == mState.getDrawFramebuffer())
9619*8975f5c5SAndroid Build Coastguard Worker         {
9620*8975f5c5SAndroid Build Coastguard Worker             mState.setDrawFramebufferBinding(nullptr);
9621*8975f5c5SAndroid Build Coastguard Worker             mDrawFramebufferObserverBinding.bind(nullptr);
9622*8975f5c5SAndroid Build Coastguard Worker         }
9623*8975f5c5SAndroid Build Coastguard Worker 
9624*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(defaultFramebuffer->unsetSurfaces(this));
9625*8975f5c5SAndroid Build Coastguard Worker         mState.mFramebufferManager->setDefaultFramebuffer(nullptr);
9626*8975f5c5SAndroid Build Coastguard Worker     }
9627*8975f5c5SAndroid Build Coastguard Worker 
9628*8975f5c5SAndroid Build Coastguard Worker     // Always unset the current surface, even if setIsCurrent fails.
9629*8975f5c5SAndroid Build Coastguard Worker     egl::Surface *drawSurface = mCurrentDrawSurface;
9630*8975f5c5SAndroid Build Coastguard Worker     egl::Surface *readSurface = mCurrentReadSurface;
9631*8975f5c5SAndroid Build Coastguard Worker     mCurrentDrawSurface       = nullptr;
9632*8975f5c5SAndroid Build Coastguard Worker     mCurrentReadSurface       = nullptr;
9633*8975f5c5SAndroid Build Coastguard Worker     if (drawSurface)
9634*8975f5c5SAndroid Build Coastguard Worker     {
9635*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(drawSurface->unMakeCurrent(this));
9636*8975f5c5SAndroid Build Coastguard Worker     }
9637*8975f5c5SAndroid Build Coastguard Worker     if (drawSurface != readSurface)
9638*8975f5c5SAndroid Build Coastguard Worker     {
9639*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(readSurface->unMakeCurrent(this));
9640*8975f5c5SAndroid Build Coastguard Worker     }
9641*8975f5c5SAndroid Build Coastguard Worker 
9642*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
9643*8975f5c5SAndroid Build Coastguard Worker }
9644*8975f5c5SAndroid Build Coastguard Worker 
onPreSwap()9645*8975f5c5SAndroid Build Coastguard Worker void Context::onPreSwap()
9646*8975f5c5SAndroid Build Coastguard Worker {
9647*8975f5c5SAndroid Build Coastguard Worker     // Dump frame capture if enabled.
9648*8975f5c5SAndroid Build Coastguard Worker     getShareGroup()->getFrameCaptureShared()->onEndFrame(this);
9649*8975f5c5SAndroid Build Coastguard Worker }
9650*8975f5c5SAndroid Build Coastguard Worker 
getTexImage(TextureTarget target,GLint level,GLenum format,GLenum type,void * pixels)9651*8975f5c5SAndroid Build Coastguard Worker void Context::getTexImage(TextureTarget target,
9652*8975f5c5SAndroid Build Coastguard Worker                           GLint level,
9653*8975f5c5SAndroid Build Coastguard Worker                           GLenum format,
9654*8975f5c5SAndroid Build Coastguard Worker                           GLenum type,
9655*8975f5c5SAndroid Build Coastguard Worker                           void *pixels)
9656*8975f5c5SAndroid Build Coastguard Worker {
9657*8975f5c5SAndroid Build Coastguard Worker     Texture *texture   = getTextureByTarget(target);
9658*8975f5c5SAndroid Build Coastguard Worker     Buffer *packBuffer = mState.getTargetBuffer(BufferBinding::PixelPack);
9659*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->getTexImage(this, mState.getPackState(), packBuffer, target, level,
9660*8975f5c5SAndroid Build Coastguard Worker                                            format, type, pixels));
9661*8975f5c5SAndroid Build Coastguard Worker }
9662*8975f5c5SAndroid Build Coastguard Worker 
getCompressedTexImage(TextureTarget target,GLint level,void * pixels)9663*8975f5c5SAndroid Build Coastguard Worker void Context::getCompressedTexImage(TextureTarget target, GLint level, void *pixels)
9664*8975f5c5SAndroid Build Coastguard Worker {
9665*8975f5c5SAndroid Build Coastguard Worker     Texture *texture   = getTextureByTarget(target);
9666*8975f5c5SAndroid Build Coastguard Worker     Buffer *packBuffer = mState.getTargetBuffer(BufferBinding::PixelPack);
9667*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->getCompressedTexImage(this, mState.getPackState(), packBuffer,
9668*8975f5c5SAndroid Build Coastguard Worker                                                      target, level, pixels));
9669*8975f5c5SAndroid Build Coastguard Worker }
9670*8975f5c5SAndroid Build Coastguard Worker 
getRenderbufferImage(GLenum target,GLenum format,GLenum type,void * pixels)9671*8975f5c5SAndroid Build Coastguard Worker void Context::getRenderbufferImage(GLenum target, GLenum format, GLenum type, void *pixels)
9672*8975f5c5SAndroid Build Coastguard Worker {
9673*8975f5c5SAndroid Build Coastguard Worker     Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer();
9674*8975f5c5SAndroid Build Coastguard Worker     Buffer *packBuffer         = mState.getTargetBuffer(BufferBinding::PixelPack);
9675*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(renderbuffer->getRenderbufferImage(this, mState.getPackState(), packBuffer,
9676*8975f5c5SAndroid Build Coastguard Worker                                                          format, type, pixels));
9677*8975f5c5SAndroid Build Coastguard Worker }
9678*8975f5c5SAndroid Build Coastguard Worker 
setLogicOpEnabledForGLES1(bool enabled)9679*8975f5c5SAndroid Build Coastguard Worker void Context::setLogicOpEnabledForGLES1(bool enabled)
9680*8975f5c5SAndroid Build Coastguard Worker {
9681*8975f5c5SAndroid Build Coastguard Worker     // Same implementation as ContextPrivateEnable(GL_COLOR_LOGIC_OP), without the GLES1 forwarding.
9682*8975f5c5SAndroid Build Coastguard Worker     getMutablePrivateState()->setLogicOpEnabled(enabled);
9683*8975f5c5SAndroid Build Coastguard Worker     getMutablePrivateStateCache()->onCapChange();
9684*8975f5c5SAndroid Build Coastguard Worker }
9685*8975f5c5SAndroid Build Coastguard Worker 
releaseHighPowerGPU()9686*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::releaseHighPowerGPU()
9687*8975f5c5SAndroid Build Coastguard Worker {
9688*8975f5c5SAndroid Build Coastguard Worker     return mImplementation->releaseHighPowerGPU(this);
9689*8975f5c5SAndroid Build Coastguard Worker }
9690*8975f5c5SAndroid Build Coastguard Worker 
reacquireHighPowerGPU()9691*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::reacquireHighPowerGPU()
9692*8975f5c5SAndroid Build Coastguard Worker {
9693*8975f5c5SAndroid Build Coastguard Worker     return mImplementation->reacquireHighPowerGPU(this);
9694*8975f5c5SAndroid Build Coastguard Worker }
9695*8975f5c5SAndroid Build Coastguard Worker 
onGPUSwitch()9696*8975f5c5SAndroid Build Coastguard Worker void Context::onGPUSwitch()
9697*8975f5c5SAndroid Build Coastguard Worker {
9698*8975f5c5SAndroid Build Coastguard Worker     // Re-initialize the renderer string, which just changed, and
9699*8975f5c5SAndroid Build Coastguard Worker     // which must be visible to applications.
9700*8975f5c5SAndroid Build Coastguard Worker     initRendererString();
9701*8975f5c5SAndroid Build Coastguard Worker }
9702*8975f5c5SAndroid Build Coastguard Worker 
acquireExternalContext(egl::Surface * drawAndReadSurface)9703*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::acquireExternalContext(egl::Surface *drawAndReadSurface)
9704*8975f5c5SAndroid Build Coastguard Worker {
9705*8975f5c5SAndroid Build Coastguard Worker     mImplementation->acquireExternalContext(this);
9706*8975f5c5SAndroid Build Coastguard Worker 
9707*8975f5c5SAndroid Build Coastguard Worker     if (drawAndReadSurface != mCurrentDrawSurface || drawAndReadSurface != mCurrentReadSurface)
9708*8975f5c5SAndroid Build Coastguard Worker     {
9709*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(unsetDefaultFramebuffer());
9710*8975f5c5SAndroid Build Coastguard Worker         ANGLE_TRY(setDefaultFramebuffer(drawAndReadSurface, drawAndReadSurface));
9711*8975f5c5SAndroid Build Coastguard Worker     }
9712*8975f5c5SAndroid Build Coastguard Worker 
9713*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
9714*8975f5c5SAndroid Build Coastguard Worker }
9715*8975f5c5SAndroid Build Coastguard Worker 
releaseExternalContext()9716*8975f5c5SAndroid Build Coastguard Worker egl::Error Context::releaseExternalContext()
9717*8975f5c5SAndroid Build Coastguard Worker {
9718*8975f5c5SAndroid Build Coastguard Worker     mImplementation->releaseExternalContext(this);
9719*8975f5c5SAndroid Build Coastguard Worker     return egl::NoError();
9720*8975f5c5SAndroid Build Coastguard Worker }
9721*8975f5c5SAndroid Build Coastguard Worker 
getProgramCacheMutex() const9722*8975f5c5SAndroid Build Coastguard Worker angle::SimpleMutex &Context::getProgramCacheMutex() const
9723*8975f5c5SAndroid Build Coastguard Worker {
9724*8975f5c5SAndroid Build Coastguard Worker     return mDisplay->getProgramCacheMutex();
9725*8975f5c5SAndroid Build Coastguard Worker }
9726*8975f5c5SAndroid Build Coastguard Worker 
supportsGeometryOrTesselation() const9727*8975f5c5SAndroid Build Coastguard Worker bool Context::supportsGeometryOrTesselation() const
9728*8975f5c5SAndroid Build Coastguard Worker {
9729*8975f5c5SAndroid Build Coastguard Worker     return mState.getClientVersion() == ES_3_2 || mState.getExtensions().geometryShaderAny() ||
9730*8975f5c5SAndroid Build Coastguard Worker            mState.getExtensions().tessellationShaderAny();
9731*8975f5c5SAndroid Build Coastguard Worker }
9732*8975f5c5SAndroid Build Coastguard Worker 
dirtyAllState()9733*8975f5c5SAndroid Build Coastguard Worker void Context::dirtyAllState()
9734*8975f5c5SAndroid Build Coastguard Worker {
9735*8975f5c5SAndroid Build Coastguard Worker     mState.setAllDirtyBits();
9736*8975f5c5SAndroid Build Coastguard Worker     mState.setAllDirtyObjects();
9737*8975f5c5SAndroid Build Coastguard Worker     getMutableGLES1State()->setAllDirty();
9738*8975f5c5SAndroid Build Coastguard Worker }
9739*8975f5c5SAndroid Build Coastguard Worker 
finishImmutable() const9740*8975f5c5SAndroid Build Coastguard Worker void Context::finishImmutable() const
9741*8975f5c5SAndroid Build Coastguard Worker {
9742*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->finish(this));
9743*8975f5c5SAndroid Build Coastguard Worker }
9744*8975f5c5SAndroid Build Coastguard Worker 
beginPerfMonitor(GLuint monitor)9745*8975f5c5SAndroid Build Coastguard Worker void Context::beginPerfMonitor(GLuint monitor)
9746*8975f5c5SAndroid Build Coastguard Worker {
9747*8975f5c5SAndroid Build Coastguard Worker     getMutablePrivateState()->setPerfMonitorActive(true);
9748*8975f5c5SAndroid Build Coastguard Worker }
9749*8975f5c5SAndroid Build Coastguard Worker 
deletePerfMonitors(GLsizei n,GLuint * monitors)9750*8975f5c5SAndroid Build Coastguard Worker void Context::deletePerfMonitors(GLsizei n, GLuint *monitors) {}
9751*8975f5c5SAndroid Build Coastguard Worker 
endPerfMonitor(GLuint monitor)9752*8975f5c5SAndroid Build Coastguard Worker void Context::endPerfMonitor(GLuint monitor)
9753*8975f5c5SAndroid Build Coastguard Worker {
9754*8975f5c5SAndroid Build Coastguard Worker     getMutablePrivateState()->setPerfMonitorActive(false);
9755*8975f5c5SAndroid Build Coastguard Worker }
9756*8975f5c5SAndroid Build Coastguard Worker 
genPerfMonitors(GLsizei n,GLuint * monitors)9757*8975f5c5SAndroid Build Coastguard Worker void Context::genPerfMonitors(GLsizei n, GLuint *monitors)
9758*8975f5c5SAndroid Build Coastguard Worker {
9759*8975f5c5SAndroid Build Coastguard Worker     for (GLsizei monitorIndex = 0; monitorIndex < n; ++monitorIndex)
9760*8975f5c5SAndroid Build Coastguard Worker     {
9761*8975f5c5SAndroid Build Coastguard Worker         monitors[n] = static_cast<GLuint>(monitorIndex);
9762*8975f5c5SAndroid Build Coastguard Worker     }
9763*8975f5c5SAndroid Build Coastguard Worker }
9764*8975f5c5SAndroid Build Coastguard Worker 
getPerfMonitorCounterData(GLuint monitor,GLenum pname,GLsizei dataSize,GLuint * data,GLint * bytesWritten)9765*8975f5c5SAndroid Build Coastguard Worker void Context::getPerfMonitorCounterData(GLuint monitor,
9766*8975f5c5SAndroid Build Coastguard Worker                                         GLenum pname,
9767*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei dataSize,
9768*8975f5c5SAndroid Build Coastguard Worker                                         GLuint *data,
9769*8975f5c5SAndroid Build Coastguard Worker                                         GLint *bytesWritten)
9770*8975f5c5SAndroid Build Coastguard Worker {
9771*8975f5c5SAndroid Build Coastguard Worker     using namespace angle;
9772*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounterGroups &perfMonitorGroups = mImplementation->getPerfMonitorCounters();
9773*8975f5c5SAndroid Build Coastguard Worker     GLint byteCount                                   = 0;
9774*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
9775*8975f5c5SAndroid Build Coastguard Worker     {
9776*8975f5c5SAndroid Build Coastguard Worker         case GL_PERFMON_RESULT_AVAILABLE_AMD:
9777*8975f5c5SAndroid Build Coastguard Worker         {
9778*8975f5c5SAndroid Build Coastguard Worker             *data = GL_TRUE;
9779*8975f5c5SAndroid Build Coastguard Worker             byteCount += sizeof(GLuint);
9780*8975f5c5SAndroid Build Coastguard Worker             break;
9781*8975f5c5SAndroid Build Coastguard Worker         }
9782*8975f5c5SAndroid Build Coastguard Worker         case GL_PERFMON_RESULT_SIZE_AMD:
9783*8975f5c5SAndroid Build Coastguard Worker         {
9784*8975f5c5SAndroid Build Coastguard Worker             GLuint resultSize = 0;
9785*8975f5c5SAndroid Build Coastguard Worker             for (const PerfMonitorCounterGroup &group : perfMonitorGroups)
9786*8975f5c5SAndroid Build Coastguard Worker             {
9787*8975f5c5SAndroid Build Coastguard Worker                 resultSize += sizeof(PerfMonitorTriplet) * group.counters.size();
9788*8975f5c5SAndroid Build Coastguard Worker             }
9789*8975f5c5SAndroid Build Coastguard Worker             *data = resultSize;
9790*8975f5c5SAndroid Build Coastguard Worker             byteCount += sizeof(GLuint);
9791*8975f5c5SAndroid Build Coastguard Worker             break;
9792*8975f5c5SAndroid Build Coastguard Worker         }
9793*8975f5c5SAndroid Build Coastguard Worker         case GL_PERFMON_RESULT_AMD:
9794*8975f5c5SAndroid Build Coastguard Worker         {
9795*8975f5c5SAndroid Build Coastguard Worker             PerfMonitorTriplet *resultsOut = reinterpret_cast<PerfMonitorTriplet *>(data);
9796*8975f5c5SAndroid Build Coastguard Worker             GLsizei maxResults             = dataSize / sizeof(PerfMonitorTriplet);
9797*8975f5c5SAndroid Build Coastguard Worker             GLsizei resultCount            = 0;
9798*8975f5c5SAndroid Build Coastguard Worker             for (size_t groupIndex = 0;
9799*8975f5c5SAndroid Build Coastguard Worker                  groupIndex < perfMonitorGroups.size() && resultCount < maxResults; ++groupIndex)
9800*8975f5c5SAndroid Build Coastguard Worker             {
9801*8975f5c5SAndroid Build Coastguard Worker                 const PerfMonitorCounterGroup &group = perfMonitorGroups[groupIndex];
9802*8975f5c5SAndroid Build Coastguard Worker                 for (size_t counterIndex = 0;
9803*8975f5c5SAndroid Build Coastguard Worker                      counterIndex < group.counters.size() && resultCount < maxResults;
9804*8975f5c5SAndroid Build Coastguard Worker                      ++counterIndex)
9805*8975f5c5SAndroid Build Coastguard Worker                 {
9806*8975f5c5SAndroid Build Coastguard Worker                     const PerfMonitorCounter &counter = group.counters[counterIndex];
9807*8975f5c5SAndroid Build Coastguard Worker                     PerfMonitorTriplet &triplet       = resultsOut[resultCount++];
9808*8975f5c5SAndroid Build Coastguard Worker                     triplet.counter                   = static_cast<GLuint>(counterIndex);
9809*8975f5c5SAndroid Build Coastguard Worker                     triplet.group                     = static_cast<GLuint>(groupIndex);
9810*8975f5c5SAndroid Build Coastguard Worker                     triplet.value                     = counter.value;
9811*8975f5c5SAndroid Build Coastguard Worker                 }
9812*8975f5c5SAndroid Build Coastguard Worker             }
9813*8975f5c5SAndroid Build Coastguard Worker             byteCount += sizeof(PerfMonitorTriplet) * resultCount;
9814*8975f5c5SAndroid Build Coastguard Worker             break;
9815*8975f5c5SAndroid Build Coastguard Worker         }
9816*8975f5c5SAndroid Build Coastguard Worker         default:
9817*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
9818*8975f5c5SAndroid Build Coastguard Worker     }
9819*8975f5c5SAndroid Build Coastguard Worker 
9820*8975f5c5SAndroid Build Coastguard Worker     if (bytesWritten)
9821*8975f5c5SAndroid Build Coastguard Worker     {
9822*8975f5c5SAndroid Build Coastguard Worker         *bytesWritten = byteCount;
9823*8975f5c5SAndroid Build Coastguard Worker     }
9824*8975f5c5SAndroid Build Coastguard Worker }
9825*8975f5c5SAndroid Build Coastguard Worker 
getPerfMonitorCounterInfo(GLuint group,GLuint counter,GLenum pname,void * data)9826*8975f5c5SAndroid Build Coastguard Worker void Context::getPerfMonitorCounterInfo(GLuint group, GLuint counter, GLenum pname, void *data)
9827*8975f5c5SAndroid Build Coastguard Worker {
9828*8975f5c5SAndroid Build Coastguard Worker     using namespace angle;
9829*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounterGroups &perfMonitorGroups = mImplementation->getPerfMonitorCounters();
9830*8975f5c5SAndroid Build Coastguard Worker     ASSERT(group < perfMonitorGroups.size());
9831*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounters &counters = perfMonitorGroups[group].counters;
9832*8975f5c5SAndroid Build Coastguard Worker     ASSERT(counter < counters.size());
9833*8975f5c5SAndroid Build Coastguard Worker 
9834*8975f5c5SAndroid Build Coastguard Worker     switch (pname)
9835*8975f5c5SAndroid Build Coastguard Worker     {
9836*8975f5c5SAndroid Build Coastguard Worker         case GL_COUNTER_TYPE_AMD:
9837*8975f5c5SAndroid Build Coastguard Worker         {
9838*8975f5c5SAndroid Build Coastguard Worker             GLenum *dataOut = reinterpret_cast<GLenum *>(data);
9839*8975f5c5SAndroid Build Coastguard Worker             *dataOut        = GL_UNSIGNED_INT;
9840*8975f5c5SAndroid Build Coastguard Worker             break;
9841*8975f5c5SAndroid Build Coastguard Worker         }
9842*8975f5c5SAndroid Build Coastguard Worker         case GL_COUNTER_RANGE_AMD:
9843*8975f5c5SAndroid Build Coastguard Worker         {
9844*8975f5c5SAndroid Build Coastguard Worker             GLuint *dataOut = reinterpret_cast<GLuint *>(data);
9845*8975f5c5SAndroid Build Coastguard Worker             dataOut[0]      = 0;
9846*8975f5c5SAndroid Build Coastguard Worker             dataOut[1]      = std::numeric_limits<GLuint>::max();
9847*8975f5c5SAndroid Build Coastguard Worker             break;
9848*8975f5c5SAndroid Build Coastguard Worker         }
9849*8975f5c5SAndroid Build Coastguard Worker         default:
9850*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
9851*8975f5c5SAndroid Build Coastguard Worker     }
9852*8975f5c5SAndroid Build Coastguard Worker }
9853*8975f5c5SAndroid Build Coastguard Worker 
getPerfMonitorCounterString(GLuint group,GLuint counter,GLsizei bufSize,GLsizei * length,GLchar * counterString)9854*8975f5c5SAndroid Build Coastguard Worker void Context::getPerfMonitorCounterString(GLuint group,
9855*8975f5c5SAndroid Build Coastguard Worker                                           GLuint counter,
9856*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei bufSize,
9857*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei *length,
9858*8975f5c5SAndroid Build Coastguard Worker                                           GLchar *counterString)
9859*8975f5c5SAndroid Build Coastguard Worker {
9860*8975f5c5SAndroid Build Coastguard Worker     using namespace angle;
9861*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounterGroups &perfMonitorGroups = mImplementation->getPerfMonitorCounters();
9862*8975f5c5SAndroid Build Coastguard Worker     ASSERT(group < perfMonitorGroups.size());
9863*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounters &counters = perfMonitorGroups[group].counters;
9864*8975f5c5SAndroid Build Coastguard Worker     ASSERT(counter < counters.size());
9865*8975f5c5SAndroid Build Coastguard Worker     GetPerfMonitorString(counters[counter].name, bufSize, length, counterString);
9866*8975f5c5SAndroid Build Coastguard Worker }
9867*8975f5c5SAndroid Build Coastguard Worker 
getPerfMonitorCounters(GLuint group,GLint * numCounters,GLint * maxActiveCounters,GLsizei counterSize,GLuint * counters)9868*8975f5c5SAndroid Build Coastguard Worker void Context::getPerfMonitorCounters(GLuint group,
9869*8975f5c5SAndroid Build Coastguard Worker                                      GLint *numCounters,
9870*8975f5c5SAndroid Build Coastguard Worker                                      GLint *maxActiveCounters,
9871*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei counterSize,
9872*8975f5c5SAndroid Build Coastguard Worker                                      GLuint *counters)
9873*8975f5c5SAndroid Build Coastguard Worker {
9874*8975f5c5SAndroid Build Coastguard Worker     using namespace angle;
9875*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounterGroups &perfMonitorGroups = mImplementation->getPerfMonitorCounters();
9876*8975f5c5SAndroid Build Coastguard Worker     ASSERT(group < perfMonitorGroups.size());
9877*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounters &groupCounters = perfMonitorGroups[group].counters;
9878*8975f5c5SAndroid Build Coastguard Worker 
9879*8975f5c5SAndroid Build Coastguard Worker     if (numCounters)
9880*8975f5c5SAndroid Build Coastguard Worker     {
9881*8975f5c5SAndroid Build Coastguard Worker         *numCounters = static_cast<GLint>(groupCounters.size());
9882*8975f5c5SAndroid Build Coastguard Worker     }
9883*8975f5c5SAndroid Build Coastguard Worker 
9884*8975f5c5SAndroid Build Coastguard Worker     if (maxActiveCounters)
9885*8975f5c5SAndroid Build Coastguard Worker     {
9886*8975f5c5SAndroid Build Coastguard Worker         *maxActiveCounters = static_cast<GLint>(groupCounters.size());
9887*8975f5c5SAndroid Build Coastguard Worker     }
9888*8975f5c5SAndroid Build Coastguard Worker 
9889*8975f5c5SAndroid Build Coastguard Worker     if (counters)
9890*8975f5c5SAndroid Build Coastguard Worker     {
9891*8975f5c5SAndroid Build Coastguard Worker         GLsizei maxCounterIndex = std::min(counterSize, static_cast<GLsizei>(groupCounters.size()));
9892*8975f5c5SAndroid Build Coastguard Worker         for (GLsizei counterIndex = 0; counterIndex < maxCounterIndex; ++counterIndex)
9893*8975f5c5SAndroid Build Coastguard Worker         {
9894*8975f5c5SAndroid Build Coastguard Worker             counters[counterIndex] = static_cast<GLuint>(counterIndex);
9895*8975f5c5SAndroid Build Coastguard Worker         }
9896*8975f5c5SAndroid Build Coastguard Worker     }
9897*8975f5c5SAndroid Build Coastguard Worker }
9898*8975f5c5SAndroid Build Coastguard Worker 
getPerfMonitorGroupString(GLuint group,GLsizei bufSize,GLsizei * length,GLchar * groupString)9899*8975f5c5SAndroid Build Coastguard Worker void Context::getPerfMonitorGroupString(GLuint group,
9900*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei bufSize,
9901*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei *length,
9902*8975f5c5SAndroid Build Coastguard Worker                                         GLchar *groupString)
9903*8975f5c5SAndroid Build Coastguard Worker {
9904*8975f5c5SAndroid Build Coastguard Worker     using namespace angle;
9905*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounterGroups &perfMonitorGroups = mImplementation->getPerfMonitorCounters();
9906*8975f5c5SAndroid Build Coastguard Worker     ASSERT(group < perfMonitorGroups.size());
9907*8975f5c5SAndroid Build Coastguard Worker     GetPerfMonitorString(perfMonitorGroups[group].name, bufSize, length, groupString);
9908*8975f5c5SAndroid Build Coastguard Worker }
9909*8975f5c5SAndroid Build Coastguard Worker 
getPerfMonitorGroups(GLint * numGroups,GLsizei groupsSize,GLuint * groups)9910*8975f5c5SAndroid Build Coastguard Worker void Context::getPerfMonitorGroups(GLint *numGroups, GLsizei groupsSize, GLuint *groups)
9911*8975f5c5SAndroid Build Coastguard Worker {
9912*8975f5c5SAndroid Build Coastguard Worker     using namespace angle;
9913*8975f5c5SAndroid Build Coastguard Worker     const PerfMonitorCounterGroups &perfMonitorGroups = mImplementation->getPerfMonitorCounters();
9914*8975f5c5SAndroid Build Coastguard Worker 
9915*8975f5c5SAndroid Build Coastguard Worker     if (numGroups)
9916*8975f5c5SAndroid Build Coastguard Worker     {
9917*8975f5c5SAndroid Build Coastguard Worker         *numGroups = static_cast<GLint>(perfMonitorGroups.size());
9918*8975f5c5SAndroid Build Coastguard Worker     }
9919*8975f5c5SAndroid Build Coastguard Worker 
9920*8975f5c5SAndroid Build Coastguard Worker     GLuint maxGroupIndex =
9921*8975f5c5SAndroid Build Coastguard Worker         std::min<GLuint>(groupsSize, static_cast<GLuint>(perfMonitorGroups.size()));
9922*8975f5c5SAndroid Build Coastguard Worker     for (GLuint groupIndex = 0; groupIndex < maxGroupIndex; ++groupIndex)
9923*8975f5c5SAndroid Build Coastguard Worker     {
9924*8975f5c5SAndroid Build Coastguard Worker         groups[groupIndex] = groupIndex;
9925*8975f5c5SAndroid Build Coastguard Worker     }
9926*8975f5c5SAndroid Build Coastguard Worker }
9927*8975f5c5SAndroid Build Coastguard Worker 
selectPerfMonitorCounters(GLuint monitor,GLboolean enable,GLuint group,GLint numCounters,GLuint * counterList)9928*8975f5c5SAndroid Build Coastguard Worker void Context::selectPerfMonitorCounters(GLuint monitor,
9929*8975f5c5SAndroid Build Coastguard Worker                                         GLboolean enable,
9930*8975f5c5SAndroid Build Coastguard Worker                                         GLuint group,
9931*8975f5c5SAndroid Build Coastguard Worker                                         GLint numCounters,
9932*8975f5c5SAndroid Build Coastguard Worker                                         GLuint *counterList)
9933*8975f5c5SAndroid Build Coastguard Worker {}
9934*8975f5c5SAndroid Build Coastguard Worker 
getPerfMonitorCounterGroups() const9935*8975f5c5SAndroid Build Coastguard Worker const angle::PerfMonitorCounterGroups &Context::getPerfMonitorCounterGroups() const
9936*8975f5c5SAndroid Build Coastguard Worker {
9937*8975f5c5SAndroid Build Coastguard Worker     return mImplementation->getPerfMonitorCounters();
9938*8975f5c5SAndroid Build Coastguard Worker }
9939*8975f5c5SAndroid Build Coastguard Worker 
framebufferFoveationConfig(FramebufferID framebufferPacked,GLuint numLayers,GLuint focalPointsPerLayer,GLuint requestedFeatures,GLuint * providedFeatures)9940*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferFoveationConfig(FramebufferID framebufferPacked,
9941*8975f5c5SAndroid Build Coastguard Worker                                          GLuint numLayers,
9942*8975f5c5SAndroid Build Coastguard Worker                                          GLuint focalPointsPerLayer,
9943*8975f5c5SAndroid Build Coastguard Worker                                          GLuint requestedFeatures,
9944*8975f5c5SAndroid Build Coastguard Worker                                          GLuint *providedFeatures)
9945*8975f5c5SAndroid Build Coastguard Worker {
9946*8975f5c5SAndroid Build Coastguard Worker     ASSERT(numLayers <= gl::IMPLEMENTATION_MAX_NUM_LAYERS);
9947*8975f5c5SAndroid Build Coastguard Worker     ASSERT(focalPointsPerLayer <= gl::IMPLEMENTATION_MAX_FOCAL_POINTS);
9948*8975f5c5SAndroid Build Coastguard Worker     ASSERT(providedFeatures);
9949*8975f5c5SAndroid Build Coastguard Worker 
9950*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = getFramebuffer(framebufferPacked);
9951*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!framebuffer->isFoveationConfigured());
9952*8975f5c5SAndroid Build Coastguard Worker 
9953*8975f5c5SAndroid Build Coastguard Worker     *providedFeatures = 0;
9954*8975f5c5SAndroid Build Coastguard Worker     // We only support GL_FOVEATION_ENABLE_BIT_QCOM feature, for now.
9955*8975f5c5SAndroid Build Coastguard Worker     // If requestedFeatures == 0 return without configuring the framebuffer.
9956*8975f5c5SAndroid Build Coastguard Worker     if (requestedFeatures != 0)
9957*8975f5c5SAndroid Build Coastguard Worker     {
9958*8975f5c5SAndroid Build Coastguard Worker         framebuffer->configureFoveation();
9959*8975f5c5SAndroid Build Coastguard Worker         *providedFeatures = framebuffer->getSupportedFoveationFeatures();
9960*8975f5c5SAndroid Build Coastguard Worker     }
9961*8975f5c5SAndroid Build Coastguard Worker }
9962*8975f5c5SAndroid Build Coastguard Worker 
framebufferFoveationParameters(FramebufferID framebufferPacked,GLuint layer,GLuint focalPoint,GLfloat focalX,GLfloat focalY,GLfloat gainX,GLfloat gainY,GLfloat foveaArea)9963*8975f5c5SAndroid Build Coastguard Worker void Context::framebufferFoveationParameters(FramebufferID framebufferPacked,
9964*8975f5c5SAndroid Build Coastguard Worker                                              GLuint layer,
9965*8975f5c5SAndroid Build Coastguard Worker                                              GLuint focalPoint,
9966*8975f5c5SAndroid Build Coastguard Worker                                              GLfloat focalX,
9967*8975f5c5SAndroid Build Coastguard Worker                                              GLfloat focalY,
9968*8975f5c5SAndroid Build Coastguard Worker                                              GLfloat gainX,
9969*8975f5c5SAndroid Build Coastguard Worker                                              GLfloat gainY,
9970*8975f5c5SAndroid Build Coastguard Worker                                              GLfloat foveaArea)
9971*8975f5c5SAndroid Build Coastguard Worker {
9972*8975f5c5SAndroid Build Coastguard Worker     Framebuffer *framebuffer = getFramebuffer(framebufferPacked);
9973*8975f5c5SAndroid Build Coastguard Worker     ASSERT(framebuffer);
9974*8975f5c5SAndroid Build Coastguard Worker     framebuffer->setFocalPoint(layer, focalPoint, focalX, focalY, gainX, gainY, foveaArea);
9975*8975f5c5SAndroid Build Coastguard Worker }
9976*8975f5c5SAndroid Build Coastguard Worker 
textureFoveationParameters(TextureID texturePacked,GLuint layer,GLuint focalPoint,GLfloat focalX,GLfloat focalY,GLfloat gainX,GLfloat gainY,GLfloat foveaArea)9977*8975f5c5SAndroid Build Coastguard Worker void Context::textureFoveationParameters(TextureID texturePacked,
9978*8975f5c5SAndroid Build Coastguard Worker                                          GLuint layer,
9979*8975f5c5SAndroid Build Coastguard Worker                                          GLuint focalPoint,
9980*8975f5c5SAndroid Build Coastguard Worker                                          GLfloat focalX,
9981*8975f5c5SAndroid Build Coastguard Worker                                          GLfloat focalY,
9982*8975f5c5SAndroid Build Coastguard Worker                                          GLfloat gainX,
9983*8975f5c5SAndroid Build Coastguard Worker                                          GLfloat gainY,
9984*8975f5c5SAndroid Build Coastguard Worker                                          GLfloat foveaArea)
9985*8975f5c5SAndroid Build Coastguard Worker {
9986*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTexture(texturePacked);
9987*8975f5c5SAndroid Build Coastguard Worker     ASSERT(texture);
9988*8975f5c5SAndroid Build Coastguard Worker     texture->setFocalPoint(layer, focalPoint, focalX, focalY, gainX, gainY, foveaArea);
9989*8975f5c5SAndroid Build Coastguard Worker }
9990*8975f5c5SAndroid Build Coastguard Worker 
endTiling(GLbitfield preserveMask)9991*8975f5c5SAndroid Build Coastguard Worker void Context::endTiling(GLbitfield preserveMask)
9992*8975f5c5SAndroid Build Coastguard Worker {
9993*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(mImplementation->endTiling(this, preserveMask));
9994*8975f5c5SAndroid Build Coastguard Worker     getMutablePrivateState()->setTiledRendering(false);
9995*8975f5c5SAndroid Build Coastguard Worker }
9996*8975f5c5SAndroid Build Coastguard Worker 
startTiling(GLuint x,GLuint y,GLuint width,GLuint height,GLbitfield preserveMask)9997*8975f5c5SAndroid Build Coastguard Worker void Context::startTiling(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
9998*8975f5c5SAndroid Build Coastguard Worker {
9999*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncDirtyObjects(kTilingDirtyObjects, Command::Other));
10000*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(syncDirtyBits(kTilingDirtyBits, kTilingExtendedDirtyBits, Command::Other));
10001*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
10002*8975f5c5SAndroid Build Coastguard Worker         mImplementation->startTiling(this, Rectangle(x, y, width, height), preserveMask));
10003*8975f5c5SAndroid Build Coastguard Worker     getMutablePrivateState()->setTiledRendering(true);
10004*8975f5c5SAndroid Build Coastguard Worker }
10005*8975f5c5SAndroid Build Coastguard Worker 
clearTexImage(TextureID texturePacked,GLint level,GLenum format,GLenum type,const void * data)10006*8975f5c5SAndroid Build Coastguard Worker void Context::clearTexImage(TextureID texturePacked,
10007*8975f5c5SAndroid Build Coastguard Worker                             GLint level,
10008*8975f5c5SAndroid Build Coastguard Worker                             GLenum format,
10009*8975f5c5SAndroid Build Coastguard Worker                             GLenum type,
10010*8975f5c5SAndroid Build Coastguard Worker                             const void *data)
10011*8975f5c5SAndroid Build Coastguard Worker {
10012*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTexture(texturePacked);
10013*8975f5c5SAndroid Build Coastguard Worker 
10014*8975f5c5SAndroid Build Coastguard Worker     // Sync the texture's state directly. EXT_clear_texture does not require that the texture is
10015*8975f5c5SAndroid Build Coastguard Worker     // bound.
10016*8975f5c5SAndroid Build Coastguard Worker     if (texture->hasAnyDirtyBit())
10017*8975f5c5SAndroid Build Coastguard Worker     {
10018*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(texture->syncState(this, Command::ClearTexture));
10019*8975f5c5SAndroid Build Coastguard Worker     }
10020*8975f5c5SAndroid Build Coastguard Worker 
10021*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
10022*8975f5c5SAndroid Build Coastguard Worker         texture->clearImage(this, level, format, type, static_cast<const uint8_t *>(data)));
10023*8975f5c5SAndroid Build Coastguard Worker }
10024*8975f5c5SAndroid Build Coastguard Worker 
clearTexSubImage(TextureID texturePacked,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const void * data)10025*8975f5c5SAndroid Build Coastguard Worker void Context::clearTexSubImage(TextureID texturePacked,
10026*8975f5c5SAndroid Build Coastguard Worker                                GLint level,
10027*8975f5c5SAndroid Build Coastguard Worker                                GLint xoffset,
10028*8975f5c5SAndroid Build Coastguard Worker                                GLint yoffset,
10029*8975f5c5SAndroid Build Coastguard Worker                                GLint zoffset,
10030*8975f5c5SAndroid Build Coastguard Worker                                GLsizei width,
10031*8975f5c5SAndroid Build Coastguard Worker                                GLsizei height,
10032*8975f5c5SAndroid Build Coastguard Worker                                GLsizei depth,
10033*8975f5c5SAndroid Build Coastguard Worker                                GLenum format,
10034*8975f5c5SAndroid Build Coastguard Worker                                GLenum type,
10035*8975f5c5SAndroid Build Coastguard Worker                                const void *data)
10036*8975f5c5SAndroid Build Coastguard Worker {
10037*8975f5c5SAndroid Build Coastguard Worker     Texture *texture = getTexture(texturePacked);
10038*8975f5c5SAndroid Build Coastguard Worker 
10039*8975f5c5SAndroid Build Coastguard Worker     // It is allowed to use extents of 0 as input args. In this case, the function should return
10040*8975f5c5SAndroid Build Coastguard Worker     // with no changes to the texture.
10041*8975f5c5SAndroid Build Coastguard Worker     if (width == 0 || height == 0 || depth == 0)
10042*8975f5c5SAndroid Build Coastguard Worker     {
10043*8975f5c5SAndroid Build Coastguard Worker         return;
10044*8975f5c5SAndroid Build Coastguard Worker     }
10045*8975f5c5SAndroid Build Coastguard Worker 
10046*8975f5c5SAndroid Build Coastguard Worker     // Sync the texture's state directly. EXT_clear_texture does not require that the texture is
10047*8975f5c5SAndroid Build Coastguard Worker     // bound.
10048*8975f5c5SAndroid Build Coastguard Worker     if (texture->hasAnyDirtyBit())
10049*8975f5c5SAndroid Build Coastguard Worker     {
10050*8975f5c5SAndroid Build Coastguard Worker         ANGLE_CONTEXT_TRY(texture->syncState(this, Command::ClearTexture));
10051*8975f5c5SAndroid Build Coastguard Worker     }
10052*8975f5c5SAndroid Build Coastguard Worker 
10053*8975f5c5SAndroid Build Coastguard Worker     Box area(xoffset, yoffset, zoffset, width, height, depth);
10054*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(texture->clearSubImage(this, level, area, format, type,
10055*8975f5c5SAndroid Build Coastguard Worker                                              static_cast<const uint8_t *>(data)));
10056*8975f5c5SAndroid Build Coastguard Worker }
10057*8975f5c5SAndroid Build Coastguard Worker 
blobCacheCallbacks(GLSETBLOBPROCANGLE set,GLGETBLOBPROCANGLE get,const void * userParam)10058*8975f5c5SAndroid Build Coastguard Worker void Context::blobCacheCallbacks(GLSETBLOBPROCANGLE set,
10059*8975f5c5SAndroid Build Coastguard Worker                                  GLGETBLOBPROCANGLE get,
10060*8975f5c5SAndroid Build Coastguard Worker                                  const void *userParam)
10061*8975f5c5SAndroid Build Coastguard Worker {
10062*8975f5c5SAndroid Build Coastguard Worker     mState.getBlobCacheCallbacks() = {set, get, userParam};
10063*8975f5c5SAndroid Build Coastguard Worker }
10064*8975f5c5SAndroid Build Coastguard Worker 
texStorageAttribs2D(GLenum target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,const GLint * attribList)10065*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageAttribs2D(GLenum target,
10066*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei levels,
10067*8975f5c5SAndroid Build Coastguard Worker                                   GLenum internalFormat,
10068*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei width,
10069*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei height,
10070*8975f5c5SAndroid Build Coastguard Worker                                   const GLint *attribList)
10071*8975f5c5SAndroid Build Coastguard Worker {
10072*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, 1);
10073*8975f5c5SAndroid Build Coastguard Worker     TextureType textype = FromGLenum<TextureType>(target);
10074*8975f5c5SAndroid Build Coastguard Worker     Texture *texture    = getTextureByType(textype);
10075*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
10076*8975f5c5SAndroid Build Coastguard Worker         texture->setStorageAttribs(this, textype, levels, internalFormat, size, attribList));
10077*8975f5c5SAndroid Build Coastguard Worker }
10078*8975f5c5SAndroid Build Coastguard Worker 
texStorageAttribs3D(GLenum target,GLsizei levels,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,const GLint * attribList)10079*8975f5c5SAndroid Build Coastguard Worker void Context::texStorageAttribs3D(GLenum target,
10080*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei levels,
10081*8975f5c5SAndroid Build Coastguard Worker                                   GLenum internalFormat,
10082*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei width,
10083*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei height,
10084*8975f5c5SAndroid Build Coastguard Worker                                   GLsizei depth,
10085*8975f5c5SAndroid Build Coastguard Worker                                   const GLint *attribList)
10086*8975f5c5SAndroid Build Coastguard Worker {
10087*8975f5c5SAndroid Build Coastguard Worker     Extents size(width, height, depth);
10088*8975f5c5SAndroid Build Coastguard Worker     TextureType textype = FromGLenum<TextureType>(target);
10089*8975f5c5SAndroid Build Coastguard Worker     Texture *texture    = getTextureByType(textype);
10090*8975f5c5SAndroid Build Coastguard Worker     ANGLE_CONTEXT_TRY(
10091*8975f5c5SAndroid Build Coastguard Worker         texture->setStorageAttribs(this, textype, levels, internalFormat, size, attribList));
10092*8975f5c5SAndroid Build Coastguard Worker }
10093*8975f5c5SAndroid Build Coastguard Worker 
10094*8975f5c5SAndroid Build Coastguard Worker // ErrorSet implementation.
ErrorSet(Debug * debug,const angle::FrontendFeatures & frontendFeatures,const egl::AttributeMap & attribs)10095*8975f5c5SAndroid Build Coastguard Worker ErrorSet::ErrorSet(Debug *debug,
10096*8975f5c5SAndroid Build Coastguard Worker                    const angle::FrontendFeatures &frontendFeatures,
10097*8975f5c5SAndroid Build Coastguard Worker                    const egl::AttributeMap &attribs)
10098*8975f5c5SAndroid Build Coastguard Worker     : mDebug(debug),
10099*8975f5c5SAndroid Build Coastguard Worker       mResetStrategy(GetResetStrategy(attribs)),
10100*8975f5c5SAndroid Build Coastguard Worker       mLoseContextOnOutOfMemory(frontendFeatures.loseContextOnOutOfMemory.enabled),
10101*8975f5c5SAndroid Build Coastguard Worker       mContextLostForced(false),
10102*8975f5c5SAndroid Build Coastguard Worker       mResetStatus(GraphicsResetStatus::NoError),
10103*8975f5c5SAndroid Build Coastguard Worker       mSkipValidation(GetNoError(attribs)),
10104*8975f5c5SAndroid Build Coastguard Worker       mContextLost(0),
10105*8975f5c5SAndroid Build Coastguard Worker       mHasAnyErrors(0)
10106*8975f5c5SAndroid Build Coastguard Worker {}
10107*8975f5c5SAndroid Build Coastguard Worker 
10108*8975f5c5SAndroid Build Coastguard Worker ErrorSet::~ErrorSet() = default;
10109*8975f5c5SAndroid Build Coastguard Worker 
handleError(GLenum errorCode,const char * message,const char * file,const char * function,unsigned int line)10110*8975f5c5SAndroid Build Coastguard Worker void ErrorSet::handleError(GLenum errorCode,
10111*8975f5c5SAndroid Build Coastguard Worker                            const char *message,
10112*8975f5c5SAndroid Build Coastguard Worker                            const char *file,
10113*8975f5c5SAndroid Build Coastguard Worker                            const char *function,
10114*8975f5c5SAndroid Build Coastguard Worker                            unsigned int line)
10115*8975f5c5SAndroid Build Coastguard Worker {
10116*8975f5c5SAndroid Build Coastguard Worker     if (errorCode == GL_OUT_OF_MEMORY && mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT &&
10117*8975f5c5SAndroid Build Coastguard Worker         mLoseContextOnOutOfMemory)
10118*8975f5c5SAndroid Build Coastguard Worker     {
10119*8975f5c5SAndroid Build Coastguard Worker         markContextLost(GraphicsResetStatus::UnknownContextReset);
10120*8975f5c5SAndroid Build Coastguard Worker     }
10121*8975f5c5SAndroid Build Coastguard Worker 
10122*8975f5c5SAndroid Build Coastguard Worker     std::stringstream errorStream;
10123*8975f5c5SAndroid Build Coastguard Worker     errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":"
10124*8975f5c5SAndroid Build Coastguard Worker                 << line << ". " << message;
10125*8975f5c5SAndroid Build Coastguard Worker 
10126*8975f5c5SAndroid Build Coastguard Worker     std::string formattedMessage = errorStream.str();
10127*8975f5c5SAndroid Build Coastguard Worker 
10128*8975f5c5SAndroid Build Coastguard Worker     // Process the error, but log it with WARN severity so it shows up in logs.
10129*8975f5c5SAndroid Build Coastguard Worker     mDebug->insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, errorCode,
10130*8975f5c5SAndroid Build Coastguard Worker                           GL_DEBUG_SEVERITY_HIGH, std::move(formattedMessage), gl::LOG_WARN,
10131*8975f5c5SAndroid Build Coastguard Worker                           angle::EntryPoint::Invalid);
10132*8975f5c5SAndroid Build Coastguard Worker 
10133*8975f5c5SAndroid Build Coastguard Worker     pushError(errorCode);
10134*8975f5c5SAndroid Build Coastguard Worker }
10135*8975f5c5SAndroid Build Coastguard Worker 
validationError(angle::EntryPoint entryPoint,GLenum errorCode,const char * message)10136*8975f5c5SAndroid Build Coastguard Worker void ErrorSet::validationError(angle::EntryPoint entryPoint, GLenum errorCode, const char *message)
10137*8975f5c5SAndroid Build Coastguard Worker {
10138*8975f5c5SAndroid Build Coastguard Worker     mDebug->insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, errorCode,
10139*8975f5c5SAndroid Build Coastguard Worker                           GL_DEBUG_SEVERITY_HIGH, message, gl::LOG_INFO, entryPoint);
10140*8975f5c5SAndroid Build Coastguard Worker 
10141*8975f5c5SAndroid Build Coastguard Worker     pushError(errorCode);
10142*8975f5c5SAndroid Build Coastguard Worker }
10143*8975f5c5SAndroid Build Coastguard Worker 
validationErrorF(angle::EntryPoint entryPoint,GLenum errorCode,const char * format,...)10144*8975f5c5SAndroid Build Coastguard Worker void ErrorSet::validationErrorF(angle::EntryPoint entryPoint,
10145*8975f5c5SAndroid Build Coastguard Worker                                 GLenum errorCode,
10146*8975f5c5SAndroid Build Coastguard Worker                                 const char *format,
10147*8975f5c5SAndroid Build Coastguard Worker                                 ...)
10148*8975f5c5SAndroid Build Coastguard Worker {
10149*8975f5c5SAndroid Build Coastguard Worker     va_list vargs;
10150*8975f5c5SAndroid Build Coastguard Worker     va_start(vargs, format);
10151*8975f5c5SAndroid Build Coastguard Worker     constexpr size_t kMessageSize = 256;
10152*8975f5c5SAndroid Build Coastguard Worker     char message[kMessageSize];
10153*8975f5c5SAndroid Build Coastguard Worker     int r = vsnprintf(message, kMessageSize, format, vargs);
10154*8975f5c5SAndroid Build Coastguard Worker     va_end(vargs);
10155*8975f5c5SAndroid Build Coastguard Worker 
10156*8975f5c5SAndroid Build Coastguard Worker     if (r > 0)
10157*8975f5c5SAndroid Build Coastguard Worker     {
10158*8975f5c5SAndroid Build Coastguard Worker         validationError(entryPoint, errorCode, message);
10159*8975f5c5SAndroid Build Coastguard Worker     }
10160*8975f5c5SAndroid Build Coastguard Worker     else
10161*8975f5c5SAndroid Build Coastguard Worker     {
10162*8975f5c5SAndroid Build Coastguard Worker         validationError(entryPoint, errorCode, format);
10163*8975f5c5SAndroid Build Coastguard Worker     }
10164*8975f5c5SAndroid Build Coastguard Worker }
10165*8975f5c5SAndroid Build Coastguard Worker 
getLockIfNotAlready()10166*8975f5c5SAndroid Build Coastguard Worker std::unique_lock<std::mutex> ErrorSet::getLockIfNotAlready()
10167*8975f5c5SAndroid Build Coastguard Worker {
10168*8975f5c5SAndroid Build Coastguard Worker     // Avoid mutex recursion and return the lock only if it is not already locked.  This can happen
10169*8975f5c5SAndroid Build Coastguard Worker     // if device loss is generated while it is being queried.
10170*8975f5c5SAndroid Build Coastguard Worker     if (mMutex.try_lock())
10171*8975f5c5SAndroid Build Coastguard Worker     {
10172*8975f5c5SAndroid Build Coastguard Worker         return std::unique_lock<std::mutex>(mMutex, std::adopt_lock);
10173*8975f5c5SAndroid Build Coastguard Worker     }
10174*8975f5c5SAndroid Build Coastguard Worker     return std::unique_lock<std::mutex>();
10175*8975f5c5SAndroid Build Coastguard Worker }
10176*8975f5c5SAndroid Build Coastguard Worker 
pushError(GLenum errorCode)10177*8975f5c5SAndroid Build Coastguard Worker void ErrorSet::pushError(GLenum errorCode)
10178*8975f5c5SAndroid Build Coastguard Worker {
10179*8975f5c5SAndroid Build Coastguard Worker     ASSERT(errorCode != GL_NO_ERROR);
10180*8975f5c5SAndroid Build Coastguard Worker     {
10181*8975f5c5SAndroid Build Coastguard Worker         std::lock_guard<std::mutex> lock(mMutex);
10182*8975f5c5SAndroid Build Coastguard Worker         mErrors.insert(errorCode);
10183*8975f5c5SAndroid Build Coastguard Worker         mHasAnyErrors = 1;
10184*8975f5c5SAndroid Build Coastguard Worker     }
10185*8975f5c5SAndroid Build Coastguard Worker }
10186*8975f5c5SAndroid Build Coastguard Worker 
popError()10187*8975f5c5SAndroid Build Coastguard Worker GLenum ErrorSet::popError()
10188*8975f5c5SAndroid Build Coastguard Worker {
10189*8975f5c5SAndroid Build Coastguard Worker     std::lock_guard<std::mutex> lock(mMutex);
10190*8975f5c5SAndroid Build Coastguard Worker 
10191*8975f5c5SAndroid Build Coastguard Worker     ASSERT(!empty());
10192*8975f5c5SAndroid Build Coastguard Worker     GLenum error = *mErrors.begin();
10193*8975f5c5SAndroid Build Coastguard Worker     mErrors.erase(mErrors.begin());
10194*8975f5c5SAndroid Build Coastguard Worker     if (mErrors.empty())
10195*8975f5c5SAndroid Build Coastguard Worker     {
10196*8975f5c5SAndroid Build Coastguard Worker         mHasAnyErrors = 0;
10197*8975f5c5SAndroid Build Coastguard Worker     }
10198*8975f5c5SAndroid Build Coastguard Worker     return error;
10199*8975f5c5SAndroid Build Coastguard Worker }
10200*8975f5c5SAndroid Build Coastguard Worker 
10201*8975f5c5SAndroid Build Coastguard Worker // NOTE: this function should not assume that this context is current!
markContextLost(GraphicsResetStatus status)10202*8975f5c5SAndroid Build Coastguard Worker void ErrorSet::markContextLost(GraphicsResetStatus status)
10203*8975f5c5SAndroid Build Coastguard Worker {
10204*8975f5c5SAndroid Build Coastguard Worker     // This function may be called indirectly through ErrorSet::getGraphicsResetStatus() from the
10205*8975f5c5SAndroid Build Coastguard Worker     // backend, in which case mMutex is already held.
10206*8975f5c5SAndroid Build Coastguard Worker     std::unique_lock<std::mutex> lock = getLockIfNotAlready();
10207*8975f5c5SAndroid Build Coastguard Worker 
10208*8975f5c5SAndroid Build Coastguard Worker     ASSERT(status != GraphicsResetStatus::NoError);
10209*8975f5c5SAndroid Build Coastguard Worker     if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT)
10210*8975f5c5SAndroid Build Coastguard Worker     {
10211*8975f5c5SAndroid Build Coastguard Worker         mResetStatus       = status;
10212*8975f5c5SAndroid Build Coastguard Worker         mContextLostForced = true;
10213*8975f5c5SAndroid Build Coastguard Worker     }
10214*8975f5c5SAndroid Build Coastguard Worker     setContextLost();
10215*8975f5c5SAndroid Build Coastguard Worker }
10216*8975f5c5SAndroid Build Coastguard Worker 
setContextLost()10217*8975f5c5SAndroid Build Coastguard Worker void ErrorSet::setContextLost()
10218*8975f5c5SAndroid Build Coastguard Worker {
10219*8975f5c5SAndroid Build Coastguard Worker     // Always called with the mutex held.
10220*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mMutex.try_lock() == false);
10221*8975f5c5SAndroid Build Coastguard Worker 
10222*8975f5c5SAndroid Build Coastguard Worker     mContextLost = 1;
10223*8975f5c5SAndroid Build Coastguard Worker 
10224*8975f5c5SAndroid Build Coastguard Worker     // Stop skipping validation, since many implementation entrypoint assume they can't
10225*8975f5c5SAndroid Build Coastguard Worker     // be called when lost, or with null object arguments, etc.
10226*8975f5c5SAndroid Build Coastguard Worker     mSkipValidation = 0;
10227*8975f5c5SAndroid Build Coastguard Worker 
10228*8975f5c5SAndroid Build Coastguard Worker     // Make sure we update TLS.
10229*8975f5c5SAndroid Build Coastguard Worker     SetCurrentValidContext(nullptr);
10230*8975f5c5SAndroid Build Coastguard Worker }
10231*8975f5c5SAndroid Build Coastguard Worker 
getGraphicsResetStatus(rx::ContextImpl * contextImpl)10232*8975f5c5SAndroid Build Coastguard Worker GLenum ErrorSet::getGraphicsResetStatus(rx::ContextImpl *contextImpl)
10233*8975f5c5SAndroid Build Coastguard Worker {
10234*8975f5c5SAndroid Build Coastguard Worker     std::lock_guard<std::mutex> lock(mMutex);
10235*8975f5c5SAndroid Build Coastguard Worker 
10236*8975f5c5SAndroid Build Coastguard Worker     // Even if the application doesn't want to know about resets, we want to know
10237*8975f5c5SAndroid Build Coastguard Worker     // as it will allow us to skip all the calls.
10238*8975f5c5SAndroid Build Coastguard Worker     if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT)
10239*8975f5c5SAndroid Build Coastguard Worker     {
10240*8975f5c5SAndroid Build Coastguard Worker         if (!isContextLost() && contextImpl->getResetStatus() != GraphicsResetStatus::NoError)
10241*8975f5c5SAndroid Build Coastguard Worker         {
10242*8975f5c5SAndroid Build Coastguard Worker             setContextLost();
10243*8975f5c5SAndroid Build Coastguard Worker         }
10244*8975f5c5SAndroid Build Coastguard Worker 
10245*8975f5c5SAndroid Build Coastguard Worker         // EXT_robustness, section 2.6: If the reset notification behavior is
10246*8975f5c5SAndroid Build Coastguard Worker         // NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of
10247*8975f5c5SAndroid Build Coastguard Worker         // reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR.
10248*8975f5c5SAndroid Build Coastguard Worker         return GL_NO_ERROR;
10249*8975f5c5SAndroid Build Coastguard Worker     }
10250*8975f5c5SAndroid Build Coastguard Worker 
10251*8975f5c5SAndroid Build Coastguard Worker     // The GL_EXT_robustness spec says that if a reset is encountered, a reset
10252*8975f5c5SAndroid Build Coastguard Worker     // status should be returned at least once, and GL_NO_ERROR should be returned
10253*8975f5c5SAndroid Build Coastguard Worker     // once the device has finished resetting.
10254*8975f5c5SAndroid Build Coastguard Worker     if (!isContextLost())
10255*8975f5c5SAndroid Build Coastguard Worker     {
10256*8975f5c5SAndroid Build Coastguard Worker         ASSERT(mResetStatus == GraphicsResetStatus::NoError);
10257*8975f5c5SAndroid Build Coastguard Worker         mResetStatus = contextImpl->getResetStatus();
10258*8975f5c5SAndroid Build Coastguard Worker 
10259*8975f5c5SAndroid Build Coastguard Worker         if (mResetStatus != GraphicsResetStatus::NoError)
10260*8975f5c5SAndroid Build Coastguard Worker         {
10261*8975f5c5SAndroid Build Coastguard Worker             setContextLost();
10262*8975f5c5SAndroid Build Coastguard Worker         }
10263*8975f5c5SAndroid Build Coastguard Worker     }
10264*8975f5c5SAndroid Build Coastguard Worker     else if (!mContextLostForced && mResetStatus != GraphicsResetStatus::NoError)
10265*8975f5c5SAndroid Build Coastguard Worker     {
10266*8975f5c5SAndroid Build Coastguard Worker         // If markContextLost was used to mark the context lost then
10267*8975f5c5SAndroid Build Coastguard Worker         // assume that is not recoverable, and continue to report the
10268*8975f5c5SAndroid Build Coastguard Worker         // lost reset status for the lifetime of this context.
10269*8975f5c5SAndroid Build Coastguard Worker         mResetStatus = contextImpl->getResetStatus();
10270*8975f5c5SAndroid Build Coastguard Worker     }
10271*8975f5c5SAndroid Build Coastguard Worker 
10272*8975f5c5SAndroid Build Coastguard Worker     return ToGLenum(mResetStatus);
10273*8975f5c5SAndroid Build Coastguard Worker }
10274*8975f5c5SAndroid Build Coastguard Worker 
getErrorForCapture() const10275*8975f5c5SAndroid Build Coastguard Worker GLenum ErrorSet::getErrorForCapture() const
10276*8975f5c5SAndroid Build Coastguard Worker {
10277*8975f5c5SAndroid Build Coastguard Worker     if (mErrors.empty())
10278*8975f5c5SAndroid Build Coastguard Worker     {
10279*8975f5c5SAndroid Build Coastguard Worker         return GL_NO_ERROR;
10280*8975f5c5SAndroid Build Coastguard Worker     }
10281*8975f5c5SAndroid Build Coastguard Worker     else
10282*8975f5c5SAndroid Build Coastguard Worker     {
10283*8975f5c5SAndroid Build Coastguard Worker         // Return the error without clearing it
10284*8975f5c5SAndroid Build Coastguard Worker         return *mErrors.begin();
10285*8975f5c5SAndroid Build Coastguard Worker     }
10286*8975f5c5SAndroid Build Coastguard Worker }
10287*8975f5c5SAndroid Build Coastguard Worker 
10288*8975f5c5SAndroid Build Coastguard Worker // StateCache implementation.
StateCache()10289*8975f5c5SAndroid Build Coastguard Worker StateCache::StateCache()
10290*8975f5c5SAndroid Build Coastguard Worker     : mCachedNonInstancedVertexElementLimit(0),
10291*8975f5c5SAndroid Build Coastguard Worker       mCachedInstancedVertexElementLimit(0),
10292*8975f5c5SAndroid Build Coastguard Worker       mCachedBasicDrawStatesErrorString(kInvalidPointer),
10293*8975f5c5SAndroid Build Coastguard Worker       mCachedBasicDrawStatesErrorCode(GL_NO_ERROR),
10294*8975f5c5SAndroid Build Coastguard Worker       mCachedBasicDrawElementsError(kInvalidPointer),
10295*8975f5c5SAndroid Build Coastguard Worker       mCachedProgramPipelineError(kInvalidPointer),
10296*8975f5c5SAndroid Build Coastguard Worker       mCachedHasAnyEnabledClientAttrib(false),
10297*8975f5c5SAndroid Build Coastguard Worker       mCachedTransformFeedbackActiveUnpaused(false),
10298*8975f5c5SAndroid Build Coastguard Worker       mCachedCanDraw(false)
10299*8975f5c5SAndroid Build Coastguard Worker {
10300*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes.fill(false);
10301*8975f5c5SAndroid Build Coastguard Worker }
10302*8975f5c5SAndroid Build Coastguard Worker 
10303*8975f5c5SAndroid Build Coastguard Worker StateCache::~StateCache() = default;
10304*8975f5c5SAndroid Build Coastguard Worker 
updateVertexElementLimits(Context * context)10305*8975f5c5SAndroid Build Coastguard Worker ANGLE_INLINE void StateCache::updateVertexElementLimits(Context *context)
10306*8975f5c5SAndroid Build Coastguard Worker {
10307*8975f5c5SAndroid Build Coastguard Worker     if (context->isBufferAccessValidationEnabled())
10308*8975f5c5SAndroid Build Coastguard Worker     {
10309*8975f5c5SAndroid Build Coastguard Worker         updateVertexElementLimitsImpl(context);
10310*8975f5c5SAndroid Build Coastguard Worker     }
10311*8975f5c5SAndroid Build Coastguard Worker }
10312*8975f5c5SAndroid Build Coastguard Worker 
initialize(Context * context)10313*8975f5c5SAndroid Build Coastguard Worker void StateCache::initialize(Context *context)
10314*8975f5c5SAndroid Build Coastguard Worker {
10315*8975f5c5SAndroid Build Coastguard Worker     updateValidDrawModes(context);
10316*8975f5c5SAndroid Build Coastguard Worker     updateValidBindTextureTypes(context);
10317*8975f5c5SAndroid Build Coastguard Worker     updateValidDrawElementsTypes(context);
10318*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10319*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawElementsError();
10320*8975f5c5SAndroid Build Coastguard Worker     updateVertexAttribTypesValidation(context);
10321*8975f5c5SAndroid Build Coastguard Worker     updateCanDraw(context);
10322*8975f5c5SAndroid Build Coastguard Worker }
10323*8975f5c5SAndroid Build Coastguard Worker 
updateActiveAttribsMask(Context * context)10324*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateActiveAttribsMask(Context *context)
10325*8975f5c5SAndroid Build Coastguard Worker {
10326*8975f5c5SAndroid Build Coastguard Worker     bool isGLES1         = context->isGLES1();
10327*8975f5c5SAndroid Build Coastguard Worker     const State &glState = context->getState();
10328*8975f5c5SAndroid Build Coastguard Worker 
10329*8975f5c5SAndroid Build Coastguard Worker     if (!isGLES1 && !glState.getProgramExecutable())
10330*8975f5c5SAndroid Build Coastguard Worker     {
10331*8975f5c5SAndroid Build Coastguard Worker         mCachedActiveBufferedAttribsMask = AttributesMask();
10332*8975f5c5SAndroid Build Coastguard Worker         mCachedActiveClientAttribsMask   = AttributesMask();
10333*8975f5c5SAndroid Build Coastguard Worker         mCachedActiveDefaultAttribsMask  = AttributesMask();
10334*8975f5c5SAndroid Build Coastguard Worker         return;
10335*8975f5c5SAndroid Build Coastguard Worker     }
10336*8975f5c5SAndroid Build Coastguard Worker 
10337*8975f5c5SAndroid Build Coastguard Worker     AttributesMask activeAttribs =
10338*8975f5c5SAndroid Build Coastguard Worker         isGLES1 ? glState.gles1().getActiveAttributesMask()
10339*8975f5c5SAndroid Build Coastguard Worker                 : glState.getProgramExecutable()->getActiveAttribLocationsMask();
10340*8975f5c5SAndroid Build Coastguard Worker 
10341*8975f5c5SAndroid Build Coastguard Worker     const VertexArray *vao = glState.getVertexArray();
10342*8975f5c5SAndroid Build Coastguard Worker     ASSERT(vao);
10343*8975f5c5SAndroid Build Coastguard Worker 
10344*8975f5c5SAndroid Build Coastguard Worker     const AttributesMask &clientAttribs  = vao->getClientAttribsMask();
10345*8975f5c5SAndroid Build Coastguard Worker     const AttributesMask &enabledAttribs = vao->getEnabledAttributesMask();
10346*8975f5c5SAndroid Build Coastguard Worker     const AttributesMask &activeEnabled  = activeAttribs & enabledAttribs;
10347*8975f5c5SAndroid Build Coastguard Worker 
10348*8975f5c5SAndroid Build Coastguard Worker     mCachedActiveClientAttribsMask   = activeEnabled & clientAttribs;
10349*8975f5c5SAndroid Build Coastguard Worker     mCachedActiveBufferedAttribsMask = activeEnabled & ~clientAttribs;
10350*8975f5c5SAndroid Build Coastguard Worker     mCachedActiveDefaultAttribsMask  = activeAttribs & ~enabledAttribs;
10351*8975f5c5SAndroid Build Coastguard Worker     mCachedHasAnyEnabledClientAttrib = (clientAttribs & enabledAttribs).any();
10352*8975f5c5SAndroid Build Coastguard Worker }
10353*8975f5c5SAndroid Build Coastguard Worker 
updateVertexElementLimitsImpl(Context * context)10354*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateVertexElementLimitsImpl(Context *context)
10355*8975f5c5SAndroid Build Coastguard Worker {
10356*8975f5c5SAndroid Build Coastguard Worker     ASSERT(context->isBufferAccessValidationEnabled());
10357*8975f5c5SAndroid Build Coastguard Worker 
10358*8975f5c5SAndroid Build Coastguard Worker     const VertexArray *vao = context->getState().getVertexArray();
10359*8975f5c5SAndroid Build Coastguard Worker 
10360*8975f5c5SAndroid Build Coastguard Worker     mCachedNonInstancedVertexElementLimit = std::numeric_limits<GLint64>::max();
10361*8975f5c5SAndroid Build Coastguard Worker     mCachedInstancedVertexElementLimit    = std::numeric_limits<GLint64>::max();
10362*8975f5c5SAndroid Build Coastguard Worker 
10363*8975f5c5SAndroid Build Coastguard Worker     // VAO can be null on Context startup. If we make this computation lazier we could ASSERT.
10364*8975f5c5SAndroid Build Coastguard Worker     // If there are no buffered attributes then we should not limit the draw call count.
10365*8975f5c5SAndroid Build Coastguard Worker     if (!vao || !mCachedActiveBufferedAttribsMask.any())
10366*8975f5c5SAndroid Build Coastguard Worker     {
10367*8975f5c5SAndroid Build Coastguard Worker         return;
10368*8975f5c5SAndroid Build Coastguard Worker     }
10369*8975f5c5SAndroid Build Coastguard Worker 
10370*8975f5c5SAndroid Build Coastguard Worker     const auto &vertexAttribs  = vao->getVertexAttributes();
10371*8975f5c5SAndroid Build Coastguard Worker     const auto &vertexBindings = vao->getVertexBindings();
10372*8975f5c5SAndroid Build Coastguard Worker 
10373*8975f5c5SAndroid Build Coastguard Worker     for (size_t attributeIndex : mCachedActiveBufferedAttribsMask)
10374*8975f5c5SAndroid Build Coastguard Worker     {
10375*8975f5c5SAndroid Build Coastguard Worker         const VertexAttribute &attrib = vertexAttribs[attributeIndex];
10376*8975f5c5SAndroid Build Coastguard Worker 
10377*8975f5c5SAndroid Build Coastguard Worker         const VertexBinding &binding = vertexBindings[attrib.bindingIndex];
10378*8975f5c5SAndroid Build Coastguard Worker         ASSERT(context->isGLES1() ||
10379*8975f5c5SAndroid Build Coastguard Worker                context->getState().getProgramExecutable()->isAttribLocationActive(attributeIndex));
10380*8975f5c5SAndroid Build Coastguard Worker 
10381*8975f5c5SAndroid Build Coastguard Worker         GLint64 limit = attrib.getCachedElementLimit();
10382*8975f5c5SAndroid Build Coastguard Worker         if (binding.getDivisor() > 0)
10383*8975f5c5SAndroid Build Coastguard Worker         {
10384*8975f5c5SAndroid Build Coastguard Worker             // For instanced draw calls, |divisor| times this limit is the limit for instance count
10385*8975f5c5SAndroid Build Coastguard Worker             // (because every |divisor| instances accesses the same attribute)
10386*8975f5c5SAndroid Build Coastguard Worker             angle::CheckedNumeric<GLint64> checkedLimit = limit;
10387*8975f5c5SAndroid Build Coastguard Worker             checkedLimit *= binding.getDivisor();
10388*8975f5c5SAndroid Build Coastguard Worker 
10389*8975f5c5SAndroid Build Coastguard Worker             mCachedInstancedVertexElementLimit =
10390*8975f5c5SAndroid Build Coastguard Worker                 std::min<GLint64>(mCachedInstancedVertexElementLimit,
10391*8975f5c5SAndroid Build Coastguard Worker                                   checkedLimit.ValueOrDefault(VertexAttribute::kIntegerOverflow));
10392*8975f5c5SAndroid Build Coastguard Worker         }
10393*8975f5c5SAndroid Build Coastguard Worker         else
10394*8975f5c5SAndroid Build Coastguard Worker         {
10395*8975f5c5SAndroid Build Coastguard Worker             mCachedNonInstancedVertexElementLimit =
10396*8975f5c5SAndroid Build Coastguard Worker                 std::min(mCachedNonInstancedVertexElementLimit, limit);
10397*8975f5c5SAndroid Build Coastguard Worker         }
10398*8975f5c5SAndroid Build Coastguard Worker     }
10399*8975f5c5SAndroid Build Coastguard Worker }
10400*8975f5c5SAndroid Build Coastguard Worker 
updateBasicDrawStatesError()10401*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateBasicDrawStatesError()
10402*8975f5c5SAndroid Build Coastguard Worker {
10403*8975f5c5SAndroid Build Coastguard Worker     mCachedBasicDrawStatesErrorString = kInvalidPointer;
10404*8975f5c5SAndroid Build Coastguard Worker     mCachedBasicDrawStatesErrorCode   = GL_NO_ERROR;
10405*8975f5c5SAndroid Build Coastguard Worker }
10406*8975f5c5SAndroid Build Coastguard Worker 
updateProgramPipelineError()10407*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateProgramPipelineError()
10408*8975f5c5SAndroid Build Coastguard Worker {
10409*8975f5c5SAndroid Build Coastguard Worker     mCachedProgramPipelineError = kInvalidPointer;
10410*8975f5c5SAndroid Build Coastguard Worker }
10411*8975f5c5SAndroid Build Coastguard Worker 
updateBasicDrawElementsError()10412*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateBasicDrawElementsError()
10413*8975f5c5SAndroid Build Coastguard Worker {
10414*8975f5c5SAndroid Build Coastguard Worker     mCachedBasicDrawElementsError = kInvalidPointer;
10415*8975f5c5SAndroid Build Coastguard Worker }
10416*8975f5c5SAndroid Build Coastguard Worker 
getBasicDrawStatesErrorImpl(const Context * context,const PrivateStateCache * privateStateCache) const10417*8975f5c5SAndroid Build Coastguard Worker intptr_t StateCache::getBasicDrawStatesErrorImpl(const Context *context,
10418*8975f5c5SAndroid Build Coastguard Worker                                                  const PrivateStateCache *privateStateCache) const
10419*8975f5c5SAndroid Build Coastguard Worker {
10420*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mCachedBasicDrawStatesErrorString == kInvalidPointer ||
10421*8975f5c5SAndroid Build Coastguard Worker            !privateStateCache->isCachedBasicDrawStatesErrorValid());
10422*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mCachedBasicDrawStatesErrorCode == GL_NO_ERROR ||
10423*8975f5c5SAndroid Build Coastguard Worker            !privateStateCache->isCachedBasicDrawStatesErrorValid());
10424*8975f5c5SAndroid Build Coastguard Worker 
10425*8975f5c5SAndroid Build Coastguard Worker     // Only assign the error code after ValidateDrawStates has completed. ValidateDrawStates calls
10426*8975f5c5SAndroid Build Coastguard Worker     // updateBasicDrawStatesError in some cases and resets the value mid-call.
10427*8975f5c5SAndroid Build Coastguard Worker     GLenum errorCode = GL_NO_ERROR;
10428*8975f5c5SAndroid Build Coastguard Worker     mCachedBasicDrawStatesErrorString =
10429*8975f5c5SAndroid Build Coastguard Worker         reinterpret_cast<intptr_t>(ValidateDrawStates(context, &errorCode));
10430*8975f5c5SAndroid Build Coastguard Worker     mCachedBasicDrawStatesErrorCode = errorCode;
10431*8975f5c5SAndroid Build Coastguard Worker 
10432*8975f5c5SAndroid Build Coastguard Worker     // Ensure that if an error is set mCachedBasicDrawStatesErrorCode must be GL_NO_ERROR and if no
10433*8975f5c5SAndroid Build Coastguard Worker     // error is set mCachedBasicDrawStatesErrorCode must be an error.
10434*8975f5c5SAndroid Build Coastguard Worker     ASSERT((mCachedBasicDrawStatesErrorString == 0) ==
10435*8975f5c5SAndroid Build Coastguard Worker            (mCachedBasicDrawStatesErrorCode == GL_NO_ERROR));
10436*8975f5c5SAndroid Build Coastguard Worker 
10437*8975f5c5SAndroid Build Coastguard Worker     privateStateCache->setCachedBasicDrawStatesErrorValid();
10438*8975f5c5SAndroid Build Coastguard Worker     return mCachedBasicDrawStatesErrorString;
10439*8975f5c5SAndroid Build Coastguard Worker }
10440*8975f5c5SAndroid Build Coastguard Worker 
getProgramPipelineErrorImpl(const Context * context) const10441*8975f5c5SAndroid Build Coastguard Worker intptr_t StateCache::getProgramPipelineErrorImpl(const Context *context) const
10442*8975f5c5SAndroid Build Coastguard Worker {
10443*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mCachedProgramPipelineError == kInvalidPointer);
10444*8975f5c5SAndroid Build Coastguard Worker     mCachedProgramPipelineError = reinterpret_cast<intptr_t>(ValidateProgramPipeline(context));
10445*8975f5c5SAndroid Build Coastguard Worker     return mCachedProgramPipelineError;
10446*8975f5c5SAndroid Build Coastguard Worker }
10447*8975f5c5SAndroid Build Coastguard Worker 
getBasicDrawElementsErrorImpl(const Context * context) const10448*8975f5c5SAndroid Build Coastguard Worker intptr_t StateCache::getBasicDrawElementsErrorImpl(const Context *context) const
10449*8975f5c5SAndroid Build Coastguard Worker {
10450*8975f5c5SAndroid Build Coastguard Worker     ASSERT(mCachedBasicDrawElementsError == kInvalidPointer);
10451*8975f5c5SAndroid Build Coastguard Worker     mCachedBasicDrawElementsError = reinterpret_cast<intptr_t>(ValidateDrawElementsStates(context));
10452*8975f5c5SAndroid Build Coastguard Worker     return mCachedBasicDrawElementsError;
10453*8975f5c5SAndroid Build Coastguard Worker }
10454*8975f5c5SAndroid Build Coastguard Worker 
onVertexArrayBindingChange(Context * context)10455*8975f5c5SAndroid Build Coastguard Worker void StateCache::onVertexArrayBindingChange(Context *context)
10456*8975f5c5SAndroid Build Coastguard Worker {
10457*8975f5c5SAndroid Build Coastguard Worker     updateActiveAttribsMask(context);
10458*8975f5c5SAndroid Build Coastguard Worker     updateVertexElementLimits(context);
10459*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10460*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawElementsError();
10461*8975f5c5SAndroid Build Coastguard Worker }
10462*8975f5c5SAndroid Build Coastguard Worker 
onProgramExecutableChange(Context * context)10463*8975f5c5SAndroid Build Coastguard Worker void StateCache::onProgramExecutableChange(Context *context)
10464*8975f5c5SAndroid Build Coastguard Worker {
10465*8975f5c5SAndroid Build Coastguard Worker     updateActiveAttribsMask(context);
10466*8975f5c5SAndroid Build Coastguard Worker     updateVertexElementLimits(context);
10467*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10468*8975f5c5SAndroid Build Coastguard Worker     updateProgramPipelineError();
10469*8975f5c5SAndroid Build Coastguard Worker     updateValidDrawModes(context);
10470*8975f5c5SAndroid Build Coastguard Worker     updateActiveShaderStorageBufferIndices(context);
10471*8975f5c5SAndroid Build Coastguard Worker     updateActiveImageUnitIndices(context);
10472*8975f5c5SAndroid Build Coastguard Worker     updateCanDraw(context);
10473*8975f5c5SAndroid Build Coastguard Worker }
10474*8975f5c5SAndroid Build Coastguard Worker 
onVertexArrayFormatChange(Context * context)10475*8975f5c5SAndroid Build Coastguard Worker void StateCache::onVertexArrayFormatChange(Context *context)
10476*8975f5c5SAndroid Build Coastguard Worker {
10477*8975f5c5SAndroid Build Coastguard Worker     updateVertexElementLimits(context);
10478*8975f5c5SAndroid Build Coastguard Worker }
10479*8975f5c5SAndroid Build Coastguard Worker 
onVertexArrayBufferContentsChange(Context * context)10480*8975f5c5SAndroid Build Coastguard Worker void StateCache::onVertexArrayBufferContentsChange(Context *context)
10481*8975f5c5SAndroid Build Coastguard Worker {
10482*8975f5c5SAndroid Build Coastguard Worker     updateVertexElementLimits(context);
10483*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10484*8975f5c5SAndroid Build Coastguard Worker }
10485*8975f5c5SAndroid Build Coastguard Worker 
onVertexArrayStateChange(Context * context)10486*8975f5c5SAndroid Build Coastguard Worker void StateCache::onVertexArrayStateChange(Context *context)
10487*8975f5c5SAndroid Build Coastguard Worker {
10488*8975f5c5SAndroid Build Coastguard Worker     updateActiveAttribsMask(context);
10489*8975f5c5SAndroid Build Coastguard Worker     updateVertexElementLimits(context);
10490*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10491*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawElementsError();
10492*8975f5c5SAndroid Build Coastguard Worker }
10493*8975f5c5SAndroid Build Coastguard Worker 
onVertexArrayBufferStateChange(Context * context)10494*8975f5c5SAndroid Build Coastguard Worker void StateCache::onVertexArrayBufferStateChange(Context *context)
10495*8975f5c5SAndroid Build Coastguard Worker {
10496*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10497*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawElementsError();
10498*8975f5c5SAndroid Build Coastguard Worker }
10499*8975f5c5SAndroid Build Coastguard Worker 
onGLES1ClientStateChange(Context * context)10500*8975f5c5SAndroid Build Coastguard Worker void StateCache::onGLES1ClientStateChange(Context *context)
10501*8975f5c5SAndroid Build Coastguard Worker {
10502*8975f5c5SAndroid Build Coastguard Worker     updateActiveAttribsMask(context);
10503*8975f5c5SAndroid Build Coastguard Worker }
10504*8975f5c5SAndroid Build Coastguard Worker 
onGLES1TextureStateChange(Context * context)10505*8975f5c5SAndroid Build Coastguard Worker void StateCache::onGLES1TextureStateChange(Context *context)
10506*8975f5c5SAndroid Build Coastguard Worker {
10507*8975f5c5SAndroid Build Coastguard Worker     updateActiveAttribsMask(context);
10508*8975f5c5SAndroid Build Coastguard Worker }
10509*8975f5c5SAndroid Build Coastguard Worker 
onDrawFramebufferChange(Context * context)10510*8975f5c5SAndroid Build Coastguard Worker void StateCache::onDrawFramebufferChange(Context *context)
10511*8975f5c5SAndroid Build Coastguard Worker {
10512*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10513*8975f5c5SAndroid Build Coastguard Worker }
10514*8975f5c5SAndroid Build Coastguard Worker 
onActiveTextureChange(Context * context)10515*8975f5c5SAndroid Build Coastguard Worker void StateCache::onActiveTextureChange(Context *context)
10516*8975f5c5SAndroid Build Coastguard Worker {
10517*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10518*8975f5c5SAndroid Build Coastguard Worker }
10519*8975f5c5SAndroid Build Coastguard Worker 
onQueryChange(Context * context)10520*8975f5c5SAndroid Build Coastguard Worker void StateCache::onQueryChange(Context *context)
10521*8975f5c5SAndroid Build Coastguard Worker {
10522*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10523*8975f5c5SAndroid Build Coastguard Worker }
10524*8975f5c5SAndroid Build Coastguard Worker 
onActiveTransformFeedbackChange(Context * context)10525*8975f5c5SAndroid Build Coastguard Worker void StateCache::onActiveTransformFeedbackChange(Context *context)
10526*8975f5c5SAndroid Build Coastguard Worker {
10527*8975f5c5SAndroid Build Coastguard Worker     updateTransformFeedbackActiveUnpaused(context);
10528*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10529*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawElementsError();
10530*8975f5c5SAndroid Build Coastguard Worker     updateValidDrawModes(context);
10531*8975f5c5SAndroid Build Coastguard Worker }
10532*8975f5c5SAndroid Build Coastguard Worker 
onUniformBufferStateChange(Context * context)10533*8975f5c5SAndroid Build Coastguard Worker void StateCache::onUniformBufferStateChange(Context *context)
10534*8975f5c5SAndroid Build Coastguard Worker {
10535*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10536*8975f5c5SAndroid Build Coastguard Worker }
10537*8975f5c5SAndroid Build Coastguard Worker 
onAtomicCounterBufferStateChange(Context * context)10538*8975f5c5SAndroid Build Coastguard Worker void StateCache::onAtomicCounterBufferStateChange(Context *context)
10539*8975f5c5SAndroid Build Coastguard Worker {
10540*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10541*8975f5c5SAndroid Build Coastguard Worker }
10542*8975f5c5SAndroid Build Coastguard Worker 
onShaderStorageBufferStateChange(Context * context)10543*8975f5c5SAndroid Build Coastguard Worker void StateCache::onShaderStorageBufferStateChange(Context *context)
10544*8975f5c5SAndroid Build Coastguard Worker {
10545*8975f5c5SAndroid Build Coastguard Worker     updateBasicDrawStatesError();
10546*8975f5c5SAndroid Build Coastguard Worker }
10547*8975f5c5SAndroid Build Coastguard Worker 
setValidDrawModes(bool pointsOK,bool linesOK,bool trisOK,bool lineAdjOK,bool triAdjOK,bool patchOK)10548*8975f5c5SAndroid Build Coastguard Worker void StateCache::setValidDrawModes(bool pointsOK,
10549*8975f5c5SAndroid Build Coastguard Worker                                    bool linesOK,
10550*8975f5c5SAndroid Build Coastguard Worker                                    bool trisOK,
10551*8975f5c5SAndroid Build Coastguard Worker                                    bool lineAdjOK,
10552*8975f5c5SAndroid Build Coastguard Worker                                    bool triAdjOK,
10553*8975f5c5SAndroid Build Coastguard Worker                                    bool patchOK)
10554*8975f5c5SAndroid Build Coastguard Worker {
10555*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::Points]                 = pointsOK;
10556*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::Lines]                  = linesOK;
10557*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::LineLoop]               = linesOK;
10558*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::LineStrip]              = linesOK;
10559*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::Triangles]              = trisOK;
10560*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::TriangleStrip]          = trisOK;
10561*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::TriangleFan]            = trisOK;
10562*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::LinesAdjacency]         = lineAdjOK;
10563*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::LineStripAdjacency]     = lineAdjOK;
10564*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::TrianglesAdjacency]     = triAdjOK;
10565*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::TriangleStripAdjacency] = triAdjOK;
10566*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawModes[PrimitiveMode::Patches]                = patchOK;
10567*8975f5c5SAndroid Build Coastguard Worker }
10568*8975f5c5SAndroid Build Coastguard Worker 
updateValidDrawModes(Context * context)10569*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateValidDrawModes(Context *context)
10570*8975f5c5SAndroid Build Coastguard Worker {
10571*8975f5c5SAndroid Build Coastguard Worker     const State &state = context->getState();
10572*8975f5c5SAndroid Build Coastguard Worker 
10573*8975f5c5SAndroid Build Coastguard Worker     const ProgramExecutable *programExecutable = context->getState().getProgramExecutable();
10574*8975f5c5SAndroid Build Coastguard Worker 
10575*8975f5c5SAndroid Build Coastguard Worker     // If tessellation is active primitive mode must be GL_PATCHES.
10576*8975f5c5SAndroid Build Coastguard Worker     if (programExecutable && programExecutable->hasLinkedTessellationShader())
10577*8975f5c5SAndroid Build Coastguard Worker     {
10578*8975f5c5SAndroid Build Coastguard Worker         setValidDrawModes(false, false, false, false, false, true);
10579*8975f5c5SAndroid Build Coastguard Worker         return;
10580*8975f5c5SAndroid Build Coastguard Worker     }
10581*8975f5c5SAndroid Build Coastguard Worker 
10582*8975f5c5SAndroid Build Coastguard Worker     if (mCachedTransformFeedbackActiveUnpaused)
10583*8975f5c5SAndroid Build Coastguard Worker     {
10584*8975f5c5SAndroid Build Coastguard Worker         TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
10585*8975f5c5SAndroid Build Coastguard Worker 
10586*8975f5c5SAndroid Build Coastguard Worker         // ES Spec 3.0 validation text:
10587*8975f5c5SAndroid Build Coastguard Worker         // When transform feedback is active and not paused, all geometric primitives generated must
10588*8975f5c5SAndroid Build Coastguard Worker         // match the value of primitiveMode passed to BeginTransformFeedback. The error
10589*8975f5c5SAndroid Build Coastguard Worker         // INVALID_OPERATION is generated by DrawArrays and DrawArraysInstanced if mode is not
10590*8975f5c5SAndroid Build Coastguard Worker         // identical to primitiveMode. The error INVALID_OPERATION is also generated by
10591*8975f5c5SAndroid Build Coastguard Worker         // DrawElements, DrawElementsInstanced, and DrawRangeElements while transform feedback is
10592*8975f5c5SAndroid Build Coastguard Worker         // active and not paused, regardless of mode. Any primitive type may be used while transform
10593*8975f5c5SAndroid Build Coastguard Worker         // feedback is paused.
10594*8975f5c5SAndroid Build Coastguard Worker         if (!context->getExtensions().geometryShaderAny() &&
10595*8975f5c5SAndroid Build Coastguard Worker             !context->getExtensions().tessellationShaderAny() &&
10596*8975f5c5SAndroid Build Coastguard Worker             context->getClientVersion() < ES_3_2)
10597*8975f5c5SAndroid Build Coastguard Worker         {
10598*8975f5c5SAndroid Build Coastguard Worker             mCachedValidDrawModes.fill(false);
10599*8975f5c5SAndroid Build Coastguard Worker             mCachedValidDrawModes[curTransformFeedback->getPrimitiveMode()] = true;
10600*8975f5c5SAndroid Build Coastguard Worker             return;
10601*8975f5c5SAndroid Build Coastguard Worker         }
10602*8975f5c5SAndroid Build Coastguard Worker     }
10603*8975f5c5SAndroid Build Coastguard Worker 
10604*8975f5c5SAndroid Build Coastguard Worker     if (!programExecutable || !programExecutable->hasLinkedShaderStage(ShaderType::Geometry))
10605*8975f5c5SAndroid Build Coastguard Worker     {
10606*8975f5c5SAndroid Build Coastguard Worker         bool adjacencyOK =
10607*8975f5c5SAndroid Build Coastguard Worker             (context->getExtensions().geometryShaderAny() || context->getClientVersion() >= ES_3_2);
10608*8975f5c5SAndroid Build Coastguard Worker 
10609*8975f5c5SAndroid Build Coastguard Worker         // All draw modes are valid, since drawing without a program does not generate an error and
10610*8975f5c5SAndroid Build Coastguard Worker         // operations requiring a GS will trigger other validation errors.
10611*8975f5c5SAndroid Build Coastguard Worker         // `patchOK = false` due to checking above already enabling it if a TS is present.
10612*8975f5c5SAndroid Build Coastguard Worker         setValidDrawModes(true, true, true, adjacencyOK, adjacencyOK, false);
10613*8975f5c5SAndroid Build Coastguard Worker         return;
10614*8975f5c5SAndroid Build Coastguard Worker     }
10615*8975f5c5SAndroid Build Coastguard Worker 
10616*8975f5c5SAndroid Build Coastguard Worker     PrimitiveMode gsMode = programExecutable->getGeometryShaderInputPrimitiveType();
10617*8975f5c5SAndroid Build Coastguard Worker     bool pointsOK        = gsMode == PrimitiveMode::Points;
10618*8975f5c5SAndroid Build Coastguard Worker     bool linesOK         = gsMode == PrimitiveMode::Lines;
10619*8975f5c5SAndroid Build Coastguard Worker     bool trisOK          = gsMode == PrimitiveMode::Triangles;
10620*8975f5c5SAndroid Build Coastguard Worker     bool lineAdjOK       = gsMode == PrimitiveMode::LinesAdjacency;
10621*8975f5c5SAndroid Build Coastguard Worker     bool triAdjOK        = gsMode == PrimitiveMode::TrianglesAdjacency;
10622*8975f5c5SAndroid Build Coastguard Worker 
10623*8975f5c5SAndroid Build Coastguard Worker     setValidDrawModes(pointsOK, linesOK, trisOK, lineAdjOK, triAdjOK, false);
10624*8975f5c5SAndroid Build Coastguard Worker }
10625*8975f5c5SAndroid Build Coastguard Worker 
updateValidBindTextureTypes(Context * context)10626*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateValidBindTextureTypes(Context *context)
10627*8975f5c5SAndroid Build Coastguard Worker {
10628*8975f5c5SAndroid Build Coastguard Worker     const Extensions &exts = context->getExtensions();
10629*8975f5c5SAndroid Build Coastguard Worker     bool isGLES3           = context->getClientMajorVersion() >= 3;
10630*8975f5c5SAndroid Build Coastguard Worker     bool isGLES31          = context->getClientVersion() >= Version(3, 1);
10631*8975f5c5SAndroid Build Coastguard Worker     bool isGLES32          = context->getClientVersion() >= Version(3, 2);
10632*8975f5c5SAndroid Build Coastguard Worker 
10633*8975f5c5SAndroid Build Coastguard Worker     mCachedValidBindTextureTypes = {{
10634*8975f5c5SAndroid Build Coastguard Worker         {TextureType::_2D, true},
10635*8975f5c5SAndroid Build Coastguard Worker         {TextureType::_2DArray, isGLES3},
10636*8975f5c5SAndroid Build Coastguard Worker         {TextureType::_2DMultisample, isGLES31 || exts.textureMultisampleANGLE},
10637*8975f5c5SAndroid Build Coastguard Worker         {TextureType::_2DMultisampleArray, isGLES32 || exts.textureStorageMultisample2dArrayOES},
10638*8975f5c5SAndroid Build Coastguard Worker         {TextureType::_3D, isGLES3 || exts.texture3DOES},
10639*8975f5c5SAndroid Build Coastguard Worker         {TextureType::External, exts.EGLImageExternalOES || exts.EGLStreamConsumerExternalNV},
10640*8975f5c5SAndroid Build Coastguard Worker         {TextureType::Rectangle, exts.textureRectangleANGLE},
10641*8975f5c5SAndroid Build Coastguard Worker         {TextureType::CubeMap, true},
10642*8975f5c5SAndroid Build Coastguard Worker         {TextureType::CubeMapArray, isGLES32 || exts.textureCubeMapArrayAny()},
10643*8975f5c5SAndroid Build Coastguard Worker         {TextureType::VideoImage, exts.videoTextureWEBGL},
10644*8975f5c5SAndroid Build Coastguard Worker         {TextureType::Buffer, isGLES32 || exts.textureBufferAny()},
10645*8975f5c5SAndroid Build Coastguard Worker     }};
10646*8975f5c5SAndroid Build Coastguard Worker }
10647*8975f5c5SAndroid Build Coastguard Worker 
updateValidDrawElementsTypes(Context * context)10648*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateValidDrawElementsTypes(Context *context)
10649*8975f5c5SAndroid Build Coastguard Worker {
10650*8975f5c5SAndroid Build Coastguard Worker     bool supportsUint =
10651*8975f5c5SAndroid Build Coastguard Worker         (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUintOES);
10652*8975f5c5SAndroid Build Coastguard Worker 
10653*8975f5c5SAndroid Build Coastguard Worker     mCachedValidDrawElementsTypes = {{
10654*8975f5c5SAndroid Build Coastguard Worker         {DrawElementsType::UnsignedByte, true},
10655*8975f5c5SAndroid Build Coastguard Worker         {DrawElementsType::UnsignedShort, true},
10656*8975f5c5SAndroid Build Coastguard Worker         {DrawElementsType::UnsignedInt, supportsUint},
10657*8975f5c5SAndroid Build Coastguard Worker     }};
10658*8975f5c5SAndroid Build Coastguard Worker }
10659*8975f5c5SAndroid Build Coastguard Worker 
updateTransformFeedbackActiveUnpaused(Context * context)10660*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateTransformFeedbackActiveUnpaused(Context *context)
10661*8975f5c5SAndroid Build Coastguard Worker {
10662*8975f5c5SAndroid Build Coastguard Worker     TransformFeedback *xfb                 = context->getState().getCurrentTransformFeedback();
10663*8975f5c5SAndroid Build Coastguard Worker     mCachedTransformFeedbackActiveUnpaused = xfb && xfb->isActive() && !xfb->isPaused();
10664*8975f5c5SAndroid Build Coastguard Worker }
10665*8975f5c5SAndroid Build Coastguard Worker 
updateVertexAttribTypesValidation(Context * context)10666*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateVertexAttribTypesValidation(Context *context)
10667*8975f5c5SAndroid Build Coastguard Worker {
10668*8975f5c5SAndroid Build Coastguard Worker     VertexAttribTypeCase halfFloatValidity = (context->getExtensions().vertexHalfFloatOES)
10669*8975f5c5SAndroid Build Coastguard Worker                                                  ? VertexAttribTypeCase::Valid
10670*8975f5c5SAndroid Build Coastguard Worker                                                  : VertexAttribTypeCase::Invalid;
10671*8975f5c5SAndroid Build Coastguard Worker 
10672*8975f5c5SAndroid Build Coastguard Worker     VertexAttribTypeCase vertexType1010102Validity = (context->getExtensions().vertexType1010102OES)
10673*8975f5c5SAndroid Build Coastguard Worker                                                          ? VertexAttribTypeCase::ValidSize3or4
10674*8975f5c5SAndroid Build Coastguard Worker                                                          : VertexAttribTypeCase::Invalid;
10675*8975f5c5SAndroid Build Coastguard Worker 
10676*8975f5c5SAndroid Build Coastguard Worker     if (context->getClientMajorVersion() <= 2)
10677*8975f5c5SAndroid Build Coastguard Worker     {
10678*8975f5c5SAndroid Build Coastguard Worker         mCachedVertexAttribTypesValidation = {{
10679*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Byte, VertexAttribTypeCase::Valid},
10680*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Short, VertexAttribTypeCase::Valid},
10681*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid},
10682*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid},
10683*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Float, VertexAttribTypeCase::Valid},
10684*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Fixed, VertexAttribTypeCase::Valid},
10685*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::HalfFloatOES, halfFloatValidity},
10686*8975f5c5SAndroid Build Coastguard Worker         }};
10687*8975f5c5SAndroid Build Coastguard Worker     }
10688*8975f5c5SAndroid Build Coastguard Worker     else
10689*8975f5c5SAndroid Build Coastguard Worker     {
10690*8975f5c5SAndroid Build Coastguard Worker         mCachedVertexAttribTypesValidation = {{
10691*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Byte, VertexAttribTypeCase::Valid},
10692*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Short, VertexAttribTypeCase::Valid},
10693*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Int, VertexAttribTypeCase::Valid},
10694*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid},
10695*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid},
10696*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid},
10697*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Float, VertexAttribTypeCase::Valid},
10698*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::HalfFloat, VertexAttribTypeCase::Valid},
10699*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Fixed, VertexAttribTypeCase::Valid},
10700*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Int2101010, VertexAttribTypeCase::ValidSize4Only},
10701*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::HalfFloatOES, halfFloatValidity},
10702*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedInt2101010, VertexAttribTypeCase::ValidSize4Only},
10703*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Int1010102, vertexType1010102Validity},
10704*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedInt1010102, vertexType1010102Validity},
10705*8975f5c5SAndroid Build Coastguard Worker         }};
10706*8975f5c5SAndroid Build Coastguard Worker 
10707*8975f5c5SAndroid Build Coastguard Worker         mCachedIntegerVertexAttribTypesValidation = {{
10708*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Byte, VertexAttribTypeCase::Valid},
10709*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Short, VertexAttribTypeCase::Valid},
10710*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::Int, VertexAttribTypeCase::Valid},
10711*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid},
10712*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid},
10713*8975f5c5SAndroid Build Coastguard Worker             {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid},
10714*8975f5c5SAndroid Build Coastguard Worker         }};
10715*8975f5c5SAndroid Build Coastguard Worker     }
10716*8975f5c5SAndroid Build Coastguard Worker }
10717*8975f5c5SAndroid Build Coastguard Worker 
updateActiveShaderStorageBufferIndices(Context * context)10718*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateActiveShaderStorageBufferIndices(Context *context)
10719*8975f5c5SAndroid Build Coastguard Worker {
10720*8975f5c5SAndroid Build Coastguard Worker     mCachedActiveShaderStorageBufferIndices.reset();
10721*8975f5c5SAndroid Build Coastguard Worker     const ProgramExecutable *executable = context->getState().getProgramExecutable();
10722*8975f5c5SAndroid Build Coastguard Worker     if (executable)
10723*8975f5c5SAndroid Build Coastguard Worker     {
10724*8975f5c5SAndroid Build Coastguard Worker         const std::vector<InterfaceBlock> &blocks = executable->getShaderStorageBlocks();
10725*8975f5c5SAndroid Build Coastguard Worker         for (size_t blockIndex = 0; blockIndex < blocks.size(); ++blockIndex)
10726*8975f5c5SAndroid Build Coastguard Worker         {
10727*8975f5c5SAndroid Build Coastguard Worker             const GLuint binding = executable->getShaderStorageBlockBinding(blockIndex);
10728*8975f5c5SAndroid Build Coastguard Worker             mCachedActiveShaderStorageBufferIndices.set(binding);
10729*8975f5c5SAndroid Build Coastguard Worker         }
10730*8975f5c5SAndroid Build Coastguard Worker     }
10731*8975f5c5SAndroid Build Coastguard Worker }
10732*8975f5c5SAndroid Build Coastguard Worker 
updateActiveImageUnitIndices(Context * context)10733*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateActiveImageUnitIndices(Context *context)
10734*8975f5c5SAndroid Build Coastguard Worker {
10735*8975f5c5SAndroid Build Coastguard Worker     mCachedActiveImageUnitIndices.reset();
10736*8975f5c5SAndroid Build Coastguard Worker     const ProgramExecutable *executable = context->getState().getProgramExecutable();
10737*8975f5c5SAndroid Build Coastguard Worker     if (executable)
10738*8975f5c5SAndroid Build Coastguard Worker     {
10739*8975f5c5SAndroid Build Coastguard Worker         for (const ImageBinding &imageBinding : executable->getImageBindings())
10740*8975f5c5SAndroid Build Coastguard Worker         {
10741*8975f5c5SAndroid Build Coastguard Worker             for (GLuint binding : imageBinding.boundImageUnits)
10742*8975f5c5SAndroid Build Coastguard Worker             {
10743*8975f5c5SAndroid Build Coastguard Worker                 mCachedActiveImageUnitIndices.set(binding);
10744*8975f5c5SAndroid Build Coastguard Worker             }
10745*8975f5c5SAndroid Build Coastguard Worker         }
10746*8975f5c5SAndroid Build Coastguard Worker     }
10747*8975f5c5SAndroid Build Coastguard Worker }
10748*8975f5c5SAndroid Build Coastguard Worker 
updateCanDraw(Context * context)10749*8975f5c5SAndroid Build Coastguard Worker void StateCache::updateCanDraw(Context *context)
10750*8975f5c5SAndroid Build Coastguard Worker {
10751*8975f5c5SAndroid Build Coastguard Worker     // Can draw if:
10752*8975f5c5SAndroid Build Coastguard Worker     //
10753*8975f5c5SAndroid Build Coastguard Worker     // - Is GLES1: GLES1 always creates programs as needed
10754*8975f5c5SAndroid Build Coastguard Worker     // - There is an installed executable with a vertex shader
10755*8975f5c5SAndroid Build Coastguard Worker     // - A program pipeline is to be used: Program pipelines don't have a specific link function, so
10756*8975f5c5SAndroid Build Coastguard Worker     //   the pipeline might just be waiting to be linked at draw time (in which case there won't
10757*8975f5c5SAndroid Build Coastguard Worker     //   necessarily be an executable installed yet).
10758*8975f5c5SAndroid Build Coastguard Worker     mCachedCanDraw =
10759*8975f5c5SAndroid Build Coastguard Worker         context->isGLES1() || (context->getState().getProgramExecutable() &&
10760*8975f5c5SAndroid Build Coastguard Worker                                context->getState().getProgramExecutable()->hasVertexShader());
10761*8975f5c5SAndroid Build Coastguard Worker }
10762*8975f5c5SAndroid Build Coastguard Worker 
isCurrentContext(const Context * context,const PrivateStateCache * privateStateCache) const10763*8975f5c5SAndroid Build Coastguard Worker bool StateCache::isCurrentContext(const Context *context,
10764*8975f5c5SAndroid Build Coastguard Worker                                   const PrivateStateCache *privateStateCache) const
10765*8975f5c5SAndroid Build Coastguard Worker {
10766*8975f5c5SAndroid Build Coastguard Worker     // Ensure that the state cache is not queried by any context other than the one that owns it.
10767*8975f5c5SAndroid Build Coastguard Worker     return &context->getStateCache() == this &&
10768*8975f5c5SAndroid Build Coastguard Worker            &context->getPrivateStateCache() == privateStateCache;
10769*8975f5c5SAndroid Build Coastguard Worker }
10770*8975f5c5SAndroid Build Coastguard Worker 
PrivateStateCache()10771*8975f5c5SAndroid Build Coastguard Worker PrivateStateCache::PrivateStateCache() : mIsCachedBasicDrawStatesErrorValid(true) {}
10772*8975f5c5SAndroid Build Coastguard Worker 
10773*8975f5c5SAndroid Build Coastguard Worker PrivateStateCache::~PrivateStateCache() = default;
10774*8975f5c5SAndroid Build Coastguard Worker }  // namespace gl
10775