• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "libANGLE/Error.h"
14 #include "libANGLE/Version.h"
15 #include "libANGLE/angletypes.h"
16 #include "libANGLE/renderer/driver_utils.h"
17 #include "libANGLE/renderer/gl/functionsgl_typedefs.h"
18 
19 #include <string>
20 #include <vector>
21 
22 namespace angle
23 {
24 struct FeaturesGL;
25 struct FrontendFeatures;
26 }  // namespace angle
27 
28 namespace gl
29 {
30 struct Caps;
31 class TextureCapsMap;
32 struct Extensions;
33 struct Version;
34 }  // namespace gl
35 
36 namespace rx
37 {
38 class BlitGL;
39 class ClearMultiviewGL;
40 class ContextGL;
41 class FunctionsGL;
42 class StateManagerGL;
43 enum class MultiviewImplementationTypeGL
44 {
45     NV_VIEWPORT_ARRAY2,
46     UNSPECIFIED
47 };
48 
49 VendorID GetVendorID(const FunctionsGL *functions);
50 
51 // Helpers for extracting the GL helper objects out of a context
52 const FunctionsGL *GetFunctionsGL(const gl::Context *context);
53 StateManagerGL *GetStateManagerGL(const gl::Context *context);
54 BlitGL *GetBlitGL(const gl::Context *context);
55 ClearMultiviewGL *GetMultiviewClearer(const gl::Context *context);
56 const angle::FeaturesGL &GetFeaturesGL(const gl::Context *context);
57 
58 namespace nativegl_gl
59 {
60 
61 void GenerateCaps(const FunctionsGL *functions,
62                   const angle::FeaturesGL &features,
63                   gl::Caps *caps,
64                   gl::TextureCapsMap *textureCapsMap,
65                   gl::Extensions *extensions,
66                   gl::Version *maxSupportedESVersion,
67                   MultiviewImplementationTypeGL *multiviewImplementationType);
68 
69 void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *features);
70 void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features);
71 }  // namespace nativegl_gl
72 
73 namespace nativegl
74 {
75 bool SupportsFenceSync(const FunctionsGL *functions);
76 bool SupportsOcclusionQueries(const FunctionsGL *functions);
77 bool SupportsNativeRendering(const FunctionsGL *functions,
78                              gl::TextureType type,
79                              GLenum internalFormat);
80 bool SupportsTexImage(gl::TextureType type);
81 bool UseTexImage2D(gl::TextureType textureType);
82 bool UseTexImage3D(gl::TextureType textureType);
83 GLenum GetTextureBindingQuery(gl::TextureType textureType);
84 }  // namespace nativegl
85 
86 bool CanMapBufferForRead(const FunctionsGL *functions);
87 uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
88                                     GLenum target,
89                                     size_t offset,
90                                     size_t length,
91                                     GLbitfield access);
92 
93 angle::Result ShouldApplyLastRowPaddingWorkaround(ContextGL *contextGL,
94                                                   const gl::Extents &size,
95                                                   const gl::PixelStoreStateBase &state,
96                                                   const gl::Buffer *pixelBuffer,
97                                                   GLenum format,
98                                                   GLenum type,
99                                                   bool is3D,
100                                                   const void *pixels,
101                                                   bool *shouldApplyOut);
102 
103 struct ContextCreationTry
104 {
105     enum class Type
106     {
107         DESKTOP_CORE,
108         DESKTOP_LEGACY,
109         ES,
110     };
111 
ContextCreationTryContextCreationTry112     ContextCreationTry(EGLint displayType, Type type, gl::Version version)
113         : displayType(displayType), type(type), version(version)
114     {}
115 
116     EGLint displayType;
117     Type type;
118     gl::Version version;
119 };
120 
121 std::vector<ContextCreationTry> GenerateContextCreationToTry(EGLint requestedType, bool isMesaGLX);
122 }  // namespace rx
123 
124 #endif  // LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
125