Vulkan: Cache pipelines with Shader Programs.

This allows for a few nice things. First and foremost it reduces the
size of the PipelineDesc, which is now 232 bytes. It also allows us
to completely forego pipeline caches for compute shaders.

We also allow sharing vertex and fragment shaders among multiple
programs for internal shaders. This is good for memory savings. To
allow this we keep the shaders as ref counted objects.

Bug: angleproject:2522
Change-Id: I2322be5061979d9669a0b25c152359561eeb80ee
Reviewed-on: https://chromium-review.googlesource.com/c/1344449
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index 771bd7e..139abff 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -1009,20 +1009,14 @@
 angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
                                            VkColorComponentFlags colorMaskFlags)
 {
-    RendererVk *renderer             = contextVk->getRenderer();
-    vk::ShaderLibrary *shaderLibrary = renderer->getShaderLibrary();
+    RendererVk *renderer = contextVk->getRenderer();
+
+    vk::ShaderProgramHelper *fullScreenClear = nullptr;
+    ANGLE_TRY(renderer->getFullScreenClearShaderProgram(contextVk, &fullScreenClear));
 
     // Trigger a new command node to ensure overlapping writes happen sequentially.
     mFramebuffer.finishCurrentCommands(renderer);
 
-    const vk::ShaderAndSerial *fullScreenQuad = nullptr;
-    ANGLE_TRY(shaderLibrary->getShader(contextVk, vk::InternalShaderID::FullScreenQuad_vert,
-                                       &fullScreenQuad));
-
-    const vk::ShaderAndSerial *pushConstantColor = nullptr;
-    ANGLE_TRY(shaderLibrary->getShader(contextVk, vk::InternalShaderID::PushConstantColor_frag,
-                                       &pushConstantColor));
-
     // The shader uses a simple pipeline layout with a push constant range.
     vk::PipelineLayoutDesc pipelineLayoutDesc;
     pipelineLayoutDesc.updatePushConstantRange(gl::ShaderType::Fragment, 0,
@@ -1047,12 +1041,10 @@
     pipelineDesc.initDefaults();
     pipelineDesc.updateColorWriteMask(colorMaskFlags, getEmulatedAlphaAttachmentMask());
     pipelineDesc.updateRenderPassDesc(getRenderPassDesc());
-    pipelineDesc.updateShaders(fullScreenQuad->getSerial(), pushConstantColor->getSerial());
 
     vk::PipelineAndSerial *pipeline = nullptr;
-    ANGLE_TRY(renderer->getPipeline(contextVk, *fullScreenQuad, *pushConstantColor,
-                                    pipelineLayout.get(), pipelineDesc, gl::AttributesMask(),
-                                    &pipeline));
+    ANGLE_TRY(fullScreenClear->getGraphicsPipeline(contextVk, pipelineLayout.get(), pipelineDesc,
+                                                   gl::AttributesMask(), &pipeline));
     pipeline->updateSerial(renderer->getCurrentQueueSerial());
 
     vk::CommandBuffer *writeCommands = nullptr;