Vulkan: Fill in glslang resources with our caps

This allows us to enable these tests:
dEQP-GLES2.functional.shaders.fragdata.valid_static_index

Bug: angleproject:2594
Change-Id: I2c9a10063500d96d1c4bfb761f4b45590114b7ef
Reviewed-on: https://chromium-review.googlesource.com/1100957
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Luc Ferron <lucferron@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp b/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp
index bdabd3e..ce6b39d 100644
--- a/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp
+++ b/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp
@@ -20,6 +20,7 @@
 
 #include "common/string_utils.h"
 #include "common/utilities.h"
+#include "libANGLE/Caps.h"
 #include "libANGLE/ProgramLinkedResources.h"
 
 namespace rx
@@ -33,6 +34,39 @@
 constexpr char kMarkerEnd[]            = " @@";
 constexpr char kUniformQualifier[]     = "uniform";
 
+void GetBuiltInResourcesFromCaps(const gl::Caps &caps, TBuiltInResource *outBuiltInResources)
+{
+    outBuiltInResources->maxDrawBuffers                   = caps.maxDrawBuffers;
+    outBuiltInResources->maxAtomicCounterBindings         = caps.maxAtomicCounterBufferBindings;
+    outBuiltInResources->maxAtomicCounterBufferSize       = caps.maxAtomicCounterBufferSize;
+    outBuiltInResources->maxClipPlanes                    = caps.maxClipPlanes;
+    outBuiltInResources->maxCombinedAtomicCounterBuffers  = caps.maxCombinedAtomicCounterBuffers;
+    outBuiltInResources->maxCombinedAtomicCounters        = caps.maxCombinedAtomicCounters;
+    outBuiltInResources->maxCombinedImageUniforms         = caps.maxCombinedImageUniforms;
+    outBuiltInResources->maxCombinedTextureImageUnits     = caps.maxCombinedTextureImageUnits;
+    outBuiltInResources->maxCombinedShaderOutputResources = caps.maxCombinedShaderOutputResources;
+    outBuiltInResources->maxComputeWorkGroupCountX        = caps.maxComputeWorkGroupCount[0];
+    outBuiltInResources->maxComputeWorkGroupCountY        = caps.maxComputeWorkGroupCount[1];
+    outBuiltInResources->maxComputeWorkGroupCountZ        = caps.maxComputeWorkGroupCount[2];
+    outBuiltInResources->maxComputeWorkGroupSizeX         = caps.maxComputeWorkGroupSize[0];
+    outBuiltInResources->maxComputeWorkGroupSizeY         = caps.maxComputeWorkGroupSize[1];
+    outBuiltInResources->maxComputeWorkGroupSizeZ         = caps.maxComputeWorkGroupSize[2];
+    outBuiltInResources->minProgramTexelOffset            = caps.minProgramTexelOffset;
+    outBuiltInResources->maxFragmentUniformVectors        = caps.maxFragmentUniformVectors;
+    outBuiltInResources->maxFragmentInputComponents       = caps.maxFragmentInputComponents;
+    outBuiltInResources->maxGeometryInputComponents       = caps.maxGeometryInputComponents;
+    outBuiltInResources->maxGeometryOutputComponents      = caps.maxGeometryOutputComponents;
+    outBuiltInResources->maxGeometryOutputVertices        = caps.maxGeometryOutputVertices;
+    outBuiltInResources->maxGeometryTotalOutputComponents = caps.maxGeometryTotalOutputComponents;
+    outBuiltInResources->maxLights                        = caps.maxLights;
+    outBuiltInResources->maxProgramTexelOffset            = caps.maxProgramTexelOffset;
+    outBuiltInResources->maxVaryingComponents             = caps.maxVaryingComponents;
+    outBuiltInResources->maxVaryingVectors                = caps.maxVaryingVectors;
+    outBuiltInResources->maxVertexAttribs                 = caps.maxVertexAttributes;
+    outBuiltInResources->maxVertexOutputComponents        = caps.maxVertexOutputComponents;
+    outBuiltInResources->maxVertexUniformVectors          = caps.maxVertexUniformVectors;
+}
+
 void InsertLayoutSpecifierString(std::string *shaderString,
                                  const std::string &variableName,
                                  const std::string &layoutString)
@@ -108,6 +142,7 @@
 gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext,
                                            const gl::ProgramState &programState,
                                            const gl::ProgramLinkedResources &resources,
+                                           const gl::Caps &glCaps,
                                            std::vector<uint32_t> *vertexCodeOut,
                                            std::vector<uint32_t> *fragmentCodeOut)
 {
@@ -242,8 +277,12 @@
     glslang::TShader vertexShader(EShLangVertex);
     vertexShader.setStringsWithLengths(&strings[0], &lengths[0], 1);
     vertexShader.setEntryPoint("main");
-    bool vertexResult = vertexShader.parse(&glslang::DefaultTBuiltInResource, 450, ECoreProfile,
-                                           false, false, messages);
+
+    TBuiltInResource builtInResources(glslang::DefaultTBuiltInResource);
+    GetBuiltInResourcesFromCaps(glCaps, &builtInResources);
+
+    bool vertexResult =
+        vertexShader.parse(&builtInResources, 450, ECoreProfile, false, false, messages);
     if (!vertexResult)
     {
         return gl::InternalError() << "Internal error parsing Vulkan vertex shader:\n"
@@ -254,8 +293,8 @@
     glslang::TShader fragmentShader(EShLangFragment);
     fragmentShader.setStringsWithLengths(&strings[1], &lengths[1], 1);
     fragmentShader.setEntryPoint("main");
-    bool fragmentResult = fragmentShader.parse(&glslang::DefaultTBuiltInResource, 450, ECoreProfile,
-                                               false, false, messages);
+    bool fragmentResult =
+        fragmentShader.parse(&builtInResources, 450, ECoreProfile, false, false, messages);
     if (!fragmentResult)
     {
         return gl::InternalError() << "Internal error parsing Vulkan fragment shader:\n"
diff --git a/src/libANGLE/renderer/vulkan/GlslangWrapper.h b/src/libANGLE/renderer/vulkan/GlslangWrapper.h
index 220e1d3..0132680 100644
--- a/src/libANGLE/renderer/vulkan/GlslangWrapper.h
+++ b/src/libANGLE/renderer/vulkan/GlslangWrapper.h
@@ -26,6 +26,7 @@
     gl::LinkResult linkProgram(const gl::Context *glContext,
                                const gl::ProgramState &programState,
                                const gl::ProgramLinkedResources &resources,
+                               const gl::Caps &glCaps,
                                std::vector<uint32_t> *vertexCodeOut,
                                std::vector<uint32_t> *fragmentCodeOut);
 
diff --git a/src/libANGLE/renderer/vulkan/ProgramVk.cpp b/src/libANGLE/renderer/vulkan/ProgramVk.cpp
index 10bb942..a0b3a66 100644
--- a/src/libANGLE/renderer/vulkan/ProgramVk.cpp
+++ b/src/libANGLE/renderer/vulkan/ProgramVk.cpp
@@ -235,9 +235,9 @@
     std::vector<uint32_t> vertexCode;
     std::vector<uint32_t> fragmentCode;
     bool linkSuccess = false;
-    ANGLE_TRY_RESULT(
-        glslangWrapper->linkProgram(glContext, mState, resources, &vertexCode, &fragmentCode),
-        linkSuccess);
+    ANGLE_TRY_RESULT(glslangWrapper->linkProgram(glContext, mState, resources, glContext->getCaps(),
+                                                 &vertexCode, &fragmentCode),
+                     linkSuccess);
     if (!linkSuccess)
     {
         return false;
diff --git a/src/tests/deqp_support/deqp_gles2_test_expectations.txt b/src/tests/deqp_support/deqp_gles2_test_expectations.txt
index 1cca3cd..b3c24eb 100644
--- a/src/tests/deqp_support/deqp_gles2_test_expectations.txt
+++ b/src/tests/deqp_support/deqp_gles2_test_expectations.txt
@@ -223,7 +223,6 @@
 2580 VULKAN : dEQP-GLES2.functional.buffer.write.random.* = SKIP
 2494 VULKAN : dEQP-GLES2.functional.shaders.struct.uniform.sampler_* = SKIP
 2592 VULKAN : dEQP-GLES2.functional.shaders.builtin_variable.depth_range* = SKIP
-2594 VULKAN : dEQP-GLES2.functional.shaders.fragdata.valid_static_index = SKIP
 2595 VULKAN : dEQP-GLES2.functional.shaders.random.all_features.fragment* = SKIP
 2597 VULKAN : dEQP-GLES2.functional.fbo.render.color.blend_rbo_rgb5_a* = SKIP
 2597 VULKAN : dEQP-GLES2.functional.fbo.render.color.blend_npot_rbo_rgb5_a* = SKIP