Add detection for AMD Radeon Pro 5000-class GPUs.

This CL also cleans up detection for existing GPUs slightly, by
verifying that GPU model numbers are composed of digits instead of
allowing arbitrary characters.

Bug: skia:10256
Change-Id: I1416a24ac34edbe56e317e75f416c80d001d4ba4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291046
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp
index 28bdbd6..04ce205 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -480,33 +480,38 @@
         static constexpr char kRadeonStr[] = "Radeon ";
         if (const char* amdString = strstr(rendererString, kRadeonStr)) {
             amdString += strlen(kRadeonStr);
-            char amdGeneration, amdTier, amdRevision;
             // Sometimes there is a (TM) and sometimes not.
             static constexpr char kTMStr[] = "(TM) ";
             if (!strncmp(amdString, kTMStr, strlen(kTMStr))) {
                 amdString += strlen(kTMStr);
             }
-            n = sscanf(amdString, "R9 M%c%c%c", &amdGeneration, &amdTier, &amdRevision);
-            if (3 == n) {
-                if ('3' == amdGeneration) {
-                    return kAMDRadeonR9M3xx_GrGLRenderer;
-                } else if ('4' == amdGeneration) {
-                    return kAMDRadeonR9M4xx_GrGLRenderer;
-                }
-            }
 
             char amd0, amd1, amd2;
+            int amdModel;
+            n = sscanf(amdString, "R9 M3%c%c", &amd0, &amd1);
+            if (2 == n && isdigit(amd0) && isdigit(amd1)) {
+                return kAMDRadeonR9M3xx_GrGLRenderer;
+            }
+
+            n = sscanf(amdString, "R9 M4%c%c", &amd0, &amd1);
+            if (2 == n && isdigit(amd0) && isdigit(amd1)) {
+                return kAMDRadeonR9M4xx_GrGLRenderer;
+            }
+
             n = sscanf(amdString, "HD 7%c%c%c Series", &amd0, &amd1, &amd2);
-            if (3 == n) {
+            if (3 == n && isdigit(amd0) && isdigit(amd1) && isdigit(amd2)) {
                 return kAMDRadeonHD7xxx_GrGLRenderer;
             }
 
-            int amdVegaModel=0;
-            n = sscanf(amdString, "Pro Vega %i", &amdVegaModel);
+            n = sscanf(amdString, "Pro 5%c%c%c", &amd0, &amd1, &amd2);
+            if (3 == n && isdigit(amd0) && isdigit(amd1) && isdigit(amd2)) {
+                return kAMDRadeonPro5xxx_GrGLRenderer;
+            }
+
+            n = sscanf(amdString, "Pro Vega %i", &amdModel);
             if (1 == n) {
                 return kAMDRadeonProVegaxx_GrGLRenderer;
             }
-
         }
 
         if (strstr(rendererString, "llvmpipe")) {
diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h
index e168275..bbe9fb3 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -130,6 +130,7 @@
     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
 
     kOther_GrGLRenderer