Move the initial GrProgramDesc keyLength into the header

This sets up for moving GrProgramDesc creation to GrCaps. I.e., we will have a virtual "GrProgramDesc GrCaps::makeDesc(const GrRenderTarget*, const GrProgramInfo&)" call.

Bug: skia:9455
Change-Id: I82053297383af9d405e6b485bf8287f10fa15967
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256696
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index 1821790..c2e1cca 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -239,6 +239,7 @@
     if (header->fColorFragmentProcessorCnt != programInfo.pipeline().numColorFragmentProcessors() ||
         header->fCoverageFragmentProcessorCnt !=
                                          programInfo.pipeline().numCoverageFragmentProcessors()) {
+        desc->key().reset();
         return false;
     }
     // If we knew the shader won't depend on origin, we could skip this (and use the same program
@@ -252,5 +253,13 @@
     // The base descriptor only stores whether or not the primitiveType is kPoints. Backend-
     // specific versions (e.g., Vulkan) require more detail
     header->fHasPointSize = (programInfo.primitiveType() == GrPrimitiveType::kPoints);
+
+    header->fInitialKeyLength = desc->keyLength();
+    // Fail if the initial key length won't fit in 27 bits.
+    if (header->fInitialKeyLength != desc->keyLength()) {
+        desc->key().reset();
+        return false;
+    }
+
     return true;
 }