Use the spvc translated version of the Vulkan shader

BUG=dawn:325

Change-Id: I66bed7fec65cadecc956878bf11fc204b66ad195
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15500
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/vulkan/ShaderModuleVk.cpp b/src/dawn_native/vulkan/ShaderModuleVk.cpp
index e756852..140abba 100644
--- a/src/dawn_native/vulkan/ShaderModuleVk.cpp
+++ b/src/dawn_native/vulkan/ShaderModuleVk.cpp
@@ -42,7 +42,7 @@
         if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
             shaderc_spvc::CompileOptions options;
             DAWN_TRY(CheckSpvcSuccess(
-                mSpvcContext.InitializeForGlsl(descriptor->code, descriptor->codeSize, options),
+                mSpvcContext.InitializeForVulkan(descriptor->code, descriptor->codeSize, options),
                 "Unable to initialize instance of spvc"));
 
             spirv_cross::Compiler* compiler;
@@ -58,8 +58,19 @@
         createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
         createInfo.pNext = nullptr;
         createInfo.flags = 0;
-        createInfo.codeSize = descriptor->codeSize * sizeof(uint32_t);
-        createInfo.pCode = descriptor->code;
+        std::vector<uint32_t> vulkanSource;
+        if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
+            shaderc_spvc::CompilationResult result;
+            DAWN_TRY(CheckSpvcSuccess(mSpvcContext.CompileShader(&result),
+                                      "Unable to generate Vulkan shader"));
+            DAWN_TRY(CheckSpvcSuccess(result.GetBinaryOutput(&vulkanSource),
+                                      "Unable to get binary output of Vulkan shader"));
+            createInfo.codeSize = vulkanSource.size() * sizeof(uint32_t);
+            createInfo.pCode = vulkanSource.data();
+        } else {
+            createInfo.codeSize = descriptor->codeSize * sizeof(uint32_t);
+            createInfo.pCode = descriptor->code;
+        }
 
         Device* device = ToBackend(GetDevice());
         return CheckVkSuccess(