Add logic for inserting vertex conversion code in HLSL.

The patch refactors the vertex input HLSL to allow for dynamic
conversion in the future. Using a placehold keyword, the code
replaces that stub with the vertex input conversion logic.

BUG=angle:560
Change-Id: I100c50cb4decd45b0f0c10d7c2c22583368b773e
Reviewed-on: https://chromium-review.googlesource.com/185194
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index c5fd884..7e3942b 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -192,9 +192,17 @@
         }
     }
 
+    // Generate new dynamic layout with attribute conversions
+    const std::string &layoutHLSL = mDynamicHLSL->generateInputLayoutHLSL(inputLayout, mShaderAttributes);
+
+    // Generate new shader source by replacing the attributes stub with the defined input layout
+    std::string vertexHLSL = mVertexHLSL;
+    size_t insertPos = vertexHLSL.find(DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING);
+    vertexHLSL.replace(insertPos, DynamicHLSL::VERTEX_ATTRIBUTE_STUB_STRING.length(), layoutHLSL);
+
     // Generate new vertex executable
     InfoLog tempInfoLog;
-    rx::ShaderExecutable *vertexExecutable = mRenderer->compileToExecutable(tempInfoLog, mVertexHLSL.c_str(), rx::SHADER_VERTEX, mVertexWorkarounds);
+    rx::ShaderExecutable *vertexExecutable = mRenderer->compileToExecutable(tempInfoLog, vertexHLSL.c_str(), rx::SHADER_VERTEX, mVertexWorkarounds);
 
     if (!vertexExecutable)
     {