Vulkan: Add framework for internal shaders.

Vulkan intenal shaders are stored in a ShaderLibrary, and this is
owned by the RendererVk. This way the shaders are reused between all
the different Contexts. They are initialized lazily to keep init time
low. They also have an associated Serial (called a ProgramSerial) so
they can be identified in a PipelineDesc (used by the Pipeline cache).

We use a python script to build and invoke the glslang validator, that
also produces SPIR-V binary code snippets. These snippets are gathered
into an auto-generated file that is exposed via an auto-generated
header file. The InternalShaderID enum class gives access to the
internal shaders that are shared through the Vulkan back-end.

This also adds simple clear shaders to be used in masked color clears.
The patch doesn't add any functionality but it is split off from the
color clear functionality to keep the code size down.

Bug: angleproject:2339
Bug: angleproject:2455
Change-Id: Ie83043eda217c9f013817b198c92a3b7ba0878b4
Reviewed-on: https://chromium-review.googlesource.com/1031372
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/scripts/run_code_generation.py b/scripts/run_code_generation.py
index fe95d2c..66a5e05 100755
--- a/scripts/run_code_generation.py
+++ b/scripts/run_code_generation.py
@@ -9,8 +9,25 @@
 
 import os, subprocess, sys
 
-# TODO(jmadill): Might be nice to have a standard way for scripts to return
-# their inputs and outputs rather than listing them here.
+root_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
+
+# auto_script is a standard way for scripts to return their inputs and outputs.
+
+def grab_from_script(script, param):
+    res = subprocess.check_output(['python', script, param]).strip()
+    return [os.path.abspath(os.path.join(os.path.dirname(script), name)) for name in res.split(',')]
+
+def auto_script(script):
+    # Set the CWD to the script directory.
+    os.chdir(os.path.dirname(os.path.abspath(script)))
+    base_script = os.path.basename(script)
+    return {
+        'script': script,
+        'inputs': grab_from_script(base_script, 'inputs'),
+        'outputs': grab_from_script(base_script, 'outputs'),
+    }
+
+# TODO(jmadill): Convert everyting to auto-script.
 generators = {
     'ANGLE format': {
         'inputs': [
@@ -159,6 +176,8 @@
         ],
         'script': 'src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py',
     },
+    'Vulkan internal shader programs':
+        auto_script('src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py'),
     'Emulated HLSL functions': {
         'inputs': [
             'src/compiler/translator/emulated_builtin_function_data_hlsl.json'
@@ -185,7 +204,6 @@
     },
 }
 
-root_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
 any_dirty = False
 
 for name, info in sorted(generators.iteritems()):