1//
2// Copyright 2012 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// renderergl_utils.h: Conversion functions and other utility routines
8// specific to the OpenGL renderer.
9
10#ifndef LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
11#define LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
12
13#include "common/debug.h"
14#include "libANGLE/Caps.h"
15#include "libANGLE/Error.h"
16#include "libANGLE/Version.h"
17#include "libANGLE/angletypes.h"
18#include "libANGLE/renderer/driver_utils.h"
19#include "libANGLE/renderer/gl/functionsgl_typedefs.h"
20
21#include <string>
22#include <vector>
23
24namespace angle
25{
26struct FeaturesGL;
27struct FrontendFeatures;
28} // namespace angle
29
30namespace gl
31{
32struct Caps;
33class TextureCapsMap;
34struct Extensions;
35struct Version;
36} // namespace gl
37
38namespace rx
39{
40class BlitGL;
41class ClearMultiviewGL;
42class ContextGL;
43class FunctionsGL;
44class StateManagerGL;
45enum class MultiviewImplementationTypeGL
46{
47 NV_VIEWPORT_ARRAY2,
48 UNSPECIFIED
49};
50
51// State-tracking data for the swap control to allow DisplayGL to remember per
52// drawable information for swap control.
53struct SwapControlData
54{
55 SwapControlData();
56
57 // Set by the drawable
58 int targetSwapInterval;
59
60 // DisplayGL-side state-tracking
61 int maxSwapInterval;
62 int currentSwapInterval;
63};
64
65VendorID GetVendorID(const FunctionsGL *functions);
66ShShaderOutput GetShaderOutputType(const FunctionsGL *functions);
67
68// Helpers for extracting the GL helper objects out of a context
69const FunctionsGL *GetFunctionsGL(const gl::Context *context);
70StateManagerGL *GetStateManagerGL(const gl::Context *context);
71BlitGL *GetBlitGL(const gl::Context *context);
72ClearMultiviewGL *GetMultiviewClearer(const gl::Context *context);
73const angle::FeaturesGL &GetFeaturesGL(const gl::Context *context);
74
75// Clear all errors on the stored context, emits console warnings
76void ClearErrors(const gl::Context *context,
77 const char *file,
78 const char *function,
79 unsigned int line);
80
81// Check for a single error
82angle::Result CheckError(const gl::Context *context,
83 const char *call,
84 const char *file,
85 const char *function,
86 unsigned int line);
87// Propagates a single error, marking it as handled, and checks for more errors.
88angle::Result HandleError(const gl::Context *context,
89 GLenum error,
90 const char *call,
91 const char *file,
92 const char *function,
93 unsigned int line);
94
95#define ANGLE_GL_TRY_ALWAYS_CHECK(context, call) \
96 (ClearErrors(context, __FILE__, __FUNCTION__, __LINE__), (call)); \
97 ANGLE_TRY(CheckError(context, #call, __FILE__, __FUNCTION__, __LINE__))
98
99#if defined(ANGLE_ENABLE_ASSERTS)
100# define ANGLE_GL_TRY(context, call) ANGLE_GL_TRY_ALWAYS_CHECK(context, call)
101#else
102# define ANGLE_GL_TRY(context, call) call
103#endif
104
105namespace nativegl_gl
106{
107
108void GenerateCaps(const FunctionsGL *functions,
109 const angle::FeaturesGL &features,
110 gl::Caps *caps,
111 gl::TextureCapsMap *textureCapsMap,
112 gl::Extensions *extensions,
113 gl::Limitations *limitations,
114 gl::Version *maxSupportedESVersion,
115 MultiviewImplementationTypeGL *multiviewImplementationType,
116 ShPixelLocalStorageOptions *);
117
118void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *features);
119void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features);
120void ReInitializeFeaturesAtGPUSwitch(const FunctionsGL *functions, angle::FeaturesGL *features);
121} // namespace nativegl_gl
122
123namespace nativegl
124{
125bool SupportsVertexArrayObjects(const FunctionsGL *functions);
126bool CanUseDefaultVertexArrayObject(const FunctionsGL *functions);
127bool SupportsCompute(const FunctionsGL *functions);
128bool SupportsFenceSync(const FunctionsGL *functions);
129bool SupportsOcclusionQueries(const FunctionsGL *functions);
130bool SupportsNativeRendering(const FunctionsGL *functions,
131 gl::TextureType type,
132 GLenum internalFormat);
133bool SupportsTexImage(gl::TextureType type);
134bool UseTexImage2D(gl::TextureType textureType);
135bool UseTexImage3D(gl::TextureType textureType);
136GLenum GetTextureBindingQuery(gl::TextureType textureType);
137GLenum GetTextureBindingTarget(gl::TextureType textureType);
138GLenum GetTextureBindingTarget(gl::TextureTarget textureTarget);
139GLenum GetBufferBindingQuery(gl::BufferBinding bufferBinding);
140std::string GetBufferBindingString(gl::BufferBinding bufferBinding);
141gl::TextureType GetNativeTextureType(gl::TextureType type);
142gl::TextureTarget GetNativeTextureTarget(gl::TextureTarget target);
143} // namespace nativegl
144
145bool CanMapBufferForRead(const FunctionsGL *functions);
146uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
147 GLenum target,
148 size_t offset,
149 size_t length,
150 GLbitfield access);
151
152angle::Result ShouldApplyLastRowPaddingWorkaround(ContextGL *contextGL,
153 const gl::Extents &size,
154 const gl::PixelStoreStateBase &state,
155 const gl::Buffer *pixelBuffer,
156 GLenum format,
157 GLenum type,
158 bool is3D,
159 const void *pixels,
160 bool *shouldApplyOut);
161
162struct ContextCreationTry
163{
164 enum class Type
165 {
166 DESKTOP_CORE,
167 DESKTOP_LEGACY,
168 ES,
169 };
170
171 ContextCreationTry(EGLint displayType, Type type, gl::Version version)
172 : displayType(displayType), type(type), version(version)
173 {}
174
175 EGLint displayType;
176 Type type;
177 gl::Version version;
178};
179
180std::vector<ContextCreationTry> GenerateContextCreationToTry(EGLint requestedType, bool isMesaGLX);
181
182std::string GetRendererString(const FunctionsGL *functions);
183std::string GetVendorString(const FunctionsGL *functions);
184std::string GetVersionString(const FunctionsGL *functions);
185
186} // namespace rx
187
188#endif // LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
189

source code of flutter_engine/third_party/angle/src/libANGLE/renderer/gl/renderergl_utils.h