Flutter Engine
The Flutter Engine
Classes | Macros | Typedefs | Enumerations | Functions
GrGLUtil.h File Reference
#include "include/gpu/gl/GrGLInterface.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkImageInfoPriv.h"
#include "src/gpu/ganesh/GrDataUtils.h"
#include "src/gpu/ganesh/GrStencilSettings.h"
#include "src/gpu/ganesh/gl/GrGLDefines.h"

Go to the source code of this file.

Classes

struct  GrGLDriverInfo
 

Macros

#define GR_GL_VER(major, minor)
 
#define GR_GLSL_VER(major, minor)
 
#define GR_GL_DRIVER_VER(major, minor, point)
 
#define GR_GL_MAJOR_VER(version)   (static_cast<uint32_t>(version) >> 16)
 
#define GR_GL_MINOR_VER(version)   (static_cast<uint32_t>(version) & 0xFFFF)
 
#define GR_GL_INVALID_VER   GR_GL_VER(0, 0)
 
#define GR_GLSL_INVALID_VER   GR_GLSL_VER(0, 0)
 
#define GR_GL_DRIVER_UNKNOWN_VER   GR_GL_DRIVER_VER(0, 0, 0)
 
#define GR_GL_INIT_ZERO   0
 
#define GR_GL_GetIntegerv(gl, e, p)
 
#define GR_GL_GetFloatv(gl, e, p)
 
#define GR_GL_GetFramebufferAttachmentParameteriv(gl, t, a, pname, p)
 
#define GR_GL_GetInternalformativ(gl, t, f, n, s, p)
 
#define GR_GL_GetNamedFramebufferAttachmentParameteriv(gl, fb, a, pname, p)
 
#define GR_GL_GetRenderbufferParameteriv(gl, t, pname, p)
 
#define GR_GL_GetTexLevelParameteriv(gl, t, l, pname, p)
 
#define GR_GL_GetShaderPrecisionFormat(gl, st, pt, range, precision)
 
#define GR_STRING(X)   GR_STRING_IMPL(X)
 
#define GR_STRING_IMPL(X)   #X
 
#define GR_FILE_AND_LINE_STR   __FILE__ "(" GR_STRING(__LINE__) ") : "
 
#define GR_GL_CHECK_ERROR_IMPL(IFACE, X)
 
#define GR_GL_LOG_CALLS_IMPL(X)
 
#define GR_GL_CALL(IFACE, X)
 
#define GR_GL_CALL_NOERRCHECK(IFACE, X)
 
#define GR_GL_CALL_RET(IFACE, RET, X)
 
#define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X)
 

Typedefs

typedef uint32_t GrGLVersion
 
typedef uint32_t GrGLSLVersion
 
typedef uint64_t GrGLDriverVersion
 

Enumerations

enum class  GrGLVendor {
  kARM , kGoogle , kImagination , kIntel ,
  kQualcomm , kNVIDIA , kATI , kApple ,
  kOther
}
 
enum class  GrGLRenderer {
  kTegra_PreK1 , kTegra , kPowerVR54x , kPowerVRBSeries ,
  kPowerVRRogue , kAdreno3xx , kAdreno430 , kAdreno4xx_other ,
  kAdreno530 , kAdreno5xx_other , kAdreno615 , kAdreno620 ,
  kAdreno630 , kAdreno640 , kAdreno6xx_other , kIntelSandyBridge ,
  kIntelIvyBridge , kIntelValleyView , kIntelHaswell , kIntelCherryView ,
  kIntelBroadwell , kIntelApolloLake , kIntelSkyLake , kIntelGeminiLake ,
  kIntelKabyLake , kIntelCoffeeLake , kIntelIceLake , kIntelRocketLake ,
  kIntelTigerLake , kIntelAlderLake , kGalliumLLVM , kMali4xx ,
  kMaliG , kMaliT , kAMDRadeonHD7xxx , kAMDRadeonR9M3xx ,
  kAMDRadeonR9M4xx , kAMDRadeonPro5xxx , kAMDRadeonProVegaxx , kApple ,
  kWebGL , kOther
}
 
enum class  GrGLDriver {
  kMesa , kNVIDIA , kIntel , kQualcomm ,
  kFreedreno , kAndroidEmulator , kImagination , kARM ,
  kApple , kUnknown
}
 
enum class  GrGLANGLEBackend {
  kUnknown , kD3D9 , kD3D11 , kMetal ,
  kOpenGL
}
 

Functions

static constexpr uint32_t GrGLFormatChannels (GrGLFormat format)
 
static constexpr GrColorFormatDesc GrGLFormatDesc (GrGLFormat format)
 
GrGLStandard GrGLGetStandardInUseFromString (const char *versionString)
 
GrGLSLVersion GrGLGetVersion (const GrGLInterface *)
 
GrGLSLVersion GrGLGetVersionFromString (const char *)
 
GrGLDriverInfo GrGLGetDriverInfo (const GrGLInterface *)
 
void GrGLCheckErr (const GrGLInterface *gl, const char *location, const char *call)
 
static constexpr GrGLFormat GrGLFormatFromGLEnum (GrGLenum glFormat)
 
static constexpr GrGLenum GrGLFormatToEnum (GrGLFormat format)
 
static constexpr size_t GrGLFormatBytesPerBlock (GrGLFormat format)
 
static constexpr int GrGLFormatStencilBits (GrGLFormat format)
 
static constexpr bool GrGLFormatIsPackedDepthStencil (GrGLFormat format)
 
static constexpr bool GrGLFormatIsSRGB (GrGLFormat format)
 
GrGLenum GrToGLStencilFunc (GrStencilTest test)
 
bool GrGLFormatIsCompressed (GrGLFormat)
 

Macro Definition Documentation

◆ GR_FILE_AND_LINE_STR

#define GR_FILE_AND_LINE_STR   __FILE__ "(" GR_STRING(__LINE__) ") : "

Creates a string of the form "<filename>(<linenumber>) : "

Definition at line 348 of file GrGLUtil.h.

◆ GR_GL_CALL

#define GR_GL_CALL (   IFACE,
  X 
)
Value:
do { \
GR_GL_CALL_NOERRCHECK(IFACE, X); \
GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
} while (false)
static const SkScalar X
Definition: StrokeBench.cpp:54

Definition at line 381 of file GrGLUtil.h.

◆ GR_GL_CALL_NOERRCHECK

#define GR_GL_CALL_NOERRCHECK (   IFACE,
  X 
)
Value:
do { \
(IFACE)->fFunctions.f##X; \
} while (false)
#define GR_GL_LOG_CALLS_IMPL(X)
Definition: GrGLUtil.h:377

Definition at line 389 of file GrGLUtil.h.

◆ GR_GL_CALL_RET

#define GR_GL_CALL_RET (   IFACE,
  RET,
  X 
)
Value:
do { \
GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \
GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
} while (false)

Definition at line 396 of file GrGLUtil.h.

◆ GR_GL_CALL_RET_NOERRCHECK

#define GR_GL_CALL_RET_NOERRCHECK (   IFACE,
  RET,
  X 
)
Value:
do { \
(RET) = (IFACE)->fFunctions.f##X; \
GR_GL_LOG_CALLS_IMPL(X); \
} while (false)

Definition at line 403 of file GrGLUtil.h.

◆ GR_GL_CHECK_ERROR_IMPL

#define GR_GL_CHECK_ERROR_IMPL (   IFACE,
  X 
)
Value:
do { \
} while (false)

Macros for using GrGLInterface to make GL calls

Definition at line 364 of file GrGLUtil.h.

◆ GR_GL_DRIVER_UNKNOWN_VER

#define GR_GL_DRIVER_UNKNOWN_VER   GR_GL_DRIVER_VER(0, 0, 0)

Definition at line 39 of file GrGLUtil.h.

◆ GR_GL_DRIVER_VER

#define GR_GL_DRIVER_VER (   major,
  minor,
  point 
)
Value:
((static_cast<uint64_t>(major) << 32) | \
(static_cast<uint64_t>(minor) << 16) | \
static_cast<uint64_t>(point))

Definition at line 30 of file GrGLUtil.h.

◆ GR_GL_GetFloatv

#define GR_GL_GetFloatv (   gl,
  e,
 
)
Value:
do { \
GR_GL_CALL(gl, GetFloatv(e, p)); \
} while (0)
#define GR_GL_INIT_ZERO
Definition: GrGLUtil.h:244
gl
Definition: malisc.py:41

Definition at line 251 of file GrGLUtil.h.

◆ GR_GL_GetFramebufferAttachmentParameteriv

#define GR_GL_GetFramebufferAttachmentParameteriv (   gl,
  t,
  a,
  pname,
 
)
Value:
do { \
GR_GL_CALL(gl, GetFramebufferAttachmentParameteriv(t, a, pname, p)); \
} while (0)
struct MyStruct a[10]

Definition at line 257 of file GrGLUtil.h.

◆ GR_GL_GetIntegerv

#define GR_GL_GetIntegerv (   gl,
  e,
 
)
Value:
do { \
GR_GL_CALL(gl, GetIntegerv(e, p)); \
} while (0)

Definition at line 245 of file GrGLUtil.h.

◆ GR_GL_GetInternalformativ

#define GR_GL_GetInternalformativ (   gl,
  t,
  f,
  n,
  s,
 
)
Value:
do { \
GR_GL_CALL(gl, GetInternalformativ(t, f, n, s, p)); \
} while (0)
struct MyStruct s

Definition at line 263 of file GrGLUtil.h.

◆ GR_GL_GetNamedFramebufferAttachmentParameteriv

#define GR_GL_GetNamedFramebufferAttachmentParameteriv (   gl,
  fb,
  a,
  pname,
 
)
Value:
do { \
GR_GL_CALL(gl, GetNamedFramebufferAttachmentParameteriv(fb, a, pname, p)); \
} while (0)

Definition at line 269 of file GrGLUtil.h.

◆ GR_GL_GetRenderbufferParameteriv

#define GR_GL_GetRenderbufferParameteriv (   gl,
  t,
  pname,
 
)
Value:
do { \
GR_GL_CALL(gl, GetRenderbufferParameteriv(t, pname, p)); \
} while (0)

Definition at line 275 of file GrGLUtil.h.

◆ GR_GL_GetShaderPrecisionFormat

#define GR_GL_GetShaderPrecisionFormat (   gl,
  st,
  pt,
  range,
  precision 
)
Value:
do { \
(range)[0] = GR_GL_INIT_ZERO; \
(range)[1] = GR_GL_INIT_ZERO; \
(*precision) = GR_GL_INIT_ZERO; \
GR_GL_CALL(gl, GetShaderPrecisionFormat(st, pt, range, precision)); \
} while (0)

Definition at line 287 of file GrGLUtil.h.

◆ GR_GL_GetTexLevelParameteriv

#define GR_GL_GetTexLevelParameteriv (   gl,
  t,
  l,
  pname,
 
)
Value:
do { \
GR_GL_CALL(gl, GetTexLevelParameteriv(t, l, pname, p)); \
} while (0)

Definition at line 281 of file GrGLUtil.h.

◆ GR_GL_INIT_ZERO

#define GR_GL_INIT_ZERO   0

Some drivers want the var-int arg to be zero-initialized on input.

Definition at line 244 of file GrGLUtil.h.

◆ GR_GL_INVALID_VER

#define GR_GL_INVALID_VER   GR_GL_VER(0, 0)

Definition at line 37 of file GrGLUtil.h.

◆ GR_GL_LOG_CALLS_IMPL

#define GR_GL_LOG_CALLS_IMPL (   X)

Definition at line 377 of file GrGLUtil.h.

◆ GR_GL_MAJOR_VER

#define GR_GL_MAJOR_VER (   version)    (static_cast<uint32_t>(version) >> 16)

Definition at line 34 of file GrGLUtil.h.

◆ GR_GL_MINOR_VER

#define GR_GL_MINOR_VER (   version)    (static_cast<uint32_t>(version) & 0xFFFF)

Definition at line 35 of file GrGLUtil.h.

◆ GR_GL_VER

#define GR_GL_VER (   major,
  minor 
)
Value:
((static_cast<uint32_t>(major) << 16) | \
static_cast<uint32_t>(minor))

Definition at line 26 of file GrGLUtil.h.

◆ GR_GLSL_INVALID_VER

#define GR_GLSL_INVALID_VER   GR_GLSL_VER(0, 0)

Definition at line 38 of file GrGLUtil.h.

◆ GR_GLSL_VER

#define GR_GLSL_VER (   major,
  minor 
)
Value:
((static_cast<uint32_t>(major) << 16) | \
static_cast<uint32_t>(minor))

Definition at line 28 of file GrGLUtil.h.

◆ GR_STRING

#define GR_STRING (   X)    GR_STRING_IMPL(X)

GR_STRING makes a string of X where X is expanded before conversion to a string if X itself contains macros.

Definition at line 342 of file GrGLUtil.h.

◆ GR_STRING_IMPL

#define GR_STRING_IMPL (   X)    #X

Definition at line 343 of file GrGLUtil.h.

Typedef Documentation

◆ GrGLDriverVersion

typedef uint64_t GrGLDriverVersion

Definition at line 24 of file GrGLUtil.h.

◆ GrGLSLVersion

typedef uint32_t GrGLSLVersion

Definition at line 23 of file GrGLUtil.h.

◆ GrGLVersion

typedef uint32_t GrGLVersion

Definition at line 22 of file GrGLUtil.h.

Enumeration Type Documentation

◆ GrGLANGLEBackend

enum class GrGLANGLEBackend
strong
Enumerator
kUnknown 
kD3D9 
kD3D11 
kMetal 
kOpenGL 

Definition at line 231 of file GrGLUtil.h.

231 {
232 kUnknown,
233 kD3D9,
234 kD3D11,
235 kMetal,
236 kOpenGL
237};
@ kOpenGL
Definition: embedder.h:80
@ kMetal
Definition: embedder.h:85

◆ GrGLDriver

enum class GrGLDriver
strong
Enumerator
kMesa 
kNVIDIA 
kIntel 
kQualcomm 
kFreedreno 
kAndroidEmulator 
kImagination 
kARM 
kApple 
kUnknown 

Definition at line 218 of file GrGLUtil.h.

◆ GrGLRenderer

enum class GrGLRenderer
strong
Enumerator
kTegra_PreK1 
kTegra 
kPowerVR54x 
kPowerVRBSeries 
kPowerVRRogue 
kAdreno3xx 
kAdreno430 
kAdreno4xx_other 
kAdreno530 
kAdreno5xx_other 
kAdreno615 
kAdreno620 
kAdreno630 
kAdreno640 
kAdreno6xx_other 
kIntelSandyBridge 

Intel GPU families, ordered by generation

kIntelIvyBridge 
kIntelValleyView 
kIntelHaswell 
kIntelCherryView 
kIntelBroadwell 
kIntelApolloLake 
kIntelSkyLake 
kIntelGeminiLake 
kIntelKabyLake 
kIntelCoffeeLake 
kIntelIceLake 
kIntelRocketLake 
kIntelTigerLake 
kIntelAlderLake 
kGalliumLLVM 
kMali4xx 
kMaliG 

G-3x, G-5x, or G-7x

kMaliT 

T-6xx, T-7xx, or T-8xx

kAMDRadeonHD7xxx 
kAMDRadeonR9M3xx 
kAMDRadeonR9M4xx 
kAMDRadeonPro5xxx 
kAMDRadeonProVegaxx 
kApple 
kWebGL 
kOther 

Definition at line 150 of file GrGLUtil.h.

150 {
151 kTegra_PreK1, // Legacy Tegra architecture (pre-K1).
152 kTegra, // Tegra with the same architecture as NVIDIA desktop GPUs (K1+).
153
157
163 kAdreno615, // Pixel3a
164 kAdreno620, // Pixel5
165 kAdreno630, // Pixel3
166 kAdreno640, // Pixel4
168
169 /** Intel GPU families, ordered by generation **/
170 // 6th gen
172
173 // 7th gen
175 kIntelValleyView, // aka BayTrail
177
178 // 8th gen
179 kIntelCherryView, // aka Braswell
181
182 // 9th gen
188
189 // 11th gen
191
192 // 12th gen
196
198
199 kMali4xx,
200 /** G-3x, G-5x, or G-7x */
201 kMaliG,
202 /** T-6xx, T-7xx, or T-8xx */
203 kMaliT,
204
205 kAMDRadeonHD7xxx, // AMD Radeon HD 7000 Series
206 kAMDRadeonR9M3xx, // AMD Radeon R9 M300 Series
207 kAMDRadeonR9M4xx, // AMD Radeon R9 M400 Series
208 kAMDRadeonPro5xxx, // AMD Radeon Pro 5000 Series
209 kAMDRadeonProVegaxx, // AMD Radeon Pro Vega
210
211 kApple,
212
213 kWebGL,
214
215 kOther
216};

◆ GrGLVendor

enum class GrGLVendor
strong

The Vendor and Renderer enum values are lazily updated as required.

Enumerator
kARM 
kGoogle 
kImagination 
kIntel 
kQualcomm 
kNVIDIA 
kATI 
kApple 
kOther 

Definition at line 137 of file GrGLUtil.h.

137 {
138 kARM,
139 kGoogle,
141 kIntel,
142 kQualcomm,
143 kNVIDIA,
144 kATI,
145 kApple,
146
147 kOther
148};

Function Documentation

◆ GrGLCheckErr()

void GrGLCheckErr ( const GrGLInterface gl,
const char *  location,
const char *  call 
)

Helpers for glGetError()

◆ GrGLFormatBytesPerBlock()

static constexpr size_t GrGLFormatBytesPerBlock ( GrGLFormat  format)
staticconstexpr

Definition at line 479 of file GrGLUtil.h.

479 {
480 switch (format) {
481 case GrGLFormat::kRGBA8: return 4;
482 case GrGLFormat::kR8: return 1;
483 case GrGLFormat::kALPHA8: return 1;
484 case GrGLFormat::kLUMINANCE8: return 1;
485 case GrGLFormat::kLUMINANCE8_ALPHA8: return 2;
486 case GrGLFormat::kBGRA8: return 4;
487 case GrGLFormat::kRGB565: return 2;
488 case GrGLFormat::kRGBA16F: return 8;
489 case GrGLFormat::kLUMINANCE16F: return 2;
490 case GrGLFormat::kR16F: return 2;
491 // We assume the GPU stores this format 4 byte aligned
492 case GrGLFormat::kRGB8: return 4;
493 case GrGLFormat::kRGBX8: return 4;
494 case GrGLFormat::kRG8: return 2;
495 case GrGLFormat::kRGB10_A2: return 4;
496 case GrGLFormat::kRGBA4: return 2;
497 case GrGLFormat::kSRGB8_ALPHA8: return 4;
502 case GrGLFormat::kR16: return 2;
503 case GrGLFormat::kRG16: return 4;
504 case GrGLFormat::kRGBA16: return 8;
505 case GrGLFormat::kRG16F: return 4;
506 case GrGLFormat::kSTENCIL_INDEX8: return 1;
507 case GrGLFormat::kSTENCIL_INDEX16: return 2;
508 case GrGLFormat::kDEPTH24_STENCIL8: return 4;
509 case GrGLFormat::kUnknown: return 0;
510 }
512}
@ kCOMPRESSED_ETC1_RGB8
@ kCOMPRESSED_RGB8_BC1
@ kCOMPRESSED_RGB8_ETC2
@ kCOMPRESSED_RGBA8_BC1
@ kLUMINANCE8_ALPHA8
#define SkUNREACHABLE
Definition: SkAssert.h:135
uint32_t uint32_t * format

◆ GrGLFormatChannels()

static constexpr uint32_t GrGLFormatChannels ( GrGLFormat  format)
staticconstexpr

Definition at line 41 of file GrGLUtil.h.

41 {
42 switch (format) {
43 case GrGLFormat::kUnknown: return 0;
68 case GrGLFormat::kSTENCIL_INDEX8: return 0;
69 case GrGLFormat::kSTENCIL_INDEX16: return 0;
70 case GrGLFormat::kDEPTH24_STENCIL8: return 0;
71 }
73}
@ kRGB_SkColorChannelFlags
Definition: SkColor.h:247
@ kRGBA_SkColorChannelFlags
Definition: SkColor.h:248
@ kRed_SkColorChannelFlag
Definition: SkColor.h:239
@ kGrayAlpha_SkColorChannelFlags
Definition: SkColor.h:245
@ kRG_SkColorChannelFlags
Definition: SkColor.h:246
@ kAlpha_SkColorChannelFlag
Definition: SkColor.h:242
@ kGray_SkColorChannelFlag
Definition: SkColor.h:243

◆ GrGLFormatDesc()

static constexpr GrColorFormatDesc GrGLFormatDesc ( GrGLFormat  format)
staticconstexpr

Definition at line 75 of file GrGLUtil.h.

75 {
76 switch (format) {
78
81 case GrGLFormat::kR8:
101 case GrGLFormat::kRG8:
109 case GrGLFormat::kR16:
119
120 // Compressed texture formats are not expected to have a description.
125
126 // This type only describes color channels.
130 }
132}
static constexpr GrColorFormatDesc MakeInvalid()
Definition: GrTypesPriv.h:756
static constexpr GrColorFormatDesc MakeRGBA(int rgba, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:720
static constexpr GrColorFormatDesc MakeAlpha(int a, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:736
static constexpr GrColorFormatDesc MakeGray(int grayBits, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:748
static constexpr GrColorFormatDesc MakeRG(int rg, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:744
static constexpr GrColorFormatDesc MakeRGB(int rgb, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:728
static constexpr GrColorFormatDesc MakeGrayAlpha(int grayAlpha, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:752
static constexpr GrColorFormatDesc MakeR(int r, GrColorTypeEncoding e)
Definition: GrTypesPriv.h:740

◆ GrGLFormatFromGLEnum()

static constexpr GrGLFormat GrGLFormatFromGLEnum ( GrGLenum  glFormat)
staticconstexpr

Definition at line 409 of file GrGLUtil.h.

409 {
410 switch (glFormat) {
411 case GR_GL_RGBA8: return GrGLFormat::kRGBA8;
412 case GR_GL_R8: return GrGLFormat::kR8;
416 case GR_GL_BGRA8: return GrGLFormat::kBGRA8;
420 case GR_GL_R16F: return GrGLFormat::kR16F;
421 case GR_GL_RGB8: return GrGLFormat::kRGB8;
422 case GR_GL_RGBX8: return GrGLFormat::kRGBX8;
423 case GR_GL_RG8: return GrGLFormat::kRG8;
425 case GR_GL_RGBA4: return GrGLFormat::kRGBA4;
431 case GR_GL_R16: return GrGLFormat::kR16;
432 case GR_GL_RG16: return GrGLFormat::kRG16;
434 case GR_GL_RG16F: return GrGLFormat::kRG16F;
438
439
440 default: return GrGLFormat::kUnknown;
441 }
442}
#define GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
Definition: GrGLDefines.h:261
#define GR_GL_RGB8
Definition: GrGLDefines.h:509
#define GR_GL_SRGB8_ALPHA8
Definition: GrGLDefines.h:526
#define GR_GL_RGB10_A2
Definition: GrGLDefines.h:525
#define GR_GL_R16
Definition: GrGLDefines.h:460
#define GR_GL_RGBA8
Definition: GrGLDefines.h:524
#define GR_GL_R8
Definition: GrGLDefines.h:459
#define GR_GL_R16F
Definition: GrGLDefines.h:494
#define GR_GL_STENCIL_INDEX16
Definition: GrGLDefines.h:450
#define GR_GL_LUMINANCE8
Definition: GrGLDefines.h:473
#define GR_GL_RG8
Definition: GrGLDefines.h:492
#define GR_GL_RGBA16
Definition: GrGLDefines.h:530
#define GR_GL_COMPRESSED_ETC1_RGB8
Definition: GrGLDefines.h:278
#define GR_GL_COMPRESSED_RGB8_ETC2
Definition: GrGLDefines.h:285
#define GR_GL_LUMINANCE8_ALPHA8
Definition: GrGLDefines.h:474
#define GR_GL_LUMINANCE16F
Definition: GrGLDefines.h:475
#define GR_GL_DEPTH24_STENCIL8
Definition: GrGLDefines.h:456
#define GR_GL_RGBA4
Definition: GrGLDefines.h:522
#define GR_GL_RG16F
Definition: GrGLDefines.h:496
#define GR_GL_STENCIL_INDEX8
Definition: GrGLDefines.h:449
#define GR_GL_RGBA16F
Definition: GrGLDefines.h:527
#define GR_GL_BGRA8
Definition: GrGLDefines.h:541
#define GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT
Definition: GrGLDefines.h:260
#define GR_GL_RGBX8
Definition: GrGLDefines.h:511
#define GR_GL_RGB565
Definition: GrGLDefines.h:508
#define GR_GL_ALPHA8
Definition: GrGLDefines.h:478
#define GR_GL_RG16
Definition: GrGLDefines.h:493

◆ GrGLFormatIsCompressed()

bool GrGLFormatIsCompressed ( GrGLFormat  format)

Returns true if the format is compressed.

Definition at line 812 of file GrGLUtil.cpp.

◆ GrGLFormatIsPackedDepthStencil()

static constexpr bool GrGLFormatIsPackedDepthStencil ( GrGLFormat  format)
staticconstexpr

◆ GrGLFormatIsSRGB()

static constexpr bool GrGLFormatIsSRGB ( GrGLFormat  format)
staticconstexpr

◆ GrGLFormatStencilBits()

static constexpr int GrGLFormatStencilBits ( GrGLFormat  format)
staticconstexpr

◆ GrGLFormatToEnum()

static constexpr GrGLenum GrGLFormatToEnum ( GrGLFormat  format)
staticconstexpr

Returns either the sized internal format or compressed internal format of the GrGLFormat.

Definition at line 445 of file GrGLUtil.h.

445 {
446 switch (format) {
447 case GrGLFormat::kRGBA8: return GR_GL_RGBA8;
448 case GrGLFormat::kR8: return GR_GL_R8;
452 case GrGLFormat::kBGRA8: return GR_GL_BGRA8;
456 case GrGLFormat::kR16F: return GR_GL_R16F;
457 case GrGLFormat::kRGB8: return GR_GL_RGB8;
458 case GrGLFormat::kRGBX8: return GR_GL_RGBX8;
459 case GrGLFormat::kRG8: return GR_GL_RG8;
461 case GrGLFormat::kRGBA4: return GR_GL_RGBA4;
467 case GrGLFormat::kR16: return GR_GL_R16;
468 case GrGLFormat::kRG16: return GR_GL_RG16;
470 case GrGLFormat::kRG16F: return GR_GL_RG16F;
474 case GrGLFormat::kUnknown: return 0;
475 }
477}

◆ GrGLGetDriverInfo()

GrGLDriverInfo GrGLGetDriverInfo ( const GrGLInterface interface)

Definition at line 723 of file GrGLUtil.cpp.

723 {
724 if (!interface) {
725 return {};
726 }
729 info.fStandard = interface->fStandard;
730
731 auto getString = [&](GrGLenum s) {
732 const GrGLubyte* bytes = interface->fFunctions.fGetString(s);
733 if (!bytes) {
734 return "";
735 }
736 return reinterpret_cast<const char*>(bytes);
737 };
738
739 const char* const version = getString(GR_GL_VERSION);
740 const char* const slversion = getString(GR_GL_SHADING_LANGUAGE_VERSION);
741 const char* const renderer = getString(GR_GL_RENDERER);
742 const char* const vendor = getString(GR_GL_VENDOR);
743
745 info.fGLSLVersion = get_glsl_version(slversion);
746 info.fVendor = get_vendor(vendor);
747 info.fRenderer = get_renderer(renderer, interface->fExtensions);
748
749 std::tie(info.fDriver, info.fDriverVersion) = get_driver_and_version(interface->fStandard,
750 info.fVendor,
751 vendor,
752 renderer,
753 version);
754
755 SkString innerAngleRendererString;
756 std::tie(info.fANGLEBackend, innerAngleRendererString) = get_angle_backend(renderer);
757
758 if (info.fANGLEBackend == GrGLANGLEBackend::kD3D9 ||
759 info.fANGLEBackend == GrGLANGLEBackend::kD3D11) {
760 std::tie(info.fANGLEVendor,
761 info.fANGLERenderer,
762 info.fANGLEDriver,
763 info.fANGLEDriverVersion) =
764 get_angle_d3d_vendor_and_renderer(innerAngleRendererString.c_str());
765 } else if (info.fANGLEBackend == GrGLANGLEBackend::kOpenGL) {
766 std::tie(info.fANGLEVendor,
767 info.fANGLERenderer,
768 info.fANGLEDriver,
769 info.fANGLEDriverVersion) =
770 get_angle_gl_vendor_and_renderer(innerAngleRendererString.c_str(),
771 interface->fExtensions);
772 }
773
774 if (info.fRenderer == GrGLRenderer::kWebGL) {
775 std::tie(info.fWebGLVendor,
776 info.fWebGLRenderer) =
778
779 }
780
781 info.fIsOverCommandBuffer = is_commamd_buffer(renderer, version);
782
783 info.fIsRunningOverVirgl = is_virgl(renderer);
784
785 return info;
786}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define GR_GL_RENDERER
Definition: GrGLDefines.h:601
#define GR_GL_SHADING_LANGUAGE_VERSION
Definition: GrGLDefines.h:572
#define GR_GL_VENDOR
Definition: GrGLDefines.h:600
#define GR_GL_VERSION
Definition: GrGLDefines.h:602
@ kNone_GrGLStandard
Definition: GrGLTypes.h:20
unsigned int GrGLenum
Definition: GrGLTypes.h:102
unsigned char GrGLubyte
Definition: GrGLTypes.h:111
static std::tuple< GrGLDriver, GrGLDriverVersion > get_driver_and_version(GrGLStandard standard, GrGLVendor vendor, const char *vendorString, const char *rendererString, const char *versionString)
Definition: GrGLUtil.cpp:415
GrGLVersion GrGLGetVersionFromString(const char *versionString)
Definition: GrGLUtil.cpp:68
static std::tuple< GrGLVendor, GrGLRenderer, GrGLDriver, GrGLDriverVersion > get_angle_gl_vendor_and_renderer(const char *innerString, const GrGLExtensions &extensions)
Definition: GrGLUtil.cpp:613
static std::tuple< GrGLVendor, GrGLRenderer > get_webgl_vendor_and_renderer(const GrGLInterface *interface)
Definition: GrGLUtil.cpp:695
static std::tuple< GrGLANGLEBackend, SkString > get_angle_backend(const char *rendererString)
Definition: GrGLUtil.cpp:589
static bool is_virgl(const char *rendererString)
Definition: GrGLUtil.cpp:411
static GrGLRenderer get_renderer(const char *rendererString, const GrGLExtensions &extensions)
Definition: GrGLUtil.cpp:170
static bool is_commamd_buffer(const char *rendererString, const char *versionString)
Definition: GrGLUtil.cpp:399
static std::tuple< GrGLVendor, GrGLRenderer, GrGLDriver, GrGLDriverVersion > get_angle_d3d_vendor_and_renderer(const char *innerString)
Definition: GrGLUtil.cpp:644
static GrGLSLVersion get_glsl_version(const char *versionString)
Definition: GrGLUtil.cpp:116
static GrGLVendor get_vendor(const char *vendorString)
Definition: GrGLUtil.cpp:141
#define SkASSERT(cond)
Definition: SkAssert.h:116
const char * c_str() const
Definition: SkString.h:133
GrGLFunction< GrGLGetStringFn > fGetString
struct GrGLInterface::Functions fFunctions
GrGLExtensions fExtensions
Definition: GrGLInterface.h:82
GrGLStandard fStandard
Definition: GrGLInterface.h:81

◆ GrGLGetStandardInUseFromString()

GrGLStandard GrGLGetStandardInUseFromString ( const char *  versionString)

Definition at line 31 of file GrGLUtil.cpp.

31 {
32 if (!versionString) {
33 SkDebugf("nullptr GL version string.");
34 return kNone_GrGLStandard;
35 }
36
37 int major, minor;
38
39 // check for desktop
40 int n = sscanf(versionString, "%d.%d", &major, &minor);
41 if (2 == n) {
42 return kGL_GrGLStandard;
43 }
44
45 // WebGL might look like "OpenGL ES 2.0 (WebGL 1.0 (OpenGL ES 2.0 Chromium))"
46 int esMajor, esMinor;
47 n = sscanf(versionString, "OpenGL ES %d.%d (WebGL %d.%d", &esMajor, &esMinor, &major, &minor);
48 if (4 == n) {
50 }
51
52 // check for ES 1
53 char profile[2];
54 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile+1, &major, &minor);
55 if (4 == n) {
56 // we no longer support ES1.
57 return kNone_GrGLStandard;
58 }
59
60 // check for ES2
61 n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor);
62 if (2 == n) {
63 return kGLES_GrGLStandard;
64 }
65 return kNone_GrGLStandard;
66}
@ kGLES_GrGLStandard
Definition: GrGLTypes.h:22
@ kWebGL_GrGLStandard
Definition: GrGLTypes.h:23
@ kGL_GrGLStandard
Definition: GrGLTypes.h:21
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1

◆ GrGLGetVersion()

GrGLSLVersion GrGLGetVersion ( const GrGLInterface gl)

Definition at line 109 of file GrGLUtil.cpp.

109 {
110 SkASSERT(gl);
111 const GrGLubyte* v;
112 GR_GL_CALL_RET(gl, v, GetString(GR_GL_VERSION));
113 return GrGLGetVersionFromString((const char*)v);
114}
#define GR_GL_CALL_RET(IFACE, RET, X)
Definition: GrGLUtil.h:396

◆ GrGLGetVersionFromString()

GrGLSLVersion GrGLGetVersionFromString ( const char *  versionString)

Definition at line 68 of file GrGLUtil.cpp.

68 {
69 if (!versionString) {
70 SkDebugf("nullptr GL version string.");
71 return GR_GL_INVALID_VER;
72 }
73
74 int major, minor;
75
76 // check for mesa
77 int mesaMajor, mesaMinor;
78 int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor, &mesaMajor, &mesaMinor);
79 if (4 == n) {
80 return GR_GL_VER(major, minor);
81 }
82
83 n = sscanf(versionString, "%d.%d", &major, &minor);
84 if (2 == n) {
85 return GR_GL_VER(major, minor);
86 }
87
88 // WebGL might look like "OpenGL ES 2.0 (WebGL 1.0 (OpenGL ES 2.0 Chromium))"
89 int esMajor, esMinor;
90 n = sscanf(versionString, "OpenGL ES %d.%d (WebGL %d.%d", &esMajor, &esMinor, &major, &minor);
91 if (4 == n) {
92 return GR_GL_VER(major, minor);
93 }
94
95 char profile[2];
96 n = sscanf(versionString, "OpenGL ES-%c%c %d.%d", profile, profile + 1, &major, &minor);
97 if (4 == n) {
98 return GR_GL_VER(major, minor);
99 }
100
101 n = sscanf(versionString, "OpenGL ES %d.%d", &major, &minor);
102 if (2 == n) {
103 return GR_GL_VER(major, minor);
104 }
105
106 return GR_GL_INVALID_VER;
107}
#define GR_GL_INVALID_VER
Definition: GrGLUtil.h:37
#define GR_GL_VER(major, minor)
Definition: GrGLUtil.h:26

◆ GrToGLStencilFunc()

GrGLenum GrToGLStencilFunc ( GrStencilTest  test)

Definition at line 788 of file GrGLUtil.cpp.

788 {
789 static const GrGLenum gTable[kGrStencilTestCount] = {
790 GR_GL_ALWAYS, // kAlways
791 GR_GL_NEVER, // kNever
792 GR_GL_GREATER, // kGreater
793 GR_GL_GEQUAL, // kGEqual
794 GR_GL_LESS, // kLess
795 GR_GL_LEQUAL, // kLEqual
796 GR_GL_EQUAL, // kEqual
797 GR_GL_NOTEQUAL, // kNotEqual
798 };
799 static_assert(0 == (int)GrStencilTest::kAlways);
800 static_assert(1 == (int)GrStencilTest::kNever);
801 static_assert(2 == (int)GrStencilTest::kGreater);
802 static_assert(3 == (int)GrStencilTest::kGEqual);
803 static_assert(4 == (int)GrStencilTest::kLess);
804 static_assert(5 == (int)GrStencilTest::kLEqual);
805 static_assert(6 == (int)GrStencilTest::kEqual);
806 static_assert(7 == (int)GrStencilTest::kNotEqual);
808
809 return gTable[(int)test];
810}
#define GR_GL_EQUAL
Definition: GrGLDefines.h:582
#define GR_GL_LEQUAL
Definition: GrGLDefines.h:583
#define GR_GL_GREATER
Definition: GrGLDefines.h:584
#define GR_GL_NOTEQUAL
Definition: GrGLDefines.h:585
#define GR_GL_GEQUAL
Definition: GrGLDefines.h:586
#define GR_GL_NEVER
Definition: GrGLDefines.h:580
#define GR_GL_LESS
Definition: GrGLDefines.h:581
#define GR_GL_ALWAYS
Definition: GrGLDefines.h:587
static constexpr int kGrStencilTestCount
GrStencilTest