Revert "Refactoring Shader objects"

This reverts commit 537dfde52a33d621ab1198c949a81b09a1269b2e.

Change-Id: I5eb8923ac8f78877e6e77a8cd897021e56ee004a
Reviewed-on: https://chromium-review.googlesource.com/214466
Reviewed-by: Brandon Jones <bajones@chromium.org>
Tested-by: Brandon Jones <bajones@chromium.org>
diff --git a/src/libGLESv2/DynamicHLSL.cpp b/src/libGLESv2/DynamicHLSL.cpp
index f09cf63..e3ec391 100644
--- a/src/libGLESv2/DynamicHLSL.cpp
+++ b/src/libGLESv2/DynamicHLSL.cpp
@@ -11,7 +11,6 @@
 #include "libGLESv2/DynamicHLSL.h"
 #include "libGLESv2/Shader.h"
 #include "libGLESv2/Program.h"
-#include "libGLESv2/renderer/d3d/ShaderD3D.h"
 #include "libGLESv2/renderer/Renderer.h"
 #include "common/utilities.h"
 #include "libGLESv2/ProgramBinary.h"
@@ -211,17 +210,14 @@
 {
     const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
 
-    rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation());
-    rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader->getImplementation());
-
-    vertexShaderD3D->resetVaryingsRegisterAssignment();
-    fragmentShaderD3D->resetVaryingsRegisterAssignment();
+    vertexShader->resetVaryingsRegisterAssignment();
+    fragmentShader->resetVaryingsRegisterAssignment();
 
     std::set<std::string> packedVaryings;
 
-    for (unsigned int varyingIndex = 0; varyingIndex < fragmentShaderD3D->mVaryings.size(); varyingIndex++)
+    for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
     {
-        PackedVarying *varying = &fragmentShaderD3D->mVaryings[varyingIndex];
+        PackedVarying *varying = &fragmentShader->mVaryings[varyingIndex];
         if (packVarying(varying, maxVaryingVectors, packing))
         {
             packedVaryings.insert(varying->name);
@@ -239,9 +235,9 @@
         if (packedVaryings.find(transformFeedbackVarying) == packedVaryings.end())
         {
             bool found = false;
-            for (unsigned int varyingIndex = 0; varyingIndex < vertexShaderD3D->mVaryings.size(); varyingIndex++)
+            for (unsigned int varyingIndex = 0; varyingIndex < vertexShader->mVaryings.size(); varyingIndex++)
             {
-                PackedVarying *varying = &vertexShaderD3D->mVaryings[varyingIndex];
+                PackedVarying *varying = &vertexShader->mVaryings[varyingIndex];
                 if (transformFeedbackVarying == varying->name)
                 {
                     if (!packVarying(varying, maxVaryingVectors, packing))
@@ -279,14 +275,12 @@
 
 std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const
 {
-    rx::VertexShaderD3D *shaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(shader->getImplementation());
-
-    std::string varyingSemantic = getVaryingSemantic(shaderD3D->mUsesPointSize);
+    std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize);
     std::string varyingHLSL;
 
-    for (unsigned int varyingIndex = 0; varyingIndex < shaderD3D->mVaryings.size(); varyingIndex++)
+    for (unsigned int varyingIndex = 0; varyingIndex < shader->mVaryings.size(); varyingIndex++)
     {
-        const PackedVarying &varying = shaderD3D->mVaryings[varyingIndex];
+        const PackedVarying &varying = shader->mVaryings[varyingIndex];
         if (varying.registerAssigned())
         {
             GLenum transposedType = TransposeMatrixType(varying.type);
@@ -610,10 +604,8 @@
 void DynamicHLSL::storeUserLinkedVaryings(const VertexShader *vertexShader,
                                           std::vector<LinkedVarying> *linkedVaryings) const
 {
-    const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation());
-
-    const std::string &varyingSemantic = getVaryingSemantic(vertexShaderD3D->mUsesPointSize);
-    const std::vector<PackedVarying> &varyings = vertexShaderD3D->mVaryings;
+    const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize);
+    const std::vector<PackedVarying> &varyings = vertexShader->mVaryings;
 
     for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++)
     {
@@ -644,15 +636,12 @@
         return false;
     }
 
-    rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation());
-    rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader->getImplementation());
-
-    bool usesMRT = fragmentShaderD3D->mUsesMultipleRenderTargets;
-    bool usesFragColor = fragmentShaderD3D->mUsesFragColor;
-    bool usesFragData = fragmentShaderD3D->mUsesFragData;
-    bool usesFragCoord = fragmentShaderD3D->mUsesFragCoord;
-    bool usesPointCoord = fragmentShaderD3D->mUsesPointCoord;
-    bool usesPointSize = vertexShaderD3D->mUsesPointSize;
+    bool usesMRT = fragmentShader->mUsesMultipleRenderTargets;
+    bool usesFragColor = fragmentShader->mUsesFragColor;
+    bool usesFragData = fragmentShader->mUsesFragData;
+    bool usesFragCoord = fragmentShader->mUsesFragCoord;
+    bool usesPointCoord = fragmentShader->mUsesPointCoord;
+    bool usesPointSize = vertexShader->mUsesPointSize;
 
     if (usesFragColor && usesFragData)
     {
@@ -669,10 +658,10 @@
     // Two cases when writing to gl_FragColor and using ESSL 1.0:
     // - with a 3.0 context, the output color is copied to channel 0
     // - with a 2.0 context, the output color is broadcast to all channels
-    const bool broadcast = (fragmentShaderD3D->mUsesFragColor && mRenderer->getCurrentClientVersion() < 3);
+    const bool broadcast = (fragmentShader->mUsesFragColor && mRenderer->getCurrentClientVersion() < 3);
     const unsigned int numRenderTargets = (broadcast || usesMRT ? mRenderer->getRendererCaps().maxDrawBuffers : 1);
 
-    int shaderVersion = vertexShaderD3D->getShaderVersion();
+    int shaderVersion = vertexShader->getShaderVersion();
 
     if (registersNeeded > maxVaryingVectors)
     {
@@ -729,9 +718,9 @@
         vertexHLSL += "    output.gl_FragCoord = gl_Position;\n";
     }
 
-    for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexShaderD3D->mVaryings.size(); vertVaryingIndex++)
+    for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexShader->mVaryings.size(); vertVaryingIndex++)
     {
-        const PackedVarying &varying = vertexShaderD3D->mVaryings[vertVaryingIndex];
+        const PackedVarying &varying = vertexShader->mVaryings[vertVaryingIndex];
         if (varying.registerAssigned())
         {
             for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
@@ -813,13 +802,13 @@
             outPixelShaderKey->push_back(outputKeyVariable);
         }
 
-        *outUsesFragDepth = fragmentShaderD3D->mUsesFragDepth;
+        *outUsesFragDepth = fragmentShader->mUsesFragDepth;
     }
     else
     {
         defineOutputVariables(fragmentShader, programOutputVars);
 
-        const std::vector<sh::Attribute> &shaderOutputVars = fragmentShaderD3D->getOutputVariables();
+        const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
         for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++)
         {
             const VariableLocation &outputLocation = locationIt->second;
@@ -841,7 +830,7 @@
 
     pixelHLSL += PIXEL_OUTPUT_STUB_STRING + "\n";
 
-    if (fragmentShaderD3D->mUsesFrontFacing)
+    if (fragmentShader->mUsesFrontFacing)
     {
         if (shaderModel >= 4)
         {
@@ -891,7 +880,7 @@
         pixelHLSL += "    gl_PointCoord.y = 1.0 - input.gl_PointCoord.y;\n";
     }
 
-    if (fragmentShaderD3D->mUsesFrontFacing)
+    if (fragmentShader->mUsesFrontFacing)
     {
         if (shaderModel <= 3)
         {
@@ -903,9 +892,9 @@
         }
     }
 
-    for (unsigned int varyingIndex = 0; varyingIndex < fragmentShaderD3D->mVaryings.size(); varyingIndex++)
+    for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
     {
-        const PackedVarying &varying = fragmentShaderD3D->mVaryings[varyingIndex];
+        const PackedVarying &varying = fragmentShader->mVaryings[varyingIndex];
         if (varying.registerAssigned())
         {
             for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
@@ -959,8 +948,7 @@
 
 void DynamicHLSL::defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
 {
-    rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader->getImplementation());
-    const std::vector<sh::Attribute> &shaderOutputVars = fragmentShaderD3D->getOutputVariables();
+    const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
 
     for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++)
     {
@@ -986,26 +974,23 @@
 
 std::string DynamicHLSL::generateGeometryShaderHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const
 {
-    rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation());
     // for now we only handle point sprite emulation
-    ASSERT(vertexShaderD3D->mUsesPointSize && mRenderer->getMajorShaderModel() >= 4);
+    ASSERT(vertexShader->mUsesPointSize && mRenderer->getMajorShaderModel() >= 4);
     return generatePointSpriteHLSL(registers, fragmentShader, vertexShader);
 }
 
 std::string DynamicHLSL::generatePointSpriteHLSL(int registers, FragmentShader *fragmentShader, VertexShader *vertexShader) const
 {
-    rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation());
-    rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader->getImplementation());
     ASSERT(registers >= 0);
-    ASSERT(vertexShaderD3D->mUsesPointSize);
+    ASSERT(vertexShader->mUsesPointSize);
     ASSERT(mRenderer->getMajorShaderModel() >= 4);
 
     std::string geomHLSL;
 
-    const SemanticInfo &inSemantics = getSemanticInfo(registers, fragmentShaderD3D->mUsesFragCoord,
+    const SemanticInfo &inSemantics = getSemanticInfo(registers, fragmentShader->mUsesFragCoord,
                                                       false, true, false);
-    const SemanticInfo &outSemantics = getSemanticInfo(registers, fragmentShaderD3D->mUsesFragCoord,
-                                                       fragmentShaderD3D->mUsesPointCoord, true, false);
+    const SemanticInfo &outSemantics = getSemanticInfo(registers, fragmentShader->mUsesFragCoord,
+                                                       fragmentShader->mUsesPointCoord, true, false);
 
     std::string varyingHLSL = generateVaryingHLSL(vertexShader);
     std::string inLinkHLSL = generateVaryingLinkHLSL(inSemantics, varyingHLSL);
@@ -1048,7 +1033,7 @@
         geomHLSL += "    output.v" + Str(r) + " = input[0].v" + Str(r) + ";\n";
     }
 
-    if (fragmentShaderD3D->mUsesFragCoord)
+    if (fragmentShader->mUsesFragCoord)
     {
         geomHLSL += "    output.gl_FragCoord = input[0].gl_FragCoord;\n";
     }
@@ -1063,7 +1048,7 @@
         geomHLSL += "    \n"
                     "    output.dx_Position = dx_Position + float4(pointSpriteCorners[" + Str(corner) + "] * viewportScale * gl_PointSize, 0.0f, 0.0f);\n";
 
-        if (fragmentShaderD3D->mUsesPointCoord)
+        if (fragmentShader->mUsesPointCoord)
         {
             geomHLSL += "    output.gl_PointCoord = pointSpriteTexcoords[" + Str(corner) + "];\n";
         }