Convert GrGLDriver/Vendor/Renderer to enum classes
Reformat uses to de-yodaify and try to improve readabilty of
complicated conditionals.
Change-Id: Ifccb84836cbe4f5a01813795ceb287089984f8ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405685
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 3256adb..9cbcacf 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -162,14 +162,14 @@
if (GR_IS_GR_GL_ES(standard)) {
// Primitive restart can cause a 3x slowdown on Adreno. Enable conservatively.
// FIXME: Primitive restart would likely be a win on iOS if we had an enum value for it.
- if (kARM_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kARM) {
fUsePrimitiveRestart = version >= GR_GL_VER(3,0);
}
}
- if (kARM_GrGLVendor == ctxInfo.vendor() ||
- kImagination_GrGLVendor == ctxInfo.vendor() ||
- kQualcomm_GrGLVendor == ctxInfo.vendor() ) {
+ if (ctxInfo.vendor() == GrGLVendor::kARM ||
+ ctxInfo.vendor() == GrGLVendor::kImagination ||
+ ctxInfo.vendor() == GrGLVendor::kQualcomm ) {
fPreferFullscreenClears = true;
}
@@ -286,8 +286,8 @@
#ifdef SK_BUILD_FOR_WIN
// We're assuming that on Windows Chromium we're using ANGLE.
- bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() ||
- kChromium_GrGLDriver == ctxInfo.driver();
+ bool isANGLE = ctxInfo.driver() == GrGLDriver::kANGLE ||
+ ctxInfo.driver() == GrGLDriver::kChromium;
// Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA).
fRGBA8888PixelsOpsAreSlow = isANGLE;
// On DX9 ANGLE reading a partial FBO is slow. TODO: Check whether this is still true and
@@ -295,7 +295,7 @@
fPartialFBOReadIsSlow = isANGLE;
#endif
- bool isMESA = kMesa_GrGLDriver == ctxInfo.driver();
+ bool isMESA = ctxInfo.driver() == GrGLDriver::kMesa;
bool isMAC = false;
#ifdef SK_BUILD_FOR_MAC
isMAC = true;
@@ -308,7 +308,7 @@
// Chrome's command buffer will zero out a buffer if null is passed to glBufferData to
// avoid letting an application see uninitialized memory.
if (GR_IS_GR_GL(standard) || GR_IS_GR_GL_ES(standard)) {
- fUseBufferDataNullHint = kChromium_GrGLDriver != ctxInfo.driver();
+ fUseBufferDataNullHint = (ctxInfo.driver() != GrGLDriver::kChromium);
} else if (GR_IS_GR_WEBGL(standard)) {
// WebGL spec explicitly disallows null values.
fUseBufferDataNullHint = false;
@@ -335,7 +335,7 @@
fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control");
} // No WebGL support
- fSkipErrorChecks = ctxInfo.driver() == kChromium_GrGLDriver;
+ fSkipErrorChecks = ctxInfo.driver() == GrGLDriver::kChromium;
if (GR_IS_GR_WEBGL(standard)) {
// Error checks are quite costly in webgl, especially in Chrome.
fSkipErrorChecks = true;
@@ -386,9 +386,9 @@
// Mali and early Adreno both have support for geometry shaders, but they appear to be
// implemented in software. In practice with ccpr, they are slower than the backup impl that
// only uses vertex shaders.
- if (kARM_GrGLVendor != ctxInfo.vendor() &&
- kAdreno3xx_GrGLRenderer != ctxInfo.renderer() &&
- kAdreno4xx_other_GrGLRenderer != ctxInfo.renderer()) {
+ if (ctxInfo.vendor() != GrGLVendor::kARM &&
+ ctxInfo.renderer() != GrGLRenderer::kAdreno3xx &&
+ ctxInfo.renderer() != GrGLRenderer::kAdreno4xx_other) {
if (version >= GR_GL_VER(3,2)) {
shaderCaps->fGeometryShaderSupport = true;
@@ -431,9 +431,10 @@
// The Chrome command buffer blocks the use of client side buffers (but may emulate VBOs with
// them). Client side buffers are not allowed in core profiles.
if (GR_IS_GR_GL(standard) || GR_IS_GR_GL_ES(standard)) {
- if (ctxInfo.driver() != kChromium_GrGLDriver && !fIsCoreProfile &&
- (ctxInfo.vendor() == kARM_GrGLVendor || ctxInfo.vendor() == kImagination_GrGLVendor ||
- ctxInfo.vendor() == kQualcomm_GrGLVendor)) {
+ if (ctxInfo.driver() != GrGLDriver::kChromium && !fIsCoreProfile &&
+ (ctxInfo.vendor() == GrGLVendor::kARM ||
+ ctxInfo.vendor() == GrGLVendor::kImagination ||
+ ctxInfo.vendor() == GrGLVendor::kQualcomm)) {
fPreferClientSideDynamicBuffers = true;
}
} // No client side arrays in WebGL https://www.khronos.org/registry/webgl/specs/1.0/#6.2
@@ -531,7 +532,7 @@
// We think mapping on Chromium will be cheaper once we know ahead of time how much space
// we will use for all GrMeshDrawOps. Right now we might wind up mapping a large buffer and
// using a small subset.
- fBufferMapThreshold = kChromium_GrGLDriver == ctxInfo.driver() ? 0 : SK_MaxS32;
+ fBufferMapThreshold = ctxInfo.driver() == GrGLDriver::kChromium ? 0 : SK_MaxS32;
#else
fBufferMapThreshold = SK_MaxS32;
#endif
@@ -567,7 +568,7 @@
GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize);
fMaxPreferredRenderTargetSize = fMaxRenderTargetSize;
- if (kARM_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kARM) {
// On Mali G71, RT's above 4k have been observed to incur a performance cost.
fMaxPreferredRenderTargetSize = std::min(4096, fMaxPreferredRenderTargetSize);
}
@@ -575,11 +576,11 @@
fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker");
// Disable scratch texture reuse on Mali and Adreno devices
- fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor();
+ fReuseScratchTextures = (ctxInfo.vendor() != GrGLVendor::kARM);
#if 0
- fReuseScratchBuffers = kARM_GrGLVendor != ctxInfo.vendor() &&
- kQualcomm_GrGLVendor != ctxInfo.vendor();
+ fReuseScratchBuffers = ctxInfo.vendor() != GrGLVendor::kARM
+ ctxInfo.vendor() != GrGLVendor::kQualcomm;
#endif
if (ctxInfo.hasExtension("GL_EXT_window_rectangles")) {
@@ -591,7 +592,7 @@
fPreferVRAMUseOverFlushes = !isANGLE;
#endif
- if (kChromium_GrGLDriver == ctxInfo.driver()) {
+ if (ctxInfo.driver() == GrGLDriver::kChromium) {
fMustClearUploadedBufferData = true;
}
@@ -731,7 +732,7 @@
fTiledRenderingSupport = ctxInfo.hasExtension("GL_QCOM_tiled_rendering");
}
- if (kARM_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kARM) {
fShouldCollapseSrcOverToSrcWhenAble = true;
}
@@ -884,8 +885,8 @@
// Flat interpolation appears to be slow on Qualcomm GPUs (tested Adreno 405 and 530). ANGLE
// Avoid on ANGLE too, it inserts a geometry shader into the pipeline to implement flat interp.
shaderCaps->fPreferFlatInterpolation = shaderCaps->fFlatInterpolationSupport &&
- kQualcomm_GrGLVendor != ctxInfo.vendor() &&
- kANGLE_GrGLDriver != ctxInfo.driver();
+ ctxInfo.vendor() != GrGLVendor::kQualcomm &&
+ ctxInfo.driver() != GrGLDriver::kANGLE;
if (GR_IS_GR_GL(standard)) {
shaderCaps->fNoPerspectiveInterpolationSupport =
ctxInfo.glslGeneration() >= k130_GrGLSLGeneration;
@@ -974,7 +975,7 @@
shaderCaps->fFloatIs32Bits = is_float_fp32(ctxInfo, gli, GR_GL_HIGH_FLOAT);
shaderCaps->fHalfIs32Bits = is_float_fp32(ctxInfo, gli, GR_GL_MEDIUM_FLOAT);
- shaderCaps->fHasLowFragmentPrecision = kMali4xx_GrGLRenderer == ctxInfo.renderer();
+ shaderCaps->fHasLowFragmentPrecision = ctxInfo.renderer() == GrGLRenderer::kMali4xx;
if (GR_IS_GR_GL(standard)) {
shaderCaps->fBuiltinFMASupport = ctxInfo.glslGeneration() >= k400_GrGLSLGeneration;
@@ -3464,16 +3465,15 @@
FormatWorkarounds* formatWorkarounds) {
// A driver bug on the nexus 6 causes incorrect dst copies when invalidate is called beforehand.
// Thus we are disabling this extension for now on Adreno4xx devices.
- if (kAdreno430_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno4xx_other_GrGLRenderer == ctxInfo.renderer() ||
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno430 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno4xx_other ||
fDriverBugWorkarounds.disable_discard_framebuffer) {
fInvalidateFBType = kNone_InvalidateFBType;
}
// glClearTexImage seems to have a bug in NVIDIA drivers that was fixed sometime between
// 340.96 and 367.57.
- if (GR_IS_GR_GL(ctxInfo.standard()) &&
- ctxInfo.driver() == kNVIDIA_GrGLDriver &&
+ if (GR_IS_GR_GL(ctxInfo.standard()) && ctxInfo.driver() == GrGLDriver::kNVIDIA &&
ctxInfo.driverVersion() < GR_GL_DRIVER_VER(367, 57, 0)) {
fClearTextureSupport = false;
}
@@ -3481,7 +3481,7 @@
#ifdef SK_BUILD_FOR_MAC
// Radeon MacBooks hit a crash in glReadPixels() when using geometry shaders.
// http://skbug.com/8097
- if (kATI_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kATI) {
shaderCaps->fGeometryShaderSupport = false;
}
// On at least some MacBooks, GLSL 4.0 geometry shaders break if we use invocations.
@@ -3490,16 +3490,16 @@
// Qualcomm driver @103.0 has been observed to crash compiling ccpr geometry
// shaders. @127.0 is the earliest verified driver to not crash.
- if (kQualcomm_GrGLDriver == ctxInfo.driver() &&
+ if (ctxInfo.driver() == GrGLDriver::kQualcomm &&
ctxInfo.driverVersion() < GR_GL_DRIVER_VER(127, 0, 0)) {
shaderCaps->fGeometryShaderSupport = false;
}
// glBlitFramebuffer seems to produce incorrect results on QC, Mali400, and Tegra3 but
// glCopyTexSubImage2D works (even though there is no extension that specifically allows it).
- if (ctxInfo.vendor() == kQualcomm_GrGLVendor ||
- ctxInfo.renderer() == kMali4xx_GrGLRenderer ||
- ctxInfo.renderer() == kTegra_PreK1_GrGLRenderer) {
+ if (ctxInfo.vendor() == GrGLVendor::kQualcomm ||
+ ctxInfo.renderer() == GrGLRenderer::kMali4xx ||
+ ctxInfo.renderer() == GrGLRenderer::kTegra_PreK1) {
fAllowBGRA8CopyTexSubImage = true;
}
@@ -3518,7 +3518,7 @@
// GL_INVALID_OPERATION thrown by glDrawArrays when using a buffer that was mapped. The same bug
// did not reproduce on a Nexus7 2013 with a 320 running Android M with driver 127.0. It's
// unclear whether this really affects a wide range of devices.
- if (ctxInfo.renderer() == kAdreno3xx_GrGLRenderer &&
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno3xx &&
ctxInfo.driverVersion() > GR_GL_DRIVER_VER(127, 0, 0)) {
fMapBufferType = kNone_MapBufferType;
fMapBufferFlags = kNone_MapFlags;
@@ -3528,17 +3528,17 @@
}
// The TransferPixelsToTexture test fails on ANGLE.
- if (kANGLE_GrGLDriver == ctxInfo.driver()) {
+ if (ctxInfo.driver() == GrGLDriver::kANGLE) {
fTransferFromBufferToTextureSupport = false;
}
// Using MIPs on this GPU seems to be a source of trouble.
- if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kPowerVR54x) {
fMipmapSupport = false;
}
#ifdef SK_BUILD_FOR_ANDROID
- if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kPowerVR54x) {
// Flutter found glTexSubImage2D for GL_RED is much slower than GL_ALPHA on the
// "MC18 PERSONAL SHOPPER"
formatWorkarounds->fDisallowR8ForPowerVRSGX54x = true;
@@ -3547,24 +3547,24 @@
// https://b.corp.google.com/issues/143074513
// https://skbug.com/11152
- if (kAdreno615_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno620_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno615 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno620) {
fMSFBOType = kNone_MSFBOType;
fMSAAResolvesAutomatically = false;
}
#ifndef SK_BUILD_FOR_IOS
- if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() ||
- kPowerVRRogue_GrGLRenderer == ctxInfo.renderer() ||
- (kAdreno3xx_GrGLRenderer == ctxInfo.renderer() &&
- ctxInfo.driver() != kChromium_GrGLDriver)) {
+ if (ctxInfo.renderer() == GrGLRenderer::kPowerVR54x ||
+ ctxInfo.renderer() == GrGLRenderer::kPowerVRRogue ||
+ (ctxInfo.renderer() == GrGLRenderer::kAdreno3xx &&
+ ctxInfo.driver() != GrGLDriver::kChromium)) {
fPerformColorClearsAsDraws = true;
}
#endif
// A lot of GPUs have trouble with full screen clears (skbug.com/7195)
- if (kAMDRadeonHD7xxx_GrGLRenderer == ctxInfo.renderer() ||
- kAMDRadeonR9M4xx_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAMDRadeonHD7xxx ||
+ ctxInfo.renderer() == GrGLRenderer::kAMDRadeonR9M4xx) {
fPerformColorClearsAsDraws = true;
}
@@ -3577,15 +3577,15 @@
// Retina MBP Early 2015 with Iris 6100. It is possibly fixed on earlier drivers as well.
// crbug.com/1039912 - Crash rate in glClear spiked after OS update, affecting mostly
// Broadwell on 10.13+
- if (kIntel_GrGLVendor == ctxInfo.vendor() &&
+ if (ctxInfo.vendor() == GrGLVendor::kIntel &&
(ctxInfo.driverVersion() < GR_GL_DRIVER_VER(10, 30, 12) ||
- ctxInfo.renderer() == kIntelBroadwell_GrGLRenderer)) {
+ ctxInfo.renderer() == GrGLRenderer::kIntelBroadwell)) {
fPerformColorClearsAsDraws = true;
}
// crbug.com/969609 - NVIDIA on Mac sometimes segfaults during glClear in chrome. It seems
// mostly concentrated in 10.13/14, GT 650Ms, driver 12+. But there are instances of older
// drivers and GTX 775s, so we'll start with a broader workaround.
- if (kNVIDIA_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kNVIDIA) {
fPerformColorClearsAsDraws = true;
}
#endif
@@ -3598,8 +3598,8 @@
fPerformColorClearsAsDraws = true;
}
- if (kAdreno430_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno4xx_other_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno430 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno4xx_other) {
// This is known to be fixed sometime between driver 145.0 and 219.0
if (ctxInfo.driverVersion() <= GR_GL_DRIVER_VER(219, 0, 0)) {
fPerformStencilClearsAsDraws = true;
@@ -3618,7 +3618,7 @@
fPerformStencilClearsAsDraws = true;
}
- if (ctxInfo.vendor() == kQualcomm_GrGLVendor) {
+ if (ctxInfo.vendor() == GrGLVendor::kQualcomm) {
// It appears that all the Adreno GPUs have less than optimal performance when
// drawing w/ large index buffers.
fAvoidLargeIndexBufferDraws = true;
@@ -3632,14 +3632,14 @@
// and not produced on:
// - A Nexus 7 2013 (Adreno 320) running Android 4 with driver 53.0
// The particular lines that get dropped from test images varies across different devices.
- if (kAdreno3xx_GrGLRenderer == ctxInfo.renderer() &&
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno3xx &&
ctxInfo.driverVersion() > GR_GL_DRIVER_VER(53, 0, 0)) {
fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines = true;
}
// TODO: Don't apply this on iOS?
- if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
- // Our Chromebook with kPowerVRRogue_GrGLRenderer crashes on large instanced draws. The
+ if (ctxInfo.renderer() == GrGLRenderer::kPowerVRRogue) {
+ // Our Chromebook with GrGLRenderer::kPowerVRRogue crashes on large instanced draws. The
// current minimum number of instances observed to crash is somewhere between 2^14 and 2^15.
// Keep the number of instances below 1000, just to be safe.
fMaxInstancesPerDrawWithoutCrashing = 999;
@@ -3648,7 +3648,7 @@
}
#ifndef SK_BUILD_FOR_IOS
- if (ctxInfo.renderer() == kPowerVRRogue_GrGLRenderer) {
+ if (GrGLRenderer::kPowerVRRogue == ctxInfo.renderer()) {
// We saw this bug on a TecnoSpark 3 Pro with a PowerVR GE8300.
// GL_VERSION: "OpenGL ES 3.2 build 1.10@51309121"
// Possibly this could be more limited by driver version or HW generation.
@@ -3667,7 +3667,7 @@
#endif
// Texture uploads sometimes seem to be ignored to textures bound to FBOS on Tegra3.
- if (kTegra_PreK1_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kTegra_PreK1) {
fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO = true;
fUseDrawInsteadOfAllRenderTargetWrites = true;
}
@@ -3685,7 +3685,7 @@
fDontSetBaseOrMaxLevelForExternalTextures = true;
// PowerVR can crash setting the levels on Android up to Q for any texture?
// https://crbug.com/1123874
- if (ctxInfo.vendor() == kImagination_GrGLVendor) {
+ if (ctxInfo.vendor() == GrGLVendor::kImagination) {
fMipmapLevelControlSupport = false;
}
#endif
@@ -3695,25 +3695,25 @@
// glGenerateMipmap. Our implementation requires mip-level sampling control. Additionally,
// it can be much slower (especially on mobile GPUs), so we opt-in only when necessary:
if (fMipmapLevelControlSupport &&
- (contextOptions.fDoManualMipmapping ||
- (kIntel_GrGLVendor == ctxInfo.vendor()) ||
- (kNVIDIA_GrGLDriver == ctxInfo.driver() && isMAC) ||
- (kATI_GrGLVendor == ctxInfo.vendor()))) {
+ (contextOptions.fDoManualMipmapping ||
+ ctxInfo.vendor() == GrGLVendor::kIntel ||
+ (ctxInfo.driver() == GrGLDriver::kNVIDIA && isMAC) ||
+ ctxInfo.vendor() == GrGLVendor::kATI)) {
fDoManualMipmapping = true;
}
// See http://crbug.com/710443
#ifdef SK_BUILD_FOR_MAC
- if (kIntelBroadwell_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kIntelBroadwell) {
fClearToBoundaryValuesIsBroken = true;
}
#endif
- if (kQualcomm_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kQualcomm) {
fDrawArraysBaseVertexIsBroken = true;
}
// http://anglebug.com/4536
- if (ctxInfo.driver() == kANGLE_GrGLDriver &&
+ if (ctxInfo.driver() == GrGLDriver::kANGLE &&
ctxInfo.angleBackend() != GrGLANGLEBackend::kOpenGL) {
fBaseVertexBaseInstanceSupport = false;
fNativeDrawIndirectSupport = false;
@@ -3730,8 +3730,8 @@
// Currently the extension is advertised but fb fetch is broken on 500 series Adrenos like the
// Galaxy S7.
// TODO: Once this is fixed we can update the check here to look at a driver version number too.
- if (kAdreno530_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno5xx_other_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno530 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno5xx_other) {
shaderCaps->fFBFetchSupport = false;
}
@@ -3739,15 +3739,15 @@
// function that may require a gradient calculation inside a conditional block may return
// undefined results". This appears to be an issue with the 'any' call since even the simple
// "result=black; if (any()) result=white;" code fails to compile.
- shaderCaps->fCanUseAnyFunctionInShader = kImagination_GrGLVendor != ctxInfo.vendor();
+ shaderCaps->fCanUseAnyFunctionInShader = (ctxInfo.vendor() != GrGLVendor::kImagination);
// Known issue on at least some Intel platforms:
// http://code.google.com/p/skia/issues/detail?id=946
- if (kIntel_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kIntel) {
shaderCaps->fFragCoordConventionsExtensionString = nullptr;
}
- if (kTegra_PreK1_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kTegra_PreK1) {
// The Tegra3 compiler will sometimes never return if we have min(abs(x), 1.0),
// so we must do the abs first in a separate expression.
shaderCaps->fCanUseMinAndAbsTogether = false;
@@ -3763,21 +3763,21 @@
// On Intel GPU there is an issue where it reads the second argument to atan "- %s.x" as an int
// thus must us -1.0 * %s.x to work correctly
- if (kIntel_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kIntel) {
shaderCaps->fMustForceNegatedAtanParamToFloat = true;
}
// On some Intel GPUs there is an issue where the driver outputs bogus values in the shader
// when floor and abs are called on the same line. Thus we must execute an Op between them to
// make sure the compiler doesn't re-inline them even if we break the calls apart.
- if (kIntel_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kIntel) {
shaderCaps->fMustDoOpBetweenFloorAndAbs = true;
}
// On Adreno devices with framebuffer fetch support, there is a bug where they always return
// the original dst color when reading the outColor even after being written to. By using a
// local outColor we can work around this bug.
- if (shaderCaps->fFBFetchSupport && kQualcomm_GrGLVendor == ctxInfo.vendor()) {
+ if (shaderCaps->fFBFetchSupport && ctxInfo.vendor() == GrGLVendor::kQualcomm) {
shaderCaps->fRequiresLocalOutputColorForFBFetch = true;
}
@@ -3787,19 +3787,19 @@
// that the shader always outputs opaque values. In that case, it appears to remove the shader
// based blending code it normally injects, turning SrcOver into Src. To fix this, we always
// insert an extra bit of math on the uniform that confuses the compiler just enough...
- if (kMaliT_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kMaliT) {
shaderCaps->fMustObfuscateUniformColor = true;
}
// On Mali G series GPUs, applying transfer functions in the fragment shader with half-floats
// produces answers that are much less accurate than expected/required. This forces full floats
// for some intermediate values to get acceptable results.
- if (kMaliG_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kMaliG) {
fShaderCaps->fColorSpaceMathNeedsFloat = true;
}
// On Mali 400 there is a bug using dFd* in the x direction. So we avoid using it when possible.
- if (ctxInfo.renderer() == kMali4xx_GrGLRenderer) {
+ if (ctxInfo.renderer() == GrGLRenderer::kMali4xx) {
fShaderCaps->fAvoidDfDxForGradientsWhenPossible = true;
}
@@ -3816,14 +3816,14 @@
// we've explicitly guarded the division with a check against zero. This manifests in much
// more complex ways in some of our shaders, so we use this caps bit to add an epsilon value
// to the denominator of divisions, even when we've added checks that the denominator isn't 0.
- if (kANGLE_GrGLDriver == ctxInfo.driver() || kChromium_GrGLDriver == ctxInfo.driver()) {
+ if (ctxInfo.driver() == GrGLDriver::kANGLE || ctxInfo.driver() == GrGLDriver::kChromium) {
shaderCaps->fMustGuardDivisionEvenAfterExplicitZeroCheck = true;
}
#endif
- if (ctxInfo.renderer() == kAdreno615_GrGLRenderer ||
- ctxInfo.renderer() == kAdreno630_GrGLRenderer ||
- ctxInfo.renderer() == kAdreno640_GrGLRenderer) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno615 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno630 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno640) {
shaderCaps->fInBlendModesFailRandomlyForAllZeroVec = true;
}
@@ -3831,18 +3831,18 @@
// (rare) situations. It's sporadic, and mostly on older drivers. Additionally, old Adreno
// compilers (see crbug.com/skia/4078) crash when accessing .zw of gl_FragCoord, so just bypass
// using gl_FragCoord at all to get around it.
- if (kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno3xx) {
shaderCaps->fCanUseFragCoord = false;
}
// gl_FragCoord has an incorrect subpixel offset on legacy Tegra hardware.
- if (kTegra_PreK1_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kTegra_PreK1) {
shaderCaps->fCanUseFragCoord = false;
}
// On Mali G71, mediump ints don't appear capable of representing every integer beyond +/-2048.
// (Are they implemented with fp16?)
- if (kARM_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kARM) {
shaderCaps->fIncompleteShortIntPrecision = true;
}
@@ -3870,26 +3870,26 @@
shaderCaps->fDualSourceBlendingSupport = false;
}
- if (kAdreno3xx_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno4xx_other_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno3xx ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno4xx_other) {
shaderCaps->fMustWriteToFragColor = true;
}
// Disabling advanced blend on various platforms with major known issues. We also block Chrome
// for now until its own denylists can be updated.
- if (kAdreno430_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno4xx_other_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno530_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno5xx_other_GrGLRenderer == ctxInfo.renderer() ||
- kIntel_GrGLDriver == ctxInfo.driver() ||
- kChromium_GrGLDriver == ctxInfo.driver() ||
- kARM_GrGLVendor == ctxInfo.vendor() /* http://skbug.com/11906 */) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno430 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno4xx_other ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno530 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno5xx_other ||
+ ctxInfo.driver() == GrGLDriver::kIntel ||
+ ctxInfo.driver() == GrGLDriver::kChromium ||
+ ctxInfo.vendor() == GrGLVendor::kARM /* http://skbug.com/11906 */) {
fBlendEquationSupport = kBasic_BlendEquationSupport;
shaderCaps->fAdvBlendEqInteraction = GrShaderCaps::kNotSupported_AdvBlendEqInteraction;
}
// Non-coherent advanced blend has an issue on NVIDIA pre 337.00.
- if (kNVIDIA_GrGLDriver == ctxInfo.driver() &&
+ if (ctxInfo.driver() == GrGLDriver::kNVIDIA &&
ctxInfo.driverVersion() < GR_GL_DRIVER_VER(337, 00, 0) &&
kAdvanced_BlendEquationSupport == fBlendEquationSupport) {
fBlendEquationSupport = kBasic_BlendEquationSupport;
@@ -3902,13 +3902,13 @@
}
if (this->advancedBlendEquationSupport()) {
- if (kNVIDIA_GrGLDriver == ctxInfo.driver() &&
+ if (ctxInfo.driver() == GrGLDriver::kNVIDIA &&
ctxInfo.driverVersion() < GR_GL_DRIVER_VER(355, 00, 0)) {
// Disable color-dodge and color-burn on pre-355.00 NVIDIA.
fAdvBlendEqDisableFlags |= (1 << kColorDodge_GrBlendEquation) |
(1 << kColorBurn_GrBlendEquation);
}
- if (kARM_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kARM) {
// Disable color-burn on ARM until the fix is released.
fAdvBlendEqDisableFlags |= (1 << kColorBurn_GrBlendEquation);
}
@@ -3935,19 +3935,19 @@
fWritePixelsRowBytesSupport = false;
#endif
- if (kIntel_GrGLVendor == ctxInfo.vendor() || // IntelIris640 drops draws completely.
- ctxInfo.renderer() == kMaliT_GrGLRenderer || // Some curves appear flat on GalaxyS6.
- ctxInfo.renderer() == kAdreno3xx_GrGLRenderer ||
- ctxInfo.renderer() == kAdreno430_GrGLRenderer ||
- ctxInfo.renderer() == kAdreno4xx_other_GrGLRenderer) { // We get garbage on Adreno405.
+ if (ctxInfo.vendor() == GrGLVendor::kIntel || // IntelIris640 drops draws completely.
+ ctxInfo.renderer() == GrGLRenderer::kMaliT || // Some curves appear flat on GalaxyS6.
+ ctxInfo.renderer() == GrGLRenderer::kAdreno3xx ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno430 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno4xx_other) { // We get garbage on Adreno405.
fDisableTessellationPathRenderer = true;
}
// http://skbug.com/9739
bool isNVIDIAPascal =
- kNVIDIA_GrGLDriver == ctxInfo.driver() &&
+ ctxInfo.driver() == GrGLDriver::kNVIDIA &&
ctxInfo.hasExtension("GL_NV_conservative_raster_pre_snap_triangles") && // Pascal+.
- !ctxInfo.hasExtension("GL_NV_conservative_raster_underestimation"); // Volta+.
+ !ctxInfo.hasExtension("GL_NV_conservative_raster_underestimation"); // Volta+.
if (isNVIDIAPascal && ctxInfo.driverVersion() < GR_GL_DRIVER_VER(440, 00, 0)) {
if (GR_IS_GR_GL(ctxInfo.standard())) {
// glMemoryBarrier wasn't around until version 4.2.
@@ -3966,7 +3966,7 @@
}
}
- if (kQualcomm_GrGLDriver == ctxInfo.driver()) {
+ if (ctxInfo.driver() == GrGLDriver::kQualcomm) {
// Qualcomm fails to link programs with tessellation and does not give an error message.
// http://skbug.com/9740
shaderCaps->fMaxTessellationSegments = 0;
@@ -3974,9 +3974,9 @@
#ifdef SK_BUILD_FOR_WIN
// glDrawElementsIndirect fails GrMeshTest on every Win10 Intel bot.
- if (ctxInfo.driver() == kIntel_GrGLDriver ||
- (ctxInfo.driver() == kANGLE_GrGLDriver &&
- ctxInfo.angleVendor() == GrGLANGLEVendor::kIntel &&
+ if (ctxInfo.driver() == GrGLDriver::kIntel ||
+ (ctxInfo.driver() == GrGLDriver::kANGLE &&
+ ctxInfo.angleVendor() == GrGLANGLEVendor::kIntel &&
ctxInfo.angleBackend() == GrGLANGLEBackend::kOpenGL)) {
fNativeDrawIndexedIndirectIsBroken = true;
fUseClientSideIndirectBuffers = true;
@@ -3984,7 +3984,7 @@
#endif
// PowerVRGX6250 drops every pixel if we modify the sample mask while color writes are disabled.
- if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kPowerVRRogue) {
fNeverDisableColorWrites = true;
shaderCaps->fMustWriteToFragColor = true;
}
@@ -3992,33 +3992,35 @@
// It appears that Qualcomm drivers don't actually support
// GL_NV_shader_noperspective_interpolation in ES 3.00 or 3.10 shaders, only 3.20.
// https://crbug.com/986581
- if (kQualcomm_GrGLVendor == ctxInfo.vendor() &&
+ if (ctxInfo.vendor() == GrGLVendor::kQualcomm &&
k320es_GrGLSLGeneration != ctxInfo.glslGeneration()) {
shaderCaps->fNoPerspectiveInterpolationSupport = false;
}
// We disable srgb write control for Adreno4xx devices.
// see: https://bug.skia.org/5329
- if (kAdreno430_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno4xx_other_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno430 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno4xx_other) {
fSRGBWriteControl = false;
}
// MacPro devices with AMD cards fail to create MSAA sRGB render buffers.
#if defined(SK_BUILD_FOR_MAC)
- formatWorkarounds->fDisableSRGBRenderWithMSAAForMacAMD = kATI_GrGLVendor == ctxInfo.vendor();
+ if (ctxInfo.vendor() == GrGLVendor::kATI) {
+ formatWorkarounds->fDisableSRGBRenderWithMSAAForMacAMD = true;
+ }
#endif
// Command buffer fails glTexSubImage2D with type == GL_HALF_FLOAT_OES if a GL_RGBA16F texture
// is created with glTexStorage2D. See crbug.com/1008003.
formatWorkarounds->fDisableRGBA16FTexStorageForCrBug1008003 =
- kChromium_GrGLDriver == ctxInfo.driver() && ctxInfo.version() < GR_GL_VER(3, 0);
+ ctxInfo.driver() == GrGLDriver::kChromium && ctxInfo.version() < GR_GL_VER(3, 0);
#if defined(SK_BUILD_FOR_WIN)
// On Intel Windows ES contexts it seems that using texture storage with BGRA causes
// problems with cross-context SkImages.
formatWorkarounds->fDisableBGRATextureStorageForIntelWindowsES =
- kIntel_GrGLDriver == ctxInfo.driver() && GR_IS_GR_GL_ES(ctxInfo.standard());
+ ctxInfo.driver() == GrGLDriver::kIntel && GR_IS_GR_GL_ES(ctxInfo.standard());
#endif
// On the Intel Iris 6100, interacting with LUM16F seems to confuse the driver. After
@@ -4027,17 +4029,17 @@
// All Adrenos claim to support LUM16F but don't appear to actually do so.
// The failing devices/gpus were: Nexus5/Adreno330, Nexus5x/Adreno418, Pixel/Adreno530,
// Pixel2XL/Adreno540 and Pixel3/Adreno630
- formatWorkarounds->fDisableLuminance16F = kIntelBroadwell_GrGLRenderer == ctxInfo.renderer() ||
- ctxInfo.vendor() == kQualcomm_GrGLVendor;
+ formatWorkarounds->fDisableLuminance16F = ctxInfo.renderer() == GrGLRenderer::kIntelBroadwell ||
+ ctxInfo.vendor() == GrGLVendor::kQualcomm;
#ifdef SK_BUILD_FOR_MAC
// On a MacBookPro 11.5 running MacOS 10.13 with a Radeon M370X the TransferPixelsFrom test
// fails when transferring out from a GL_RG8 texture using GL_RG/GL_UNSIGNED_BYTE.
// The same error also occurs in MacOS 10.15 with a Radeon Pro 5300M.
formatWorkarounds->fDisallowDirectRG8ReadPixels =
- ctxInfo.renderer() == kAMDRadeonR9M3xx_GrGLRenderer ||
- ctxInfo.renderer() == kAMDRadeonPro5xxx_GrGLRenderer ||
- ctxInfo.renderer() == kAMDRadeonProVegaxx_GrGLRenderer;
+ ctxInfo.renderer() == GrGLRenderer::kAMDRadeonR9M3xx ||
+ ctxInfo.renderer() == GrGLRenderer::kAMDRadeonPro5xxx ||
+ ctxInfo.renderer() == GrGLRenderer::kAMDRadeonProVegaxx;
#endif
#ifdef SK_BUILD_FOR_ANDROID
@@ -4049,18 +4051,18 @@
// GL_EXT_texture_norm16 cause errors if they are created with glTexImage2D() with
// an unsized internal format. We wouldn't normally do that but Chrome can limit us
// artificially to ES2. (crbug.com/1003481)
- if (kNVIDIA_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kNVIDIA) {
formatWorkarounds->fDontDisableTexStorageOnAndroid = true;
}
#endif
// https://github.com/flutter/flutter/issues/38700
- if (kAndroidEmulator_GrGLDriver == ctxInfo.driver()) {
+ if (ctxInfo.driver() == GrGLDriver::kAndroidEmulator) {
shaderCaps->fNoDefaultPrecisionForExternalSamplers = true;
}
// http://skbug.com/9491: Nexus5 produces rendering artifacts when we use QCOM_tiled_rendering.
- if (kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno3xx) {
fTiledRenderingSupport = false;
}
// https://github.com/flutter/flutter/issues/47164
@@ -4082,12 +4084,12 @@
// We disable MSAA for all Intel GPUs. Before Gen9, performance was very bad. Even with Gen9,
// we've seen driver crashes in the wild. We don't have data on Gen11 yet.
// (crbug.com/527565, crbug.com/983926)
- if (kIntel_GrGLVendor == ctxInfo.vendor()) {
+ if (ctxInfo.vendor() == GrGLVendor::kIntel) {
fMSFBOType = kNone_MSFBOType;
}
// ANGLE doesn't support do-while loops
- if (kANGLE_GrGLDriver == ctxInfo.driver()) {
+ if (ctxInfo.driver() == GrGLDriver::kANGLE) {
shaderCaps->fCanUseDoLoops = false;
}
@@ -4100,7 +4102,7 @@
// Two Adreno 530 devices (LG G6 and OnePlus 3T) appear to have driver bugs that are corrupting
// SkSL::Program memory. To get better/different crash reports, disable node-pooling, so that
// program allocations aren't reused. (crbug.com/1147008, crbug.com/1164271)
- if (kAdreno530_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno530) {
shaderCaps->fUseNodePools = false;
}
@@ -4110,8 +4112,8 @@
}
// skbug.com/11935. Don't reorder on these GPUs in GL.
- if (kAdreno620_GrGLRenderer == ctxInfo.renderer() ||
- kAdreno640_GrGLRenderer == ctxInfo.renderer()) {
+ if (ctxInfo.renderer() == GrGLRenderer::kAdreno620 ||
+ ctxInfo.renderer() == GrGLRenderer::kAdreno640) {
fAvoidReorderingRenderTasks = true;
}
}
diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp
index f12b8d6..55b6ff2 100644
--- a/src/gpu/gl/GrGLContext.cpp
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -43,7 +43,7 @@
*/
#ifdef SK_BUILD_FOR_ANDROID
if (!options.fDisableDriverCorrectnessWorkarounds &&
- kAdreno3xx_GrGLRenderer == args.fDriverInfo.fRenderer) {
+ args.fDriverInfo.fRenderer == GrGLRenderer::kAdreno3xx) {
char androidAPIVersion[PROP_VALUE_MAX];
int strLength = __system_property_get("ro.build.version.sdk", androidAPIVersion);
if (strLength == 0 || atoi(androidAPIVersion) < 26) {
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 8453ea3..3dfab74 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2544,7 +2544,7 @@
// Workaround for the ARM KHR_blend_equation_advanced disable flags issue
// https://code.google.com/p/skia/issues/detail?id=3943
- if (kARM_GrGLVendor == this->ctxInfo().vendor() &&
+ if (this->ctxInfo().vendor() == GrGLVendor::kARM &&
GrBlendEquationIsAdvanced(fHWBlendState.fEquation)) {
SkASSERT(this->caps()->advancedBlendEquationSupport());
// Set to any basic blending equation.
diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp
index 58fa731..c48471f 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -136,27 +136,27 @@
static GrGLVendor get_vendor(const char* vendorString) {
SkASSERT(vendorString);
if (0 == strcmp(vendorString, "ARM")) {
- return kARM_GrGLVendor;
+ return GrGLVendor::kARM;
}
if (0 == strcmp(vendorString, "Google Inc.")) {
- return kGoogle_GrGLVendor;
+ return GrGLVendor::kGoogle;
}
if (0 == strcmp(vendorString, "Imagination Technologies")) {
- return kImagination_GrGLVendor;
+ return GrGLVendor::kImagination;
}
if (0 == strncmp(vendorString, "Intel ", 6) || 0 == strcmp(vendorString, "Intel")) {
- return kIntel_GrGLVendor;
+ return GrGLVendor::kIntel;
}
if (0 == strcmp(vendorString, "Qualcomm") || 0 == strcmp(vendorString, "freedreno")) {
- return kQualcomm_GrGLVendor;
+ return GrGLVendor::kQualcomm;
}
if (0 == strcmp(vendorString, "NVIDIA Corporation")) {
- return kNVIDIA_GrGLVendor;
+ return GrGLVendor::kNVIDIA;
}
if (0 == strcmp(vendorString, "ATI Technologies Inc.")) {
- return kATI_GrGLVendor;
+ return GrGLVendor::kATI;
}
- return kOther_GrGLVendor;
+ return GrGLVendor::kOther;
}
static bool is_renderer_angle(const char* rendererString) {
@@ -172,13 +172,13 @@
if (0 == strncmp(rendererString, kTegraStr, SK_ARRAY_COUNT(kTegraStr) - 1)) {
// Tegra strings are not very descriptive. We distinguish between the modern and legacy
// architectures by the presence of NV_path_rendering.
- return extensions.has("GL_NV_path_rendering") ? kTegra_GrGLRenderer
- : kTegra_PreK1_GrGLRenderer;
+ return extensions.has("GL_NV_path_rendering") ? GrGLRenderer::kTegra
+ : GrGLRenderer::kTegra_PreK1;
}
int lastDigit;
int n = sscanf(rendererString, "PowerVR SGX 54%d", &lastDigit);
if (1 == n && lastDigit >= 0 && lastDigit <= 9) {
- return kPowerVR54x_GrGLRenderer;
+ return GrGLRenderer::kPowerVR54x;
}
// certain iOS devices also use PowerVR54x GPUs
static const char kAppleA4Str[] = "Apple A4";
@@ -187,7 +187,7 @@
if (0 == strncmp(rendererString, kAppleA4Str, SK_ARRAY_COUNT(kAppleA4Str) - 1) ||
0 == strncmp(rendererString, kAppleA5Str, SK_ARRAY_COUNT(kAppleA5Str) - 1) ||
0 == strncmp(rendererString, kAppleA6Str, SK_ARRAY_COUNT(kAppleA6Str) - 1)) {
- return kPowerVR54x_GrGLRenderer;
+ return GrGLRenderer::kPowerVR54x;
}
static const char kPowerVRRogueStr[] = "PowerVR Rogue";
static const char kAppleA7Str[] = "Apple A7";
@@ -195,7 +195,7 @@
if (0 == strncmp(rendererString, kPowerVRRogueStr, SK_ARRAY_COUNT(kPowerVRRogueStr) - 1) ||
0 == strncmp(rendererString, kAppleA7Str, SK_ARRAY_COUNT(kAppleA7Str) - 1) ||
0 == strncmp(rendererString, kAppleA8Str, SK_ARRAY_COUNT(kAppleA8Str) - 1)) {
- return kPowerVRRogue_GrGLRenderer;
+ return GrGLRenderer::kPowerVRRogue;
}
int adrenoNumber;
n = sscanf(rendererString, "Adreno (TM) %d", &adrenoNumber);
@@ -206,45 +206,45 @@
if (1 == n) {
if (adrenoNumber >= 300) {
if (adrenoNumber < 400) {
- return kAdreno3xx_GrGLRenderer;
+ return GrGLRenderer::kAdreno3xx;
}
if (adrenoNumber < 500) {
- return adrenoNumber >= 430 ? kAdreno430_GrGLRenderer
- : kAdreno4xx_other_GrGLRenderer;
+ return adrenoNumber >= 430 ? GrGLRenderer::kAdreno430
+ : GrGLRenderer::kAdreno4xx_other;
}
if (adrenoNumber < 600) {
- return adrenoNumber == 530 ? kAdreno530_GrGLRenderer
- : kAdreno5xx_other_GrGLRenderer;
+ return adrenoNumber == 530 ? GrGLRenderer::kAdreno530
+ : GrGLRenderer::kAdreno5xx_other;
}
if (adrenoNumber == 615) {
- return kAdreno615_GrGLRenderer;
+ return GrGLRenderer::kAdreno615;
}
if (adrenoNumber == 620) {
- return kAdreno620_GrGLRenderer;
+ return GrGLRenderer::kAdreno620;
}
if (adrenoNumber == 630) {
- return kAdreno630_GrGLRenderer;
+ return GrGLRenderer::kAdreno630;
}
if (adrenoNumber == 640) {
- return kAdreno640_GrGLRenderer;
+ return GrGLRenderer::kAdreno640;
}
}
}
if (0 == strcmp("Google SwiftShader", rendererString)) {
- return kGoogleSwiftShader_GrGLRenderer;
+ return GrGLRenderer::kGoogleSwiftShader;
}
if (const char* intelString = strstr(rendererString, "Intel")) {
// These generic strings seem to always come from Haswell: Iris 5100 or Iris Pro 5200
if (0 == strcmp("Intel Iris OpenGL Engine", intelString) ||
0 == strcmp("Intel Iris Pro OpenGL Engine", intelString)) {
- return kIntelHaswell_GrGLRenderer;
+ return GrGLRenderer::kIntelHaswell;
}
if (strstr(intelString, "Sandybridge")) {
- return kIntelSandyBridge_GrGLRenderer;
+ return GrGLRenderer::kIntelSandyBridge;
}
if (strstr(intelString, "Bay Trail")) {
- return kIntelValleyView_GrGLRenderer;
+ return GrGLRenderer::kIntelValleyView;
}
// There are many possible intervening strings here:
// 'Intel(R)' is a common prefix
@@ -259,43 +259,43 @@
if (sscanf(intelGfxString, "Graphics %d", &intelNumber) ||
sscanf(intelGfxString, "Graphics P%d", &intelNumber)) {
if (intelNumber == 2000 || intelNumber == 3000) {
- return kIntelSandyBridge_GrGLRenderer;
+ return GrGLRenderer::kIntelSandyBridge;
}
if (intelNumber == 2500 || intelNumber == 4000) {
- return kIntelIvyBridge_GrGLRenderer;
+ return GrGLRenderer::kIntelIvyBridge;
}
if (intelNumber >= 4200 && intelNumber <= 5200) {
- return kIntelHaswell_GrGLRenderer;
+ return GrGLRenderer::kIntelHaswell;
}
if (intelNumber >= 400 && intelNumber <= 405) {
- return kIntelCherryView_GrGLRenderer;
+ return GrGLRenderer::kIntelCherryView;
}
if (intelNumber >= 5300 && intelNumber <= 6300) {
- return kIntelBroadwell_GrGLRenderer;
+ return GrGLRenderer::kIntelBroadwell;
}
if (intelNumber >= 500 && intelNumber <= 505) {
- return kIntelApolloLake_GrGLRenderer;
+ return GrGLRenderer::kIntelApolloLake;
}
if (intelNumber >= 510 && intelNumber <= 580) {
- return kIntelSkyLake_GrGLRenderer;
+ return GrGLRenderer::kIntelSkyLake;
}
if (intelNumber >= 600 && intelNumber <= 605) {
- return kIntelGeminiLake_GrGLRenderer;
+ return GrGLRenderer::kIntelGeminiLake;
}
// 610 and 630 are reused from KabyLake to CoffeeLake. The CoffeeLake variants
// are "UHD Graphics", while the KabyLake ones are "HD Graphics"
if (intelNumber == 610 || intelNumber == 630) {
- return strstr(intelString, "UHD") ? kIntelCoffeeLake_GrGLRenderer
- : kIntelKabyLake_GrGLRenderer;
+ return strstr(intelString, "UHD") ? GrGLRenderer::kIntelCoffeeLake
+ : GrGLRenderer::kIntelKabyLake;
}
if (intelNumber >= 610 && intelNumber <= 650) {
- return kIntelKabyLake_GrGLRenderer;
+ return GrGLRenderer::kIntelKabyLake;
}
if (intelNumber == 655) {
- return kIntelCoffeeLake_GrGLRenderer;
+ return GrGLRenderer::kIntelCoffeeLake;
}
if (intelNumber >= 910 && intelNumber <= 950) {
- return kIntelIceLake_GrGLRenderer;
+ return GrGLRenderer::kIntelIceLake;
}
}
}
@@ -315,50 +315,50 @@
int amdModel;
n = sscanf(amdString, "R9 M3%c%c", &amd0, &amd1);
if (2 == n && isdigit(amd0) && isdigit(amd1)) {
- return kAMDRadeonR9M3xx_GrGLRenderer;
+ return GrGLRenderer::kAMDRadeonR9M3xx;
}
n = sscanf(amdString, "R9 M4%c%c", &amd0, &amd1);
if (2 == n && isdigit(amd0) && isdigit(amd1)) {
- return kAMDRadeonR9M4xx_GrGLRenderer;
+ return GrGLRenderer::kAMDRadeonR9M4xx;
}
n = sscanf(amdString, "HD 7%c%c%c Series", &amd0, &amd1, &amd2);
if (3 == n && isdigit(amd0) && isdigit(amd1) && isdigit(amd2)) {
- return kAMDRadeonHD7xxx_GrGLRenderer;
+ return GrGLRenderer::kAMDRadeonHD7xxx;
}
n = sscanf(amdString, "Pro 5%c%c%c", &amd0, &amd1, &amd2);
if (3 == n && isdigit(amd0) && isdigit(amd1) && isdigit(amd2)) {
- return kAMDRadeonPro5xxx_GrGLRenderer;
+ return GrGLRenderer::kAMDRadeonPro5xxx;
}
n = sscanf(amdString, "Pro Vega %i", &amdModel);
if (1 == n) {
- return kAMDRadeonProVegaxx_GrGLRenderer;
+ return GrGLRenderer::kAMDRadeonProVegaxx;
}
}
if (strstr(rendererString, "llvmpipe")) {
- return kGalliumLLVM_GrGLRenderer;
+ return GrGLRenderer::kGalliumLLVM;
}
static const char kMaliGStr[] = "Mali-G";
if (0 == strncmp(rendererString, kMaliGStr, SK_ARRAY_COUNT(kMaliGStr) - 1)) {
- return kMaliG_GrGLRenderer;
+ return GrGLRenderer::kMaliG;
}
static const char kMaliTStr[] = "Mali-T";
if (0 == strncmp(rendererString, kMaliTStr, SK_ARRAY_COUNT(kMaliTStr) - 1)) {
- return kMaliT_GrGLRenderer;
+ return GrGLRenderer::kMaliT;
}
int mali400Num;
if (1 == sscanf(rendererString, "Mali-%d", &mali400Num) && mali400Num >= 400 &&
mali400Num < 500) {
- return kMali4xx_GrGLRenderer;
+ return GrGLRenderer::kMali4xx;
}
if (is_renderer_angle(rendererString)) {
- return kANGLE_GrGLRenderer;
+ return GrGLRenderer::kANGLE;
}
- return kOther_GrGLRenderer;
+ return GrGLRenderer::kOther;
}
std::tuple<GrGLANGLEBackend, GrGLANGLEVendor, GrGLANGLERenderer>
@@ -455,10 +455,10 @@
if (0 == strcmp(renderer, kChromium) ||
(3 == sscanf(version, "OpenGL ES %d.%d %8s", &major, &minor, suffix) &&
0 == strcmp(kChromium, suffix))) {
- info.fDriver = kChromium_GrGLDriver;
+ info.fDriver = GrGLDriver::kChromium;
} else if (GR_IS_GR_GL(interface->fStandard)) {
- if (info.fVendor == kNVIDIA_GrGLVendor) {
- info.fDriver = kNVIDIA_GrGLDriver;
+ if (info.fVendor == GrGLVendor::kNVIDIA) {
+ info.fDriver = GrGLDriver::kNVIDIA;
int n = sscanf(version,
"%d.%d.%d NVIDIA %d.%d",
&major,
@@ -481,13 +481,13 @@
&driverMinor);
}
if (n == 4) {
- info.fDriver = kMesa_GrGLDriver;
+ info.fDriver = GrGLDriver::kMesa;
info.fDriverVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor, 0);
}
}
} else if (GR_IS_GR_GL_ES(interface->fStandard)) {
- if (info.fVendor == kNVIDIA_GrGLVendor) {
- info.fDriver = kNVIDIA_GrGLDriver;
+ if (info.fVendor == GrGLVendor::kNVIDIA) {
+ info.fDriver = GrGLDriver::kNVIDIA;
int n = sscanf(version,
"OpenGL ES %d.%d NVIDIA %d.%d",
&major,
@@ -506,10 +506,10 @@
&driverMajor,
&driverMinor);
if (n == 4) {
- info.fDriver = kMesa_GrGLDriver;
+ info.fDriver = GrGLDriver::kMesa;
info.fDriverVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor, 0);
} else if (0 == strncmp("ANGLE", renderer, 5)) {
- info.fDriver = kANGLE_GrGLDriver;
+ info.fDriver = GrGLDriver::kANGLE;
n = sscanf(version,
"OpenGL ES %d.%d (ANGLE %d.%d",
&major,
@@ -523,10 +523,10 @@
}
}
- if (info.fDriver == kUnknown_GrGLDriver) {
- if (info.fVendor == kGoogle_GrGLVendor) {
+ if (info.fDriver == GrGLDriver::kUnknown) {
+ if (info.fVendor == GrGLVendor::kGoogle) {
// Swiftshader is the only Google vendor at the moment
- info.fDriver = kSwiftShader_GrGLDriver;
+ info.fDriver = GrGLDriver::kSwiftShader;
// Swiftshader has a strange version string: w.x.y.z Going to arbitrarily ignore
// y and assume w,x and z are major, minor, point.
@@ -541,9 +541,9 @@
if (n == 5) {
info.fDriverVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor, driverPoint);
}
- } else if (info.fVendor == kIntel_GrGLVendor) {
+ } else if (info.fVendor == GrGLVendor::kIntel) {
// We presume we're on the Intel driver since it hasn't identified itself as Mesa.
- info.fDriver = kIntel_GrGLDriver;
+ info.fDriver = GrGLDriver::kIntel;
// This is how the macOS version strings are structured. This might be different on
// different
@@ -558,14 +558,14 @@
if (n == 5) {
info.fDriverVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor, driverPoint);
}
- } else if (info.fVendor == kQualcomm_GrGLVendor) {
- info.fDriver = kQualcomm_GrGLDriver;
+ } else if (info.fVendor == GrGLVendor::kQualcomm) {
+ info.fDriver = GrGLDriver::kQualcomm;
int n = sscanf(
version, "OpenGL ES %d.%d V@%d.%d", &major, &minor, &driverMajor, &driverMinor);
if (n == 4) {
info.fDriverVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor, 0);
}
- } else if (info.fVendor == kImagination_GrGLVendor) {
+ } else if (info.fVendor == GrGLVendor::kImagination) {
int revision;
int n = sscanf(version,
"OpenGL ES %d.%d build %d.%d@%d",
@@ -582,7 +582,7 @@
} else {
static constexpr char kEmulatorPrefix[] = "Android Emulator OpenGL ES Translator";
if (0 == strncmp(kEmulatorPrefix, renderer, strlen(kEmulatorPrefix))) {
- info.fDriver = kAndroidEmulator_GrGLDriver;
+ info.fDriver = GrGLDriver::kAndroidEmulator;
}
}
}
diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h
index 88987dd..71d2a69 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -74,84 +74,88 @@
/**
* The Vendor and Renderer enum values are lazily updated as required.
*/
-enum GrGLVendor {
- kARM_GrGLVendor,
- kGoogle_GrGLVendor,
- kImagination_GrGLVendor,
- kIntel_GrGLVendor,
- kQualcomm_GrGLVendor,
- kNVIDIA_GrGLVendor,
- kATI_GrGLVendor,
+enum class GrGLVendor {
+ kARM,
+ kGoogle,
+ kImagination,
+ kIntel,
+ kQualcomm,
+ kNVIDIA,
+ kATI,
- kOther_GrGLVendor
+ kOther
};
-enum GrGLRenderer {
- kTegra_PreK1_GrGLRenderer, // Legacy Tegra architecture (pre-K1).
- kTegra_GrGLRenderer, // Tegra with the same architecture as NVIDIA desktop GPUs (K1+).
- kPowerVR54x_GrGLRenderer,
- kPowerVRRogue_GrGLRenderer,
- kAdreno3xx_GrGLRenderer,
- kAdreno430_GrGLRenderer,
- kAdreno4xx_other_GrGLRenderer,
- kAdreno530_GrGLRenderer,
- kAdreno5xx_other_GrGLRenderer,
- kAdreno615_GrGLRenderer, // Pixel3a
- kAdreno620_GrGLRenderer, // Pixel5
- kAdreno630_GrGLRenderer, // Pixel3
- kAdreno640_GrGLRenderer, // Pixel4
- kGoogleSwiftShader_GrGLRenderer,
+enum class GrGLRenderer {
+ kTegra_PreK1, // Legacy Tegra architecture (pre-K1).
+ kTegra, // Tegra with the same architecture as NVIDIA desktop GPUs (K1+).
+
+ kPowerVR54x,
+ kPowerVRRogue,
+
+ kAdreno3xx,
+ kAdreno430,
+ kAdreno4xx_other,
+ kAdreno530,
+ kAdreno5xx_other,
+ kAdreno615, // Pixel3a
+ kAdreno620, // Pixel5
+ kAdreno630, // Pixel3
+ kAdreno640, // Pixel4
+
+ kGoogleSwiftShader,
/** Intel GPU families, ordered by generation **/
// 6th gen
- kIntelSandyBridge_GrGLRenderer,
+ kIntelSandyBridge,
// 7th gen
- kIntelIvyBridge_GrGLRenderer,
- kIntelValleyView_GrGLRenderer, // aka BayTrail
- kIntelHaswell_GrGLRenderer,
+ kIntelIvyBridge,
+ kIntelValleyView, // aka BayTrail
+ kIntelHaswell,
// 8th gen
- kIntelCherryView_GrGLRenderer, // aka Braswell
- kIntelBroadwell_GrGLRenderer,
+ kIntelCherryView, // aka Braswell
+ kIntelBroadwell,
// 9th gen
- kIntelApolloLake_GrGLRenderer,
- kIntelSkyLake_GrGLRenderer,
- kIntelGeminiLake_GrGLRenderer,
- kIntelKabyLake_GrGLRenderer,
- kIntelCoffeeLake_GrGLRenderer,
+ kIntelApolloLake,
+ kIntelSkyLake,
+ kIntelGeminiLake,
+ kIntelKabyLake,
+ kIntelCoffeeLake,
// 11th gen
- kIntelIceLake_GrGLRenderer,
+ kIntelIceLake,
- kGalliumLLVM_GrGLRenderer,
- kMali4xx_GrGLRenderer,
+ kGalliumLLVM,
+
+ kMali4xx,
/** G-3x, G-5x, or G-7x */
- kMaliG_GrGLRenderer,
+ kMaliG,
/** T-6xx, T-7xx, or T-8xx */
- kMaliT_GrGLRenderer,
- kANGLE_GrGLRenderer,
+ kMaliT,
+ kANGLE,
- kAMDRadeonHD7xxx_GrGLRenderer, // AMD Radeon HD 7000 Series
- kAMDRadeonR9M3xx_GrGLRenderer, // AMD Radeon R9 M300 Series
- kAMDRadeonR9M4xx_GrGLRenderer, // AMD Radeon R9 M400 Series
- kAMDRadeonPro5xxx_GrGLRenderer, // AMD Radeon Pro 5000 Series
- kAMDRadeonProVegaxx_GrGLRenderer, // AMD Radeon Pro Vega
+ kAMDRadeonHD7xxx, // AMD Radeon HD 7000 Series
+ kAMDRadeonR9M3xx, // AMD Radeon R9 M300 Series
+ kAMDRadeonR9M4xx, // AMD Radeon R9 M400 Series
+ kAMDRadeonPro5xxx, // AMD Radeon Pro 5000 Series
+ kAMDRadeonProVegaxx, // AMD Radeon Pro Vega
- kOther_GrGLRenderer
+ kOther
};
-enum GrGLDriver {
- kMesa_GrGLDriver,
- kChromium_GrGLDriver,
- kNVIDIA_GrGLDriver,
- kIntel_GrGLDriver,
- kANGLE_GrGLDriver,
- kSwiftShader_GrGLDriver,
- kQualcomm_GrGLDriver,
- kAndroidEmulator_GrGLDriver,
- kUnknown_GrGLDriver
+enum class GrGLDriver {
+ kMesa,
+ kChromium,
+ kNVIDIA,
+ kIntel,
+ kANGLE,
+ kSwiftShader,
+ kQualcomm,
+ kAndroidEmulator,
+ kUnknown
};
enum class GrGLANGLEBackend {
@@ -235,9 +239,9 @@
GrGLStandard fStandard = kNone_GrGLStandard;
GrGLVersion fVersion = GR_GL_INVALID_VER;
GrGLSLVersion fGLSLVersion = GR_GLSL_INVALID_VER;
- GrGLVendor fVendor = kOther_GrGLVendor;
- GrGLRenderer fRenderer = kOther_GrGLRenderer;
- GrGLDriver fDriver = kUnknown_GrGLDriver;
+ GrGLVendor fVendor = GrGLVendor::kOther;
+ GrGLRenderer fRenderer = GrGLRenderer::kOther;
+ GrGLDriver fDriver = GrGLDriver::kUnknown;
GrGLDriverVersion fDriverVersion = GR_GL_DRIVER_UNKNOWN_VER;
GrGLANGLEBackend fANGLEBackend = GrGLANGLEBackend::kUnknown;
GrGLANGLEVendor fANGLEVendor = GrGLANGLEVendor::kUnknown;
diff --git a/tests/ProgramsTest.cpp b/tests/ProgramsTest.cpp
index 98cf7d9..68dbd8e 100644
--- a/tests/ProgramsTest.cpp
+++ b/tests/ProgramsTest.cpp
@@ -342,9 +342,9 @@
// Android devices. We have passes on ARM devices with the default number of stages.
// TODO When we run ES 3.00 GLSL in more places, test again
#ifdef SK_BUILD_FOR_ANDROID
- if (kARM_GrGLVendor != gpu->ctxInfo().vendor()) {
- maxStages = 1;
- }
+ if (gpu->ctxInfo().vendor() != GrGLVendor::kARM) {
+ maxStages = 1;
+ }
#endif
// On iOS we can exceed the maximum number of varyings. http://skbug.com/6627.
#ifdef SK_BUILD_FOR_IOS
@@ -377,7 +377,7 @@
GrGLGpu* gpu = static_cast<GrGLGpu*>(ctxInfo.directContext()->priv().getGpu());
// Tecno Spark 3 Pro with Power VR Rogue GE8300 will fail shader compiles with
// no message if the shader is particularly long.
- if (gpu->ctxInfo().vendor() == kImagination_GrGLVendor) {
+ if (gpu->ctxInfo().vendor() == GrGLVendor::kImagination) {
maxTreeLevels = 3;
}
#endif