Add ShaderExecutable and ShaderExecutable9 classes to encapsulate back-end specific shader-isms.

Trac #22155
Signed-off-by: Geoff Lang
Signed-off-by: Nicolas Capens
Author: Shannon Woods & Daniel Koch

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1498 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/build_angle.gypi b/src/build_angle.gypi
index 930b47a..e2ee4cc 100644
--- a/src/build_angle.gypi
+++ b/src/build_angle.gypi
@@ -275,6 +275,9 @@
             'libGLESv2/renderer/RenderTarget9.h',
             'libGLESv2/renderer/RenderTarget9.cpp',
             'libGLESv2/renderer/ShaderCache.h',
+            'libGLESv2/renderer/ShaderExecutable.h',
+            'libGLESv2/renderer/ShaderExecutable9.cpp',
+            'libGLESv2/renderer/ShaderExecutable9.h',
             'libGLESv2/renderer/SwapChain.h',
             'libGLESv2/renderer/SwapChain9.cpp',
             'libGLESv2/renderer/SwapChain9.h',
diff --git a/src/libGLESv2/libGLESv2.vcxproj b/src/libGLESv2/libGLESv2.vcxproj
index 7cbd28b..984c8e4 100644
--- a/src/libGLESv2/libGLESv2.vcxproj
+++ b/src/libGLESv2/libGLESv2.vcxproj
@@ -255,6 +255,7 @@
     <ClCompile Include="renderer\RenderTarget11.cpp" />

     <ClCompile Include="renderer\RenderTarget9.cpp" />

     <ClCompile Include="renderer\RenderStateCache.cpp" />

+    <ClCompile Include="renderer\ShaderExecutable9.cpp" />

     <ClCompile Include="renderer\SwapChain11.cpp" />

     <ClCompile Include="renderer\SwapChain9.cpp" />

     <ClCompile Include="renderer\TextureStorage.cpp" />

@@ -299,6 +300,8 @@
     <ClInclude Include="renderer\RenderTarget9.h" />

     <ClInclude Include="renderer\RenderStateCache.h" />

     <ClInclude Include="renderer\ShaderCache.h" />

+    <ClInclude Include="renderer\ShaderExecutable.h" />

+    <ClInclude Include="renderer\ShaderExecutable9.h" />

     <ClInclude Include="renderer\SwapChain.h" />

     <ClInclude Include="renderer\SwapChain11.h" />

     <ClInclude Include="renderer\SwapChain9.h" />

diff --git a/src/libGLESv2/libGLESv2.vcxproj.filters b/src/libGLESv2/libGLESv2.vcxproj.filters
index 6b53194..f96824c 100644
--- a/src/libGLESv2/libGLESv2.vcxproj.filters
+++ b/src/libGLESv2/libGLESv2.vcxproj.filters
@@ -131,6 +131,9 @@
     <ClCompile Include="renderer\VertexDeclarationCache.cpp">

       <Filter>Renderer</Filter>

     </ClCompile>

+    <ClCompile Include="renderer\ShaderExecutable9.cpp">

+      <Filter>Renderer</Filter>

+    </ClCompile>

   </ItemGroup>

   <ItemGroup>

     <ClInclude Include="BinaryStream.h">

@@ -268,6 +271,12 @@
     <ClInclude Include="renderer\VertexDeclarationCache.h">

       <Filter>Renderer</Filter>

     </ClInclude>

+    <ClInclude Include="renderer\ShaderExecutable.h">

+      <Filter>Renderer</Filter>

+    </ClInclude>

+    <ClInclude Include="renderer\ShaderExecutable9.h">

+      <Filter>Renderer</Filter>

+    </ClInclude>

   </ItemGroup>

   <ItemGroup>

     <None Include="libGLESv2.def">

diff --git a/src/libGLESv2/renderer/ShaderExecutable.h b/src/libGLESv2/renderer/ShaderExecutable.h
new file mode 100644
index 0000000..d43f378
--- /dev/null
+++ b/src/libGLESv2/renderer/ShaderExecutable.h
@@ -0,0 +1,30 @@
+//
+// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// ShaderExecutable.h: Defines a renderer-agnostic class to contain shader
+// executable implementation details.
+
+#ifndef LIBGLESV2_RENDERER_SHADEREXECUTABLE_H_
+#define LIBGLESV2_RENDERER_SHADEREXECUTABLE_H_
+
+#include "common/angleutils.h"
+
+namespace rx
+{
+
+class ShaderExecutable
+{
+  public:
+    ShaderExecutable() {};
+    virtual ~ShaderExecutable() {};
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(ShaderExecutable);
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_
\ No newline at end of file
diff --git a/src/libGLESv2/renderer/ShaderExecutable9.cpp b/src/libGLESv2/renderer/ShaderExecutable9.cpp
new file mode 100644
index 0000000..5bd4486
--- /dev/null
+++ b/src/libGLESv2/renderer/ShaderExecutable9.cpp
@@ -0,0 +1,78 @@
+//
+// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// ShaderExecutable9.cpp: Implements a D3D9-specific class to contain shader
+// executable implementation details.
+
+#include "libGLESv2/renderer/ShaderExecutable9.h"
+
+#include "common/debug.h"
+
+namespace rx
+{
+
+ShaderExecutable9::ShaderExecutable9(IDirect3DPixelShader9 *executable, gl::D3DConstantTable *constantTable)
+{
+    mPixelExecutable = executable;
+    mVertexExecutable = NULL;
+    mConstantTable = constantTable;
+}
+
+ShaderExecutable9::ShaderExecutable9(IDirect3DVertexShader9 *executable, gl::D3DConstantTable *constantTable)
+{
+    mVertexExecutable = executable;
+    mPixelExecutable = NULL;
+    mConstantTable = constantTable;
+}
+
+ShaderExecutable9::~ShaderExecutable9()
+{
+    if (mVertexExecutable)
+    {
+        mVertexExecutable->Release();
+    }
+    if (mPixelExecutable)
+    {
+        mPixelExecutable->Release();
+    }
+
+    delete mConstantTable;
+}
+
+ShaderExecutable9 *ShaderExecutable9::makeShaderExecutable9(ShaderExecutable *executable)
+{
+    ASSERT(dynamic_cast<ShaderExecutable9*>(executable) != NULL);
+    return static_cast<ShaderExecutable9*>(executable);
+}
+
+IDirect3DVertexShader9 *ShaderExecutable9::getVertexShader()
+{
+    // Caller is responsible for releasing the returned shader reference.
+    if (mVertexExecutable)
+    {
+        mVertexExecutable->AddRef();
+    }
+
+    return mVertexExecutable;
+}
+
+IDirect3DPixelShader9 *ShaderExecutable9::getPixelShader()
+{
+    // Caller is responsible for releasing the returned shader reference.
+    if (mPixelExecutable)
+    {
+        mPixelExecutable->AddRef();
+    }
+
+    return mPixelExecutable;
+}
+
+gl::D3DConstantTable *ShaderExecutable9::getConstantTable()
+{
+    return mConstantTable;
+}
+
+}
\ No newline at end of file
diff --git a/src/libGLESv2/renderer/ShaderExecutable9.h b/src/libGLESv2/renderer/ShaderExecutable9.h
new file mode 100644
index 0000000..721dee0
--- /dev/null
+++ b/src/libGLESv2/renderer/ShaderExecutable9.h
@@ -0,0 +1,45 @@
+//
+// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// ShaderExecutable9.h: Defines a D3D9-specific class to contain shader
+// executable implementation details.
+
+#ifndef LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_
+#define LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_
+
+#include <d3d9.h>
+
+#include "libGLESv2/renderer/ShaderExecutable.h"
+#include "libGLESv2/D3DConstantTable.h"
+
+namespace rx
+{
+
+class ShaderExecutable9 : public ShaderExecutable
+{
+  public:
+    ShaderExecutable9(IDirect3DPixelShader9 *executable, gl::D3DConstantTable *constantTable);
+    ShaderExecutable9(IDirect3DVertexShader9 *executable, gl::D3DConstantTable *constantTable);
+    virtual ~ShaderExecutable9();
+
+    static ShaderExecutable9 *makeShaderExecutable9(ShaderExecutable *executable);
+
+    IDirect3DPixelShader9 *getPixelShader();
+    IDirect3DVertexShader9 *getVertexShader();
+    gl::D3DConstantTable *getConstantTable();
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(ShaderExecutable9);
+
+    IDirect3DPixelShader9 *mPixelExecutable;
+    IDirect3DVertexShader9 *mVertexExecutable;
+
+    gl::D3DConstantTable *mConstantTable;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_SHADEREXECUTABLE9_H_
\ No newline at end of file