Finish updating ANGLE.
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 May 2014 19:24:46 +0000 (19:24 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 May 2014 19:24:46 +0000 (19:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132434

Reviewed by Dean Jackson.

Source/ThirdParty/ANGLE:
* ANGLE.xcodeproj/project.pbxproj:
Removed Uniform.cpp which is no longer in ANGLE.
* changes.diff:
Added more changes from ANGLE which are already included in WebKit.

Updated ANGLE source files to e7a453a5bd76705ccb151117fa844846d4aa90af.  Long list of changes omitted.

Source/WebCore:
* CMakeLists.txt:
Removed Uniform.cpp which is no longer in ANGLE.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168115 268f45cc-cd09-0410-ab3c-d52691b4dbfc

99 files changed:
Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
Source/ThirdParty/ANGLE/ChangeLog
Source/ThirdParty/ANGLE/changes.diff
Source/ThirdParty/ANGLE/src/build_angle.gypi [deleted file]
Source/ThirdParty/ANGLE/src/common/system.h [deleted file]
Source/ThirdParty/ANGLE/src/compiler/preprocessor/length_limits.h [deleted file]
Source/ThirdParty/ANGLE/src/compiler/translator/Uniform.cpp [deleted file]
Source/ThirdParty/ANGLE/src/compiler/translator/Uniform.h [deleted file]
Source/ThirdParty/ANGLE/src/libEGL/libEGL.vcxproj [deleted file]
Source/ThirdParty/ANGLE/src/libEGL/libEGL.vcxproj.filters [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/Program.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/constants.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ImageSSE2.cpp [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Blit11.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Blit11.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Clear11.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Clear11.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/PixelTransfer11.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/formatutils11.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/formatutils11.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/BufferToTexture11.hlsl [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough11.hlsl [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough3D11.hlsl [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Swizzle11.hlsl [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11ps.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearmultiple11ps.h with 96% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11vs.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clear11vs.h with 96% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearsingle11ps.h [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearsint11vs.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/clearuint11vs.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough11vs.h with 96% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11gs.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11vs.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughdepth2d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum2d11ps.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum11ps.h with 85% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum3d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha11ps.h with 84% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2d11ps.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb11ps.h with 85% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba11ps.h with 84% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3d11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3di11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3dui11ps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2darrayps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2dps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlef3dps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2darrayps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2dps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzlei3dps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2darrayps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2dps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/swizzleui3dps.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Blit9.cpp [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Blit.cpp with 77% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Blit9.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/Blit.h with 93% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/ShaderCache.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ShaderCache.h with 89% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/formatutils9.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/formatutils9.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/imageformats.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/loadimage.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/loadimage.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/loadimageSSE2.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/renderer/vertexconversion.h [moved from Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d9/vertexconversion.h with 100% similarity]
Source/ThirdParty/ANGLE/src/libGLESv2/utilities.cpp [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/utilities.h [deleted file]
Source/ThirdParty/ANGLE/src/libGLESv2/validationES.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/validationES.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/validationES2.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/validationES2.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/validationES3.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libGLESv2/validationES3.h [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog

index 0fb3f3e..79226f0 100644 (file)
                5C9FFF4F19102A000025B8FA /* FlagStd140Structs.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9FFF4D19102A000025B8FA /* FlagStd140Structs.h */; };
                5CC7D452191024E4000B8C1F /* LoopInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D44B191024E3000B8C1F /* LoopInfo.cpp */; };
                5CC7D453191024E4000B8C1F /* LoopInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D44C191024E4000B8C1F /* LoopInfo.h */; };
-               5CC7D456191024E4000B8C1F /* Uniform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D44F191024E4000B8C1F /* Uniform.cpp */; };
                5CC7D457191024E4000B8C1F /* ValidateOutputs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D450191024E4000B8C1F /* ValidateOutputs.cpp */; };
                5CC7D458191024E4000B8C1F /* ValidateOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D451191024E4000B8C1F /* ValidateOutputs.h */; };
                5CC7D46B19102620000B8C1F /* angleutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D45A19102620000B8C1F /* angleutils.h */; };
                5C9FFF4D19102A000025B8FA /* FlagStd140Structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlagStd140Structs.h; sourceTree = "<group>"; };
                5CC7D44B191024E3000B8C1F /* LoopInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoopInfo.cpp; sourceTree = "<group>"; };
                5CC7D44C191024E4000B8C1F /* LoopInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoopInfo.h; sourceTree = "<group>"; };
-               5CC7D44F191024E4000B8C1F /* Uniform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Uniform.cpp; sourceTree = "<group>"; };
                5CC7D450191024E4000B8C1F /* ValidateOutputs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValidateOutputs.cpp; sourceTree = "<group>"; };
                5CC7D451191024E4000B8C1F /* ValidateOutputs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValidateOutputs.h; sourceTree = "<group>"; };
                5CC7D45A19102620000B8C1F /* angleutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = angleutils.h; path = src/common/angleutils.h; sourceTree = "<group>"; };
                                5C9FFF4D19102A000025B8FA /* FlagStd140Structs.h */,
                                5CC7D44B191024E3000B8C1F /* LoopInfo.cpp */,
                                5CC7D44C191024E4000B8C1F /* LoopInfo.h */,
-                               5CC7D44F191024E4000B8C1F /* Uniform.cpp */,
                                5CC7D450191024E4000B8C1F /* ValidateOutputs.cpp */,
                                5CC7D451191024E4000B8C1F /* ValidateOutputs.h */,
                                31012DA918B97B9B0039062F /* depgraph */,
                                31012E5918B97B9B0039062F /* QualifierAlive.cpp in Sources */,
                                31012E7118B97B9B0039062F /* UnfoldShortCircuit.cpp in Sources */,
                                31012E6418B97B9B0039062F /* SymbolTable.cpp in Sources */,
-                               5CC7D456191024E4000B8C1F /* Uniform.cpp in Sources */,
                                A264F8B416974DED006FAA5A /* Input.cpp in Sources */,
                                5CC7D47919102621000B8C1F /* utilities.cpp in Sources */,
                                A264F8B616974DED006FAA5A /* Lexer.cpp in Sources */,
index 070f8df..43716d5 100644 (file)
@@ -1,3 +1,17 @@
+2014-05-01  Alex Christensen  <achristensen@webkit.org>
+
+        Finish updating ANGLE.
+        https://bugs.webkit.org/show_bug.cgi?id=132434
+
+        Reviewed by Dean Jackson.
+
+        * ANGLE.xcodeproj/project.pbxproj:
+        Removed Uniform.cpp which is no longer in ANGLE.
+        * changes.diff:
+        Added more changes from ANGLE which are already included in WebKit.
+
+        Updated ANGLE source files to e7a453a5bd76705ccb151117fa844846d4aa90af.  Long list of changes omitted.
+
 2014-04-30  Alex Christensen  <achristensen@webkit.org>
 
         Updated ANGLE.
index c4c30b7..d829c41 100644 (file)
@@ -1,5 +1,5 @@
 diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h
-index 7970bfa..9cdcc24 100644
+index 7970bfa..b716c6f 100644
 --- a/include/GLSLANG/ShaderLang.h
 +++ b/include/GLSLANG/ShaderLang.h
 @@ -23,7 +23,7 @@
@@ -11,6 +11,17 @@ index 7970bfa..9cdcc24 100644
  #include <stddef.h>
  
  //
+@@ -423,8 +423,8 @@ COMPILER_EXPORT void ShGetInfoLog(const ShHandle handle, char* infoLog);
+ // Returns null-terminated object code for a compiled shader.
+ // Parameters:
+ // handle: Specifies the compiler
+-// infoLog: Specifies an array of characters that is used to return
+-//          the object code. It is assumed that infoLog has enough memory to
++// objCode: Specifies an array of characters that is used to return
++//          the object code. It is assumed that objCode has enough memory to
+ //          accomodate the object code. The size of the buffer required to
+ //          store the returned object code can be obtained by calling
+ //          ShGetInfo with SH_OBJECT_CODE_LENGTH.
 diff --git a/src/common/mathutil.h b/src/common/mathutil.h
 index 9061bbd..0b4f384 100644
 --- a/src/common/mathutil.h
@@ -145,6 +156,117 @@ index ab9d99a..850c639 100644
  namespace pp {
  
  Tokenizer::Tokenizer(Diagnostics* diagnostics) : mHandle(0)
+diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
+index 1864cd8..c3111c1 100644
+--- a/src/compiler/translator/Compiler.cpp
++++ b/src/compiler/translator/Compiler.cpp
+@@ -96,6 +96,7 @@ TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
+     : shaderType(type),
+       shaderSpec(spec),
+       maxUniformVectors(0),
++      maxVaryingVectors(0),
+       maxExpressionComplexity(0),
+       maxCallStackDepth(0),
+       fragmentPrecisionHigh(false),
+@@ -114,6 +115,7 @@ bool TCompiler::Init(const ShBuiltInResources& resources)
+     maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
+         resources.MaxVertexUniformVectors :
+         resources.MaxFragmentUniformVectors;
++    maxVaryingVectors = resources.MaxVaryingVectors;
+     maxExpressionComplexity = resources.MaxExpressionComplexity;
+     maxCallStackDepth = resources.MaxCallStackDepth;
+@@ -238,14 +240,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
+         {
+             collectVariables(root);
+             if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
+-            {
+                 success = enforcePackingRestrictions();
+-                if (!success)
+-                {
+-                    infoSink.info.prefix(EPrefixError);
+-                    infoSink.info << "too many uniforms";
+-                }
+-            }
+             if (success && shaderType == SH_VERTEX_SHADER &&
+                 (compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
+                 initializeVaryingsWithoutStaticUse(root);
+@@ -458,7 +453,21 @@ void TCompiler::collectVariables(TIntermNode* root)
+ bool TCompiler::enforcePackingRestrictions()
+ {
+     VariablePacker packer;
+-    return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
++    bool success = packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
++    if (!success) {
++        infoSink.info.prefix(EPrefixError);
++        infoSink.info << "too many uniforms";
++        return false;
++    }
++
++    success = packer.CheckVariablesWithinPackingLimits(maxVaryingVectors, varyings);
++
++    if (!success) {
++        infoSink.info.prefix(EPrefixError);
++        infoSink.info << "too many varyings";
++        return false;
++    }
++    return true;
+ }
+ void TCompiler::initializeGLPosition(TIntermNode* root)
+diff --git a/src/compiler/translator/ShHandle.h b/src/compiler/translator/ShHandle.h
+index 50a8d58..687ff63 100644
+--- a/src/compiler/translator/ShHandle.h
++++ b/src/compiler/translator/ShHandle.h
+@@ -95,7 +95,7 @@ protected:
+     // Translate to object code.
+     virtual void translate(TIntermNode* root) = 0;
+     // Returns true if, after applying the packing rules in the GLSL 1.017 spec
+-    // Appendix A, section 7, the shader does not use too many uniforms.
++    // Appendix A, section 7, the shader does not use too many uniforms or varyings.
+     bool enforcePackingRestrictions();
+     // Insert statements to initialize varyings without static use in the beginning
+     // of main(). It is to work around a Mac driver where such varyings in a vertex
+@@ -130,6 +130,7 @@ private:
+     ShShaderSpec shaderSpec;
+     int maxUniformVectors;
++    int maxVaryingVectors;
+     int maxExpressionComplexity;
+     int maxCallStackDepth;
+diff --git a/src/compiler/translator/ShaderLang.cpp b/src/compiler/translator/ShaderLang.cpp
+index b98c371..dd26873 100644
+--- a/src/compiler/translator/ShaderLang.cpp
++++ b/src/compiler/translator/ShaderLang.cpp
+@@ -242,8 +242,12 @@ void ShGetInfoLog(const ShHandle handle, char* infoLog)
+     TCompiler* compiler = base->getAsCompiler();
+     if (!compiler) return;
++    size_t infoLogLength = 0;
++    ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &infoLogLength);
++
+     TInfoSink& infoSink = compiler->getInfoSink();
+-    strcpy(infoLog, infoSink.info.c_str());
++    strncpy(infoLog, infoSink.info.c_str(), infoLogLength);
++    infoLog[infoLogLength - 1] = '\0';
+ }
+ //
+@@ -258,8 +262,12 @@ void ShGetObjectCode(const ShHandle handle, char* objCode)
+     TCompiler* compiler = base->getAsCompiler();
+     if (!compiler) return;
++    size_t objCodeLength = 0;
++    ShGetInfo(handle, SH_OBJECT_CODE_LENGTH, &objCodeLength);
++
+     TInfoSink& infoSink = compiler->getInfoSink();
+-    strcpy(objCode, infoSink.obj.c_str());
++    strncpy(objCode, infoSink.obj.c_str(), objCodeLength);
++    objCode[objCodeLength - 1] = '\0';
+ }
+ void ShGetVariableInfo(const ShHandle handle,
 diff --git a/src/compiler/translator/glslang.l b/src/compiler/translator/glslang.l
 index 518b78d..c8ff855 100644
 --- a/src/compiler/translator/glslang.l
@@ -225,3 +347,47 @@ index c6a61dc..09a38d4 100644
  /* Bison interface for Yacc-like parsers in C
     
        Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+diff --git a/src/libGLESv2/Program.cpp b/src/libGLESv2/Program.cpp
+index 8a9fb04..46db788 100644
+--- a/src/libGLESv2/Program.cpp
++++ b/src/libGLESv2/Program.cpp
+@@ -101,22 +101,27 @@ void InfoLog::append(const char *format, ...)
+     va_end(vararg);
+     char *logPointer = NULL;
++    size_t logLength = 0;
+     if (!mInfoLog)
+     {
+         mInfoLog = new char[infoLength + 2];
+         logPointer = mInfoLog;
++        logLength = infoLenfth + 2;
+     }
+     else
+     {
+         size_t currentlogLength = strlen(mInfoLog);
+-        char *newLog = new char[currentlogLength + infoLength + 2];
+-        strcpy(newLog, mInfoLog);
++        size_t newInfoLogLength = currentlogLength + infoLength + 2;
++        char *newLog = new char[newInfoLogLength];
++        strncpy(newLog, mInfoLog, newInfoLogLength);
++        newLog[newInfoLogLength - 1] = '\0';
+         delete[] mInfoLog;
+         mInfoLog = newLog;
+         logPointer = mInfoLog + currentlogLength;
++        logLength = newInfoLogLength - currentlogLength;
+     }
+     va_start(vararg, format);
+@@ -124,7 +129,8 @@ void InfoLog::append(const char *format, ...)
+     va_end(vararg);
+     logPointer[infoLength] = 0;
+-    strcpy(logPointer + infoLength, "\n");
++    strncpy(logPointer + infoLength, "\n", logLength - infoLength);
++    logPointer[logLength - 1] = '\0';
+ }
+ void InfoLog::reset()
diff --git a/Source/ThirdParty/ANGLE/src/build_angle.gypi b/Source/ThirdParty/ANGLE/src/build_angle.gypi
deleted file mode 100644 (file)
index 13c42f9..0000000
+++ /dev/null
@@ -1,423 +0,0 @@
-# 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.
-
-{
-  'variables': {
-    'angle_code': 1,
-    'translator_sources': [
-        'compiler/BaseTypes.h',
-        'compiler/BuiltInFunctionEmulator.cpp',
-        'compiler/BuiltInFunctionEmulator.h',
-        'compiler/CodeGen.cpp',
-        'compiler/Common.h',
-        'compiler/Compiler.cpp',
-        'compiler/ConstantUnion.h',
-        'compiler/debug.cpp',
-        'compiler/debug.h',
-        'compiler/DetectCallDepth.cpp',
-        'compiler/DetectCallDepth.h',
-        'compiler/DetectDiscontinuity.cpp',
-        'compiler/DetectDiscontinuity.h',
-        'compiler/Diagnostics.h',
-        'compiler/Diagnostics.cpp',
-        'compiler/DirectiveHandler.h',
-        'compiler/DirectiveHandler.cpp',
-        'compiler/ExtensionBehavior.h',
-        'compiler/ForLoopUnroll.cpp',
-        'compiler/ForLoopUnroll.h',
-        'compiler/glslang.h',
-        'compiler/glslang_lex.cpp',
-        'compiler/glslang_tab.cpp',
-        'compiler/glslang_tab.h',
-        'compiler/HashNames.h',
-        'compiler/InfoSink.cpp',
-        'compiler/InfoSink.h',
-        'compiler/Initialize.cpp',
-        'compiler/Initialize.h',
-        'compiler/InitializeDll.cpp',
-        'compiler/InitializeDll.h',
-        'compiler/InitializeGlobals.h',
-        'compiler/InitializeGLPosition.cpp',
-        'compiler/InitializeGLPosition.h',
-        'compiler/InitializeParseContext.cpp',
-        'compiler/InitializeParseContext.h',
-        'compiler/Intermediate.cpp',
-        'compiler/intermediate.h',
-        'compiler/intermOut.cpp',
-        'compiler/IntermTraverse.cpp',
-        'compiler/localintermediate.h',
-        'compiler/MapLongVariableNames.cpp',
-        'compiler/MapLongVariableNames.h',
-        'compiler/MMap.h',
-        'compiler/osinclude.h',
-        'compiler/OutputESSL.cpp',
-        'compiler/OutputESSL.h',
-        'compiler/OutputGLSLBase.cpp',
-        'compiler/OutputGLSLBase.h',
-        'compiler/OutputGLSL.cpp',
-        'compiler/OutputGLSL.h',
-        'compiler/OutputHLSL.cpp',
-        'compiler/OutputHLSL.h',
-        'compiler/parseConst.cpp',
-        'compiler/ParseContext.cpp',
-        'compiler/ParseContext.h',
-        'compiler/PoolAlloc.cpp',
-        'compiler/PoolAlloc.h',
-        'compiler/QualifierAlive.cpp',
-        'compiler/QualifierAlive.h',
-        'compiler/RemoveTree.cpp',
-        'compiler/RemoveTree.h',
-        'compiler/RenameFunction.h',
-        'compiler/SearchSymbol.cpp',
-        'compiler/SearchSymbol.h',
-        'compiler/ShaderLang.cpp',
-        'compiler/ShHandle.h',
-        'compiler/SymbolTable.cpp',
-        'compiler/SymbolTable.h',
-        'compiler/TranslatorESSL.cpp',
-        'compiler/TranslatorESSL.h',
-        'compiler/TranslatorGLSL.cpp',
-        'compiler/TranslatorGLSL.h',
-        'compiler/TranslatorHLSL.cpp',
-        'compiler/TranslatorHLSL.h',
-        'compiler/Types.h',
-        'compiler/UnfoldShortCircuitAST.cpp',
-        'compiler/UnfoldShortCircuitAST.h',
-        'compiler/UnfoldShortCircuit.cpp',
-        'compiler/UnfoldShortCircuit.h',
-        'compiler/Uniform.cpp',
-        'compiler/Uniform.h',
-        'compiler/util.cpp',
-        'compiler/util.h',
-        'compiler/ValidateLimitations.cpp',
-        'compiler/ValidateLimitations.h',
-        'compiler/VariableInfo.cpp',
-        'compiler/VariableInfo.h',
-        'compiler/VariablePacker.cpp',
-        'compiler/VariablePacker.h',
-        'compiler/VersionGLSL.cpp',
-        'compiler/VersionGLSL.h',
-        # Dependency graph
-        'compiler/depgraph/DependencyGraph.cpp',
-        'compiler/depgraph/DependencyGraph.h',
-        'compiler/depgraph/DependencyGraphBuilder.cpp',
-        'compiler/depgraph/DependencyGraphBuilder.h',
-        'compiler/depgraph/DependencyGraphOutput.cpp',
-        'compiler/depgraph/DependencyGraphOutput.h',
-        'compiler/depgraph/DependencyGraphTraverse.cpp',
-        # Timing restrictions
-        'compiler/timing/RestrictFragmentShaderTiming.cpp',
-        'compiler/timing/RestrictFragmentShaderTiming.h',
-        'compiler/timing/RestrictVertexShaderTiming.cpp',
-        'compiler/timing/RestrictVertexShaderTiming.h',
-        'third_party/compiler/ArrayBoundsClamper.cpp',
-        'third_party/compiler/ArrayBoundsClamper.h',
-      ],
-  },
-  'target_defaults': {
-    'defines': [
-      'ANGLE_DISABLE_TRACE',
-      'ANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL1',
-      'ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ TEXT("d3dcompiler_46.dll"), TEXT("d3dcompiler_43.dll") }',
-    ],
-  },
-  'targets': [
-    {
-      'target_name': 'preprocessor',
-      'type': 'static_library',
-      'include_dirs': [
-      ],
-      'sources': [
-        'compiler/preprocessor/DiagnosticsBase.cpp',
-        'compiler/preprocessor/DiagnosticsBase.h',
-        'compiler/preprocessor/DirectiveHandlerBase.cpp',
-        'compiler/preprocessor/DirectiveHandlerBase.h',
-        'compiler/preprocessor/DirectiveParser.cpp',
-        'compiler/preprocessor/DirectiveParser.h',
-        'compiler/preprocessor/ExpressionParser.cpp',
-        'compiler/preprocessor/ExpressionParser.h',
-        'compiler/preprocessor/Input.cpp',
-        'compiler/preprocessor/Input.h',
-        'compiler/preprocessor/length_limits.h',
-        'compiler/preprocessor/Lexer.cpp',
-        'compiler/preprocessor/Lexer.h',
-        'compiler/preprocessor/Macro.cpp',
-        'compiler/preprocessor/Macro.h',
-        'compiler/preprocessor/MacroExpander.cpp',
-        'compiler/preprocessor/MacroExpander.h',
-        'compiler/preprocessor/numeric_lex.h',
-        'compiler/preprocessor/pp_utils.h',
-        'compiler/preprocessor/Preprocessor.cpp',
-        'compiler/preprocessor/Preprocessor.h',
-        'compiler/preprocessor/SourceLocation.h',
-        'compiler/preprocessor/Token.cpp',
-        'compiler/preprocessor/Token.h',
-        'compiler/preprocessor/Tokenizer.cpp',
-        'compiler/preprocessor/Tokenizer.h',
-      ],
-      # TODO(jschuh): http://crbug.com/167187
-      'msvs_disabled_warnings': [
-        4267,
-      ],
-    },
-    {
-      'target_name': 'translator',
-      'type': '<(component)',
-      'dependencies': ['preprocessor'],
-      'include_dirs': [
-        '.',
-        '../include',
-      ],
-      'defines': [
-        'ANGLE_TRANSLATOR_IMPLEMENTATION',
-      ],
-      'sources': ['<@(translator_sources)'],
-      # TODO(jschuh): http://crbug.com/167187 size_t -> int
-      'msvs_disabled_warnings': [ 4267 ],
-      'conditions': [
-        ['OS=="win"', {
-          'sources': ['compiler/ossource_win.cpp'],
-        }, { # else: posix
-          'sources': ['compiler/ossource_posix.cpp'],
-        }],
-      ],
-    },
-    {
-      'target_name': 'translator_static',
-      'type': 'static_library',
-      'dependencies': ['preprocessor'],
-      'include_dirs': [
-        '.',
-        '../include',
-      ],
-      'direct_dependent_settings': {
-        'defines': [
-          'ANGLE_TRANSLATOR_STATIC',
-        ],
-      },
-      'defines': [
-        'ANGLE_TRANSLATOR_STATIC',
-      ],
-      'sources': ['<@(translator_sources)'],
-      # TODO(jschuh): http://crbug.com/167187 size_t -> int
-      'msvs_disabled_warnings': [ 4267 ],
-      'conditions': [
-        ['OS=="win"', {
-          'sources': ['compiler/ossource_win.cpp'],
-        }, { # else: posix
-          'sources': ['compiler/ossource_posix.cpp'],
-        }],
-      ],
-    },
-  ],
-  'conditions': [
-    ['OS=="win"', {
-      'targets': [
-        {
-          'target_name': 'libGLESv2',
-          'type': 'shared_library',
-          'dependencies': ['translator'],
-          'include_dirs': [
-            '.',
-            '../include',
-            'libGLESv2',
-          ],
-          'sources': [
-            'third_party/murmurhash/MurmurHash3.h',
-            'third_party/murmurhash/MurmurHash3.cpp',
-            'third_party/trace_event/trace_event.h',
-            'common/angleutils.h',
-            'common/debug.cpp',
-            'common/debug.h',
-            'common/event_tracer.cpp',
-            'common/event_tracer.h',
-            'common/RefCountObject.cpp',
-            'common/RefCountObject.h',
-            'common/version.h',
-            'libGLESv2/precompiled.h',
-            'libGLESv2/precompiled.cpp',
-            'libGLESv2/BinaryStream.h',
-            'libGLESv2/Buffer.cpp',
-            'libGLESv2/Buffer.h',
-            'libGLESv2/constants.h',
-            'libGLESv2/Context.cpp',
-            'libGLESv2/Context.h',
-            'libGLESv2/angletypes.h',
-            'libGLESv2/Fence.cpp',
-            'libGLESv2/Fence.h',
-            'libGLESv2/Float16ToFloat32.cpp',
-            'libGLESv2/Framebuffer.cpp',
-            'libGLESv2/Framebuffer.h',
-            'libGLESv2/HandleAllocator.cpp',
-            'libGLESv2/HandleAllocator.h',
-            'libGLESv2/libGLESv2.cpp',
-            'libGLESv2/libGLESv2.def',
-            'libGLESv2/libGLESv2.rc',
-            'libGLESv2/main.cpp',
-            'libGLESv2/main.h',
-            'libGLESv2/mathutil.h',
-            'libGLESv2/Program.cpp',
-            'libGLESv2/Program.h',
-            'libGLESv2/ProgramBinary.cpp',
-            'libGLESv2/ProgramBinary.h',
-            'libGLESv2/Query.h',
-            'libGLESv2/Query.cpp',
-            'libGLESv2/Renderbuffer.cpp',
-            'libGLESv2/Renderbuffer.h',
-            'libGLESv2/renderer/Blit.cpp',
-            'libGLESv2/renderer/Blit.h',
-            'libGLESv2/renderer/BufferStorage.h',
-            'libGLESv2/renderer/BufferStorage.cpp',
-            'libGLESv2/renderer/BufferStorage9.cpp',
-            'libGLESv2/renderer/BufferStorage9.h',
-            'libGLESv2/renderer/BufferStorage11.cpp',
-            'libGLESv2/renderer/BufferStorage11.h',
-            'libGLESv2/renderer/FenceImpl.h',
-            'libGLESv2/renderer/Fence9.cpp',
-            'libGLESv2/renderer/Fence9.h',
-            'libGLESv2/renderer/Fence11.cpp',
-            'libGLESv2/renderer/Fence11.h',
-            'libGLESv2/renderer/generatemip.h',
-            'libGLESv2/renderer/Image.cpp',
-            'libGLESv2/renderer/Image.h',
-            'libGLESv2/renderer/Image11.cpp',
-            'libGLESv2/renderer/Image11.h',
-            'libGLESv2/renderer/Image9.cpp',
-            'libGLESv2/renderer/Image9.h',
-            'libGLESv2/renderer/ImageSSE2.cpp',
-            'libGLESv2/renderer/IndexBuffer.cpp',
-            'libGLESv2/renderer/IndexBuffer.h',
-            'libGLESv2/renderer/IndexBuffer9.cpp',
-            'libGLESv2/renderer/IndexBuffer9.h',
-            'libGLESv2/renderer/IndexBuffer11.cpp',
-            'libGLESv2/renderer/IndexBuffer11.h',
-            'libGLESv2/renderer/IndexDataManager.cpp',
-            'libGLESv2/renderer/IndexDataManager.h',
-            'libGLESv2/renderer/IndexRangeCache.cpp',
-            'libGLESv2/renderer/IndexRangeCache.h',
-            'libGLESv2/renderer/InputLayoutCache.cpp',
-            'libGLESv2/renderer/InputLayoutCache.h',
-            'libGLESv2/renderer/QueryImpl.h',
-            'libGLESv2/renderer/Query9.cpp',
-            'libGLESv2/renderer/Query9.h',
-            'libGLESv2/renderer/Query11.cpp',
-            'libGLESv2/renderer/Query11.h',
-            'libGLESv2/renderer/Renderer.cpp',
-            'libGLESv2/renderer/Renderer.h',
-            'libGLESv2/renderer/Renderer11.cpp',
-            'libGLESv2/renderer/Renderer11.h',
-            'libGLESv2/renderer/renderer11_utils.cpp',
-            'libGLESv2/renderer/renderer11_utils.h',
-            'libGLESv2/renderer/Renderer9.cpp',
-            'libGLESv2/renderer/Renderer9.h',
-            'libGLESv2/renderer/renderer9_utils.cpp',
-            'libGLESv2/renderer/renderer9_utils.h',
-            'libGLESv2/renderer/RenderStateCache.cpp',
-            'libGLESv2/renderer/RenderStateCache.h',
-            'libGLESv2/renderer/RenderTarget.h',
-            'libGLESv2/renderer/RenderTarget11.h',
-            'libGLESv2/renderer/RenderTarget11.cpp',
-            '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/ShaderExecutable11.cpp',
-            'libGLESv2/renderer/ShaderExecutable11.h',
-            'libGLESv2/renderer/SwapChain.h',
-            'libGLESv2/renderer/SwapChain9.cpp',
-            'libGLESv2/renderer/SwapChain9.h',
-            'libGLESv2/renderer/SwapChain11.cpp',
-            'libGLESv2/renderer/SwapChain11.h',
-            'libGLESv2/renderer/TextureStorage.cpp',
-            'libGLESv2/renderer/TextureStorage.h',
-            'libGLESv2/renderer/TextureStorage11.cpp',
-            'libGLESv2/renderer/TextureStorage11.h',
-            'libGLESv2/renderer/TextureStorage9.cpp',
-            'libGLESv2/renderer/TextureStorage9.h',
-            'libGLESv2/renderer/VertexBuffer.cpp',
-            'libGLESv2/renderer/VertexBuffer.h',
-            'libGLESv2/renderer/VertexBuffer9.cpp',
-            'libGLESv2/renderer/VertexBuffer9.h',
-            'libGLESv2/renderer/VertexBuffer11.cpp',
-            'libGLESv2/renderer/VertexBuffer11.h',
-            'libGLESv2/renderer/vertexconversion.h',
-            'libGLESv2/renderer/VertexDataManager.cpp',
-            'libGLESv2/renderer/VertexDataManager.h',
-            'libGLESv2/renderer/VertexDeclarationCache.cpp',
-            'libGLESv2/renderer/VertexDeclarationCache.h',
-            'libGLESv2/ResourceManager.cpp',
-            'libGLESv2/ResourceManager.h',
-            'libGLESv2/Shader.cpp',
-            'libGLESv2/Shader.h',
-            'libGLESv2/Texture.cpp',
-            'libGLESv2/Texture.h',
-            'libGLESv2/Uniform.cpp',
-            'libGLESv2/Uniform.h',
-            'libGLESv2/utilities.cpp',
-            'libGLESv2/utilities.h',
-          ],
-          # TODO(jschuh): http://crbug.com/167187 size_t -> int
-          'msvs_disabled_warnings': [ 4267 ],
-          'msvs_settings': {
-            'VCLinkerTool': {
-              'AdditionalDependencies': [
-                'd3d9.lib',
-                'dxguid.lib',
-              ],
-            }
-          },
-        },
-        {
-          'target_name': 'libEGL',
-          'type': 'shared_library',
-          'dependencies': ['libGLESv2'],
-          'include_dirs': [
-            '.',
-            '../include',
-            'libGLESv2',
-          ],
-          'sources': [
-            'common/angleutils.h',
-            'common/debug.cpp',
-            'common/debug.h',
-            'common/RefCountObject.cpp',
-            'common/RefCountObject.h',
-            'common/version.h',
-            'libEGL/Config.cpp',
-            'libEGL/Config.h',
-            'libEGL/Display.cpp',
-            'libEGL/Display.h',
-            'libEGL/libEGL.cpp',
-            'libEGL/libEGL.def',
-            'libEGL/libEGL.rc',
-            'libEGL/main.cpp',
-            'libEGL/main.h',
-            'libEGL/Surface.cpp',
-            'libEGL/Surface.h',
-          ],
-          # TODO(jschuh): http://crbug.com/167187 size_t -> int
-          'msvs_disabled_warnings': [ 4267 ],
-          'msvs_settings': {
-            'VCLinkerTool': {
-              'AdditionalDependencies': [
-                'd3d9.lib',
-              ],
-            }
-          },
-        },
-      ],
-    }],
-  ],
-}
-
-# Local Variables:
-# tab-width:2
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=2 shiftwidth=2:
-# 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.
diff --git a/Source/ThirdParty/ANGLE/src/common/system.h b/Source/ThirdParty/ANGLE/src/common/system.h
deleted file mode 100644 (file)
index 5eb140b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-// Copyright (c) 2002-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.
-//
-
-// system.h: Includes Windows system headers and undefines macros that conflict.
-
-#ifndef COMMON_SYSTEM_H
-#define COMMON_SYSTEM_H
-
-#if !defined(WIN32_LEAN_AND_MEAN)
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#include <windows.h>
-
-#if defined(min)
-#undef min
-#endif
-
-#if defined(max)
-#undef max
-#endif
-
-#endif   // COMMON_SYSTEM_H
diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/length_limits.h b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/length_limits.h
deleted file mode 100644 (file)
index 4f1f713..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// Copyright (c) 2011 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.
-//
-
-//
-// length_limits.h
-//
-
-#if !defined(__LENGTH_LIMITS_H)
-#define __LENGTH_LIMITS_H 1
-
-// These constants are factored out from the rest of the headers to
-// make it easier to reference them from the compiler sources.
-
-// These lengths do not include the NULL terminator.
-#define MAX_SYMBOL_NAME_LEN 256
-#define MAX_STRING_LEN 511
-
-#endif // !(defined(__LENGTH_LIMITS_H)
diff --git a/Source/ThirdParty/ANGLE/src/compiler/translator/Uniform.cpp b/Source/ThirdParty/ANGLE/src/compiler/translator/Uniform.cpp
deleted file mode 100644 (file)
index 922e13f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-#include "compiler/translator/Uniform.h"
-
-namespace sh
-{
-
-Uniform::Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex)
-{
-    this->type = type;
-    this->precision = precision;
-    this->name = name;
-    this->arraySize = arraySize;
-    this->registerIndex = registerIndex;
-}
-
-}
diff --git a/Source/ThirdParty/ANGLE/src/compiler/translator/Uniform.h b/Source/ThirdParty/ANGLE/src/compiler/translator/Uniform.h
deleted file mode 100644 (file)
index 4c53ffa..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-#ifndef COMPILER_UNIFORM_H_
-#define COMPILER_UNIFORM_H_
-
-#include <string>
-#include <vector>
-
-#define GL_APICALL
-#include <GLES2/gl2.h>
-
-namespace sh
-{
-
-struct Uniform
-{
-    Uniform(GLenum type, GLenum precision, const char *name, int arraySize, int registerIndex);
-
-    GLenum type;
-    GLenum precision;
-    std::string name;
-    unsigned int arraySize;
-    
-    int registerIndex;
-};
-
-typedef std::vector<Uniform> ActiveUniforms;
-
-}
-
-#endif   // COMPILER_UNIFORM_H_
diff --git a/Source/ThirdParty/ANGLE/src/libEGL/libEGL.vcxproj b/Source/ThirdParty/ANGLE/src/libEGL/libEGL.vcxproj
deleted file mode 100644 (file)
index 631a4c6..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <ItemGroup Label="ProjectConfigurations">\r
-    <ProjectConfiguration Include="Debug|Win32">\r
-      <Configuration>Debug</Configuration>\r
-      <Platform>Win32</Platform>\r
-    </ProjectConfiguration>\r
-    <ProjectConfiguration Include="Debug|x64">\r
-      <Configuration>Debug</Configuration>\r
-      <Platform>x64</Platform>\r
-    </ProjectConfiguration>\r
-    <ProjectConfiguration Include="Release|Win32">\r
-      <Configuration>Release</Configuration>\r
-      <Platform>Win32</Platform>\r
-    </ProjectConfiguration>\r
-    <ProjectConfiguration Include="Release|x64">\r
-      <Configuration>Release</Configuration>\r
-      <Platform>x64</Platform>\r
-    </ProjectConfiguration>\r
-  </ItemGroup>\r
-  <PropertyGroup Label="Globals">\r
-    <ProjectGuid>{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}</ProjectGuid>\r
-    <RootNamespace>libEGL</RootNamespace>\r
-    <Keyword>Win32Proj</Keyword>\r
-  </PropertyGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
-    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-    <WholeProgramOptimization>true</WholeProgramOptimization>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
-    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
-    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-    <WholeProgramOptimization>true</WholeProgramOptimization>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
-    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-  </PropertyGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
-  <ImportGroup Label="ExtensionSettings">\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-  </ImportGroup>\r
-  <PropertyGroup Label="UserMacros" />\r
-  <PropertyGroup>\r
-    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\r
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>\r
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>\r
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>\r
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>\r
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>\r
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>\r
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>\r
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>\r
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>\r
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>\r
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>\r
-    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>\r
-    <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LibraryPath)</LibraryPath>\r
-    <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(DXSDK_DIR)\lib\x86;$(LibraryPath)</LibraryPath>\r
-    <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LibraryPath)</LibraryPath>\r
-    <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(LibraryPath)</LibraryPath>\r
-    <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(DXSDK_DIR)\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>\r
-  </PropertyGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
-    <ClCompile>\r
-      <Optimization>Disabled</Optimization>\r
-      <AdditionalIncludeDirectories>$(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <MinimalRebuild>true</MinimalRebuild>\r
-      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
-      <PrecompiledHeader>\r
-      </PrecompiledHeader>\r
-      <WarningLevel>Level4</WarningLevel>\r
-      <TreatWarningAsError>true</TreatWarningAsError>\r
-      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r
-      <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
-    </ClCompile>\r
-    <Link>\r
-      <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
-      <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>\r
-      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r
-      <GenerateDebugInformation>true</GenerateDebugInformation>\r
-      <SubSystem>Windows</SubSystem>\r
-      <DataExecutionPrevention>\r
-      </DataExecutionPrevention>\r
-      <TargetMachine>MachineX86</TargetMachine>\r
-    </Link>\r
-    <PostBuildEvent>\r
-      <Command>%40echo on\r
-mkdir "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-%40echo off\r
-</Command>\r
-    </PostBuildEvent>\r
-  </ItemDefinitionGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
-    <ClCompile>\r
-      <Optimization>MaxSpeed</Optimization>\r
-      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r
-      <AdditionalIncludeDirectories>$(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>ANGLE_DISABLE_TRACE;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
-      <PrecompiledHeader>\r
-      </PrecompiledHeader>\r
-      <WarningLevel>Level4</WarningLevel>\r
-      <TreatWarningAsError>true</TreatWarningAsError>\r
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
-      <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
-    </ClCompile>\r
-    <Link>\r
-      <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
-      <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>\r
-      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r
-      <GenerateDebugInformation>true</GenerateDebugInformation>\r
-      <SubSystem>Windows</SubSystem>\r
-      <OptimizeReferences>true</OptimizeReferences>\r
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
-      <DataExecutionPrevention>\r
-      </DataExecutionPrevention>\r
-      <TargetMachine>MachineX86</TargetMachine>\r
-    </Link>\r
-    <PostBuildEvent>\r
-      <Command>%40echo on\r
-mkdir "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-%40echo off\r
-</Command>\r
-    </PostBuildEvent>\r
-  </ItemDefinitionGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
-    <Midl>\r
-      <TargetEnvironment>X64</TargetEnvironment>\r
-    </Midl>\r
-    <ClCompile>\r
-      <Optimization>Disabled</Optimization>\r
-      <AdditionalIncludeDirectories>$(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <MinimalRebuild>true</MinimalRebuild>\r
-      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
-      <PrecompiledHeader>\r
-      </PrecompiledHeader>\r
-      <WarningLevel>Level4</WarningLevel>\r
-      <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
-      <TreatWarningAsError>true</TreatWarningAsError>\r
-    </ClCompile>\r
-    <Link>\r
-      <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
-      <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>\r
-      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r
-      <GenerateDebugInformation>true</GenerateDebugInformation>\r
-      <SubSystem>Windows</SubSystem>\r
-      <DataExecutionPrevention>\r
-      </DataExecutionPrevention>\r
-      <TargetMachine>MachineX64</TargetMachine>\r
-    </Link>\r
-    <PostBuildEvent>\r
-      <Command>%40echo on\r
-mkdir "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-%40echo off\r
-</Command>\r
-    </PostBuildEvent>\r
-  </ItemDefinitionGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
-    <Midl>\r
-      <TargetEnvironment>X64</TargetEnvironment>\r
-    </Midl>\r
-    <ClCompile>\r
-      <Optimization>MaxSpeed</Optimization>\r
-      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\r
-      <AdditionalIncludeDirectories>$(ProjectDir)/..; $(ProjectDir)/../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
-      <PrecompiledHeader>\r
-      </PrecompiledHeader>\r
-      <WarningLevel>Level4</WarningLevel>\r
-      <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
-      <TreatWarningAsError>true</TreatWarningAsError>\r
-    </ClCompile>\r
-    <Link>\r
-      <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
-      <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>\r
-      <DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>\r
-      <GenerateDebugInformation>true</GenerateDebugInformation>\r
-      <SubSystem>Windows</SubSystem>\r
-      <OptimizeReferences>true</OptimizeReferences>\r
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
-      <DataExecutionPrevention>\r
-      </DataExecutionPrevention>\r
-      <TargetMachine>MachineX64</TargetMachine>\r
-    </Link>\r
-    <PostBuildEvent>\r
-      <Command>%40echo on\r
-mkdir "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"\r
-%40echo off\r
-</Command>\r
-    </PostBuildEvent>\r
-  </ItemDefinitionGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="Config.cpp" />\r
-    <ClCompile Include="..\Common\debug.cpp" />\r
-    <ClCompile Include="Display.cpp" />\r
-    <ClCompile Include="libEGL.cpp" />\r
-    <ClCompile Include="main.cpp" />\r
-    <ClCompile Include="Surface.cpp" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="Config.h" />\r
-    <ClInclude Include="Display.h" />\r
-    <ClInclude Include="..\..\include\EGL\egl.h" />\r
-    <ClInclude Include="..\..\include\EGL\eglext.h" />\r
-    <ClInclude Include="..\..\include\EGL\eglplatform.h" />\r
-    <ClInclude Include="main.h" />\r
-    <ClInclude Include="resource.h" />\r
-    <ClInclude Include="Surface.h" />\r
-    <ClInclude Include="..\common\version.h" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <None Include="libEGL.def" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ResourceCompile Include="libEGL.rc" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ProjectReference Include="..\libGLESv2\libGLESv2.vcxproj">\r
-      <Project>{b5871a7a-968c-42e3-a33b-981e6f448e78}</Project>\r
-    </ProjectReference>\r
-  </ItemGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
-  <ImportGroup Label="ExtensionTargets">\r
-  </ImportGroup>\r
-</Project>
\ No newline at end of file
diff --git a/Source/ThirdParty/ANGLE/src/libEGL/libEGL.vcxproj.filters b/Source/ThirdParty/ANGLE/src/libEGL/libEGL.vcxproj.filters
deleted file mode 100644 (file)
index 860e169..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <ItemGroup>\r
-    <Filter Include="Source Files">\r
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
-    </Filter>\r
-    <Filter Include="Header Files">\r
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
-    </Filter>\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="Config.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="..\Common\debug.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="Display.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="libEGL.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="main.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="Surface.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="Config.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="Display.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="..\..\include\EGL\egl.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="..\..\include\EGL\eglext.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="..\..\include\EGL\eglplatform.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="main.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="resource.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="Surface.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="..\common\version.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ResourceCompile Include="libEGL.rc" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <None Include="libEGL.def" />\r
-  </ItemGroup>\r
-</Project>
\ No newline at end of file
index e5ddf93..46db788 100644 (file)
@@ -112,7 +112,7 @@ void InfoLog::append(const char *format, ...)
     else
     {
         size_t currentlogLength = strlen(mInfoLog);
-        size_t newInfoLogLength = currentlogLength + infoLength + 2; 
+        size_t newInfoLogLength = currentlogLength + infoLength + 2;
         char *newLog = new char[newInfoLogLength];
         strncpy(newLog, mInfoLog, newInfoLogLength);
         newLog[newInfoLogLength - 1] = '\0';
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/constants.h b/Source/ThirdParty/ANGLE/src/libGLESv2/constants.h
new file mode 100644 (file)
index 0000000..734cbc4
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// Copyright (c) 2013 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.
+//
+
+// Contants.h: Defines some implementation specific and gl constants
+
+#ifndef LIBGLESV2_CONSTANTS_H_
+#define LIBGLESV2_CONSTANTS_H_
+
+namespace gl
+{
+
+enum
+{
+    MAX_VERTEX_ATTRIBS = 16,
+    MAX_TEXTURE_IMAGE_UNITS = 16,
+
+    // Implementation upper limits, real maximums depend on the hardware
+    IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 16,
+    IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS,    
+
+    IMPLEMENTATION_MAX_VARYING_VECTORS = 32,
+    IMPLEMENTATION_MAX_DRAW_BUFFERS = 8,
+
+    IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS = 16,
+    IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS = 16,
+    IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS = IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS +
+                                                         IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS,
+
+    IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS = 4,
+};
+
+const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;
+const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;
+const float ALIASED_POINT_SIZE_RANGE_MIN = 1.0f;
+
+}
+
+#endif // LIBGLESV2_CONSTANTS_H_
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h b/Source/ThirdParty/ANGLE/src/libGLESv2/mathutil.h
deleted file mode 100644 (file)
index f902131..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-//
-// Copyright (c) 2002-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.
-//
-
-// mathutil.h: Math and bit manipulation functions.
-
-#ifndef LIBGLESV2_MATHUTIL_H_
-#define LIBGLESV2_MATHUTIL_H_
-
-#include <intrin.h>
-
-#include "common/debug.h"
-
-namespace gl
-{
-struct Vector4
-{
-    Vector4() {}
-    Vector4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
-
-    float x;
-    float y;
-    float z;
-    float w;
-};
-
-inline bool isPow2(int x)
-{
-    return (x & (x - 1)) == 0 && (x != 0);
-}
-
-inline int log2(int x)
-{
-    int r = 0;
-    while ((x >> r) > 1) r++;
-    return r;
-}
-
-inline unsigned int ceilPow2(unsigned int x)
-{
-    if (x != 0) x--;
-    x |= x >> 1;
-    x |= x >> 2;
-    x |= x >> 4;
-    x |= x >> 8;
-    x |= x >> 16;
-    x++;
-
-    return x;
-}
-
-template<typename T, typename MIN, typename MAX>
-inline T clamp(T x, MIN min, MAX max)
-{
-    // Since NaNs fail all comparison tests, a NaN value will default to min
-    return x > min ? (x > max ? max : x) : min;
-}
-
-inline float clamp01(float x)
-{
-    return clamp(x, 0.0f, 1.0f);
-}
-
-template<const int n>
-inline unsigned int unorm(float x)
-{
-    const unsigned int max = 0xFFFFFFFF >> (32 - n);
-
-    if (x > 1)
-    {
-        return max;
-    }
-    else if (x < 0)
-    {
-        return 0;
-    }
-    else
-    {
-        return (unsigned int)(max * x + 0.5f);
-    }
-}
-
-inline bool supportsSSE2()
-{
-    static bool checked = false;
-    static bool supports = false;
-
-    if (checked)
-    {
-        return supports;
-    }
-
-    int info[4];
-    __cpuid(info, 0);
-    
-    if (info[0] >= 1)
-    {
-        __cpuid(info, 1);
-
-        supports = (info[3] >> 26) & 1;
-    }
-
-    checked = true;
-
-    return supports;
-}
-
-inline unsigned short float32ToFloat16(float fp32)
-{
-    unsigned int fp32i = (unsigned int&)fp32;
-    unsigned int sign = (fp32i & 0x80000000) >> 16;
-    unsigned int abs = fp32i & 0x7FFFFFFF;
-
-    if(abs > 0x47FFEFFF)   // Infinity
-    {
-        return sign | 0x7FFF;
-    }
-    else if(abs < 0x38800000)   // Denormal
-    {
-        unsigned int mantissa = (abs & 0x007FFFFF) | 0x00800000;   
-        int e = 113 - (abs >> 23);
-
-        if(e < 24)
-        {
-            abs = mantissa >> e;
-        }
-        else
-        {
-            abs = 0;
-        }
-
-        return sign | (abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13;
-    }
-    else
-    {
-        return sign | (abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13;
-    }
-}
-
-float float16ToFloat32(unsigned short h);
-
-}
-
-namespace rx
-{
-
-struct Range
-{
-    Range() {}
-    Range(int lo, int hi) : start(lo), end(hi) { ASSERT(lo <= hi); }
-
-    int start;
-    int end;
-};
-
-}
-
-#endif   // LIBGLESV2_MATHUTIL_H_
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ImageSSE2.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/ImageSSE2.cpp
deleted file mode 100644 (file)
index b2a90ca..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "precompiled.h"
-//
-// Copyright (c) 2002-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.
-//
-
-// ImageSSE2.cpp: Implements SSE2-based functions of rx::Image class. It's
-// in a separated file for GCC, which can enable SSE usage only per-file,
-// not for code blocks that use SSE2 explicitly.
-
-#include "libGLESv2/Texture.h"
-#include "libGLESv2/renderer/Image.h"
-
-namespace rx
-{
-
-void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height,
-                                        int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned int *source = NULL;
-    unsigned int *dest = NULL;
-    __m128i brMask = _mm_set1_epi32(0x00ff00ff);
-
-    for (int y = 0; y < height; y++)
-    {
-        source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch);
-        dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputPitch);
-        int x = 0;
-
-        // Make output writes aligned
-        for (x = 0; ((reinterpret_cast<intptr_t>(&dest[x]) & 15) != 0) && x < width; x++)
-        {
-            unsigned int rgba = source[x];
-            dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
-        }
-
-        for (; x + 3 < width; x += 4)
-        {
-            __m128i sourceData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&source[x]));
-            // Mask out g and a, which don't change
-            __m128i gaComponents = _mm_andnot_si128(brMask, sourceData);
-            // Mask out b and r
-            __m128i brComponents = _mm_and_si128(sourceData, brMask);
-            // Swap b and r
-            __m128i brSwapped = _mm_shufflehi_epi16(_mm_shufflelo_epi16(brComponents, _MM_SHUFFLE(2, 3, 0, 1)), _MM_SHUFFLE(2, 3, 0, 1));
-            __m128i result = _mm_or_si128(gaComponents, brSwapped);
-            _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), result);
-        }
-
-        // Perform leftover writes
-        for (; x < width; x++)
-        {
-            unsigned int rgba = source[x];
-            dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
-        }
-    }
-}
-
-void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height,
-                                    int inputPitch, const void *input, size_t outputPitch, void *output)
-{
-    const unsigned char *source = NULL;
-    unsigned int *dest = NULL;
-    __m128i zeroWide = _mm_setzero_si128();
-
-    for (int y = 0; y < height; y++)
-    {
-        source = static_cast<const unsigned char*>(input) + y * inputPitch;
-        dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputPitch);
-
-        int x;
-        // Make output writes aligned
-        for (x = 0; ((reinterpret_cast<intptr_t>(&dest[x]) & 0xF) != 0 && x < width); x++)
-        {
-            dest[x] = static_cast<unsigned int>(source[x]) << 24;
-        }
-
-        for (; x + 7 < width; x += 8)
-        {
-            __m128i sourceData = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(&source[x]));
-            // Interleave each byte to 16bit, make the lower byte to zero
-            sourceData = _mm_unpacklo_epi8(zeroWide, sourceData);
-            // Interleave each 16bit to 32bit, make the lower 16bit to zero
-            __m128i lo = _mm_unpacklo_epi16(zeroWide, sourceData);
-            __m128i hi = _mm_unpackhi_epi16(zeroWide, sourceData);
-
-            _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), lo);
-            _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x + 4]), hi);
-        }
-
-        // Handle the remainder
-        for (; x < width; x++)
-        {
-            dest[x] = static_cast<unsigned int>(source[x]) << 24;
-        }
-    }
-}
-
-}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Blit11.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Blit11.cpp
new file mode 100644 (file)
index 0000000..9a41713
--- /dev/null
@@ -0,0 +1,1040 @@
+#include "precompiled.h"
+//
+// Copyright (c) 2013 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.
+//
+
+// Blit11.cpp: Texture copy utility class.
+
+#include "libGLESv2/main.h"
+#include "libGLESv2/formatutils.h"
+#include "libGLESv2/renderer/d3d11/Blit11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/formatutils11.h"
+
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough2d11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughdepth2d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba2di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb2di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg2di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr2di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum2d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha2d11ps.h"
+
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthrough3d11gs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgba3di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrgb3di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughrg3di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3dui11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughr3di11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlum3d11ps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/passthroughlumalpha3d11ps.h"
+
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2dps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2dps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2dps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlef3dps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlei3dps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzleui3dps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlef2darrayps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzlei2darrayps.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/swizzleui2darrayps.h"
+
+namespace rx
+{
+
+static DXGI_FORMAT GetTextureFormat(ID3D11Resource *resource)
+{
+    ID3D11Texture2D *texture = d3d11::DynamicCastComObject<ID3D11Texture2D>(resource);
+    if (!texture)
+    {
+        return DXGI_FORMAT_UNKNOWN;
+    }
+
+    D3D11_TEXTURE2D_DESC desc;
+    texture->GetDesc(&desc);
+
+    SafeRelease(texture);
+
+    return desc.Format;
+}
+
+static ID3D11Resource *CreateStagingTexture(ID3D11Device *device, ID3D11DeviceContext *context,
+                                            ID3D11Resource *source, unsigned int subresource,
+                                            const gl::Extents &size, unsigned int cpuAccessFlags)
+{
+    D3D11_TEXTURE2D_DESC stagingDesc;
+    stagingDesc.Width = size.width;
+    stagingDesc.Height = size.height;
+    stagingDesc.MipLevels = 1;
+    stagingDesc.ArraySize = 1;
+    stagingDesc.Format = GetTextureFormat(source);
+    stagingDesc.SampleDesc.Count = 1;
+    stagingDesc.SampleDesc.Quality = 0;
+    stagingDesc.Usage = D3D11_USAGE_STAGING;
+    stagingDesc.CPUAccessFlags = cpuAccessFlags;
+    stagingDesc.MiscFlags = 0;
+    stagingDesc.BindFlags = 0;
+
+    ID3D11Texture2D *stagingTexture = NULL;
+    HRESULT result = device->CreateTexture2D(&stagingDesc, NULL, &stagingTexture);
+    if (FAILED(result))
+    {
+        ERR("Failed to create staging texture for depth stencil blit. HRESULT: 0x%X.", result);
+        return NULL;
+    }
+
+    context->CopySubresourceRegion(stagingTexture, 0, 0, 0, 0, source, subresource, NULL);
+
+    return stagingTexture;
+}
+
+inline static void GenerateVertexCoords(const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                                        const gl::Box &destArea, const gl::Extents &destSize,
+                                        float *x1, float *y1, float *x2, float *y2,
+                                        float *u1, float *v1, float *u2, float *v2)
+{
+    *x1 = (destArea.x / float(destSize.width)) * 2.0f - 1.0f;
+    *y1 = ((destSize.height - destArea.y - destArea.height) / float(destSize.height)) * 2.0f - 1.0f;
+    *x2 = ((destArea.x + destArea.width) / float(destSize.width)) * 2.0f - 1.0f;
+    *y2 = ((destSize.height - destArea.y) / float(destSize.height)) * 2.0f - 1.0f;
+
+    *u1 = sourceArea.x / float(sourceSize.width);
+    *v1 = sourceArea.y / float(sourceSize.height);
+    *u2 = (sourceArea.x + sourceArea.width) / float(sourceSize.width);
+    *v2 = (sourceArea.y + sourceArea.height) / float(sourceSize.height);
+}
+
+static void Write2DVertices(const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                            const gl::Box &destArea, const gl::Extents &destSize,
+                            void *outVertices, unsigned int *outStride, unsigned int *outVertexCount,
+                            D3D11_PRIMITIVE_TOPOLOGY *outTopology)
+{
+    float x1, y1, x2, y2, u1, v1, u2, v2;
+    GenerateVertexCoords(sourceArea, sourceSize, destArea, destSize, &x1, &y1, &x2, &y2, &u1, &v1, &u2, &v2);
+
+    d3d11::PositionTexCoordVertex *vertices = static_cast<d3d11::PositionTexCoordVertex*>(outVertices);
+
+    d3d11::SetPositionTexCoordVertex(&vertices[0], x1, y1, u1, v2);
+    d3d11::SetPositionTexCoordVertex(&vertices[1], x1, y2, u1, v1);
+    d3d11::SetPositionTexCoordVertex(&vertices[2], x2, y1, u2, v2);
+    d3d11::SetPositionTexCoordVertex(&vertices[3], x2, y2, u2, v1);
+
+    *outStride = sizeof(d3d11::PositionTexCoordVertex);
+    *outVertexCount = 4;
+    *outTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
+}
+
+static void Write3DVertices(const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                            const gl::Box &destArea, const gl::Extents &destSize,
+                            void *outVertices, unsigned int *outStride, unsigned int *outVertexCount,
+                            D3D11_PRIMITIVE_TOPOLOGY *outTopology)
+{
+    ASSERT(sourceSize.depth > 0 && destSize.depth > 0);
+
+    float x1, y1, x2, y2, u1, v1, u2, v2;
+    GenerateVertexCoords(sourceArea, sourceSize, destArea, destSize, &x1, &y1, &x2, &y2, &u1, &v1, &u2, &v2);
+
+    d3d11::PositionLayerTexCoord3DVertex *vertices = static_cast<d3d11::PositionLayerTexCoord3DVertex*>(outVertices);
+
+    for (int i = 0; i < destSize.depth; i++)
+    {
+        float readDepth = (float)i / std::max(destSize.depth - 1, 1);
+
+        d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 0], x1, y1, i, u1, v2, readDepth);
+        d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 1], x1, y2, i, u1, v1, readDepth);
+        d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 2], x2, y1, i, u2, v2, readDepth);
+
+        d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 3], x1, y2, i, u1, v1, readDepth);
+        d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 4], x2, y2, i, u2, v1, readDepth);
+        d3d11::SetPositionLayerTexCoord3DVertex(&vertices[i * 6 + 5], x2, y1, i, u2, v2, readDepth);
+    }
+
+    *outStride = sizeof(d3d11::PositionLayerTexCoord3DVertex);
+    *outVertexCount = destSize.depth * 6;
+    *outTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
+}
+
+Blit11::Blit11(rx::Renderer11 *renderer)
+    : mRenderer(renderer), mBlitShaderMap(compareBlitParameters), mSwizzleShaderMap(compareSwizzleParameters),
+      mVertexBuffer(NULL), mPointSampler(NULL), mLinearSampler(NULL), mScissorEnabledRasterizerState(NULL),
+      mScissorDisabledRasterizerState(NULL), mDepthStencilState(NULL),
+      mQuad2DIL(NULL), mQuad2DVS(NULL), mDepthPS(NULL),
+      mQuad3DIL(NULL), mQuad3DVS(NULL), mQuad3DGS(NULL),
+      mSwizzleCB(NULL)
+{
+    HRESULT result;
+    ID3D11Device *device = mRenderer->getDevice();
+
+    D3D11_BUFFER_DESC vbDesc;
+    vbDesc.ByteWidth = std::max(sizeof(d3d11::PositionLayerTexCoord3DVertex), sizeof(d3d11::PositionTexCoordVertex)) *
+                       6 * renderer->getMaxTextureDepth();
+    vbDesc.Usage = D3D11_USAGE_DYNAMIC;
+    vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
+    vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    vbDesc.MiscFlags = 0;
+    vbDesc.StructureByteStride = 0;
+
+    result = device->CreateBuffer(&vbDesc, NULL, &mVertexBuffer);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mVertexBuffer, "Blit11 vertex buffer");
+
+    D3D11_SAMPLER_DESC pointSamplerDesc;
+    pointSamplerDesc.Filter = D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR;
+    pointSamplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
+    pointSamplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
+    pointSamplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
+    pointSamplerDesc.MipLODBias = 0.0f;
+    pointSamplerDesc.MaxAnisotropy = 0;
+    pointSamplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
+    pointSamplerDesc.BorderColor[0] = 0.0f;
+    pointSamplerDesc.BorderColor[1] = 0.0f;
+    pointSamplerDesc.BorderColor[2] = 0.0f;
+    pointSamplerDesc.BorderColor[3] = 0.0f;
+    pointSamplerDesc.MinLOD = 0.0f;
+    pointSamplerDesc.MaxLOD = 0.0f;
+
+    result = device->CreateSamplerState(&pointSamplerDesc, &mPointSampler);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mPointSampler, "Blit11 point sampler");
+
+    D3D11_SAMPLER_DESC linearSamplerDesc;
+    linearSamplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
+    linearSamplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
+    linearSamplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
+    linearSamplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
+    linearSamplerDesc.MipLODBias = 0.0f;
+    linearSamplerDesc.MaxAnisotropy = 0;
+    linearSamplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
+    linearSamplerDesc.BorderColor[0] = 0.0f;
+    linearSamplerDesc.BorderColor[1] = 0.0f;
+    linearSamplerDesc.BorderColor[2] = 0.0f;
+    linearSamplerDesc.BorderColor[3] = 0.0f;
+    linearSamplerDesc.MinLOD = 0.0f;
+    linearSamplerDesc.MaxLOD = 0.0f;
+
+    result = device->CreateSamplerState(&linearSamplerDesc, &mLinearSampler);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mLinearSampler, "Blit11 linear sampler");
+
+    // Use a rasterizer state that will not cull so that inverted quads will not be culled
+    D3D11_RASTERIZER_DESC rasterDesc;
+    rasterDesc.FillMode = D3D11_FILL_SOLID;
+    rasterDesc.CullMode = D3D11_CULL_NONE;
+    rasterDesc.FrontCounterClockwise = FALSE;
+    rasterDesc.DepthBias = 0;
+    rasterDesc.SlopeScaledDepthBias = 0.0f;
+    rasterDesc.DepthBiasClamp = 0.0f;
+    rasterDesc.DepthClipEnable = TRUE;
+    rasterDesc.MultisampleEnable = FALSE;
+    rasterDesc.AntialiasedLineEnable = FALSE;
+
+    rasterDesc.ScissorEnable = TRUE;
+    result = device->CreateRasterizerState(&rasterDesc, &mScissorEnabledRasterizerState);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mScissorEnabledRasterizerState, "Blit11 scissoring rasterizer state");
+
+    rasterDesc.ScissorEnable = FALSE;
+    result = device->CreateRasterizerState(&rasterDesc, &mScissorDisabledRasterizerState);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mScissorDisabledRasterizerState, "Blit11 no scissoring rasterizer state");
+
+    D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
+    depthStencilDesc.DepthEnable = true;
+    depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
+    depthStencilDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
+    depthStencilDesc.StencilEnable = FALSE;
+    depthStencilDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
+    depthStencilDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
+    depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+    depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+
+    result = device->CreateDepthStencilState(&depthStencilDesc, &mDepthStencilState);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mDepthStencilState, "Blit11 depth stencil state");
+
+    D3D11_INPUT_ELEMENT_DESC quad2DLayout[] =
+    {
+        { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+        { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+    };
+
+    result = device->CreateInputLayout(quad2DLayout, ArraySize(quad2DLayout), g_VS_Passthrough2D, ArraySize(g_VS_Passthrough2D), &mQuad2DIL);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mQuad2DIL, "Blit11 2D input layout");
+
+    result = device->CreateVertexShader(g_VS_Passthrough2D, ArraySize(g_VS_Passthrough2D), NULL, &mQuad2DVS);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mQuad2DVS, "Blit11 2D vertex shader");
+
+    result = device->CreatePixelShader(g_PS_PassthroughDepth2D, ArraySize(g_PS_PassthroughDepth2D), NULL, &mDepthPS);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mDepthPS, "Blit11 2D depth pixel shader");
+
+    D3D11_INPUT_ELEMENT_DESC quad3DLayout[] =
+    {
+        { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT,    0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+        { "LAYER",    0, DXGI_FORMAT_R32_UINT,        0,  8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+        { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+    };
+
+    result = device->CreateInputLayout(quad3DLayout, ArraySize(quad3DLayout), g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), &mQuad3DIL);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mQuad3DIL, "Blit11 3D input layout");
+
+    result = device->CreateVertexShader(g_VS_Passthrough3D, ArraySize(g_VS_Passthrough3D), NULL, &mQuad3DVS);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mQuad3DVS, "Blit11 3D vertex shader");
+
+    result = device->CreateGeometryShader(g_GS_Passthrough3D, ArraySize(g_GS_Passthrough3D), NULL, &mQuad3DGS);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mQuad3DGS, "Renderer11 copy 3D texture geometry shader");
+
+    buildShaderMap();
+
+    D3D11_BUFFER_DESC swizzleBufferDesc;
+    swizzleBufferDesc.ByteWidth = sizeof(unsigned int) * 4;
+    swizzleBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
+    swizzleBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+    swizzleBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    swizzleBufferDesc.MiscFlags = 0;
+    swizzleBufferDesc.StructureByteStride = 0;
+
+    result = device->CreateBuffer(&swizzleBufferDesc, NULL, &mSwizzleCB);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mSwizzleCB, "Blit11 swizzle constant buffer");
+}
+
+Blit11::~Blit11()
+{
+    SafeRelease(mVertexBuffer);
+    SafeRelease(mPointSampler);
+    SafeRelease(mLinearSampler);
+    SafeRelease(mScissorEnabledRasterizerState);
+    SafeRelease(mScissorDisabledRasterizerState);
+    SafeRelease(mDepthStencilState);
+
+    SafeRelease(mQuad2DIL);
+    SafeRelease(mQuad2DVS);
+    SafeRelease(mDepthPS);
+
+    SafeRelease(mQuad3DIL);
+    SafeRelease(mQuad3DVS);
+    SafeRelease(mQuad3DGS);
+
+    SafeRelease(mSwizzleCB);
+
+    clearShaderMap();
+}
+
+static inline unsigned int GetSwizzleIndex(GLenum swizzle)
+{
+    unsigned int colorIndex = 0;
+
+    switch (swizzle)
+    {
+      case GL_RED:   colorIndex = 0; break;
+      case GL_GREEN: colorIndex = 1; break;
+      case GL_BLUE:  colorIndex = 2; break;
+      case GL_ALPHA: colorIndex = 3; break;
+      case GL_ZERO:  colorIndex = 4; break;
+      case GL_ONE:   colorIndex = 5; break;
+      default:       UNREACHABLE();  break;
+    }
+
+    return colorIndex;
+}
+
+bool Blit11::swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTargetView *dest, const gl::Extents &size,
+                            GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha)
+{
+    HRESULT result;
+    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+    D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc;
+    source->GetDesc(&sourceSRVDesc);
+    GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format, mRenderer->getCurrentClientVersion());
+
+    GLenum shaderType = GL_NONE;
+    switch (gl::GetComponentType(sourceInternalFormat, mRenderer->getCurrentClientVersion()))
+    {
+      case GL_UNSIGNED_NORMALIZED:
+      case GL_SIGNED_NORMALIZED:
+      case GL_FLOAT:
+        shaderType = GL_FLOAT;
+        break;
+      case GL_INT:
+        shaderType = GL_INT;
+        break;
+      case GL_UNSIGNED_INT:
+        shaderType = GL_UNSIGNED_INT;
+        break;
+      default:
+        UNREACHABLE();
+        break;
+    }
+
+    SwizzleParameters parameters = { 0 };
+    parameters.mDestinationType = shaderType;
+    parameters.mViewDimension = sourceSRVDesc.ViewDimension;
+
+    SwizzleShaderMap::const_iterator i = mSwizzleShaderMap.find(parameters);
+    if (i == mSwizzleShaderMap.end())
+    {
+        UNREACHABLE();
+        return false;
+    }
+
+    const Shader &shader = i->second;
+
+    // Set vertices
+    D3D11_MAPPED_SUBRESOURCE mappedResource;
+    result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    if (FAILED(result))
+    {
+        ERR("Failed to map vertex buffer for texture swizzle, HRESULT: 0x%X.", result);
+        return false;
+    }
+
+    UINT stride = 0;
+    UINT startIdx = 0;
+    UINT drawCount = 0;
+    D3D11_PRIMITIVE_TOPOLOGY topology;
+
+    gl::Box area(0, 0, 0, size.width, size.height, size.depth);
+    shader.mVertexWriteFunction(area, size, area, size, mappedResource.pData, &stride, &drawCount, &topology);
+
+    deviceContext->Unmap(mVertexBuffer, 0);
+
+    // Set constant buffer
+    result = deviceContext->Map(mSwizzleCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    if (FAILED(result))
+    {
+        ERR("Failed to map constant buffer for texture swizzle, HRESULT: 0x%X.", result);
+        return false;
+    }
+
+    unsigned int *swizzleIndices = reinterpret_cast<unsigned int*>(mappedResource.pData);
+    swizzleIndices[0] = GetSwizzleIndex(swizzleRed);
+    swizzleIndices[1] = GetSwizzleIndex(swizzleGreen);
+    swizzleIndices[2] = GetSwizzleIndex(swizzleBlue);
+    swizzleIndices[3] = GetSwizzleIndex(swizzleAlpha);
+
+    deviceContext->Unmap(mSwizzleCB, 0);
+
+    // Apply vertex buffer
+    deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &startIdx);
+
+    // Apply constant buffer
+    deviceContext->PSSetConstantBuffers(0, 1, &mSwizzleCB);
+
+    // Apply state
+    deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
+    deviceContext->OMSetDepthStencilState(NULL, 0xFFFFFFFF);
+    deviceContext->RSSetState(mScissorDisabledRasterizerState);
+
+    // Apply shaders
+    deviceContext->IASetInputLayout(shader.mInputLayout);
+    deviceContext->IASetPrimitiveTopology(topology);
+    deviceContext->VSSetShader(shader.mVertexShader, NULL, 0);
+
+    deviceContext->PSSetShader(shader.mPixelShader, NULL, 0);
+    deviceContext->GSSetShader(shader.mGeometryShader, NULL, 0);
+
+    // Unset the currently bound shader resource to avoid conflicts
+    ID3D11ShaderResourceView *const nullSRV = NULL;
+    deviceContext->PSSetShaderResources(0, 1, &nullSRV);
+
+    // Apply render target
+    mRenderer->setOneTimeRenderTarget(dest);
+
+    // Set the viewport
+    D3D11_VIEWPORT viewport;
+    viewport.TopLeftX = 0;
+    viewport.TopLeftY = 0;
+    viewport.Width = size.width;
+    viewport.Height = size.height;
+    viewport.MinDepth = 0.0f;
+    viewport.MaxDepth = 1.0f;
+    deviceContext->RSSetViewports(1, &viewport);
+
+    // Apply textures
+    deviceContext->PSSetShaderResources(0, 1, &source);
+
+    // Apply samplers
+    deviceContext->PSSetSamplers(0, 1, &mPointSampler);
+
+    // Draw the quad
+    deviceContext->Draw(drawCount, 0);
+
+    // Unbind textures and render targets and vertex buffer
+    deviceContext->PSSetShaderResources(0, 1, &nullSRV);
+
+    mRenderer->unapplyRenderTargets();
+
+    UINT zero = 0;
+    ID3D11Buffer *const nullBuffer = NULL;
+    deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
+
+    mRenderer->markAllStateDirty();
+
+    return true;
+}
+
+bool Blit11::copyTexture(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                         ID3D11RenderTargetView *dest, const gl::Box &destArea, const gl::Extents &destSize,
+                         const gl::Rectangle *scissor, GLenum destFormat, GLenum filter)
+{
+    HRESULT result;
+    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+    // Determine if the source format is a signed integer format, the destFormat will already
+    // be GL_XXXX_INTEGER but it does not tell us if it is signed or unsigned.
+    D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc;
+    source->GetDesc(&sourceSRVDesc);
+    GLenum sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format, mRenderer->getCurrentClientVersion());
+
+    BlitParameters parameters = { 0 };
+    parameters.mDestinationFormat = destFormat;
+    parameters.mSignedInteger = gl::GetComponentType(sourceInternalFormat, mRenderer->getCurrentClientVersion()) == GL_INT;
+    parameters.m3DBlit = sourceArea.depth > 1;
+
+    BlitShaderMap::const_iterator i = mBlitShaderMap.find(parameters);
+    if (i == mBlitShaderMap.end())
+    {
+        UNREACHABLE();
+        return false;
+    }
+
+    const Shader& shader = i->second;
+
+    // Set vertices
+    D3D11_MAPPED_SUBRESOURCE mappedResource;
+    result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    if (FAILED(result))
+    {
+        ERR("Failed to map vertex buffer for texture copy, HRESULT: 0x%X.", result);
+        return false;
+    }
+
+    UINT stride = 0;
+    UINT startIdx = 0;
+    UINT drawCount = 0;
+    D3D11_PRIMITIVE_TOPOLOGY topology;
+
+    shader.mVertexWriteFunction(sourceArea, sourceSize, destArea, destSize, mappedResource.pData,
+                                &stride, &drawCount, &topology);
+
+    deviceContext->Unmap(mVertexBuffer, 0);
+
+    // Apply vertex buffer
+    deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &startIdx);
+
+    // Apply state
+    deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
+    deviceContext->OMSetDepthStencilState(NULL, 0xFFFFFFFF);
+
+    if (scissor)
+    {
+        D3D11_RECT scissorRect;
+        scissorRect.left = scissor->x;
+        scissorRect.right = scissor->x + scissor->width;
+        scissorRect.top = scissor->y;
+        scissorRect.bottom = scissor->y + scissor->height;
+
+        deviceContext->RSSetScissorRects(1, &scissorRect);
+        deviceContext->RSSetState(mScissorEnabledRasterizerState);
+    }
+    else
+    {
+        deviceContext->RSSetState(mScissorDisabledRasterizerState);
+    }
+
+    // Apply shaders
+    deviceContext->IASetInputLayout(shader.mInputLayout);
+    deviceContext->IASetPrimitiveTopology(topology);
+    deviceContext->VSSetShader(shader.mVertexShader, NULL, 0);
+
+    deviceContext->PSSetShader(shader.mPixelShader, NULL, 0);
+    deviceContext->GSSetShader(shader.mGeometryShader, NULL, 0);
+
+    // Unset the currently bound shader resource to avoid conflicts
+    ID3D11ShaderResourceView *const nullSRV = NULL;
+    deviceContext->PSSetShaderResources(0, 1, &nullSRV);
+
+    // Apply render target
+    mRenderer->setOneTimeRenderTarget(dest);
+
+    // Set the viewport
+    D3D11_VIEWPORT viewport;
+    viewport.TopLeftX = 0;
+    viewport.TopLeftY = 0;
+    viewport.Width = destSize.width;
+    viewport.Height = destSize.height;
+    viewport.MinDepth = 0.0f;
+    viewport.MaxDepth = 1.0f;
+    deviceContext->RSSetViewports(1, &viewport);
+
+    // Apply textures
+    deviceContext->PSSetShaderResources(0, 1, &source);
+
+    // Apply samplers
+    ID3D11SamplerState *sampler = NULL;
+    switch (filter)
+    {
+      case GL_NEAREST: sampler = mPointSampler;  break;
+      case GL_LINEAR:  sampler = mLinearSampler; break;
+      default:         UNREACHABLE(); return false;
+    }
+    deviceContext->PSSetSamplers(0, 1, &sampler);
+
+    // Draw the quad
+    deviceContext->Draw(drawCount, 0);
+
+    // Unbind textures and render targets and vertex buffer
+    deviceContext->PSSetShaderResources(0, 1, &nullSRV);
+
+    mRenderer->unapplyRenderTargets();
+
+    UINT zero = 0;
+    ID3D11Buffer *const nullBuffer = NULL;
+    deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
+
+    mRenderer->markAllStateDirty();
+
+    return true;
+}
+
+bool Blit11::copyStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                         ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
+                         const gl::Rectangle *scissor)
+{
+    return copyDepthStencil(source, sourceSubresource, sourceArea, sourceSize,
+                            dest, destSubresource, destArea, destSize,
+                            scissor, true);
+}
+
+bool Blit11::copyDepth(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                       ID3D11DepthStencilView *dest, const gl::Box &destArea, const gl::Extents &destSize,
+                       const gl::Rectangle *scissor)
+{
+    HRESULT result;
+    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+    // Set vertices
+    D3D11_MAPPED_SUBRESOURCE mappedResource;
+    result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    if (FAILED(result))
+    {
+        ERR("Failed to map vertex buffer for texture copy, HRESULT: 0x%X.", result);
+        return false;
+    }
+
+    UINT stride = 0;
+    UINT startIdx = 0;
+    UINT drawCount = 0;
+    D3D11_PRIMITIVE_TOPOLOGY topology;
+
+    Write2DVertices(sourceArea, sourceSize, destArea, destSize, mappedResource.pData,
+                    &stride, &drawCount, &topology);
+
+    deviceContext->Unmap(mVertexBuffer, 0);
+
+    // Apply vertex buffer
+    deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &startIdx);
+
+    // Apply state
+    deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
+    deviceContext->OMSetDepthStencilState(mDepthStencilState, 0xFFFFFFFF);
+
+    if (scissor)
+    {
+        D3D11_RECT scissorRect;
+        scissorRect.left = scissor->x;
+        scissorRect.right = scissor->x + scissor->width;
+        scissorRect.top = scissor->y;
+        scissorRect.bottom = scissor->y + scissor->height;
+
+        deviceContext->RSSetScissorRects(1, &scissorRect);
+        deviceContext->RSSetState(mScissorEnabledRasterizerState);
+    }
+    else
+    {
+        deviceContext->RSSetState(mScissorDisabledRasterizerState);
+    }
+
+    // Apply shaders
+    deviceContext->IASetInputLayout(mQuad2DIL);
+    deviceContext->IASetPrimitiveTopology(topology);
+    deviceContext->VSSetShader(mQuad2DVS, NULL, 0);
+
+    deviceContext->PSSetShader(mDepthPS, NULL, 0);
+    deviceContext->GSSetShader(NULL, NULL, 0);
+
+    // Unset the currently bound shader resource to avoid conflicts
+    ID3D11ShaderResourceView *const nullSRV = NULL;
+    deviceContext->PSSetShaderResources(0, 1, &nullSRV);
+
+    // Apply render target
+    deviceContext->OMSetRenderTargets(0, NULL, dest);
+
+    // Set the viewport
+    D3D11_VIEWPORT viewport;
+    viewport.TopLeftX = 0;
+    viewport.TopLeftY = 0;
+    viewport.Width = destSize.width;
+    viewport.Height = destSize.height;
+    viewport.MinDepth = 0.0f;
+    viewport.MaxDepth = 1.0f;
+    deviceContext->RSSetViewports(1, &viewport);
+
+    // Apply textures
+    deviceContext->PSSetShaderResources(0, 1, &source);
+
+    // Apply samplers
+    deviceContext->PSSetSamplers(0, 1, &mPointSampler);
+
+    // Draw the quad
+    deviceContext->Draw(drawCount, 0);
+
+    // Unbind textures and render targets and vertex buffer
+    deviceContext->PSSetShaderResources(0, 1, &nullSRV);
+
+    mRenderer->unapplyRenderTargets();
+
+    UINT zero = 0;
+    ID3D11Buffer *const nullBuffer = NULL;
+    deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
+
+    mRenderer->markAllStateDirty();
+
+    return true;
+}
+
+bool Blit11::copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                              ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
+                              const gl::Rectangle *scissor)
+{
+    return copyDepthStencil(source, sourceSubresource, sourceArea, sourceSize,
+                            dest, destSubresource, destArea, destSize,
+                            scissor, false);
+}
+
+bool Blit11::copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                              ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
+                              const gl::Rectangle *scissor, bool stencilOnly)
+{
+    ID3D11Device *device = mRenderer->getDevice();
+    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+    ID3D11Resource *sourceStaging = CreateStagingTexture(device, deviceContext, source, sourceSubresource, sourceSize, D3D11_CPU_ACCESS_READ);
+    // HACK: Create the destination staging buffer as a read/write texture so ID3D11DevicContext::UpdateSubresource can be called
+    //       using it's mapped data as a source
+    ID3D11Resource *destStaging = CreateStagingTexture(device, deviceContext, dest, destSubresource, destSize, D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE);
+
+    if (!sourceStaging || !destStaging)
+    {
+        SafeRelease(sourceStaging);
+        SafeRelease(destStaging);
+        return false;
+    }
+
+    DXGI_FORMAT format = GetTextureFormat(source);
+    ASSERT(format == GetTextureFormat(dest));
+
+    unsigned int pixelSize = d3d11::GetFormatPixelBytes(format);
+    unsigned int copyOffset = 0;
+    unsigned int copySize = pixelSize;
+    if (stencilOnly)
+    {
+        copyOffset = d3d11::GetStencilOffset(format) / 8;
+        copySize = d3d11::GetStencilBits(format) / 8;
+
+        // It would be expensive to have non-byte sized stencil sizes since it would
+        // require reading from the destination, currently there aren't any though.
+        ASSERT(d3d11::GetStencilBits(format)   % 8 == 0 &&
+               d3d11::GetStencilOffset(format) % 8 == 0);
+    }
+
+    D3D11_MAPPED_SUBRESOURCE sourceMapping, destMapping;
+    deviceContext->Map(sourceStaging, 0, D3D11_MAP_READ, 0, &sourceMapping);
+    deviceContext->Map(destStaging, 0, D3D11_MAP_WRITE, 0, &destMapping);
+
+    if (!sourceMapping.pData || !destMapping.pData)
+    {
+        if (!sourceMapping.pData)
+        {
+            deviceContext->Unmap(sourceStaging, 0);
+        }
+        if (!destMapping.pData)
+        {
+            deviceContext->Unmap(destStaging, 0);
+        }
+        SafeRelease(sourceStaging);
+        SafeRelease(destStaging);
+        return false;
+    }
+
+    gl::Rectangle clippedDestArea(destArea.x, destArea.y, destArea.width, destArea.height);
+
+    // Clip dest area to the destination size
+    gl::ClipRectangle(clippedDestArea, gl::Rectangle(0, 0, destSize.width, destSize.height), &clippedDestArea);
+
+    // Clip dest area to the scissor
+    if (scissor)
+    {
+        gl::ClipRectangle(clippedDestArea, *scissor, &clippedDestArea);
+    }
+
+    // Determine if entire rows can be copied at once instead of each individual pixel, requires that there is
+    // no out of bounds lookups required, the entire pixel is copied and no stretching
+    bool wholeRowCopy = sourceArea.width == clippedDestArea.width &&
+                        sourceArea.x >= 0 && sourceArea.x + sourceArea.width <= sourceSize.width &&
+                        copySize == pixelSize;
+
+    for (int y = clippedDestArea.y; y < clippedDestArea.y + clippedDestArea.height; y++)
+    {
+        float yPerc = static_cast<float>(y - destArea.y) / (destArea.height - 1);
+
+        // Interpolate using the original source rectangle to determine which row to sample from while clamping to the edges
+        unsigned int readRow = gl::clamp(sourceArea.y + floor(yPerc * (sourceArea.height - 1) + 0.5f), 0, sourceSize.height - 1);
+        unsigned int writeRow = y;
+
+        if (wholeRowCopy)
+        {
+            void *sourceRow = reinterpret_cast<char*>(sourceMapping.pData) +
+                              readRow * sourceMapping.RowPitch +
+                              sourceArea.x * pixelSize;
+
+            void *destRow = reinterpret_cast<char*>(destMapping.pData) +
+                            writeRow * destMapping.RowPitch +
+                            destArea.x * pixelSize;
+
+            memcpy(destRow, sourceRow, pixelSize * destArea.width);
+        }
+        else
+        {
+            for (int x = clippedDestArea.x; x < clippedDestArea.x + clippedDestArea.width; x++)
+            {
+                float xPerc = static_cast<float>(x - destArea.x) / (destArea.width - 1);
+
+                // Interpolate the original source rectangle to determine which column to sample from while clamping to the edges
+                unsigned int readColumn = gl::clamp(sourceArea.x + floor(xPerc * (sourceArea.width - 1) + 0.5f), 0, sourceSize.width - 1);
+                unsigned int writeColumn = x;
+
+                void *sourcePixel = reinterpret_cast<char*>(sourceMapping.pData) +
+                                    readRow * sourceMapping.RowPitch +
+                                    readColumn * pixelSize +
+                                    copyOffset;
+
+                void *destPixel = reinterpret_cast<char*>(destMapping.pData) +
+                                  writeRow * destMapping.RowPitch +
+                                  writeColumn * pixelSize +
+                                  copyOffset;
+
+                memcpy(destPixel, sourcePixel, copySize);
+            }
+        }
+    }
+
+    // HACK: Use ID3D11DevicContext::UpdateSubresource which causes an extra copy compared to ID3D11DevicContext::CopySubresourceRegion
+    //       according to MSDN.
+    deviceContext->UpdateSubresource(dest, destSubresource, NULL, destMapping.pData, destMapping.RowPitch, destMapping.DepthPitch);
+
+    deviceContext->Unmap(sourceStaging, 0);
+    deviceContext->Unmap(destStaging, 0);
+
+    // TODO: Determine why this call to ID3D11DevicContext::CopySubresourceRegion causes a TDR timeout on some
+    //       systems when called repeatedly.
+    // deviceContext->CopySubresourceRegion(dest, destSubresource, 0, 0, 0, destStaging, 0, NULL);
+
+    SafeRelease(sourceStaging);
+    SafeRelease(destStaging);
+
+    return true;
+}
+
+bool Blit11::compareBlitParameters(const Blit11::BlitParameters &a, const Blit11::BlitParameters &b)
+{
+    return memcmp(&a, &b, sizeof(Blit11::BlitParameters)) < 0;
+}
+
+bool Blit11::compareSwizzleParameters(const SwizzleParameters &a, const SwizzleParameters &b)
+{
+    return memcmp(&a, &b, sizeof(Blit11::SwizzleParameters)) < 0;
+}
+
+void Blit11::add2DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps)
+{
+    BlitParameters params = { 0 };
+    params.mDestinationFormat = destFormat;
+    params.mSignedInteger = signedInteger;
+    params.m3DBlit = false;
+
+    ASSERT(mBlitShaderMap.find(params) == mBlitShaderMap.end());
+    ASSERT(ps);
+
+    Shader shader;
+    shader.mVertexWriteFunction = Write2DVertices;
+    shader.mInputLayout = mQuad2DIL;
+    shader.mVertexShader = mQuad2DVS;
+    shader.mGeometryShader = NULL;
+    shader.mPixelShader = ps;
+
+    mBlitShaderMap[params] = shader;
+}
+
+void Blit11::add3DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps)
+{
+    BlitParameters params = { 0 };
+    params.mDestinationFormat = destFormat;
+    params.mSignedInteger = signedInteger;
+    params.m3DBlit = true;
+
+    ASSERT(mBlitShaderMap.find(params) == mBlitShaderMap.end());
+    ASSERT(ps);
+
+    Shader shader;
+    shader.mVertexWriteFunction = Write3DVertices;
+    shader.mInputLayout = mQuad3DIL;
+    shader.mVertexShader = mQuad3DVS;
+    shader.mGeometryShader = mQuad3DGS;
+    shader.mPixelShader = ps;
+
+    mBlitShaderMap[params] = shader;
+}
+
+void Blit11::addSwizzleShaderToMap(GLenum destType, D3D11_SRV_DIMENSION viewDimension, ID3D11PixelShader *ps)
+{
+    SwizzleParameters params = { 0 };
+    params.mDestinationType = destType;
+    params.mViewDimension = viewDimension;
+
+    ASSERT(mSwizzleShaderMap.find(params) == mSwizzleShaderMap.end());
+    ASSERT(ps);
+
+    Shader shader;
+    switch (viewDimension)
+    {
+      case D3D_SRV_DIMENSION_TEXTURE2D:
+        shader.mVertexWriteFunction = Write2DVertices;
+        shader.mInputLayout = mQuad2DIL;
+        shader.mVertexShader = mQuad2DVS;
+        shader.mGeometryShader = NULL;
+        break;
+
+      case D3D_SRV_DIMENSION_TEXTURE3D:
+      case D3D_SRV_DIMENSION_TEXTURE2DARRAY:
+      case D3D_SRV_DIMENSION_TEXTURECUBE:
+        shader.mVertexWriteFunction = Write3DVertices;
+        shader.mInputLayout = mQuad3DIL;
+        shader.mVertexShader = mQuad3DVS;
+        shader.mGeometryShader = mQuad3DGS;
+        break;
+
+      default:
+        UNREACHABLE();
+        break;
+    }
+    shader.mPixelShader = ps;
+
+    mSwizzleShaderMap[params] = shader;
+}
+
+void Blit11::buildShaderMap()
+{
+    ID3D11Device *device = mRenderer->getDevice();
+
+    add2DBlitShaderToMap(GL_RGBA,            false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D,     "Blit11 2D RGBA pixel shader"           ));
+    add2DBlitShaderToMap(GL_RGBA_INTEGER,    false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2DUI,   "Blit11 2D RGBA UI pixel shader"        ));
+    add2DBlitShaderToMap(GL_RGBA_INTEGER,    true,  d3d11::CompilePS(device, g_PS_PassthroughRGBA2DI,    "Blit11 2D RGBA I pixel shader"         ));
+    add2DBlitShaderToMap(GL_BGRA_EXT,        false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D,     "Blit11 2D BGRA pixel shader"           ));
+    add2DBlitShaderToMap(GL_RGB,             false, d3d11::CompilePS(device, g_PS_PassthroughRGB2D,      "Blit11 2D RGB pixel shader"            ));
+    add2DBlitShaderToMap(GL_RGB_INTEGER,     false, d3d11::CompilePS(device, g_PS_PassthroughRGB2DUI,    "Blit11 2D RGB UI pixel shader"         ));
+    add2DBlitShaderToMap(GL_RGB_INTEGER,     true,  d3d11::CompilePS(device, g_PS_PassthroughRGB2DI,     "Blit11 2D RGB I pixel shader"          ));
+    add2DBlitShaderToMap(GL_RG,              false, d3d11::CompilePS(device, g_PS_PassthroughRG2D,       "Blit11 2D RG pixel shader"             ));
+    add2DBlitShaderToMap(GL_RG_INTEGER,      false, d3d11::CompilePS(device, g_PS_PassthroughRG2DUI,     "Blit11 2D RG UI pixel shader"          ));
+    add2DBlitShaderToMap(GL_RG_INTEGER,      true,  d3d11::CompilePS(device, g_PS_PassthroughRG2DI,      "Blit11 2D RG I pixel shader"           ));
+    add2DBlitShaderToMap(GL_RED,             false, d3d11::CompilePS(device, g_PS_PassthroughR2D,        "Blit11 2D R pixel shader"              ));
+    add2DBlitShaderToMap(GL_RED_INTEGER,     false, d3d11::CompilePS(device, g_PS_PassthroughR2DUI,      "Blit11 2D R UI pixel shader"           ));
+    add2DBlitShaderToMap(GL_RED_INTEGER,     true,  d3d11::CompilePS(device, g_PS_PassthroughR2DI,       "Blit11 2D R I pixel shader"            ));
+    add2DBlitShaderToMap(GL_ALPHA,           false, d3d11::CompilePS(device, g_PS_PassthroughRGBA2D,     "Blit11 2D alpha pixel shader"          ));
+    add2DBlitShaderToMap(GL_LUMINANCE,       false, d3d11::CompilePS(device, g_PS_PassthroughLum2D,      "Blit11 2D lum pixel shader"            ));
+    add2DBlitShaderToMap(GL_LUMINANCE_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughLumAlpha2D, "Blit11 2D luminance alpha pixel shader"));
+
+    add3DBlitShaderToMap(GL_RGBA,            false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3D,     "Blit11 3D RGBA pixel shader"           ));
+    add3DBlitShaderToMap(GL_RGBA_INTEGER,    false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3DUI,   "Blit11 3D UI RGBA pixel shader"        ));
+    add3DBlitShaderToMap(GL_RGBA_INTEGER,    true,  d3d11::CompilePS(device, g_PS_PassthroughRGBA3DI,    "Blit11 3D I RGBA pixel shader"         ));
+    add3DBlitShaderToMap(GL_BGRA_EXT,        false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3D,     "Blit11 3D BGRA pixel shader"           ));
+    add3DBlitShaderToMap(GL_RGB,             false, d3d11::CompilePS(device, g_PS_PassthroughRGB3D,      "Blit11 3D RGB pixel shader"            ));
+    add3DBlitShaderToMap(GL_RGB_INTEGER,     false, d3d11::CompilePS(device, g_PS_PassthroughRGB3DUI,    "Blit11 3D RGB UI pixel shader"         ));
+    add3DBlitShaderToMap(GL_RGB_INTEGER,     true,  d3d11::CompilePS(device, g_PS_PassthroughRGB3DI,     "Blit11 3D RGB I pixel shader"          ));
+    add3DBlitShaderToMap(GL_RG,              false, d3d11::CompilePS(device, g_PS_PassthroughRG3D,       "Blit11 3D RG pixel shader"             ));
+    add3DBlitShaderToMap(GL_RG_INTEGER,      false, d3d11::CompilePS(device, g_PS_PassthroughRG3DUI,     "Blit11 3D RG UI pixel shader"          ));
+    add3DBlitShaderToMap(GL_RG_INTEGER,      true,  d3d11::CompilePS(device, g_PS_PassthroughRG3DI,      "Blit11 3D RG I pixel shader"           ));
+    add3DBlitShaderToMap(GL_RED,             false, d3d11::CompilePS(device, g_PS_PassthroughR3D,        "Blit11 3D R pixel shader"              ));
+    add3DBlitShaderToMap(GL_RED_INTEGER,     false, d3d11::CompilePS(device, g_PS_PassthroughR3DUI,      "Blit11 3D R UI pixel shader"           ));
+    add3DBlitShaderToMap(GL_RED_INTEGER,     true,  d3d11::CompilePS(device, g_PS_PassthroughR3DI,       "Blit11 3D R I pixel shader"            ));
+    add3DBlitShaderToMap(GL_ALPHA,           false, d3d11::CompilePS(device, g_PS_PassthroughRGBA3D,     "Blit11 3D alpha pixel shader"          ));
+    add3DBlitShaderToMap(GL_LUMINANCE,       false, d3d11::CompilePS(device, g_PS_PassthroughLum3D,      "Blit11 3D luminance pixel shader"      ));
+    add3DBlitShaderToMap(GL_LUMINANCE_ALPHA, false, d3d11::CompilePS(device, g_PS_PassthroughLumAlpha3D, "Blit11 3D luminance alpha pixel shader"));
+
+    addSwizzleShaderToMap(GL_FLOAT,        D3D_SRV_DIMENSION_TEXTURE2D,      d3d11::CompilePS(device, g_PS_SwizzleF2D,       "Blit11 2D F swizzle pixel shader" ));
+    addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURE2D,      d3d11::CompilePS(device, g_PS_SwizzleUI2D,      "Blit11 2D UI swizzle pixel shader"));
+    addSwizzleShaderToMap(GL_INT,          D3D_SRV_DIMENSION_TEXTURE2D,      d3d11::CompilePS(device, g_PS_SwizzleI2D,       "Blit11 2D I swizzle pixel shader" ));
+
+    addSwizzleShaderToMap(GL_FLOAT,        D3D_SRV_DIMENSION_TEXTURECUBE,    d3d11::CompilePS(device, g_PS_SwizzleF2DArray,  "Blit11 2D Cube F swizzle pixel shader" ));
+    addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURECUBE,    d3d11::CompilePS(device, g_PS_SwizzleUI2DArray, "Blit11 2D Cube UI swizzle pixel shader"));
+    addSwizzleShaderToMap(GL_INT,          D3D_SRV_DIMENSION_TEXTURECUBE,    d3d11::CompilePS(device, g_PS_SwizzleI2DArray,  "Blit11 2D Cube I swizzle pixel shader" ));
+
+    addSwizzleShaderToMap(GL_FLOAT,        D3D_SRV_DIMENSION_TEXTURE3D,      d3d11::CompilePS(device, g_PS_SwizzleF3D,       "Blit11 3D F swizzle pixel shader" ));
+    addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURE3D,      d3d11::CompilePS(device, g_PS_SwizzleUI3D,      "Blit11 3D UI swizzle pixel shader"));
+    addSwizzleShaderToMap(GL_INT,          D3D_SRV_DIMENSION_TEXTURE3D,      d3d11::CompilePS(device, g_PS_SwizzleI3D,       "Blit11 3D I swizzle pixel shader" ));
+
+    addSwizzleShaderToMap(GL_FLOAT,        D3D_SRV_DIMENSION_TEXTURE2DARRAY, d3d11::CompilePS(device, g_PS_SwizzleF2DArray,  "Blit11 2D Array F swizzle pixel shader" ));
+    addSwizzleShaderToMap(GL_UNSIGNED_INT, D3D_SRV_DIMENSION_TEXTURE2DARRAY, d3d11::CompilePS(device, g_PS_SwizzleUI2DArray, "Blit11 2D Array UI swizzle pixel shader"));
+    addSwizzleShaderToMap(GL_INT,          D3D_SRV_DIMENSION_TEXTURE2DARRAY, d3d11::CompilePS(device, g_PS_SwizzleI2DArray,  "Blit11 2D Array I swizzle pixel shader" ));
+}
+
+void Blit11::clearShaderMap()
+{
+    for (BlitShaderMap::iterator i = mBlitShaderMap.begin(); i != mBlitShaderMap.end(); ++i)
+    {
+        Shader &shader = i->second;
+        SafeRelease(shader.mPixelShader);
+    }
+    mBlitShaderMap.clear();
+
+    for (SwizzleShaderMap::iterator i = mSwizzleShaderMap.begin(); i != mSwizzleShaderMap.end(); ++i)
+    {
+        Shader &shader = i->second;
+        SafeRelease(shader.mPixelShader);
+    }
+    mSwizzleShaderMap.clear();
+}
+
+}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Blit11.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Blit11.h
new file mode 100644 (file)
index 0000000..fba89e2
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// Copyright (c) 2013 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.
+//
+
+// Blit11.cpp: Texture copy utility class.
+
+#ifndef LIBGLESV2_BLIT11_H_
+#define LIBGLESV2_BLIT11_H_
+
+#include "common/angleutils.h"
+#include "libGLESv2/angletypes.h"
+
+namespace rx
+{
+class Renderer11;
+
+enum Filter
+{
+    Point,
+    Linear,
+};
+
+class Blit11
+{
+  public:
+    explicit Blit11(Renderer11 *renderer);
+    ~Blit11();
+
+    bool swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTargetView *dest, const gl::Extents &size,
+                        GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
+
+    bool copyTexture(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                     ID3D11RenderTargetView *dest, const gl::Box &destArea, const gl::Extents &destSize,
+                     const gl::Rectangle *scissor, GLenum destFormat, GLenum filter);
+
+    bool copyStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                     ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
+                     const gl::Rectangle *scissor);
+
+    bool copyDepth(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                   ID3D11DepthStencilView *dest, const gl::Box &destArea, const gl::Extents &destSize,
+                   const gl::Rectangle *scissor);
+
+    bool copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                          ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
+                          const gl::Rectangle *scissor);
+
+  private:
+    rx::Renderer11 *mRenderer;
+
+    struct BlitParameters
+    {
+        GLenum mDestinationFormat;
+        bool mSignedInteger;
+        bool m3DBlit;
+    };
+
+    bool copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                          ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
+                          const gl::Rectangle *scissor, bool stencilOnly);
+
+    static bool compareBlitParameters(const BlitParameters &a, const BlitParameters &b);
+
+    typedef void (*WriteVertexFunction)(const gl::Box &sourceArea, const gl::Extents &sourceSize,
+                                        const gl::Box &destArea, const gl::Extents &destSize,
+                                        void *outVertices, unsigned int *outStride, unsigned int *outVertexCount,
+                                        D3D11_PRIMITIVE_TOPOLOGY *outTopology);
+
+    struct Shader
+    {
+        WriteVertexFunction mVertexWriteFunction;
+        ID3D11InputLayout *mInputLayout;
+        ID3D11VertexShader *mVertexShader;
+        ID3D11GeometryShader *mGeometryShader;
+        ID3D11PixelShader *mPixelShader;
+    };
+
+    typedef bool (*BlitParametersComparisonFunction)(const BlitParameters&, const BlitParameters &);
+    typedef std::map<BlitParameters, Shader, BlitParametersComparisonFunction> BlitShaderMap;
+    BlitShaderMap mBlitShaderMap;
+
+    void add2DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
+    void add3DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
+
+    struct SwizzleParameters
+    {
+        GLenum mDestinationType;
+        D3D11_SRV_DIMENSION mViewDimension;
+    };
+
+    static bool compareSwizzleParameters(const SwizzleParameters &a, const SwizzleParameters &b);
+
+    typedef bool (*SwizzleParametersComparisonFunction)(const SwizzleParameters&, const SwizzleParameters &);
+    typedef std::map<SwizzleParameters, Shader, SwizzleParametersComparisonFunction> SwizzleShaderMap;
+    SwizzleShaderMap mSwizzleShaderMap;
+
+    void addSwizzleShaderToMap(GLenum destType, D3D11_SRV_DIMENSION viewDimension, ID3D11PixelShader *ps);
+
+    void buildShaderMap();
+    void clearShaderMap();
+
+    ID3D11Buffer *mVertexBuffer;
+    ID3D11SamplerState *mPointSampler;
+    ID3D11SamplerState *mLinearSampler;
+    ID3D11RasterizerState *mScissorEnabledRasterizerState;
+    ID3D11RasterizerState *mScissorDisabledRasterizerState;
+    ID3D11DepthStencilState *mDepthStencilState;
+
+    ID3D11InputLayout *mQuad2DIL;
+    ID3D11VertexShader *mQuad2DVS;
+    ID3D11PixelShader *mDepthPS;
+
+    ID3D11InputLayout *mQuad3DIL;
+    ID3D11VertexShader *mQuad3DVS;
+    ID3D11GeometryShader *mQuad3DGS;
+
+    ID3D11Buffer *mSwizzleCB;
+
+    DISALLOW_COPY_AND_ASSIGN(Blit11);
+};
+
+}
+
+#endif   // LIBGLESV2_BLIT11_H_
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Clear11.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Clear11.cpp
new file mode 100644 (file)
index 0000000..c02cd9e
--- /dev/null
@@ -0,0 +1,557 @@
+#include "precompiled.h"
+//
+// Copyright (c) 2013 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.
+//
+
+// Clear11.cpp: Framebuffer clear utility class.
+
+#include "libGLESv2/renderer/d3d11/Clear11.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/RenderTarget11.h"
+
+#include "libGLESv2/formatutils.h"
+#include "libGLESv2/Framebuffer.h"
+#include "libGLESv2/Renderbuffer.h"
+
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearfloat11ps.h"
+
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearuint11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearuint11ps.h"
+
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearsint11vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/clearsint11ps.h"
+
+namespace rx
+{
+
+template <typename T>
+static void ApplyVertices(const gl::Extents &framebufferSize, const gl::Rectangle *scissor, const gl::Color<T> &color, float depth, void *buffer)
+{
+    d3d11::PositionDepthColorVertex<T> *vertices = reinterpret_cast<d3d11::PositionDepthColorVertex<T>*>(buffer);
+
+    float depthClear = gl::clamp01(depth);
+    float left = -1.0f;
+    float right = 1.0f;
+    float top = -1.0f;
+    float bottom = 1.0f;
+
+    // Clip the quad coordinates to the scissor if needed
+    if (scissor != NULL)
+    {
+        left = std::max(left, (scissor->x / float(framebufferSize.width)) * 2.0f - 1.0f);
+        right = std::min(right, ((scissor->x + scissor->width) / float(framebufferSize.width)) * 2.0f - 1.0f);
+        top = std::max(top, ((framebufferSize.height - scissor->y - scissor->height) / float(framebufferSize.height)) * 2.0f - 1.0f);
+        bottom = std::min(bottom, ((framebufferSize.height - scissor->y) / float(framebufferSize.height)) * 2.0f - 1.0f);
+    }
+
+    d3d11::SetPositionDepthColorVertex<T>(vertices + 0, left,  bottom, depthClear, color);
+    d3d11::SetPositionDepthColorVertex<T>(vertices + 1, left,  top,    depthClear, color);
+    d3d11::SetPositionDepthColorVertex<T>(vertices + 2, right, bottom, depthClear, color);
+    d3d11::SetPositionDepthColorVertex<T>(vertices + 3, right, top,    depthClear, color);
+}
+
+template <unsigned int vsSize, unsigned int psSize>
+Clear11::ClearShader Clear11::CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize])
+{
+    HRESULT result;
+
+    ClearShader shader = { 0 };
+
+    D3D11_INPUT_ELEMENT_DESC quadLayout[] =
+    {
+        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+        { "COLOR",    0, colorType,                   0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+    };
+
+    result = device->CreateInputLayout(quadLayout, ArraySize(quadLayout), vsByteCode, vsSize, &shader.inputLayout);
+    ASSERT(SUCCEEDED(result));
+
+    result = device->CreateVertexShader(vsByteCode, vsSize, NULL, &shader.vertexShader);
+    ASSERT(SUCCEEDED(result));
+
+    result = device->CreatePixelShader(psByteCode, psSize, NULL, &shader.pixelShader);
+    ASSERT(SUCCEEDED(result));
+
+    return shader;
+}
+
+Clear11::Clear11(Renderer11 *renderer)
+    : mRenderer(renderer), mClearBlendStates(StructLessThan<ClearBlendInfo>), mClearDepthStencilStates(StructLessThan<ClearDepthStencilInfo>),
+      mVertexBuffer(NULL), mRasterizerState(NULL)
+{
+    HRESULT result;
+    ID3D11Device *device = renderer->getDevice();
+
+    D3D11_BUFFER_DESC vbDesc;
+    vbDesc.ByteWidth = sizeof(d3d11::PositionDepthColorVertex<float>) * 4;
+    vbDesc.Usage = D3D11_USAGE_DYNAMIC;
+    vbDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
+    vbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    vbDesc.MiscFlags = 0;
+    vbDesc.StructureByteStride = 0;
+
+    result = device->CreateBuffer(&vbDesc, NULL, &mVertexBuffer);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mVertexBuffer, "Clear11 masked clear vertex buffer");
+
+    D3D11_RASTERIZER_DESC rsDesc;
+    rsDesc.FillMode = D3D11_FILL_SOLID;
+    rsDesc.CullMode = D3D11_CULL_NONE;
+    rsDesc.FrontCounterClockwise = FALSE;
+    rsDesc.DepthBias = 0;
+    rsDesc.DepthBiasClamp = 0.0f;
+    rsDesc.SlopeScaledDepthBias = 0.0f;
+    rsDesc.DepthClipEnable = FALSE;
+    rsDesc.ScissorEnable = FALSE;
+    rsDesc.MultisampleEnable = FALSE;
+    rsDesc.AntialiasedLineEnable = FALSE;
+
+    result = device->CreateRasterizerState(&rsDesc, &mRasterizerState);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mRasterizerState, "Clear11 masked clear rasterizer state");
+
+    mFloatClearShader = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_FLOAT, g_VS_ClearFloat, g_PS_ClearFloat);
+    mUintClearShader  = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_UINT,  g_VS_ClearUint,  g_PS_ClearUint );
+    mIntClearShader   = CreateClearShader(device, DXGI_FORMAT_R32G32B32A32_SINT,  g_VS_ClearSint,  g_PS_ClearSint );
+}
+
+Clear11::~Clear11()
+{
+    for (ClearBlendStateMap::iterator i = mClearBlendStates.begin(); i != mClearBlendStates.end(); i++)
+    {
+        SafeRelease(i->second);
+    }
+    mClearBlendStates.clear();
+
+    SafeRelease(mFloatClearShader.inputLayout);
+    SafeRelease(mFloatClearShader.vertexShader);
+    SafeRelease(mFloatClearShader.pixelShader);
+
+    SafeRelease(mUintClearShader.inputLayout);
+    SafeRelease(mUintClearShader.vertexShader);
+    SafeRelease(mUintClearShader.pixelShader);
+
+    SafeRelease(mIntClearShader.inputLayout);
+    SafeRelease(mIntClearShader.vertexShader);
+    SafeRelease(mIntClearShader.pixelShader);
+
+    for (ClearDepthStencilStateMap::iterator i = mClearDepthStencilStates.begin(); i != mClearDepthStencilStates.end(); i++)
+    {
+        SafeRelease(i->second);
+    }
+    mClearDepthStencilStates.clear();
+
+    SafeRelease(mVertexBuffer);
+    SafeRelease(mRasterizerState);
+}
+
+void Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
+{
+    // First determine if a scissored clear is needed, this will always require drawing a quad.
+    //
+    // Otherwise, iterate over the color buffers which require clearing and determine if they can be
+    // cleared with ID3D11DeviceContext::ClearRenderTargetView... This requires:
+    // 1) The render target is being cleared to a float value (will be cast to integer when clearing integer
+    //    render targets as expected but does not work the other way around)
+    // 2) The format of the render target has no color channels that are currently masked out.
+    // Clear the easy-to-clear buffers on the spot and accumulate the ones that require special work.
+    //
+    // Also determine if the depth stencil can be cleared with ID3D11DeviceContext::ClearDepthStencilView
+    // by checking if the stencil write mask covers the entire stencil.
+    //
+    // To clear the remaining buffers, quads must be drawn containing an int, uint or float vertex color
+    // attribute.
+
+    gl::Extents framebufferSize;
+    if (frameBuffer->getFirstColorbuffer() != NULL)
+    {
+        gl::Renderbuffer *renderBuffer = frameBuffer->getFirstColorbuffer();
+        framebufferSize.width = renderBuffer->getWidth();
+        framebufferSize.height = renderBuffer->getHeight();
+        framebufferSize.depth = 1;
+    }
+    else if (frameBuffer->getDepthOrStencilbuffer() != NULL)
+    {
+        gl::Renderbuffer *renderBuffer = frameBuffer->getDepthOrStencilbuffer();
+        framebufferSize.width = renderBuffer->getWidth();
+        framebufferSize.height = renderBuffer->getHeight();
+        framebufferSize.depth = 1;
+    }
+    else
+    {
+        UNREACHABLE();
+        return;
+    }
+
+    if (clearParams.scissorEnabled && (clearParams.scissor.x >= framebufferSize.width || 
+                                       clearParams.scissor.y >= framebufferSize.height ||
+                                       clearParams.scissor.x + clearParams.scissor.width <= 0 ||
+                                       clearParams.scissor.y + clearParams.scissor.height <= 0))
+    {
+        // Scissor is enabled and the scissor rectangle is outside the renderbuffer
+        return;
+    }
+
+    bool needScissoredClear = clearParams.scissorEnabled && (clearParams.scissor.x > 0 || clearParams.scissor.y > 0 ||
+                                                             clearParams.scissor.x + clearParams.scissor.width < framebufferSize.width ||
+                                                             clearParams.scissor.y + clearParams.scissor.height < framebufferSize.height);
+
+    GLuint clientVersion = mRenderer->getCurrentClientVersion();
+
+    std::vector<RenderTarget11*> maskedClearRenderTargets;
+    RenderTarget11* maskedClearDepthStencil = NULL;
+
+    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+    for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
+    {
+        if (clearParams.clearColor[colorAttachment] && frameBuffer->isEnabledColorAttachment(colorAttachment))
+        {
+            gl::Renderbuffer *renderbuffer = frameBuffer->getColorbuffer(colorAttachment);
+            if (renderbuffer)
+            {
+                RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbuffer->getRenderTarget());
+                if (!renderTarget)
+                {
+                    ERR("Render target pointer unexpectedly null.");
+                    return;
+                }
+
+                GLenum internalFormat = renderbuffer->getInternalFormat();
+                GLenum actualFormat = renderbuffer->getActualFormat();
+                GLenum componentType = gl::GetComponentType(internalFormat, clientVersion);
+                if (clearParams.colorClearType == GL_FLOAT &&
+                    !(componentType == GL_FLOAT || componentType == GL_UNSIGNED_NORMALIZED || componentType == GL_SIGNED_NORMALIZED))
+                {
+                    ERR("It is undefined behaviour to clear a render buffer which is not normalized fixed point or floating-"
+                        "point to floating point values (color attachment %u has internal format 0x%X).", colorAttachment, internalFormat);
+                }
+
+                GLuint internalRedBits = gl::GetRedBits(internalFormat, clientVersion);
+                GLuint internalGreenBits = gl::GetGreenBits(internalFormat, clientVersion);
+                GLuint internalBlueBits = gl::GetBlueBits(internalFormat, clientVersion);
+                GLuint internalAlphaBits = gl::GetAlphaBits(internalFormat, clientVersion);
+
+                if ((internalRedBits   == 0 || !clearParams.colorMaskRed) &&
+                    (internalGreenBits == 0 || !clearParams.colorMaskGreen) &&
+                    (internalBlueBits  == 0 || !clearParams.colorMaskBlue) &&
+                    (internalAlphaBits == 0 || !clearParams.colorMaskAlpha))
+                {
+                    // Every channel either does not exist in the render target or is masked out
+                    continue;
+                }
+                else if (needScissoredClear || clearParams.colorClearType != GL_FLOAT ||
+                         (internalRedBits   > 0 && !clearParams.colorMaskRed)   ||
+                         (internalGreenBits > 0 && !clearParams.colorMaskGreen) ||
+                         (internalBlueBits  > 0 && !clearParams.colorMaskBlue)  ||
+                         (internalAlphaBits > 0 && !clearParams.colorMaskAlpha))
+                {
+                    // A scissored or masked clear is required
+                    maskedClearRenderTargets.push_back(renderTarget);
+                }
+                else
+                {
+                    // ID3D11DeviceContext::ClearRenderTargetView is possible
+
+                    ID3D11RenderTargetView *framebufferRTV = renderTarget->getRenderTargetView();
+                    if (!framebufferRTV)
+                    {
+                        ERR("Render target view pointer unexpectedly null.");
+                        return;
+                    }
+
+                    // Check if the actual format has a channel that the internal format does not and set them to the
+                    // default values
+                    GLuint actualRedBits   = gl::GetRedBits(actualFormat, clientVersion);
+                    GLuint actualGreenBits = gl::GetGreenBits(actualFormat, clientVersion);
+                    GLuint actualBlueBits  = gl::GetBlueBits(actualFormat, clientVersion);
+                    GLuint actualAlphaBits = gl::GetAlphaBits(actualFormat, clientVersion);
+
+                    const float clearValues[4] =
+                    {
+                        ((internalRedBits   == 0 && actualRedBits   > 0) ? 0.0f : clearParams.colorFClearValue.red),
+                        ((internalGreenBits == 0 && actualGreenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
+                        ((internalBlueBits  == 0 && actualBlueBits  > 0) ? 0.0f : clearParams.colorFClearValue.blue),
+                        ((internalAlphaBits == 0 && actualAlphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
+                    };
+
+                    deviceContext->ClearRenderTargetView(framebufferRTV, clearValues);
+                }
+            }
+        }
+    }
+
+    if (clearParams.clearDepth || clearParams.clearStencil)
+    {
+        gl::Renderbuffer *renderbuffer = frameBuffer->getDepthOrStencilbuffer();
+        if (renderbuffer)
+        {
+            RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(renderbuffer->getDepthStencil());
+            if (!renderTarget)
+            {
+                ERR("Depth stencil render target pointer unexpectedly null.");
+                return;
+            }
+
+            GLenum actualFormat = renderbuffer->getActualFormat();
+
+            unsigned int stencilUnmasked = frameBuffer->hasStencil() ? (1 << gl::GetStencilBits(actualFormat, clientVersion)) - 1 : 0;
+            bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
+
+            if (needScissoredClear || needMaskedStencilClear)
+            {
+                maskedClearDepthStencil = renderTarget;
+            }
+            else
+            {
+                ID3D11DepthStencilView *framebufferDSV = renderTarget->getDepthStencilView();
+                if (!framebufferDSV)
+                {
+                    ERR("Depth stencil view pointer unexpectedly null.");
+                    return;
+                }
+
+                UINT clearFlags = (clearParams.clearDepth   ? D3D11_CLEAR_DEPTH   : 0) |
+                                  (clearParams.clearStencil ? D3D11_CLEAR_STENCIL : 0);
+                FLOAT depthClear = gl::clamp01(clearParams.depthClearValue);
+                UINT8 stencilClear = clearParams.stencilClearValue & 0xFF;
+
+                deviceContext->ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, stencilClear);
+            }
+        }
+    }
+
+    if (maskedClearRenderTargets.size() > 0 || maskedClearDepthStencil)
+    {
+        // To clear the render targets and depth stencil in one pass:
+        //
+        // Render a quad clipped to the scissor rectangle which draws the clear color and a blend
+        // state that will perform the required color masking.
+        //
+        // The quad's depth is equal to the depth clear value with a depth stencil state that
+        // will enable or disable depth test/writes if the depth buffer should be cleared or not.
+        //
+        // The rasterizer state's stencil is set to always pass or fail based on if the stencil
+        // should be cleared or not with a stencil write mask of the stencil clear value.
+        //
+        // ======================================================================================
+        //
+        // Luckily, the gl spec (ES 3.0.2 pg 183) states that the results of clearing a render-
+        // buffer that is not normalized fixed point or floating point with floating point values
+        // are undefined so we can just write floats to them and D3D11 will bit cast them to
+        // integers.
+        //
+        // Also, we don't have to worry about attempting to clear a normalized fixed/floating point
+        // buffer with integer values because there is no gl API call which would allow it,
+        // glClearBuffer* calls only clear a single renderbuffer at a time which is verified to
+        // be a compatible clear type.
+
+        // Bind all the render targets which need clearing
+        ASSERT(maskedClearRenderTargets.size() <= mRenderer->getMaxRenderTargets());
+        std::vector<ID3D11RenderTargetView*> rtvs(maskedClearRenderTargets.size());
+        for (unsigned int i = 0; i < maskedClearRenderTargets.size(); i++)
+        {
+            ID3D11RenderTargetView *renderTarget = maskedClearRenderTargets[i]->getRenderTargetView();
+            if (!renderTarget)
+            {
+                ERR("Render target pointer unexpectedly null.");
+                return;
+            }
+
+            rtvs[i] = renderTarget;
+        }
+        ID3D11DepthStencilView *dsv = maskedClearDepthStencil ? maskedClearDepthStencil->getDepthStencilView() : NULL;
+
+        ID3D11BlendState *blendState = getBlendState(clearParams, maskedClearRenderTargets);
+        const FLOAT blendFactors[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
+        const UINT sampleMask = 0xFFFFFFFF;
+
+        ID3D11DepthStencilState *dsState = getDepthStencilState(clearParams);
+        const UINT stencilClear = clearParams.stencilClearValue & 0xFF;
+
+        // Set the vertices
+        UINT vertexStride = 0;
+        const UINT startIdx = 0;
+        const ClearShader* shader = NULL;
+        D3D11_MAPPED_SUBRESOURCE mappedResource;
+        HRESULT result = deviceContext->Map(mVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+        if (FAILED(result))
+        {
+            ERR("Failed to map masked clear vertex buffer, HRESULT: 0x%X.", result);
+            return;
+        }
+
+        const gl::Rectangle *scissorPtr = clearParams.scissorEnabled ? &clearParams.scissor : NULL;
+        switch (clearParams.colorClearType)
+        {
+          case GL_FLOAT:
+            ApplyVertices(framebufferSize, scissorPtr, clearParams.colorFClearValue, clearParams.depthClearValue, mappedResource.pData);
+            vertexStride = sizeof(d3d11::PositionDepthColorVertex<float>);
+            shader = &mFloatClearShader;
+            break;
+
+          case GL_UNSIGNED_INT:
+            ApplyVertices(framebufferSize, scissorPtr, clearParams.colorUIClearValue, clearParams.depthClearValue, mappedResource.pData);
+            vertexStride = sizeof(d3d11::PositionDepthColorVertex<unsigned int>);
+            shader = &mUintClearShader;
+            break;
+
+          case GL_INT:
+            ApplyVertices(framebufferSize, scissorPtr, clearParams.colorIClearValue, clearParams.depthClearValue, mappedResource.pData);
+            vertexStride = sizeof(d3d11::PositionDepthColorVertex<int>);
+            shader = &mIntClearShader;
+            break;
+
+          default:
+            UNREACHABLE();
+            break;
+        }
+
+        deviceContext->Unmap(mVertexBuffer, 0);
+
+        // Set the viewport to be the same size as the framebuffer
+        D3D11_VIEWPORT viewport;
+        viewport.TopLeftX = 0;
+        viewport.TopLeftY = 0;
+        viewport.Width = framebufferSize.width;
+        viewport.Height = framebufferSize.height;
+        viewport.MinDepth = 0;
+        viewport.MaxDepth = 1;
+        deviceContext->RSSetViewports(1, &viewport);
+
+        // Apply state
+        deviceContext->OMSetBlendState(blendState, blendFactors, sampleMask);
+        deviceContext->OMSetDepthStencilState(dsState, stencilClear);
+        deviceContext->RSSetState(mRasterizerState);
+
+        // Apply shaders
+        deviceContext->IASetInputLayout(shader->inputLayout);
+        deviceContext->VSSetShader(shader->vertexShader, NULL, 0);
+        deviceContext->PSSetShader(shader->pixelShader, NULL, 0);
+        deviceContext->GSSetShader(NULL, NULL, 0);
+
+        // Apply vertex buffer
+        deviceContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &vertexStride, &startIdx);
+        deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+
+        // Apply render targets
+        deviceContext->OMSetRenderTargets(rtvs.size(), (rtvs.empty() ? NULL : &rtvs[0]), dsv);
+
+        // Draw the clear quad
+        deviceContext->Draw(4, 0);
+
+        // Clean up
+        mRenderer->markAllStateDirty();
+    }
+}
+
+ID3D11BlendState *Clear11::getBlendState(const gl::ClearParameters &clearParams, const std::vector<RenderTarget11*>& rts)
+{
+    GLuint clientVersion = mRenderer->getCurrentClientVersion();
+
+    ClearBlendInfo blendKey = { 0 };
+    for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
+    {
+        if (i < rts.size())
+        {
+            GLint internalFormat = rts[i]->getInternalFormat();
+
+            blendKey.maskChannels[i][0] = clearParams.clearColor ? (clearParams.colorMaskRed   && gl::GetRedBits(internalFormat, clientVersion)   > 0) : false;
+            blendKey.maskChannels[i][1] = clearParams.clearColor ? (clearParams.colorMaskGreen && gl::GetGreenBits(internalFormat, clientVersion) > 0) : false;
+            blendKey.maskChannels[i][2] = clearParams.clearColor ? (clearParams.colorMaskBlue  && gl::GetBlueBits(internalFormat, clientVersion)  > 0) : false;
+            blendKey.maskChannels[i][3] = clearParams.clearColor ? (clearParams.colorMaskAlpha && gl::GetAlphaBits(internalFormat, clientVersion) > 0) : false;
+        }
+        else
+        {
+            blendKey.maskChannels[i][0] = false;
+            blendKey.maskChannels[i][1] = false;
+            blendKey.maskChannels[i][2] = false;
+            blendKey.maskChannels[i][3] = false;
+        }
+    }
+
+    ClearBlendStateMap::const_iterator i = mClearBlendStates.find(blendKey);
+    if (i != mClearBlendStates.end())
+    {
+        return i->second;
+    }
+    else
+    {
+        D3D11_BLEND_DESC blendDesc = { 0 };
+        blendDesc.AlphaToCoverageEnable = FALSE;
+        blendDesc.IndependentBlendEnable = (rts.size() > 1) ? TRUE : FALSE;
+
+        for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
+        {
+            blendDesc.RenderTarget[i].BlendEnable = FALSE;
+            blendDesc.RenderTarget[i].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskChannels[i][0],
+                                                                                         blendKey.maskChannels[i][1],
+                                                                                         blendKey.maskChannels[i][2],
+                                                                                         blendKey.maskChannels[i][3]);
+        }
+
+        ID3D11Device *device = mRenderer->getDevice();
+        ID3D11BlendState* blendState = NULL;
+        HRESULT result = device->CreateBlendState(&blendDesc, &blendState);
+        if (FAILED(result) || !blendState)
+        {
+            ERR("Unable to create a ID3D11BlendState, HRESULT: 0x%X.", result);
+            return NULL;
+        }
+
+        mClearBlendStates[blendKey] = blendState;
+
+        return blendState;
+    }
+}
+
+ID3D11DepthStencilState *Clear11::getDepthStencilState(const gl::ClearParameters &clearParams)
+{
+    ClearDepthStencilInfo dsKey = { 0 };
+    dsKey.clearDepth = clearParams.clearDepth;
+    dsKey.clearStencil = clearParams.clearStencil;
+    dsKey.stencilWriteMask = clearParams.stencilWriteMask & 0xFF;
+
+    ClearDepthStencilStateMap::const_iterator i = mClearDepthStencilStates.find(dsKey);
+    if (i != mClearDepthStencilStates.end())
+    {
+        return i->second;
+    }
+    else
+    {
+        D3D11_DEPTH_STENCIL_DESC dsDesc = { 0 };
+        dsDesc.DepthEnable = dsKey.clearDepth ? TRUE : FALSE;
+        dsDesc.DepthWriteMask = dsKey.clearDepth ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
+        dsDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
+        dsDesc.StencilEnable = dsKey.clearStencil ? TRUE : FALSE;
+        dsDesc.StencilReadMask = 0;
+        dsDesc.StencilWriteMask = dsKey.stencilWriteMask;
+        dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE;
+        dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE;
+        dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE;
+        dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+        dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE;
+        dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE;
+        dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE;
+        dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+
+        ID3D11Device *device = mRenderer->getDevice();
+        ID3D11DepthStencilState* dsState = NULL;
+        HRESULT result = device->CreateDepthStencilState(&dsDesc, &dsState);
+        if (FAILED(result) || !dsState)
+        {
+            ERR("Unable to create a ID3D11DepthStencilState, HRESULT: 0x%X.", result);
+            return NULL;
+        }
+
+        mClearDepthStencilStates[dsKey] = dsState;
+
+        return dsState;
+    }
+}
+
+}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Clear11.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/Clear11.h
new file mode 100644 (file)
index 0000000..e8e4c9e
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// Copyright (c) 2013 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.
+//
+
+// Clear11.h: Framebuffer clear utility class.
+
+#ifndef LIBGLESV2_RENDERER_CLEAR11_H_
+#define LIBGLESV2_RENDERER_CLEAR11_H_
+
+#include "libGLESv2/angletypes.h"
+
+namespace gl
+{
+class Framebuffer;
+}
+
+namespace rx
+{
+class Renderer11;
+class RenderTarget11;
+
+class Clear11
+{
+  public:
+    explicit Clear11(Renderer11 *renderer);
+    ~Clear11();
+
+    // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied.
+    void clearFramebuffer(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
+
+  private:
+    Renderer11 *mRenderer;
+
+    struct ClearBlendInfo
+    {
+        bool maskChannels[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT][4];
+    };
+    typedef bool (*ClearBlendInfoComparisonFunction)(const ClearBlendInfo&, const ClearBlendInfo &);
+    typedef std::map<ClearBlendInfo, ID3D11BlendState*, ClearBlendInfoComparisonFunction> ClearBlendStateMap;
+    ClearBlendStateMap mClearBlendStates;
+
+    ID3D11BlendState *getBlendState(const gl::ClearParameters &clearParams, const std::vector<RenderTarget11*>& rts);
+
+    struct ClearShader
+    {
+        ID3D11InputLayout *inputLayout;
+        ID3D11VertexShader *vertexShader;
+        ID3D11PixelShader *pixelShader;
+    };
+    ClearShader mFloatClearShader;
+    ClearShader mUintClearShader;
+    ClearShader mIntClearShader;
+
+    template <unsigned int vsSize, unsigned int psSize>
+    static ClearShader CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize]);
+
+    struct ClearDepthStencilInfo
+    {
+        bool clearDepth;
+        bool clearStencil;
+        UINT8 stencilWriteMask;
+    };
+    typedef bool (*ClearDepthStencilInfoComparisonFunction)(const ClearDepthStencilInfo&, const ClearDepthStencilInfo &);
+    typedef std::map<ClearDepthStencilInfo, ID3D11DepthStencilState*, ClearDepthStencilInfoComparisonFunction> ClearDepthStencilStateMap;
+    ClearDepthStencilStateMap mClearDepthStencilStates;
+
+    ID3D11DepthStencilState *getDepthStencilState(const gl::ClearParameters &clearParams);
+
+    ID3D11Buffer *mVertexBuffer;
+    ID3D11RasterizerState *mRasterizerState;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_CLEAR11_H_
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp
new file mode 100644 (file)
index 0000000..dcd1f99
--- /dev/null
@@ -0,0 +1,252 @@
+#include "precompiled.h"
+//
+// Copyright (c) 2013 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.
+//
+
+// PixelTransfer11.cpp:
+//   Implementation for buffer-to-texture and texture-to-buffer copies.
+//   Used to implement pixel transfers from unpack and to pack buffers.
+//
+
+#include "libGLESv2/renderer/d3d11/PixelTransfer11.h"
+#include "libGLESv2/formatutils.h"
+#include "libGLESv2/Texture.h"
+#include "libGLESv2/Buffer.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+#include "libGLESv2/renderer/d3d11/renderer11_utils.h"
+#include "libGLESv2/renderer/d3d11/formatutils11.h"
+#include "libGLESv2/renderer/d3d11/BufferStorage11.h"
+#include "libGLESv2/renderer/d3d11/TextureStorage11.h"
+#include "libGLESv2/renderer/d3d11/RenderTarget11.h"
+#include "libGLESv2/Context.h"
+
+// Precompiled shaders
+#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h"
+#include "libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h"
+
+namespace rx
+{
+
+PixelTransfer11::PixelTransfer11(Renderer11 *renderer)
+    : mRenderer(renderer),
+      mBufferToTextureVS(NULL),
+      mBufferToTextureGS(NULL),
+      mParamsConstantBuffer(NULL),
+      mCopyRasterizerState(NULL),
+      mCopyDepthStencilState(NULL)
+{
+    HRESULT result = S_OK;
+    ID3D11Device *device = mRenderer->getDevice();
+
+    D3D11_RASTERIZER_DESC rasterDesc;
+    rasterDesc.FillMode = D3D11_FILL_SOLID;
+    rasterDesc.CullMode = D3D11_CULL_NONE;
+    rasterDesc.FrontCounterClockwise = FALSE;
+    rasterDesc.DepthBias = 0;
+    rasterDesc.SlopeScaledDepthBias = 0.0f;
+    rasterDesc.DepthBiasClamp = 0.0f;
+    rasterDesc.DepthClipEnable = TRUE;
+    rasterDesc.ScissorEnable = FALSE;
+    rasterDesc.MultisampleEnable = FALSE;
+    rasterDesc.AntialiasedLineEnable = FALSE;
+
+    result = device->CreateRasterizerState(&rasterDesc, &mCopyRasterizerState);
+    ASSERT(SUCCEEDED(result));
+
+    D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
+    depthStencilDesc.DepthEnable = true;
+    depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
+    depthStencilDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
+    depthStencilDesc.StencilEnable = FALSE;
+    depthStencilDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
+    depthStencilDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
+    depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+    depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
+    depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+
+    result = device->CreateDepthStencilState(&depthStencilDesc, &mCopyDepthStencilState);
+    ASSERT(SUCCEEDED(result));
+
+    D3D11_BUFFER_DESC constantBufferDesc = { 0 };
+    constantBufferDesc.ByteWidth = rx::roundUp<UINT>(sizeof(CopyShaderParams), 32u);
+    constantBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
+    constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+    constantBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    constantBufferDesc.MiscFlags = 0;
+    constantBufferDesc.StructureByteStride = 0;
+
+    result = device->CreateBuffer(&constantBufferDesc, NULL, &mParamsConstantBuffer);
+    ASSERT(SUCCEEDED(result));
+    d3d11::SetDebugName(mParamsConstantBuffer, "PixelTransfer11 constant buffer");
+
+    // init shaders
+    mBufferToTextureVS = d3d11::CompileVS(device, g_VS_BufferToTexture, "BufferToTexture VS");
+    mBufferToTextureGS = d3d11::CompileGS(device, g_GS_BufferToTexture, "BufferToTexture GS");
+
+    buildShaderMap();
+
+    StructZero(&mParamsData);
+}
+
+PixelTransfer11::~PixelTransfer11()
+{
+    for (auto shaderMapIt = mBufferToTexturePSMap.begin(); shaderMapIt != mBufferToTexturePSMap.end(); shaderMapIt++)
+    {
+        SafeRelease(shaderMapIt->second);
+    }
+
+    mBufferToTexturePSMap.clear();
+
+    SafeRelease(mBufferToTextureVS);
+    SafeRelease(mBufferToTextureGS);
+    SafeRelease(mParamsConstantBuffer);
+    SafeRelease(mCopyRasterizerState);
+    SafeRelease(mCopyDepthStencilState);
+}
+
+void PixelTransfer11::setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
+                                                   const gl::PixelUnpackState &unpack, unsigned int offset, CopyShaderParams *parametersOut)
+{
+    StructZero(parametersOut);
+
+    float texelCenterX = 0.5f / static_cast<float>(destSize.width - 1);
+    float texelCenterY = 0.5f / static_cast<float>(destSize.height - 1);
+
+    unsigned int bytesPerPixel = gl::GetPixelBytes(internalFormat, 3);
+    unsigned int alignmentBytes = static_cast<unsigned int>(unpack.alignment);
+    unsigned int alignmentPixels = (alignmentBytes <= bytesPerPixel ? 1 : alignmentBytes / bytesPerPixel);
+
+    parametersOut->FirstPixelOffset     = offset;
+    parametersOut->PixelsPerRow         = static_cast<unsigned int>(destArea.width);
+    parametersOut->RowStride            = roundUp(parametersOut->PixelsPerRow, alignmentPixels);
+    parametersOut->RowsPerSlice         = static_cast<unsigned int>(destArea.height);
+    parametersOut->PositionOffset[0]    = texelCenterX + (destArea.x / float(destSize.width)) * 2.0f - 1.0f;
+    parametersOut->PositionOffset[1]    = texelCenterY + ((destSize.height - destArea.y - 1) / float(destSize.height)) * 2.0f - 1.0f;
+    parametersOut->PositionScale[0]     = 2.0f / static_cast<float>(destSize.width);
+    parametersOut->PositionScale[1]     = -2.0f / static_cast<float>(destSize.height);
+}
+
+bool PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
+                                          GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea)
+{
+    gl::Extents destSize = destRenderTarget->getExtents();
+
+    if (destArea.x   < 0 || destArea.x   + destArea.width    > destSize.width    ||
+        destArea.y   < 0 || destArea.y   + destArea.height   > destSize.height   ||
+        destArea.z   < 0 || destArea.z   + destArea.depth    > destSize.depth    )
+    {
+        return false;
+    }
+
+    int clientVersion = mRenderer->getCurrentClientVersion();
+    const gl::Buffer &sourceBuffer = *unpack.pixelBuffer.get();
+
+    ASSERT(mRenderer->supportsFastCopyBufferToTexture(destinationFormat));
+
+    ID3D11PixelShader *pixelShader = findBufferToTexturePS(destinationFormat);
+    ASSERT(pixelShader);
+
+    // The SRV must be in the proper read format, which may be different from the destination format
+    // EG: for half float data, we can load full precision floats with implicit conversion
+    GLenum unsizedFormat = gl::GetFormat(destinationFormat, clientVersion);
+    GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType, clientVersion);
+
+    DXGI_FORMAT srvFormat = gl_d3d11::GetSRVFormat(sourceFormat, clientVersion);
+    ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN);
+    BufferStorage11 *bufferStorage11 = BufferStorage11::makeBufferStorage11(sourceBuffer.getStorage());
+    ID3D11ShaderResourceView *bufferSRV = bufferStorage11->getSRV(srvFormat);
+    ASSERT(bufferSRV != NULL);
+
+    ID3D11RenderTargetView *textureRTV = RenderTarget11::makeRenderTarget11(destRenderTarget)->getRenderTargetView();
+    ASSERT(textureRTV != NULL);
+
+    CopyShaderParams shaderParams;
+    setBufferToTextureCopyParams(destArea, destSize, sourceFormat, unpack, offset, &shaderParams);
+
+    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+    ID3D11ShaderResourceView *nullSRV = NULL;
+    ID3D11Buffer *nullBuffer = NULL;
+    UINT zero = 0;
+
+    // Are we doing a 2D or 3D copy?
+    ID3D11GeometryShader *geometryShader = ((destSize.depth > 1) ? mBufferToTextureGS : NULL);
+
+    deviceContext->VSSetShader(mBufferToTextureVS, NULL, 0);
+    deviceContext->GSSetShader(geometryShader, NULL, 0);
+    deviceContext->PSSetShader(pixelShader, NULL, 0);
+    deviceContext->PSSetShaderResources(0, 1, &bufferSRV);
+    deviceContext->IASetInputLayout(NULL);
+    deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
+
+    deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
+    deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
+    deviceContext->OMSetDepthStencilState(mCopyDepthStencilState, 0xFFFFFFFF);
+    deviceContext->RSSetState(mCopyRasterizerState);
+
+    mRenderer->setOneTimeRenderTarget(textureRTV);
+
+    if (!StructEquals(mParamsData, shaderParams))
+    {
+        d3d11::SetBufferData(deviceContext, mParamsConstantBuffer, shaderParams);
+        mParamsData = shaderParams;
+    }
+
+    deviceContext->VSSetConstantBuffers(0, 1, &mParamsConstantBuffer);
+
+    // Set the viewport
+    D3D11_VIEWPORT viewport;
+    viewport.TopLeftX = 0;
+    viewport.TopLeftY = 0;
+    viewport.Width = destSize.width;
+    viewport.Height = destSize.height;
+    viewport.MinDepth = 0.0f;
+    viewport.MaxDepth = 1.0f;
+    deviceContext->RSSetViewports(1, &viewport);
+
+    UINT numPixels = (destArea.width * destArea.height * destArea.depth);
+    deviceContext->Draw(numPixels, 0);
+
+    // Unbind textures and render targets and vertex buffer
+    deviceContext->PSSetShaderResources(0, 1, &nullSRV);
+    deviceContext->VSSetConstantBuffers(0, 1, &nullBuffer);
+
+    mRenderer->markAllStateDirty();
+
+    return true;
+}
+
+void PixelTransfer11::buildShaderMap()
+{
+    ID3D11Device *device = mRenderer->getDevice();
+
+    mBufferToTexturePSMap[GL_FLOAT]        = d3d11::CompilePS(device, g_PS_BufferToTexture_4F,  "BufferToTexture RGBA ps");
+    mBufferToTexturePSMap[GL_INT]          = d3d11::CompilePS(device, g_PS_BufferToTexture_4I,  "BufferToTexture RGBA-I ps");
+    mBufferToTexturePSMap[GL_UNSIGNED_INT] = d3d11::CompilePS(device, g_PS_BufferToTexture_4UI, "BufferToTexture RGBA-UI ps");
+}
+
+ID3D11PixelShader *PixelTransfer11::findBufferToTexturePS(GLenum internalFormat) const
+{
+    int clientVersion = mRenderer->getCurrentClientVersion();
+    GLenum componentType = gl::GetComponentType(internalFormat, clientVersion);
+
+    if (componentType == GL_SIGNED_NORMALIZED || componentType == GL_UNSIGNED_NORMALIZED)
+    {
+        componentType = GL_FLOAT;
+    }
+
+    auto shaderMapIt = mBufferToTexturePSMap.find(componentType);
+    return (shaderMapIt == mBufferToTexturePSMap.end() ? NULL : shaderMapIt->second);
+}
+
+}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/PixelTransfer11.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/PixelTransfer11.h
new file mode 100644 (file)
index 0000000..574140d
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// Copyright (c) 2013 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.
+//
+
+// PixelTransfer11.h:
+//   Buffer-to-Texture and Texture-to-Buffer data transfers.
+//   Used to implement pixel unpack and pixel pack buffers in ES3.
+
+#ifndef LIBGLESV2_PIXELTRANSFER11_H_
+#define LIBGLESV2_PIXELTRANSFER11_H_
+
+namespace gl
+{
+
+class Buffer;
+struct Box;
+struct Extents;
+struct PixelUnpackState;
+
+}
+
+namespace rx
+{
+class Renderer11;
+class RenderTarget;
+
+class PixelTransfer11
+{
+  public:
+    explicit PixelTransfer11(Renderer11 *renderer);
+    ~PixelTransfer11();
+
+    static bool supportsBufferToTextureCopy(GLenum internalFormat);
+
+    // unpack: the source buffer is stored in the unpack state, and buffer strides
+    // offset: the start of the data within the unpack buffer
+    // destRenderTarget: individual slice/layer of a target texture
+    // destinationFormat/sourcePixelsType: determines shaders + shader parameters
+    // destArea: the sub-section of destRenderTarget to copy to
+    bool copyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
+                             GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
+
+  private:
+
+    struct CopyShaderParams
+    {
+        unsigned int FirstPixelOffset;
+        unsigned int PixelsPerRow;
+        unsigned int RowStride;
+        unsigned int RowsPerSlice;
+        float PositionOffset[2];
+        float PositionScale[2];
+        int TexLocationOffset[2];
+        int TexLocationScale[2];
+    };
+
+    static void setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
+                                             const gl::PixelUnpackState &unpack, unsigned int offset, CopyShaderParams *parametersOut);
+
+    void buildShaderMap();
+    ID3D11PixelShader *findBufferToTexturePS(GLenum internalFormat) const;
+
+    Renderer11 *mRenderer;
+
+    std::map<GLenum, ID3D11PixelShader *> mBufferToTexturePSMap;
+    ID3D11VertexShader *mBufferToTextureVS;
+    ID3D11GeometryShader *mBufferToTextureGS;
+    ID3D11Buffer *mParamsConstantBuffer;
+    CopyShaderParams mParamsData;
+
+    ID3D11RasterizerState *mCopyRasterizerState;
+    ID3D11DepthStencilState *mCopyDepthStencilState;
+
+};
+
+}
+
+#endif // LIBGLESV2_PIXELTRANSFER11_H_
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/formatutils11.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/formatutils11.cpp
new file mode 100644 (file)
index 0000000..fb73513
--- /dev/null
@@ -0,0 +1,1665 @@
+#include "precompiled.h"
+//
+// Copyright (c) 2013 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.
+//
+
+// formatutils11.cpp: Queries for GL image formats and their translations to D3D11
+// formats.
+
+#include "libGLESv2/renderer/d3d11/formatutils11.h"
+#include "libGLESv2/renderer/generatemip.h"
+#include "libGLESv2/renderer/loadimage.h"
+#include "libGLESv2/renderer/copyimage.h"
+#include "libGLESv2/renderer/Renderer.h"
+#include "libGLESv2/renderer/copyvertex.h"
+
+namespace rx
+{
+
+struct D3D11ES3FormatInfo
+{
+    DXGI_FORMAT mTexFormat;
+    DXGI_FORMAT mSRVFormat;
+    DXGI_FORMAT mRTVFormat;
+    DXGI_FORMAT mDSVFormat;
+
+    D3D11ES3FormatInfo()
+        : mTexFormat(DXGI_FORMAT_UNKNOWN), mDSVFormat(DXGI_FORMAT_UNKNOWN), mRTVFormat(DXGI_FORMAT_UNKNOWN), mSRVFormat(DXGI_FORMAT_UNKNOWN)
+    { }
+
+    D3D11ES3FormatInfo(DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat)
+        : mTexFormat(texFormat), mDSVFormat(dsvFormat), mRTVFormat(rtvFormat), mSRVFormat(srvFormat)
+    { }
+};
+
+// For sized GL internal formats, there is only one corresponding D3D11 format. This map type allows
+// querying for the DXGI texture formats to use for textures, SRVs, RTVs and DSVs given a GL internal
+// format.
+typedef std::pair<GLenum, D3D11ES3FormatInfo> D3D11ES3FormatPair;
+typedef std::map<GLenum, D3D11ES3FormatInfo> D3D11ES3FormatMap;
+
+static D3D11ES3FormatMap BuildD3D11ES3FormatMap()
+{
+    D3D11ES3FormatMap map;
+
+    //                           | GL internal format  |                  | D3D11 texture format            | D3D11 SRV format               | D3D11 RTV format               | D3D11 DSV format   |
+    map.insert(D3D11ES3FormatPair(GL_NONE,              D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,              DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R8,                D3D11ES3FormatInfo(DXGI_FORMAT_R8_UNORM,             DXGI_FORMAT_R8_UNORM,            DXGI_FORMAT_R8_UNORM,            DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R8_SNORM,          D3D11ES3FormatInfo(DXGI_FORMAT_R8_SNORM,             DXGI_FORMAT_R8_SNORM,            DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG8,               D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_UNORM,           DXGI_FORMAT_R8G8_UNORM,          DXGI_FORMAT_R8G8_UNORM,          DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG8_SNORM,         D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_SNORM,           DXGI_FORMAT_R8G8_SNORM,          DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB8,              D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB8_SNORM,        D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM,       DXGI_FORMAT_R8G8B8A8_SNORM,      DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB565,            D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA4,             D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB5_A1,           D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA8,             D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA8_SNORM,       D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM,       DXGI_FORMAT_R8G8B8A8_SNORM,      DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB10_A2,          D3D11ES3FormatInfo(DXGI_FORMAT_R10G10B10A2_UNORM,    DXGI_FORMAT_R10G10B10A2_UNORM,   DXGI_FORMAT_R10G10B10A2_UNORM,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB10_A2UI,        D3D11ES3FormatInfo(DXGI_FORMAT_R10G10B10A2_UINT,     DXGI_FORMAT_R10G10B10A2_UINT,    DXGI_FORMAT_R10G10B10A2_UINT,    DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_SRGB8,             D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,  DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_SRGB8_ALPHA8,      D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,  DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R16F,              D3D11ES3FormatInfo(DXGI_FORMAT_R16_FLOAT,            DXGI_FORMAT_R16_FLOAT,           DXGI_FORMAT_R16_FLOAT,           DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG16F,             D3D11ES3FormatInfo(DXGI_FORMAT_R16G16_FLOAT,         DXGI_FORMAT_R16G16_FLOAT,        DXGI_FORMAT_R16G16_FLOAT,        DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB16F,            D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT,   DXGI_FORMAT_R16G16B16A16_FLOAT,  DXGI_FORMAT_R16G16B16A16_FLOAT,  DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA16F,           D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT,   DXGI_FORMAT_R16G16B16A16_FLOAT,  DXGI_FORMAT_R16G16B16A16_FLOAT,  DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R32F,              D3D11ES3FormatInfo(DXGI_FORMAT_R32_FLOAT,            DXGI_FORMAT_R32_FLOAT,           DXGI_FORMAT_R32_FLOAT,           DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG32F,             D3D11ES3FormatInfo(DXGI_FORMAT_R32G32_FLOAT,         DXGI_FORMAT_R32G32_FLOAT,        DXGI_FORMAT_R32G32_FLOAT,        DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB32F,            D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT,   DXGI_FORMAT_R32G32B32A32_FLOAT,  DXGI_FORMAT_R32G32B32A32_FLOAT,  DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA32F,           D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT,   DXGI_FORMAT_R32G32B32A32_FLOAT,  DXGI_FORMAT_R32G32B32A32_FLOAT,  DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R11F_G11F_B10F,    D3D11ES3FormatInfo(DXGI_FORMAT_R11G11B10_FLOAT,      DXGI_FORMAT_R11G11B10_FLOAT,     DXGI_FORMAT_R11G11B10_FLOAT,     DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB9_E5,           D3D11ES3FormatInfo(DXGI_FORMAT_R9G9B9E5_SHAREDEXP,   DXGI_FORMAT_R9G9B9E5_SHAREDEXP,  DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R8I,               D3D11ES3FormatInfo(DXGI_FORMAT_R8_SINT,              DXGI_FORMAT_R8_SINT,             DXGI_FORMAT_R8_SINT,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R8UI,              D3D11ES3FormatInfo(DXGI_FORMAT_R8_UINT,              DXGI_FORMAT_R8_UINT,             DXGI_FORMAT_R8_UINT,             DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R16I,              D3D11ES3FormatInfo(DXGI_FORMAT_R16_SINT,             DXGI_FORMAT_R16_SINT,            DXGI_FORMAT_R16_SINT,            DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R16UI,             D3D11ES3FormatInfo(DXGI_FORMAT_R16_UINT,             DXGI_FORMAT_R16_UINT,            DXGI_FORMAT_R16_UINT,            DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R32I,              D3D11ES3FormatInfo(DXGI_FORMAT_R32_SINT,             DXGI_FORMAT_R32_SINT,            DXGI_FORMAT_R32_SINT,            DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_R32UI,             D3D11ES3FormatInfo(DXGI_FORMAT_R32_UINT,             DXGI_FORMAT_R32_UINT,            DXGI_FORMAT_R32_UINT,            DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG8I,              D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_SINT,            DXGI_FORMAT_R8G8_SINT,           DXGI_FORMAT_R8G8_SINT,           DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG8UI,             D3D11ES3FormatInfo(DXGI_FORMAT_R8G8_UINT,            DXGI_FORMAT_R8G8_UINT,           DXGI_FORMAT_R8G8_UINT,           DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG16I,             D3D11ES3FormatInfo(DXGI_FORMAT_R16G16_SINT,          DXGI_FORMAT_R16G16_SINT,         DXGI_FORMAT_R16G16_SINT,         DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG16UI,            D3D11ES3FormatInfo(DXGI_FORMAT_R16G16_UINT,          DXGI_FORMAT_R16G16_UINT,         DXGI_FORMAT_R16G16_UINT,         DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG32I,             D3D11ES3FormatInfo(DXGI_FORMAT_R32G32_SINT,          DXGI_FORMAT_R32G32_SINT,         DXGI_FORMAT_R32G32_SINT,         DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RG32UI,            D3D11ES3FormatInfo(DXGI_FORMAT_R32G32_UINT,          DXGI_FORMAT_R32G32_UINT,         DXGI_FORMAT_R32G32_UINT,         DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB8I,             D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SINT,        DXGI_FORMAT_R8G8B8A8_SINT,       DXGI_FORMAT_R8G8B8A8_SINT,       DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB8UI,            D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UINT,        DXGI_FORMAT_R8G8B8A8_UINT,       DXGI_FORMAT_R8G8B8A8_UINT,       DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB16I,            D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_SINT,    DXGI_FORMAT_R16G16B16A16_SINT,   DXGI_FORMAT_R16G16B16A16_SINT,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB16UI,           D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_UINT,    DXGI_FORMAT_R16G16B16A16_UINT,   DXGI_FORMAT_R16G16B16A16_UINT,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB32I,            D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_SINT,    DXGI_FORMAT_R32G32B32A32_SINT,   DXGI_FORMAT_R32G32B32A32_SINT,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB32UI,           D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_UINT,    DXGI_FORMAT_R32G32B32A32_UINT,   DXGI_FORMAT_R32G32B32A32_UINT,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA8I,            D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_SINT,        DXGI_FORMAT_R8G8B8A8_SINT,       DXGI_FORMAT_R8G8B8A8_SINT,       DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA8UI,           D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UINT,        DXGI_FORMAT_R8G8B8A8_UINT,       DXGI_FORMAT_R8G8B8A8_UINT,       DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA16I,           D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_SINT,    DXGI_FORMAT_R16G16B16A16_SINT,   DXGI_FORMAT_R16G16B16A16_SINT,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA16UI,          D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_UINT,    DXGI_FORMAT_R16G16B16A16_UINT,   DXGI_FORMAT_R16G16B16A16_UINT,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA32I,           D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_SINT,    DXGI_FORMAT_R32G32B32A32_SINT,   DXGI_FORMAT_R32G32B32A32_SINT,   DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA32UI,          D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_UINT,    DXGI_FORMAT_R32G32B32A32_UINT,   DXGI_FORMAT_R32G32B32A32_UINT,   DXGI_FORMAT_UNKNOWN)));
+
+    // Unsized formats, TODO: Are types of float and half float allowed for the unsized types? Would it change the DXGI format?
+    map.insert(D3D11ES3FormatPair(GL_ALPHA,             D3D11ES3FormatInfo(DXGI_FORMAT_A8_UNORM,             DXGI_FORMAT_A8_UNORM,            DXGI_FORMAT_A8_UNORM,            DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE,         D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA,   D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGB,               D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_RGBA,              D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,       DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_R8G8B8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_BGRA_EXT,          D3D11ES3FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM,       DXGI_FORMAT_B8G8R8A8_UNORM,      DXGI_FORMAT_B8G8R8A8_UNORM,      DXGI_FORMAT_UNKNOWN)));
+
+    // From GL_EXT_texture_storage
+    //                           | GL internal format       |                  | D3D11 texture format          | D3D11 SRV format                    | D3D11 RTV format              | D3D11 DSV format               |
+    map.insert(D3D11ES3FormatPair(GL_ALPHA8_EXT,             D3D11ES3FormatInfo(DXGI_FORMAT_A8_UNORM,           DXGI_FORMAT_A8_UNORM,                 DXGI_FORMAT_A8_UNORM,           DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE8_EXT,         D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,           DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_ALPHA32F_EXT,           D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,       DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE32F_EXT,       D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,       DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_ALPHA16F_EXT,           D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT,       DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE16F_EXT,       D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN,                  DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE8_ALPHA8_EXT,  D3D11ES3FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,           DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA32F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,       DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_LUMINANCE_ALPHA16F_EXT, D3D11ES3FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT,       DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_BGRA8_EXT,              D3D11ES3FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_B8G8R8A8_UNORM,           DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_BGRA4_ANGLEX,           D3D11ES3FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_B8G8R8A8_UNORM,           DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_UNKNOWN             )));
+    map.insert(D3D11ES3FormatPair(GL_BGR5_A1_ANGLEX,         D3D11ES3FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_B8G8R8A8_UNORM,           DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_UNKNOWN             )));
+
+    // Depth stencil formats
+    map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT16,     D3D11ES3FormatInfo(DXGI_FORMAT_R16_TYPELESS,        DXGI_FORMAT_R16_UNORM,                DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D16_UNORM           )));
+    map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT24,     D3D11ES3FormatInfo(DXGI_FORMAT_R24G8_TYPELESS,      DXGI_FORMAT_R24_UNORM_X8_TYPELESS,    DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D24_UNORM_S8_UINT   )));
+    map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT32F,    D3D11ES3FormatInfo(DXGI_FORMAT_R32_TYPELESS,        DXGI_FORMAT_R32_FLOAT,                DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D32_FLOAT           )));
+    map.insert(D3D11ES3FormatPair(GL_DEPTH24_STENCIL8,      D3D11ES3FormatInfo(DXGI_FORMAT_R24G8_TYPELESS,      DXGI_FORMAT_R24_UNORM_X8_TYPELESS,    DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D24_UNORM_S8_UINT   )));
+    map.insert(D3D11ES3FormatPair(GL_DEPTH32F_STENCIL8,     D3D11ES3FormatInfo(DXGI_FORMAT_R32G8X24_TYPELESS,   DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D32_FLOAT_S8X24_UINT)));
+    map.insert(D3D11ES3FormatPair(GL_STENCIL_INDEX8,        D3D11ES3FormatInfo(DXGI_FORMAT_R24G8_TYPELESS,      DXGI_FORMAT_X24_TYPELESS_G8_UINT,     DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D24_UNORM_S8_UINT   )));
+
+    // From GL_ANGLE_depth_texture
+    map.insert(D3D11ES3FormatPair(GL_DEPTH_COMPONENT32_OES, D3D11ES3FormatInfo(DXGI_FORMAT_R24G8_TYPELESS,      DXGI_FORMAT_R24_UNORM_X8_TYPELESS,    DXGI_FORMAT_UNKNOWN,             DXGI_FORMAT_D24_UNORM_S8_UINT  )));
+
+    // Compressed formats, From ES 3.0.1 spec, table 3.16
+    //                           | GL internal format                          |                  | D3D11 texture format | D3D11 SRV format     | D3D11 RTV format   | D3D11 DSV format  |
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_R11_EAC,                        D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SIGNED_R11_EAC,                 D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RG11_EAC,                       D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SIGNED_RG11_EAC,                D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB8_ETC2,                      D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_ETC2,                     D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA8_ETC2_EAC,                 D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          D3D11ES3FormatInfo(DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN,   DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+
+    // From GL_EXT_texture_compression_dxt1
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT,              D3D11ES3FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,             D3D11ES3FormatInfo(DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+
+    // From GL_ANGLE_texture_compression_dxt3
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,           D3D11ES3FormatInfo(DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+
+    // From GL_ANGLE_texture_compression_dxt5
+    map.insert(D3D11ES3FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,           D3D11ES3FormatInfo(DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN)));
+
+    return map;
+}
+
+static bool GetD3D11ES3FormatInfo(GLenum internalFormat, GLuint clientVersion, D3D11ES3FormatInfo *outFormatInfo)
+{
+    static const D3D11ES3FormatMap formatMap = BuildD3D11ES3FormatMap();
+    D3D11ES3FormatMap::const_iterator iter = formatMap.find(internalFormat);
+    if (iter != formatMap.end())
+    {
+        if (outFormatInfo)
+        {
+            *outFormatInfo = iter->second;
+        }
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+// ES3 image loading functions vary based on the internal format and data type given,
+// this map type determines the loading function from the internal format and type supplied
+// to glTex*Image*D and the destination DXGI_FORMAT. Source formats and types are taken from
+// Tables 3.2 and 3.3 of the ES 3 spec.
+typedef std::pair<GLenum, GLenum> InternalFormatTypePair;
+typedef std::pair<InternalFormatTypePair, LoadImageFunction> D3D11LoadFunctionPair;
+typedef std::map<InternalFormatTypePair, LoadImageFunction> D3D11LoadFunctionMap;
+
+static void UnimplementedLoadFunction(int width, int height, int depth,
+                                      const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
+                                      void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+{
+    UNIMPLEMENTED();
+}
+
+static void UnreachableLoadFunction(int width, int height, int depth,
+                                    const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
+                                    void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+{
+    UNREACHABLE();
+}
+
+// A helper function to insert data into the D3D11LoadFunctionMap with fewer characters.
+static inline void insertLoadFunction(D3D11LoadFunctionMap *map, GLenum internalFormat, GLenum type,
+                                      LoadImageFunction loadFunc)
+{
+    map->insert(D3D11LoadFunctionPair(InternalFormatTypePair(internalFormat, type), loadFunc));
+}
+
+D3D11LoadFunctionMap buildD3D11LoadFunctionMap()
+{
+    D3D11LoadFunctionMap map;
+
+    //                      | Internal format      | Type                             | Load function                       |
+    insertLoadFunction(&map, GL_RGBA8,              GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>             );
+    insertLoadFunction(&map, GL_RGB5_A1,            GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>             );
+    insertLoadFunction(&map, GL_RGBA4,              GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>             );
+    insertLoadFunction(&map, GL_SRGB8_ALPHA8,       GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>             );
+    insertLoadFunction(&map, GL_RGBA8_SNORM,        GL_BYTE,                           loadToNative<GLbyte, 4>              );
+    insertLoadFunction(&map, GL_RGBA4,              GL_UNSIGNED_SHORT_4_4_4_4,         loadRGBA4444DataToRGBA               );
+    insertLoadFunction(&map, GL_RGB10_A2,           GL_UNSIGNED_INT_2_10_10_10_REV,    loadToNative<GLuint, 1>              );
+    insertLoadFunction(&map, GL_RGB5_A1,            GL_UNSIGNED_SHORT_5_5_5_1,         loadRGBA5551DataToRGBA               );
+    insertLoadFunction(&map, GL_RGB5_A1,            GL_UNSIGNED_INT_2_10_10_10_REV,    loadRGBA2101010ToRGBA                );
+    insertLoadFunction(&map, GL_RGBA16F,            GL_HALF_FLOAT,                     loadToNative<GLhalf, 4>              );
+    insertLoadFunction(&map, GL_RGBA32F,            GL_FLOAT,                          loadToNative<GLfloat, 4>             );
+    insertLoadFunction(&map, GL_RGBA16F,            GL_FLOAT,                          loadFloatDataToHalfFloat<4>          );
+    insertLoadFunction(&map, GL_RGBA8UI,            GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>             );
+    insertLoadFunction(&map, GL_RGBA8I,             GL_BYTE,                           loadToNative<GLbyte, 4>              );
+    insertLoadFunction(&map, GL_RGBA16UI,           GL_UNSIGNED_SHORT,                 loadToNative<GLushort, 4>            );
+    insertLoadFunction(&map, GL_RGBA16I,            GL_SHORT,                          loadToNative<GLshort, 4>             );
+    insertLoadFunction(&map, GL_RGBA32UI,           GL_UNSIGNED_INT,                   loadToNative<GLuint, 4>              );
+    insertLoadFunction(&map, GL_RGBA32I,            GL_INT,                            loadToNative<GLint, 4>               );
+    insertLoadFunction(&map, GL_RGB10_A2UI,         GL_UNSIGNED_INT_2_10_10_10_REV,    loadToNative<GLuint, 1>              );
+    insertLoadFunction(&map, GL_RGB8,               GL_UNSIGNED_BYTE,                  loadRGBUByteDataToRGBA               );
+    insertLoadFunction(&map, GL_RGB565,             GL_UNSIGNED_BYTE,                  loadToNative3To4<GLubyte, 0xFF>      );
+    insertLoadFunction(&map, GL_SRGB8,              GL_UNSIGNED_BYTE,                  loadToNative3To4<GLubyte, 0xFF>      );
+    insertLoadFunction(&map, GL_RGB8_SNORM,         GL_BYTE,                           loadRGBSByteDataToRGBA               );
+    insertLoadFunction(&map, GL_RGB565,             GL_UNSIGNED_SHORT_5_6_5,           loadRGB565DataToRGBA                 );
+    insertLoadFunction(&map, GL_R11F_G11F_B10F,     GL_UNSIGNED_INT_10F_11F_11F_REV,   loadToNative<GLuint, 1>              );
+    insertLoadFunction(&map, GL_RGB9_E5,            GL_UNSIGNED_INT_5_9_9_9_REV,       loadToNative<GLuint, 1>              );
+    insertLoadFunction(&map, GL_RGB16F,             GL_HALF_FLOAT,                     loadToNative3To4<GLhalf, gl::Float16One>);
+    insertLoadFunction(&map, GL_R11F_G11F_B10F,     GL_HALF_FLOAT,                     loadRGBHalfFloatDataTo111110Float    );
+    insertLoadFunction(&map, GL_RGB9_E5,            GL_HALF_FLOAT,                     loadRGBHalfFloatDataTo999E5          );
+    insertLoadFunction(&map, GL_RGB32F,             GL_FLOAT,                          loadToNative3To4<GLfloat, gl::Float32One>);
+    insertLoadFunction(&map, GL_RGB16F,             GL_FLOAT,                          loadFloatRGBDataToHalfFloatRGBA      );
+    insertLoadFunction(&map, GL_R11F_G11F_B10F,     GL_FLOAT,                          loadRGBFloatDataTo111110Float        );
+    insertLoadFunction(&map, GL_RGB9_E5,            GL_FLOAT,                          loadRGBFloatDataTo999E5              );
+    insertLoadFunction(&map, GL_RGB8UI,             GL_UNSIGNED_BYTE,                  loadToNative3To4<GLubyte, 0x01>      );
+    insertLoadFunction(&map, GL_RGB8I,              GL_BYTE,                           loadToNative3To4<GLbyte, 0x01>       );
+    insertLoadFunction(&map, GL_RGB16UI,            GL_UNSIGNED_SHORT,                 loadToNative3To4<GLushort, 0x0001>   );
+    insertLoadFunction(&map, GL_RGB16I,             GL_SHORT,                          loadToNative3To4<GLshort, 0x0001>    );
+    insertLoadFunction(&map, GL_RGB32UI,            GL_UNSIGNED_INT,                   loadToNative3To4<GLuint, 0x00000001> );
+    insertLoadFunction(&map, GL_RGB32I,             GL_INT,                            loadToNative3To4<GLint, 0x00000001>  );
+    insertLoadFunction(&map, GL_RG8,                GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 2>             );
+    insertLoadFunction(&map, GL_RG8_SNORM,          GL_BYTE,                           loadToNative<GLbyte, 2>              );
+    insertLoadFunction(&map, GL_RG16F,              GL_HALF_FLOAT,                     loadToNative<GLhalf, 2>              );
+    insertLoadFunction(&map, GL_RG32F,              GL_FLOAT,                          loadToNative<GLfloat, 2>             );
+    insertLoadFunction(&map, GL_RG16F,              GL_FLOAT,                          loadFloatDataToHalfFloat<2>          );
+    insertLoadFunction(&map, GL_RG8UI,              GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 2>             );
+    insertLoadFunction(&map, GL_RG8I,               GL_BYTE,                           loadToNative<GLbyte, 2>              );
+    insertLoadFunction(&map, GL_RG16UI,             GL_UNSIGNED_SHORT,                 loadToNative<GLushort, 2>            );
+    insertLoadFunction(&map, GL_RG16I,              GL_SHORT,                          loadToNative<GLshort, 2>             );
+    insertLoadFunction(&map, GL_RG32UI,             GL_UNSIGNED_INT,                   loadToNative<GLuint, 2>              );
+    insertLoadFunction(&map, GL_RG32I,              GL_INT,                            loadToNative<GLint, 2>               );
+    insertLoadFunction(&map, GL_R8,                 GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 1>             );
+    insertLoadFunction(&map, GL_R8_SNORM,           GL_BYTE,                           loadToNative<GLbyte, 1>              );
+    insertLoadFunction(&map, GL_R16F,               GL_HALF_FLOAT,                     loadToNative<GLhalf, 1>              );
+    insertLoadFunction(&map, GL_R32F,               GL_FLOAT,                          loadToNative<GLfloat, 1>             );
+    insertLoadFunction(&map, GL_R16F,               GL_FLOAT,                          loadFloatDataToHalfFloat<1>          );
+    insertLoadFunction(&map, GL_R8UI,               GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 1>             );
+    insertLoadFunction(&map, GL_R8I,                GL_BYTE,                           loadToNative<GLbyte, 1>              );
+    insertLoadFunction(&map, GL_R16UI,              GL_UNSIGNED_SHORT,                 loadToNative<GLushort, 1>            );
+    insertLoadFunction(&map, GL_R16I,               GL_SHORT,                          loadToNative<GLshort, 1>             );
+    insertLoadFunction(&map, GL_R32UI,              GL_UNSIGNED_INT,                   loadToNative<GLuint, 1>              );
+    insertLoadFunction(&map, GL_R32I,               GL_INT,                            loadToNative<GLint, 1>               );
+    insertLoadFunction(&map, GL_DEPTH_COMPONENT16,  GL_UNSIGNED_SHORT,                 loadToNative<GLushort, 1>            );
+    insertLoadFunction(&map, GL_DEPTH_COMPONENT24,  GL_UNSIGNED_INT,                   loadG8R24DataToR24G8                 );
+    insertLoadFunction(&map, GL_DEPTH_COMPONENT16,  GL_UNSIGNED_INT,                   loadUintDataToUshort                 );
+    insertLoadFunction(&map, GL_DEPTH_COMPONENT32F, GL_FLOAT,                          loadToNative<GLfloat, 1>             );
+    insertLoadFunction(&map, GL_DEPTH24_STENCIL8,   GL_UNSIGNED_INT_24_8,              loadG8R24DataToR24G8                 );
+    insertLoadFunction(&map, GL_DEPTH32F_STENCIL8,  GL_FLOAT_32_UNSIGNED_INT_24_8_REV, loadToNative<GLuint, 2>              );
+
+    // Unsized formats
+    // Load functions are unreachable because they are converted to sized internal formats based on
+    // the format and type before loading takes place.
+    insertLoadFunction(&map, GL_RGBA,               GL_UNSIGNED_BYTE,                  UnreachableLoadFunction              );
+    insertLoadFunction(&map, GL_RGBA,               GL_UNSIGNED_SHORT_4_4_4_4,         UnreachableLoadFunction              );
+    insertLoadFunction(&map, GL_RGBA,               GL_UNSIGNED_SHORT_5_5_5_1,         UnreachableLoadFunction              );
+    insertLoadFunction(&map, GL_RGB,                GL_UNSIGNED_BYTE,                  UnreachableLoadFunction              );
+    insertLoadFunction(&map, GL_RGB,                GL_UNSIGNED_SHORT_5_6_5,           UnreachableLoadFunction              );
+    insertLoadFunction(&map, GL_LUMINANCE_ALPHA,    GL_UNSIGNED_BYTE,                  UnreachableLoadFunction              );
+    insertLoadFunction(&map, GL_LUMINANCE,          GL_UNSIGNED_BYTE,                  UnreachableLoadFunction              );
+    insertLoadFunction(&map, GL_ALPHA,              GL_UNSIGNED_BYTE,                  UnreachableLoadFunction              );
+
+    // From GL_OES_texture_float
+    insertLoadFunction(&map, GL_LUMINANCE_ALPHA,    GL_FLOAT,                          loadLuminanceAlphaFloatDataToRGBA    );
+    insertLoadFunction(&map, GL_LUMINANCE,          GL_FLOAT,                          loadLuminanceFloatDataToRGB          );
+    insertLoadFunction(&map, GL_ALPHA,              GL_FLOAT,                          loadAlphaFloatDataToRGBA             );
+
+    // From GL_OES_texture_half_float
+    insertLoadFunction(&map, GL_LUMINANCE_ALPHA,    GL_HALF_FLOAT,                     loadLuminanceAlphaHalfFloatDataToRGBA);
+    insertLoadFunction(&map, GL_LUMINANCE,          GL_HALF_FLOAT,                     loadLuminanceHalfFloatDataToRGBA     );
+    insertLoadFunction(&map, GL_ALPHA,              GL_HALF_FLOAT,                     loadAlphaHalfFloatDataToRGBA         );
+
+    // From GL_EXT_texture_storage
+    insertLoadFunction(&map, GL_ALPHA8_EXT,             GL_UNSIGNED_BYTE,              loadToNative<GLubyte, 1>             );
+    insertLoadFunction(&map, GL_LUMINANCE8_EXT,         GL_UNSIGNED_BYTE,              loadLuminanceDataToBGRA              );
+    insertLoadFunction(&map, GL_LUMINANCE8_ALPHA8_EXT,  GL_UNSIGNED_BYTE,              loadLuminanceAlphaDataToBGRA         );
+    insertLoadFunction(&map, GL_ALPHA32F_EXT,           GL_FLOAT,                      loadAlphaFloatDataToRGBA             );
+    insertLoadFunction(&map, GL_LUMINANCE32F_EXT,       GL_FLOAT,                      loadLuminanceFloatDataToRGB          );
+    insertLoadFunction(&map, GL_LUMINANCE_ALPHA32F_EXT, GL_FLOAT,                      loadLuminanceAlphaFloatDataToRGBA    );
+    insertLoadFunction(&map, GL_ALPHA16F_EXT,           GL_HALF_FLOAT,                 loadAlphaHalfFloatDataToRGBA         );
+    insertLoadFunction(&map, GL_LUMINANCE16F_EXT,       GL_HALF_FLOAT,                 loadLuminanceHalfFloatDataToRGBA     );
+    insertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT,                 loadLuminanceAlphaHalfFloatDataToRGBA);
+
+    insertLoadFunction(&map, GL_BGRA8_EXT,              GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>         );
+    insertLoadFunction(&map, GL_BGRA4_ANGLEX,           GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, loadRGBA4444DataToRGBA           );
+    insertLoadFunction(&map, GL_BGRA4_ANGLEX,           GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>         );
+    insertLoadFunction(&map, GL_BGR5_A1_ANGLEX,         GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, loadRGBA5551DataToRGBA           );
+    insertLoadFunction(&map, GL_BGR5_A1_ANGLEX,         GL_UNSIGNED_BYTE,                  loadToNative<GLubyte, 4>         );
+
+    // Compressed formats
+    // From ES 3.0.1 spec, table 3.16
+    //                      | Internal format                             | Type            | Load function                     |
+    insertLoadFunction(&map, GL_COMPRESSED_R11_EAC,                        GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_R11_EAC,                        GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_SIGNED_R11_EAC,                 GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_RG11_EAC,                       GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_SIGNED_RG11_EAC,                GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_RGB8_ETC2,                      GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_SRGB8_ETC2,                     GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_RGBA8_ETC2_EAC,                 GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+    insertLoadFunction(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          GL_UNSIGNED_BYTE, UnimplementedLoadFunction          );
+
+    // From GL_EXT_texture_compression_dxt1
+    insertLoadFunction(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,              GL_UNSIGNED_BYTE, loadCompressedBlockDataToNative<4, 4,  8>);
+    insertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,             GL_UNSIGNED_BYTE, loadCompressedBlockDataToNative<4, 4,  8>);
+
+    // From GL_ANGLE_texture_compression_dxt3
+    insertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,           GL_UNSIGNED_BYTE, loadCompressedBlockDataToNative<4, 4, 16>);
+
+    // From GL_ANGLE_texture_compression_dxt5
+    insertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,           GL_UNSIGNED_BYTE, loadCompressedBlockDataToNative<4, 4, 16>);
+
+    return map;
+}
+
+struct D3D11ES2FormatInfo
+{
+    DXGI_FORMAT mTexFormat;
+    DXGI_FORMAT mSRVFormat;
+    DXGI_FORMAT mRTVFormat;
+    DXGI_FORMAT mDSVFormat;
+
+    LoadImageFunction mLoadImageFunction;
+
+    D3D11ES2FormatInfo()
+        : mTexFormat(DXGI_FORMAT_UNKNOWN), mDSVFormat(DXGI_FORMAT_UNKNOWN), mRTVFormat(DXGI_FORMAT_UNKNOWN),
+        mSRVFormat(DXGI_FORMAT_UNKNOWN), mLoadImageFunction(NULL)
+    { }
+
+    D3D11ES2FormatInfo(DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat,
+        LoadImageFunction loadFunc)
+        : mTexFormat(texFormat), mDSVFormat(dsvFormat), mRTVFormat(rtvFormat), mSRVFormat(srvFormat),
+        mLoadImageFunction(loadFunc)
+    { }
+};
+
+// ES2 internal formats can map to DXGI formats and loading functions
+typedef std::pair<GLenum, D3D11ES2FormatInfo> D3D11ES2FormatPair;
+typedef std::map<GLenum, D3D11ES2FormatInfo> D3D11ES2FormatMap;
+
+static D3D11ES2FormatMap BuildD3D11ES2FormatMap()
+{
+    D3D11ES2FormatMap map;
+
+    //                           | Internal format                   |                  | Texture format                | SRV format                       | RTV format                    | DSV format                   | Load function                           |
+    map.insert(D3D11ES2FormatPair(GL_NONE,                            D3D11ES2FormatInfo(DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN,               DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN,           UnreachableLoadFunction                  )));
+    map.insert(D3D11ES2FormatPair(GL_DEPTH_COMPONENT16,               D3D11ES2FormatInfo(DXGI_FORMAT_R16_TYPELESS,       DXGI_FORMAT_R16_UNORM,             DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D16_UNORM,         UnreachableLoadFunction                  )));
+    map.insert(D3D11ES2FormatPair(GL_DEPTH_COMPONENT32_OES,           D3D11ES2FormatInfo(DXGI_FORMAT_R32_TYPELESS,       DXGI_FORMAT_R32_FLOAT,             DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D32_FLOAT,         UnreachableLoadFunction                  )));
+    map.insert(D3D11ES2FormatPair(GL_DEPTH24_STENCIL8_OES,            D3D11ES2FormatInfo(DXGI_FORMAT_R24G8_TYPELESS,     DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D24_UNORM_S8_UINT, UnreachableLoadFunction                  )));
+    map.insert(D3D11ES2FormatPair(GL_STENCIL_INDEX8,                  D3D11ES2FormatInfo(DXGI_FORMAT_R24G8_TYPELESS,     DXGI_FORMAT_X24_TYPELESS_G8_UINT,  DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_D24_UNORM_S8_UINT, UnreachableLoadFunction                  )));
+
+    map.insert(D3D11ES2FormatPair(GL_RGBA32F_EXT,                     D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,    DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN,           loadRGBAFloatDataToRGBA                  )));
+    map.insert(D3D11ES2FormatPair(GL_RGB32F_EXT,                      D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,    DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN,           loadRGBFloatDataToRGBA                   )));
+    map.insert(D3D11ES2FormatPair(GL_ALPHA32F_EXT,                    D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,    DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN,           loadAlphaFloatDataToRGBA                 )));
+    map.insert(D3D11ES2FormatPair(GL_LUMINANCE32F_EXT,                D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,    DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN,           loadLuminanceFloatDataToRGBA             )));
+    map.insert(D3D11ES2FormatPair(GL_LUMINANCE_ALPHA32F_EXT,          D3D11ES2FormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT,    DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_UNKNOWN,           loadLuminanceAlphaFloatDataToRGBA        )));
+
+    map.insert(D3D11ES2FormatPair(GL_RGBA16F_EXT,                     D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT,    DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN,           loadRGBAHalfFloatDataToRGBA              )));
+    map.insert(D3D11ES2FormatPair(GL_RGB16F_EXT,                      D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT,    DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN,           loadRGBHalfFloatDataToRGBA               )));
+    map.insert(D3D11ES2FormatPair(GL_ALPHA16F_EXT,                    D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT,    DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN,           loadAlphaHalfFloatDataToRGBA             )));
+    map.insert(D3D11ES2FormatPair(GL_LUMINANCE16F_EXT,                D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT,    DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN,           loadLuminanceHalfFloatDataToRGBA         )));
+    map.insert(D3D11ES2FormatPair(GL_LUMINANCE_ALPHA16F_EXT,          D3D11ES2FormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT,    DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN,           loadLuminanceAlphaHalfFloatDataToRGBA    )));
+
+    map.insert(D3D11ES2FormatPair(GL_ALPHA8_EXT,                      D3D11ES2FormatInfo(DXGI_FORMAT_A8_UNORM,           DXGI_FORMAT_A8_UNORM,              DXGI_FORMAT_A8_UNORM,           DXGI_FORMAT_UNKNOWN,           loadAlphaDataToNative                    )));
+    map.insert(D3D11ES2FormatPair(GL_LUMINANCE8_EXT,                  D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,        DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadLuminanceDataToBGRA                  )));
+    map.insert(D3D11ES2FormatPair(GL_LUMINANCE8_ALPHA8_EXT,           D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,        DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadLuminanceAlphaDataToBGRA             )));
+
+    map.insert(D3D11ES2FormatPair(GL_RGB8_OES,                        D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,        DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadRGBUByteDataToRGBA                   )));
+    map.insert(D3D11ES2FormatPair(GL_RGB565,                          D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,        DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadRGB565DataToRGBA                     )));
+    map.insert(D3D11ES2FormatPair(GL_RGBA8_OES,                       D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,        DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadRGBAUByteDataToNative                )));
+    map.insert(D3D11ES2FormatPair(GL_RGBA4,                           D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,        DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadRGBA4444DataToRGBA                   )));
+    map.insert(D3D11ES2FormatPair(GL_RGB5_A1,                         D3D11ES2FormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,        DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadRGBA5551DataToRGBA                   )));
+    map.insert(D3D11ES2FormatPair(GL_BGRA8_EXT,                       D3D11ES2FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_B8G8R8A8_UNORM,        DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadBGRADataToBGRA                       )));
+    map.insert(D3D11ES2FormatPair(GL_BGRA4_ANGLEX,                    D3D11ES2FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_B8G8R8A8_UNORM,        DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadRGBA4444DataToRGBA                   )));
+    map.insert(D3D11ES2FormatPair(GL_BGR5_A1_ANGLEX,                  D3D11ES2FormatInfo(DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_B8G8R8A8_UNORM,        DXGI_FORMAT_B8G8R8A8_UNORM,     DXGI_FORMAT_UNKNOWN,           loadRGBA5551DataToRGBA                   )));
+
+    // From GL_EXT_texture_rg
+    map.insert(D3D11ES2FormatPair(GL_R8_EXT,                          D3D11ES2FormatInfo(DXGI_FORMAT_R8_UNORM,           DXGI_FORMAT_R8_UNORM,              DXGI_FORMAT_R8_UNORM,           DXGI_FORMAT_UNKNOWN,           loadToNative<GLubyte, 1>                 )));
+    map.insert(D3D11ES2FormatPair(GL_R32F_EXT,                        D3D11ES2FormatInfo(DXGI_FORMAT_R32_FLOAT,          DXGI_FORMAT_R32_FLOAT,             DXGI_FORMAT_R32_FLOAT,          DXGI_FORMAT_UNKNOWN,           loadToNative<GLfloat, 1>                 )));
+    map.insert(D3D11ES2FormatPair(GL_R16F_EXT,                        D3D11ES2FormatInfo(DXGI_FORMAT_R16_FLOAT,          DXGI_FORMAT_R16_FLOAT,             DXGI_FORMAT_R16_FLOAT,          DXGI_FORMAT_UNKNOWN,           loadToNative<GLhalf, 1>                  )));
+    map.insert(D3D11ES2FormatPair(GL_RG8_EXT,                         D3D11ES2FormatInfo(DXGI_FORMAT_R8G8_UNORM,         DXGI_FORMAT_R8G8_UNORM,            DXGI_FORMAT_R8G8_UNORM,         DXGI_FORMAT_UNKNOWN,           loadToNative<GLubyte, 2>                 )));
+    map.insert(D3D11ES2FormatPair(GL_RG32F_EXT,                       D3D11ES2FormatInfo(DXGI_FORMAT_R32G32_FLOAT,       DXGI_FORMAT_R32G32_FLOAT,          DXGI_FORMAT_R32G32_FLOAT,       DXGI_FORMAT_UNKNOWN,           loadToNative<GLfloat, 2>                 )));
+    map.insert(D3D11ES2FormatPair(GL_RG16F_EXT,                       D3D11ES2FormatInfo(DXGI_FORMAT_R16G16_FLOAT,       DXGI_FORMAT_R16G16_FLOAT,          DXGI_FORMAT_R16G16_FLOAT,       DXGI_FORMAT_UNKNOWN,           loadToNative<GLhalf, 2>                  )));
+
+    map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    D3D11ES2FormatInfo(DXGI_FORMAT_BC1_UNORM,          DXGI_FORMAT_BC1_UNORM,             DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN,           loadCompressedBlockDataToNative<4, 4,  8>)));
+    map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   D3D11ES2FormatInfo(DXGI_FORMAT_BC1_UNORM,          DXGI_FORMAT_BC1_UNORM,             DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN,           loadCompressedBlockDataToNative<4, 4,  8>)));
+    map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, D3D11ES2FormatInfo(DXGI_FORMAT_BC2_UNORM,          DXGI_FORMAT_BC2_UNORM,             DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN,           loadCompressedBlockDataToNative<4, 4, 16>)));
+    map.insert(D3D11ES2FormatPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, D3D11ES2FormatInfo(DXGI_FORMAT_BC3_UNORM,          DXGI_FORMAT_BC3_UNORM,             DXGI_FORMAT_UNKNOWN,            DXGI_FORMAT_UNKNOWN,           loadCompressedBlockDataToNative<4, 4, 16>)));
+
+    return map;
+}
+
+static bool GetD3D11ES2FormatInfo(GLenum internalFormat, GLuint clientVersion, D3D11ES2FormatInfo *outFormatInfo)
+{
+    static const D3D11ES2FormatMap formatMap = BuildD3D11ES2FormatMap();
+    D3D11ES2FormatMap::const_iterator iter = formatMap.find(internalFormat);
+    if (iter != formatMap.end())
+    {
+        if (outFormatInfo)
+        {
+            *outFormatInfo = iter->second;
+        }
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+// A map to determine the pixel size and mipmap generation function of a given DXGI format
+struct DXGIFormatInfo
+{
+    GLuint mPixelBits;
+    GLuint mBlockWidth;
+    GLuint mBlockHeight;
+    GLenum mComponentType;
+
+    MipGenerationFunction mMipGenerationFunction;
+    ColorReadFunction mColorReadFunction;
+
+    DXGIFormatInfo()
+        : mPixelBits(0), mBlockWidth(0), mBlockHeight(0), mComponentType(GL_NONE), mMipGenerationFunction(NULL),
+          mColorReadFunction(NULL)
+    { }
+
+    DXGIFormatInfo(GLuint pixelBits, GLuint blockWidth, GLuint blockHeight, GLenum componentType,
+                   MipGenerationFunction mipFunc, ColorReadFunction readFunc)
+        : mPixelBits(pixelBits), mBlockWidth(blockWidth), mBlockHeight(blockHeight), mComponentType(componentType),
+          mMipGenerationFunction(mipFunc), mColorReadFunction(readFunc)
+    { }
+};
+
+typedef std::map<DXGI_FORMAT, DXGIFormatInfo> DXGIFormatInfoMap;
+
+void AddDXGIFormat(DXGIFormatInfoMap *map, DXGI_FORMAT dxgiFormat, GLuint pixelBits, GLuint blockWidth, GLuint blockHeight,
+                   GLenum componentType, MipGenerationFunction mipFunc, ColorReadFunction readFunc)
+{
+    map->insert(std::make_pair(dxgiFormat, DXGIFormatInfo(pixelBits, blockWidth, blockHeight, componentType, mipFunc, readFunc)));
+}
+
+static DXGIFormatInfoMap BuildDXGIFormatInfoMap()
+{
+    DXGIFormatInfoMap map;
+
+    //                | DXGI format                          |S   |W |H |Component Type        | Mip generation function   | Color read function
+    AddDXGIFormat(&map, DXGI_FORMAT_UNKNOWN,                  0,   0, 0, GL_NONE,                NULL,                       NULL);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_A8_UNORM,                 8,   1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<A8>,            ReadColor<A8, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8_UNORM,                 8,   1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8>,            ReadColor<R8, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8_UNORM,               16,  1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8G8>,          ReadColor<R8G8, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UNORM,           32,  1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8G8B8A8>,      ReadColor<R8G8B8A8, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,      32,  1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R8G8B8A8>,      ReadColor<R8G8B8A8, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_B8G8R8A8_UNORM,           32,  1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<B8G8R8A8>,      ReadColor<B8G8R8A8, GLfloat>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R8_SNORM,                 8,   1, 1, GL_SIGNED_NORMALIZED,   GenerateMip<R8S>,           ReadColor<R8S, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8_SNORM,               16,  1, 1, GL_SIGNED_NORMALIZED,   GenerateMip<R8G8S>,         ReadColor<R8G8S, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_SNORM,           32,  1, 1, GL_SIGNED_NORMALIZED,   GenerateMip<R8G8B8A8S>,     ReadColor<R8G8B8A8S, GLfloat>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R8_UINT,                  8,   1, 1, GL_UNSIGNED_INT,        GenerateMip<R8>,            ReadColor<R8, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16_UINT,                 16,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R16>,           ReadColor<R16, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32_UINT,                 32,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R32>,           ReadColor<R32, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8_UINT,                16,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R8G8>,          ReadColor<R8G8, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16_UINT,              32,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R16G16>,        ReadColor<R16G16, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32_UINT,              64,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R32G32>,        ReadColor<R32G32, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_UINT,           96,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R32G32B32>,     ReadColor<R32G32B32, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_UINT,            32,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R8G8B8A8>,      ReadColor<R8G8B8A8, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_UINT,        64,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R16G16B16A16>,  ReadColor<R16G16B16A16, GLuint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_UINT,        128, 1, 1, GL_UNSIGNED_INT,        GenerateMip<R32G32B32A32>,  ReadColor<R32G32B32A32, GLuint>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R8_SINT,                  8,   1, 1, GL_INT,                 GenerateMip<R8S>,           ReadColor<R8S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16_SINT,                 16,  1, 1, GL_INT,                 GenerateMip<R16S>,          ReadColor<R16S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32_SINT,                 32,  1, 1, GL_INT,                 GenerateMip<R32S>,          ReadColor<R32S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8_SINT,                16,  1, 1, GL_INT,                 GenerateMip<R8G8S>,         ReadColor<R8G8S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16_SINT,              32,  1, 1, GL_INT,                 GenerateMip<R16G16S>,       ReadColor<R16G16S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32_SINT,              64,  1, 1, GL_INT,                 GenerateMip<R32G32S>,       ReadColor<R32G32S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_SINT,           96,  1, 1, GL_INT,                 GenerateMip<R32G32B32S>,    ReadColor<R32G32B32S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R8G8B8A8_SINT,            32,  1, 1, GL_INT,                 GenerateMip<R8G8B8A8S>,     ReadColor<R8G8B8A8S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_SINT,        64,  1, 1, GL_INT,                 GenerateMip<R16G16B16A16S>, ReadColor<R16G16B16A16S, GLint>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_SINT,        128, 1, 1, GL_INT,                 GenerateMip<R32G32B32A32S>, ReadColor<R32G32B32A32S, GLint>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R10G10B10A2_UNORM,        32,  1, 1, GL_UNSIGNED_NORMALIZED, GenerateMip<R10G10B10A2>,   ReadColor<R10G10B10A2, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R10G10B10A2_UINT,         32,  1, 1, GL_UNSIGNED_INT,        GenerateMip<R10G10B10A2>,   ReadColor<R10G10B10A2, GLuint>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R16_FLOAT,                16,  1, 1, GL_FLOAT,               GenerateMip<R16F>,          ReadColor<R16F, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16_FLOAT,             32,  1, 1, GL_FLOAT,               GenerateMip<R16G16F>,       ReadColor<R16G16F, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_FLOAT,       64,  1, 1, GL_FLOAT,               GenerateMip<R16G16B16A16F>, ReadColor<R16G16B16A16F, GLfloat>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R32_FLOAT,                32,  1, 1, GL_FLOAT,               GenerateMip<R32F>,          ReadColor<R32F, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32_FLOAT,             64,  1, 1, GL_FLOAT,               GenerateMip<R32G32F>,       ReadColor<R32G32F, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32_FLOAT,          96,  1, 1, GL_FLOAT,               NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G32B32A32_FLOAT,       128, 1, 1, GL_FLOAT,               GenerateMip<R32G32B32A32F>, ReadColor<R32G32B32A32F, GLfloat>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R9G9B9E5_SHAREDEXP,       32,  1, 1, GL_FLOAT,               GenerateMip<R9G9B9E5>,      ReadColor<R9G9B9E5, GLfloat>);
+    AddDXGIFormat(&map, DXGI_FORMAT_R11G11B10_FLOAT,          32,  1, 1, GL_FLOAT,               GenerateMip<R11G11B10F>,    ReadColor<R11G11B10F, GLfloat>);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_R16_TYPELESS,             16,  1, 1, GL_NONE,                NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16_UNORM,                16,  1, 1, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_D16_UNORM,                16,  1, 1, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R24G8_TYPELESS,           32,  1, 1, GL_NONE,                NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS,    32,  1, 1, GL_NONE,                NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_D24_UNORM_S8_UINT,        32,  1, 1, GL_UNSIGNED_INT,        NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32G8X24_TYPELESS,        64,  1, 1, GL_NONE,                NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, 64,  1, 1, GL_NONE,                NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT,     64,  1, 1, GL_UNSIGNED_INT,        NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R32_TYPELESS,             32,  1, 1, GL_NONE,                NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_D32_FLOAT,                32,  1, 1, GL_FLOAT,               NULL,                       NULL);
+
+    AddDXGIFormat(&map, DXGI_FORMAT_BC1_UNORM,                64,  4, 4, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_BC2_UNORM,                128, 4, 4, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_BC3_UNORM,                128, 4, 4, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+
+    // Useful formats for vertex buffers
+    AddDXGIFormat(&map, DXGI_FORMAT_R16_UNORM,                16,  1, 1, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16_SNORM,                16,  1, 1, GL_SIGNED_NORMALIZED,   NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16_UNORM,             32,  1, 1, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16_SNORM,             32,  1, 1, GL_SIGNED_NORMALIZED,   NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_UNORM,       64,  1, 1, GL_UNSIGNED_NORMALIZED, NULL,                       NULL);
+    AddDXGIFormat(&map, DXGI_FORMAT_R16G16B16A16_SNORM,       64,  1, 1, GL_SIGNED_NORMALIZED,   NULL,                       NULL);
+
+    return map;
+}
+
+typedef std::map<DXGI_FORMAT, GLenum> DXGIToESFormatMap;
+
+inline void AddDXGIToESEntry(DXGIToESFormatMap *map, DXGI_FORMAT key, GLenum value)
+{
+    map->insert(std::make_pair(key, value));
+}
+
+static DXGIToESFormatMap BuildCommonDXGIToESFormatMap()
+{
+    DXGIToESFormatMap map;
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_UNKNOWN,                  GL_NONE);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_A8_UNORM,                 GL_ALPHA8_EXT);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8_UNORM,                 GL_R8);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_UNORM,               GL_RG8);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_UNORM,           GL_RGBA8);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,      GL_SRGB8_ALPHA8);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_B8G8R8A8_UNORM,           GL_BGRA8_EXT);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8_SNORM,                 GL_R8_SNORM);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_SNORM,               GL_RG8_SNORM);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_SNORM,           GL_RGBA8_SNORM);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8_UINT,                  GL_R8UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16_UINT,                 GL_R16UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32_UINT,                 GL_R32UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_UINT,                GL_RG8UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16_UINT,              GL_RG16UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32_UINT,              GL_RG32UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32_UINT,           GL_RGB32UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_UINT,            GL_RGBA8UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16B16A16_UINT,        GL_RGBA16UI);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32A32_UINT,        GL_RGBA32UI);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8_SINT,                  GL_R8I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16_SINT,                 GL_R16I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32_SINT,                 GL_R32I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8_SINT,                GL_RG8I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16_SINT,              GL_RG16I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32_SINT,              GL_RG32I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32_SINT,           GL_RGB32I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R8G8B8A8_SINT,            GL_RGBA8I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16B16A16_SINT,        GL_RGBA16I);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32A32_SINT,        GL_RGBA32I);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R10G10B10A2_UNORM,        GL_RGB10_A2);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R10G10B10A2_UINT,         GL_RGB10_A2UI);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16_FLOAT,                GL_R16F);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16_FLOAT,             GL_RG16F);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16G16B16A16_FLOAT,       GL_RGBA16F);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32_FLOAT,                GL_R32F);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32_FLOAT,             GL_RG32F);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32_FLOAT,          GL_RGB32F);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G32B32A32_FLOAT,       GL_RGBA32F);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R9G9B9E5_SHAREDEXP,       GL_RGB9_E5);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R11G11B10_FLOAT,          GL_R11F_G11F_B10F);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16_TYPELESS,             GL_DEPTH_COMPONENT16);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R16_UNORM,                GL_DEPTH_COMPONENT16);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_D16_UNORM,                GL_DEPTH_COMPONENT16);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R24G8_TYPELESS,           GL_DEPTH24_STENCIL8_OES);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R24_UNORM_X8_TYPELESS,    GL_DEPTH24_STENCIL8_OES);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_D24_UNORM_S8_UINT,        GL_DEPTH24_STENCIL8_OES);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32G8X24_TYPELESS,        GL_DEPTH32F_STENCIL8);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, GL_DEPTH32F_STENCIL8);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_D32_FLOAT_S8X24_UINT,     GL_DEPTH32F_STENCIL8);
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_BC1_UNORM,                GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_BC2_UNORM,                GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_BC3_UNORM,                GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
+
+    return map;
+}
+
+static DXGIToESFormatMap BuildDXGIToES2FormatMap()
+{
+    DXGIToESFormatMap map = BuildCommonDXGIToESFormatMap();
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32_TYPELESS, GL_DEPTH_COMPONENT32_OES);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_D32_FLOAT,    GL_DEPTH_COMPONENT32_OES);
+
+    return map;
+}
+
+static DXGIToESFormatMap BuildDXGIToES3FormatMap()
+{
+    DXGIToESFormatMap map = BuildCommonDXGIToESFormatMap();
+
+    AddDXGIToESEntry(&map, DXGI_FORMAT_R32_TYPELESS, GL_DEPTH_COMPONENT32F);
+    AddDXGIToESEntry(&map, DXGI_FORMAT_D32_FLOAT,    GL_DEPTH_COMPONENT32F);
+
+    return map;
+}
+
+static const DXGIFormatInfoMap &GetDXGIFormatInfoMap()
+{
+    static const DXGIFormatInfoMap infoMap = BuildDXGIFormatInfoMap();
+    return infoMap;
+}
+
+static bool GetDXGIFormatInfo(DXGI_FORMAT format, DXGIFormatInfo *outFormatInfo)
+{
+    const DXGIFormatInfoMap &infoMap = GetDXGIFormatInfoMap();
+    DXGIFormatInfoMap::const_iterator iter = infoMap.find(format);
+    if (iter != infoMap.end())
+    {
+        if (outFormatInfo)
+        {
+            *outFormatInfo = iter->second;
+        }
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+static d3d11::DXGIFormatSet BuildAllDXGIFormatSet()
+{
+    d3d11::DXGIFormatSet set;
+
+    const DXGIFormatInfoMap &infoMap = GetDXGIFormatInfoMap();
+    for (DXGIFormatInfoMap::const_iterator i = infoMap.begin(); i != infoMap.end(); ++i)
+    {
+        set.insert(i->first);
+    }
+
+    return set;
+}
+
+struct D3D11FastCopyFormat
+{
+    DXGI_FORMAT mSourceFormat;
+    GLenum mDestFormat;
+    GLenum mDestType;
+
+    D3D11FastCopyFormat(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType)
+        : mSourceFormat(sourceFormat), mDestFormat(destFormat), mDestType(destType)
+    { }
+
+    bool operator<(const D3D11FastCopyFormat& other) const
+    {
+        return memcmp(this, &other, sizeof(D3D11FastCopyFormat)) < 0;
+    }
+};
+
+typedef std::map<D3D11FastCopyFormat, ColorCopyFunction> D3D11FastCopyMap;
+typedef std::pair<D3D11FastCopyFormat, ColorCopyFunction> D3D11FastCopyPair;
+
+static D3D11FastCopyMap BuildFastCopyMap()
+{
+    D3D11FastCopyMap map;
+
+    map.insert(D3D11FastCopyPair(D3D11FastCopyFormat(DXGI_FORMAT_B8G8R8A8_UNORM, GL_RGBA, GL_UNSIGNED_BYTE), CopyBGRAUByteToRGBAUByte));
+
+    return map;
+}
+
+struct DXGIDepthStencilInfo
+{
+    unsigned int mDepthBits;
+    unsigned int mDepthOffset;
+    unsigned int mStencilBits;
+    unsigned int mStencilOffset;
+
+    DXGIDepthStencilInfo()
+        : mDepthBits(0), mDepthOffset(0), mStencilBits(0), mStencilOffset(0)
+    { }
+
+    DXGIDepthStencilInfo(unsigned int depthBits, unsigned int depthOffset, unsigned int stencilBits, unsigned int stencilOffset)
+        : mDepthBits(depthBits), mDepthOffset(depthOffset), mStencilBits(stencilBits), mStencilOffset(stencilOffset)
+    { }
+};
+
+typedef std::map<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoMap;
+typedef std::pair<DXGI_FORMAT, DXGIDepthStencilInfo> DepthStencilInfoPair;
+
+static DepthStencilInfoMap BuildDepthStencilInfoMap()
+{
+    DepthStencilInfoMap map;
+
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R16_TYPELESS,             DXGIDepthStencilInfo(16, 0, 0,  0)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R16_UNORM,                DXGIDepthStencilInfo(16, 0, 0,  0)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_D16_UNORM,                DXGIDepthStencilInfo(16, 0, 0,  0)));
+
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R24G8_TYPELESS,           DXGIDepthStencilInfo(24, 0, 8, 24)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R24_UNORM_X8_TYPELESS,    DXGIDepthStencilInfo(24, 0, 8, 24)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_D24_UNORM_S8_UINT,        DXGIDepthStencilInfo(24, 0, 8, 24)));
+
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R32_TYPELESS,             DXGIDepthStencilInfo(32, 0, 0,  0)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R32_FLOAT,                DXGIDepthStencilInfo(32, 0, 0,  0)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_D32_FLOAT,                DXGIDepthStencilInfo(32, 0, 0,  0)));
+
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R32G8X24_TYPELESS,        DXGIDepthStencilInfo(32, 0, 8, 32)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, DXGIDepthStencilInfo(32, 0, 8, 32)));
+    map.insert(DepthStencilInfoPair(DXGI_FORMAT_D32_FLOAT_S8X24_UINT,     DXGIDepthStencilInfo(32, 0, 8, 32)));
+
+    return map;
+}
+
+static const DepthStencilInfoMap &GetDepthStencilInfoMap()
+{
+    static const DepthStencilInfoMap infoMap = BuildDepthStencilInfoMap();
+    return infoMap;
+}
+
+bool GetDepthStencilInfo(DXGI_FORMAT format, DXGIDepthStencilInfo *outDepthStencilInfo)
+{
+    const DepthStencilInfoMap& infoMap = GetDepthStencilInfoMap();
+    DepthStencilInfoMap::const_iterator iter = infoMap.find(format);
+    if (iter != infoMap.end())
+    {
+        if (outDepthStencilInfo)
+        {
+            *outDepthStencilInfo = iter->second;
+        }
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+struct SwizzleSizeType
+{
+    unsigned int mMaxComponentSize;
+    GLenum mComponentType;
+
+    SwizzleSizeType()
+        : mMaxComponentSize(0), mComponentType(GL_NONE)
+    { }
+
+    SwizzleSizeType(unsigned int maxComponentSize, GLenum componentType)
+        : mMaxComponentSize(maxComponentSize), mComponentType(componentType)
+    { }
+
+    bool operator<(const SwizzleSizeType& other) const
+    {
+        return (mMaxComponentSize != other.mMaxComponentSize) ? (mMaxComponentSize < other.mMaxComponentSize)
+                                                              : (mComponentType < other.mComponentType);
+    }
+};
+
+struct SwizzleFormatInfo
+{
+    DXGI_FORMAT mTexFormat;
+    DXGI_FORMAT mSRVFormat;
+    DXGI_FORMAT mRTVFormat;
+
+    SwizzleFormatInfo()
+        : mTexFormat(DXGI_FORMAT_UNKNOWN), mSRVFormat(DXGI_FORMAT_UNKNOWN), mRTVFormat(DXGI_FORMAT_UNKNOWN)
+    { }
+
+    SwizzleFormatInfo(DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat)
+        : mTexFormat(texFormat), mSRVFormat(srvFormat), mRTVFormat(rtvFormat)
+    { }
+};
+
+typedef std::map<SwizzleSizeType, SwizzleFormatInfo> SwizzleInfoMap;
+typedef std::pair<SwizzleSizeType, SwizzleFormatInfo> SwizzleInfoPair;
+
+static SwizzleInfoMap BuildSwizzleInfoMap()
+{
+    SwizzleInfoMap map;
+
+    map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM,     DXGI_FORMAT_R8G8B8A8_UNORM    )));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_UNORM, DXGI_FORMAT_R16G16B16A16_UNORM, DXGI_FORMAT_R16G16B16A16_UNORM)));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(24, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT)));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_UNSIGNED_NORMALIZED), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT)));
+
+    map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_SIGNED_NORMALIZED  ), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_SNORM,     DXGI_FORMAT_R8G8B8A8_SNORM,     DXGI_FORMAT_R8G8B8A8_SNORM    )));
+
+    map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_FLOAT              ), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT)));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_FLOAT              ), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT)));
+
+    map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_UNSIGNED_INT       ), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_UINT,      DXGI_FORMAT_R8G8B8A8_UINT,      DXGI_FORMAT_R8G8B8A8_UINT     )));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_UNSIGNED_INT       ), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_UINT,  DXGI_FORMAT_R16G16B16A16_UINT,  DXGI_FORMAT_R16G16B16A16_UINT )));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_UNSIGNED_INT       ), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_UINT,  DXGI_FORMAT_R32G32B32A32_UINT,  DXGI_FORMAT_R32G32B32A32_UINT )));
+
+    map.insert(SwizzleInfoPair(SwizzleSizeType( 8, GL_INT                ), SwizzleFormatInfo(DXGI_FORMAT_R8G8B8A8_SINT,      DXGI_FORMAT_R8G8B8A8_SINT,      DXGI_FORMAT_R8G8B8A8_SINT     )));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(16, GL_INT                ), SwizzleFormatInfo(DXGI_FORMAT_R16G16B16A16_SINT,  DXGI_FORMAT_R16G16B16A16_SINT,  DXGI_FORMAT_R16G16B16A16_SINT )));
+    map.insert(SwizzleInfoPair(SwizzleSizeType(32, GL_INT                ), SwizzleFormatInfo(DXGI_FORMAT_R32G32B32A32_SINT,  DXGI_FORMAT_R32G32B32A32_SINT,  DXGI_FORMAT_R32G32B32A32_SINT )));
+
+    return map;
+}
+typedef std::pair<GLint, InitializeTextureDataFunction> InternalFormatInitializerPair;
+typedef std::map<GLint, InitializeTextureDataFunction> InternalFormatInitializerMap;
+
+static InternalFormatInitializerMap BuildInternalFormatInitializerMap()
+{
+    InternalFormatInitializerMap map;
+
+    map.insert(InternalFormatInitializerPair(GL_RGB8,    initialize4ComponentData<GLubyte,  0x00,       0x00,       0x00,       0xFF>          ));
+    map.insert(InternalFormatInitializerPair(GL_RGB565,  initialize4ComponentData<GLubyte,  0x00,       0x00,       0x00,       0xFF>          ));
+    map.insert(InternalFormatInitializerPair(GL_SRGB8,   initialize4ComponentData<GLubyte,  0x00,       0x00,       0x00,       0xFF>          ));
+    map.insert(InternalFormatInitializerPair(GL_RGB16F,  initialize4ComponentData<GLhalf,   0x0000,     0x0000,     0x0000,     gl::Float16One>));
+    map.insert(InternalFormatInitializerPair(GL_RGB32F,  initialize4ComponentData<GLfloat,  0x00000000, 0x00000000, 0x00000000, gl::Float32One>));
+    map.insert(InternalFormatInitializerPair(GL_RGB8UI,  initialize4ComponentData<GLubyte,  0x00,       0x00,       0x00,       0x01>          ));
+    map.insert(InternalFormatInitializerPair(GL_RGB8I,   initialize4ComponentData<GLbyte,   0x00,       0x00,       0x00,       0x01>          ));
+    map.insert(InternalFormatInitializerPair(GL_RGB16UI, initialize4ComponentData<GLushort, 0x0000,     0x0000,     0x0000,     0x0001>        ));
+    map.insert(InternalFormatInitializerPair(GL_RGB16I,  initialize4ComponentData<GLshort,  0x0000,     0x0000,     0x0000,     0x0001>        ));
+    map.insert(InternalFormatInitializerPair(GL_RGB32UI, initialize4ComponentData<GLuint,   0x00000000, 0x00000000, 0x00000000, 0x00000001>    ));
+    map.insert(InternalFormatInitializerPair(GL_RGB32I,  initialize4ComponentData<GLint,    0x00000000, 0x00000000, 0x00000000, 0x00000001>    ));
+
+    return map;
+}
+
+static const SwizzleInfoMap &GetSwizzleInfoMap()
+{
+    static const SwizzleInfoMap map = BuildSwizzleInfoMap();
+    return map;
+}
+
+static const SwizzleFormatInfo GetSwizzleFormatInfo(GLint internalFormat, GLuint clientVersion)
+{
+    // Get the maximum sized component
+    unsigned int maxBits = 1;
+
+    if (gl::IsFormatCompressed(internalFormat, clientVersion))
+    {
+        unsigned int compressedBitsPerBlock = gl::GetPixelBytes(internalFormat, clientVersion) * 8;
+        unsigned int blockSize = gl::GetCompressedBlockWidth(internalFormat, clientVersion) *
+                                 gl::GetCompressedBlockHeight(internalFormat, clientVersion);
+        maxBits = std::max(compressedBitsPerBlock / blockSize, maxBits);
+    }
+    else
+    {
+        maxBits = std::max(maxBits, gl::GetAlphaBits(    internalFormat, clientVersion));
+        maxBits = std::max(maxBits, gl::GetRedBits(      internalFormat, clientVersion));
+        maxBits = std::max(maxBits, gl::GetGreenBits(    internalFormat, clientVersion));
+        maxBits = std::max(maxBits, gl::GetBlueBits(     internalFormat, clientVersion));
+        maxBits = std::max(maxBits, gl::GetLuminanceBits(internalFormat, clientVersion));
+        maxBits = std::max(maxBits, gl::GetDepthBits(    internalFormat, clientVersion));
+    }
+
+    maxBits = roundUp(maxBits, 8U);
+
+    GLenum componentType = gl::GetComponentType(internalFormat, clientVersion);
+
+    const SwizzleInfoMap &map = GetSwizzleInfoMap();
+    SwizzleInfoMap::const_iterator iter = map.find(SwizzleSizeType(maxBits, componentType));
+
+    if (iter != map.end())
+    {
+        return iter->second;
+    }
+    else
+    {
+        UNREACHABLE();
+        static const SwizzleFormatInfo defaultFormatInfo;
+        return defaultFormatInfo;
+    }
+}
+
+static const InternalFormatInitializerMap &GetInternalFormatInitializerMap()
+{
+    static const InternalFormatInitializerMap map = BuildInternalFormatInitializerMap();
+    return map;
+}
+
+namespace d3d11
+{
+
+MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format)
+{
+    DXGIFormatInfo formatInfo;
+    if (GetDXGIFormatInfo(format, &formatInfo))
+    {
+        return formatInfo.mMipGenerationFunction;
+    }
+    else
+    {
+        UNREACHABLE();
+        return NULL;
+    }
+}
+
+LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        D3D11ES2FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mLoadImageFunction;
+        }
+        else
+        {
+            UNREACHABLE();
+            return NULL;
+        }
+    }
+    else if (clientVersion == 3)
+    {
+        static const D3D11LoadFunctionMap loadImageMap = buildD3D11LoadFunctionMap();
+        D3D11LoadFunctionMap::const_iterator iter = loadImageMap.find(InternalFormatTypePair(internalFormat, type));
+        if (iter != loadImageMap.end())
+        {
+            return iter->second;
+        }
+        else
+        {
+            UNREACHABLE();
+            return NULL;
+        }
+    }
+    else
+    {
+        UNREACHABLE();
+        return NULL;
+    }
+}
+
+GLuint GetFormatPixelBytes(DXGI_FORMAT format)
+{
+    DXGIFormatInfo dxgiFormatInfo;
+    if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
+    {
+        return dxgiFormatInfo.mPixelBits / 8;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetBlockWidth(DXGI_FORMAT format)
+{
+    DXGIFormatInfo dxgiFormatInfo;
+    if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
+    {
+        return dxgiFormatInfo.mBlockWidth;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLuint GetBlockHeight(DXGI_FORMAT format)
+{
+    DXGIFormatInfo dxgiFormatInfo;
+    if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
+    {
+        return dxgiFormatInfo.mBlockHeight;
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+GLenum GetComponentType(DXGI_FORMAT format)
+{
+    DXGIFormatInfo dxgiFormatInfo;
+    if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
+    {
+        return dxgiFormatInfo.mComponentType;
+    }
+    else
+    {
+        UNREACHABLE();
+        return GL_NONE;
+    }
+}
+
+GLuint GetDepthBits(DXGI_FORMAT format)
+{
+    DXGIDepthStencilInfo dxgiDSInfo;
+    if (GetDepthStencilInfo(format, &dxgiDSInfo))
+    {
+        return dxgiDSInfo.mDepthBits;
+    }
+    else
+    {
+        // Since the depth stencil info map does not contain all used DXGI formats,
+        // we should not assert that the format exists
+        return 0;
+    }
+}
+
+GLuint GetDepthOffset(DXGI_FORMAT format)
+{
+    DXGIDepthStencilInfo dxgiDSInfo;
+    if (GetDepthStencilInfo(format, &dxgiDSInfo))
+    {
+        return dxgiDSInfo.mDepthOffset;
+    }
+    else
+    {
+        // Since the depth stencil info map does not contain all used DXGI formats,
+        // we should not assert that the format exists
+        return 0;
+    }
+}
+
+GLuint GetStencilBits(DXGI_FORMAT format)
+{
+    DXGIDepthStencilInfo dxgiDSInfo;
+    if (GetDepthStencilInfo(format, &dxgiDSInfo))
+    {
+        return dxgiDSInfo.mStencilBits;
+    }
+    else
+    {
+        // Since the depth stencil info map does not contain all used DXGI formats,
+        // we should not assert that the format exists
+        return 0;
+    }
+}
+
+GLuint GetStencilOffset(DXGI_FORMAT format)
+{
+    DXGIDepthStencilInfo dxgiDSInfo;
+    if (GetDepthStencilInfo(format, &dxgiDSInfo))
+    {
+        return dxgiDSInfo.mStencilOffset;
+    }
+    else
+    {
+        // Since the depth stencil info map does not contain all used DXGI formats,
+        // we should not assert that the format exists
+        return 0;
+    }
+}
+
+void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset)
+{
+    DXGIFormatInfo dxgiFormatInfo;
+    if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
+    {
+        int upsampleCount = 0;
+
+        GLsizei blockWidth = dxgiFormatInfo.mBlockWidth;
+        GLsizei blockHeight = dxgiFormatInfo.mBlockHeight;
+
+        // Don't expand the size of full textures that are at least (blockWidth x blockHeight) already.
+        if (isImage || *requestWidth < blockWidth || *requestHeight < blockHeight)
+        {
+            while (*requestWidth % blockWidth != 0 || *requestHeight % blockHeight != 0)
+            {
+                *requestWidth <<= 1;
+                *requestHeight <<= 1;
+                upsampleCount++;
+            }
+        }
+        *levelOffset = upsampleCount;
+    }
+    else
+    {
+        UNREACHABLE();
+    }
+}
+
+const DXGIFormatSet &GetAllUsedDXGIFormats()
+{
+    static DXGIFormatSet formatSet = BuildAllDXGIFormatSet();
+    return formatSet;
+}
+
+ColorReadFunction GetColorReadFunction(DXGI_FORMAT format)
+{
+    DXGIFormatInfo dxgiFormatInfo;
+    if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
+    {
+        return dxgiFormatInfo.mColorReadFunction;
+    }
+    else
+    {
+        UNREACHABLE();
+        return NULL;
+    }
+}
+
+ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType)
+{
+    static const D3D11FastCopyMap fastCopyMap = BuildFastCopyMap();
+    D3D11FastCopyMap::const_iterator iter = fastCopyMap.find(D3D11FastCopyFormat(sourceFormat, destFormat, destType));
+    return (iter != fastCopyMap.end()) ? iter->second : NULL;
+}
+
+}
+
+namespace gl_d3d11
+{
+
+DXGI_FORMAT GetTexFormat(GLenum internalFormat, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        D3D11ES2FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mTexFormat;
+        }
+        else
+        {
+            UNREACHABLE();
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else if (clientVersion == 3)
+    {
+        D3D11ES3FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mTexFormat;
+        }
+        else
+        {
+            UNREACHABLE();
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else
+    {
+        UNREACHABLE();
+        return DXGI_FORMAT_UNKNOWN;
+    }
+}
+
+DXGI_FORMAT GetSRVFormat(GLenum internalFormat, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        D3D11ES2FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mSRVFormat;
+        }
+        else
+        {
+            UNREACHABLE();
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else if (clientVersion == 3)
+    {
+        D3D11ES3FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mSRVFormat;
+        }
+        else
+        {
+            UNREACHABLE();
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else
+    {
+        UNREACHABLE();
+        return DXGI_FORMAT_UNKNOWN;
+    }
+}
+
+DXGI_FORMAT GetRTVFormat(GLenum internalFormat, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        D3D11ES2FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mRTVFormat;
+        }
+        else
+        {
+            UNREACHABLE();
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else if (clientVersion == 3)
+    {
+        D3D11ES3FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mRTVFormat;
+        }
+        else
+        {
+            UNREACHABLE();
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else
+    {
+        UNREACHABLE();
+        return DXGI_FORMAT_UNKNOWN;
+    }
+}
+
+DXGI_FORMAT GetDSVFormat(GLenum internalFormat, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        D3D11ES2FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES2FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mDSVFormat;
+        }
+        else
+        {
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else if (clientVersion == 3)
+    {
+        D3D11ES3FormatInfo d3d11FormatInfo;
+        if (GetD3D11ES3FormatInfo(internalFormat, clientVersion, &d3d11FormatInfo))
+        {
+            return d3d11FormatInfo.mDSVFormat;
+        }
+        else
+        {
+            return DXGI_FORMAT_UNKNOWN;
+        }
+    }
+    else
+    {
+        UNREACHABLE();
+        return DXGI_FORMAT_UNKNOWN;
+    }
+}
+
+// Given a GL internal format, this function returns the DSV format if it is depth- or stencil-renderable,
+// the RTV format if it is color-renderable, and the (nonrenderable) texture format otherwise.
+DXGI_FORMAT GetRenderableFormat(GLenum internalFormat, GLuint clientVersion)
+{
+    DXGI_FORMAT targetFormat = GetDSVFormat(internalFormat, clientVersion);
+    if (targetFormat == DXGI_FORMAT_UNKNOWN)
+        targetFormat = GetRTVFormat(internalFormat, clientVersion);
+    if (targetFormat == DXGI_FORMAT_UNKNOWN)
+        targetFormat = GetTexFormat(internalFormat, clientVersion);
+
+    return targetFormat;
+}
+
+DXGI_FORMAT GetSwizzleTexFormat(GLint internalFormat, const Renderer *renderer)
+{
+    GLuint clientVersion = renderer->getCurrentClientVersion();
+    if (gl::GetComponentCount(internalFormat, clientVersion) != 4 || !gl::IsColorRenderingSupported(internalFormat, renderer))
+    {
+        const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat, clientVersion);
+        return swizzleInfo.mTexFormat;
+    }
+    else
+    {
+        return GetTexFormat(internalFormat, clientVersion);
+    }
+}
+
+DXGI_FORMAT GetSwizzleSRVFormat(GLint internalFormat, const Renderer *renderer)
+{
+    GLuint clientVersion = renderer->getCurrentClientVersion();
+    if (gl::GetComponentCount(internalFormat, clientVersion) != 4 || !gl::IsColorRenderingSupported(internalFormat, renderer))
+    {
+        const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat, clientVersion);
+        return swizzleInfo.mSRVFormat;
+    }
+    else
+    {
+        return GetTexFormat(internalFormat, clientVersion);
+    }
+}
+
+DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat, const Renderer *renderer)
+{
+    GLuint clientVersion = renderer->getCurrentClientVersion();
+    if (gl::GetComponentCount(internalFormat, clientVersion) != 4 || !gl::IsColorRenderingSupported(internalFormat, renderer))
+    {
+        const SwizzleFormatInfo &swizzleInfo = GetSwizzleFormatInfo(internalFormat, clientVersion);
+        return swizzleInfo.mRTVFormat;
+    }
+    else
+    {
+        return GetTexFormat(internalFormat, clientVersion);
+    }
+}
+
+bool RequiresTextureDataInitialization(GLint internalFormat)
+{
+    const InternalFormatInitializerMap &map = GetInternalFormatInitializerMap();
+    return map.find(internalFormat) != map.end();
+}
+
+InitializeTextureDataFunction GetTextureDataInitializationFunction(GLint internalFormat)
+{
+    const InternalFormatInitializerMap &map = GetInternalFormatInitializerMap();
+    InternalFormatInitializerMap::const_iterator iter = map.find(internalFormat);
+    if (iter != map.end())
+    {
+        return iter->second;
+    }
+    else
+    {
+        UNREACHABLE();
+        return NULL;
+    }
+}
+
+struct D3D11VertexFormatInfo
+{
+    rx::VertexConversionType mConversionType;
+    DXGI_FORMAT mNativeFormat;
+    VertexCopyFunction mCopyFunction;
+
+    D3D11VertexFormatInfo()
+        : mConversionType(VERTEX_CONVERT_NONE),
+          mNativeFormat(DXGI_FORMAT_UNKNOWN),
+          mCopyFunction(NULL)
+    {}
+
+    D3D11VertexFormatInfo(VertexConversionType conversionType, DXGI_FORMAT nativeFormat, VertexCopyFunction copyFunction)
+        : mConversionType(conversionType),
+          mNativeFormat(nativeFormat),
+          mCopyFunction(copyFunction)
+    {}
+};
+
+typedef std::map<gl::VertexFormat, D3D11VertexFormatInfo> D3D11VertexFormatInfoMap;
+
+typedef std::pair<gl::VertexFormat, D3D11VertexFormatInfo> D3D11VertexFormatPair;
+
+static void addVertexFormatInfo(D3D11VertexFormatInfoMap *map, GLenum inputType, GLboolean normalized, GLuint componentCount,
+                                VertexConversionType conversionType, DXGI_FORMAT nativeFormat, VertexCopyFunction copyFunction)
+{
+    gl::VertexFormat inputFormat(inputType, normalized, componentCount, false);
+    map->insert(D3D11VertexFormatPair(inputFormat, D3D11VertexFormatInfo(conversionType, nativeFormat, copyFunction)));
+}
+
+static void addIntegerVertexFormatInfo(D3D11VertexFormatInfoMap *map, GLenum inputType, GLuint componentCount,
+                                       VertexConversionType conversionType, DXGI_FORMAT nativeFormat, VertexCopyFunction copyFunction)
+{
+    gl::VertexFormat inputFormat(inputType, GL_FALSE, componentCount, true);
+    map->insert(D3D11VertexFormatPair(inputFormat, D3D11VertexFormatInfo(conversionType, nativeFormat, copyFunction)));
+}
+
+static D3D11VertexFormatInfoMap BuildD3D11VertexFormatInfoMap()
+{
+    D3D11VertexFormatInfoMap map;
+
+    // TODO: column legend
+
+    //
+    // Float formats
+    //
+
+    // GL_BYTE -- un-normalized
+    addVertexFormatInfo(&map, GL_BYTE,           GL_FALSE, 1, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R8_SINT,            &copyVertexData<GLbyte, 1, 0>);
+    addVertexFormatInfo(&map, GL_BYTE,           GL_FALSE, 2, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R8G8_SINT,          &copyVertexData<GLbyte, 2, 0>);
+    addVertexFormatInfo(&map, GL_BYTE,           GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_SINT,      &copyVertexData<GLbyte, 3, 1>);
+    addVertexFormatInfo(&map, GL_BYTE,           GL_FALSE, 4, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R8G8B8A8_SINT,      &copyVertexData<GLbyte, 4, 0>);
+
+    // GL_BYTE -- normalized
+    addVertexFormatInfo(&map, GL_BYTE,           GL_TRUE,  1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_SNORM,           &copyVertexData<GLbyte, 1, 0>);
+    addVertexFormatInfo(&map, GL_BYTE,           GL_TRUE,  2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_SNORM,         &copyVertexData<GLbyte, 2, 0>);
+    addVertexFormatInfo(&map, GL_BYTE,           GL_TRUE,  3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R8G8B8A8_SNORM,     &copyVertexData<GLbyte, 3, INT8_MAX>);
+    addVertexFormatInfo(&map, GL_BYTE,           GL_TRUE,  4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_SNORM,     &copyVertexData<GLbyte, 4, 0>);
+
+    // GL_UNSIGNED_BYTE -- un-normalized
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_FALSE, 1, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R8_UINT,            &copyVertexData<GLubyte, 1, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_FALSE, 2, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R8G8_UINT,          &copyVertexData<GLubyte, 2, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R8G8B8A8_UINT,      &copyVertexData<GLubyte, 3, 1>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_FALSE, 4, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R8G8B8A8_UINT,      &copyVertexData<GLubyte, 4, 0>);
+
+    // GL_UNSIGNED_BYTE -- normalized
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_TRUE,  1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8_UNORM,           &copyVertexData<GLubyte, 1, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_TRUE,  2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8_UNORM,         &copyVertexData<GLubyte, 2, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_TRUE,  3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R8G8B8A8_UNORM,     &copyVertexData<GLubyte, 3, UINT8_MAX>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  GL_TRUE,  4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R8G8B8A8_UNORM,     &copyVertexData<GLubyte, 4, 0>);
+
+    // GL_SHORT -- un-normalized
+    addVertexFormatInfo(&map, GL_SHORT,          GL_FALSE, 1, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R16_SINT,           &copyVertexData<GLshort, 1, 0>);
+    addVertexFormatInfo(&map, GL_SHORT,          GL_FALSE, 2, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R16G16_SINT,        &copyVertexData<GLshort, 2, 0>);
+    addVertexFormatInfo(&map, GL_SHORT,          GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_SINT,  &copyVertexData<GLshort, 4, 1>);
+    addVertexFormatInfo(&map, GL_SHORT,          GL_FALSE, 4, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R16G16B16A16_SINT,  &copyVertexData<GLshort, 4, 0>);
+
+    // GL_SHORT -- normalized
+    addVertexFormatInfo(&map, GL_SHORT,          GL_TRUE,  1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_SNORM,          &copyVertexData<GLshort, 1, 0>);
+    addVertexFormatInfo(&map, GL_SHORT,          GL_TRUE,  2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_SNORM,       &copyVertexData<GLshort, 2, 0>);
+    addVertexFormatInfo(&map, GL_SHORT,          GL_TRUE,  3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R16G16B16A16_SNORM, &copyVertexData<GLshort, 3, INT16_MAX>);
+    addVertexFormatInfo(&map, GL_SHORT,          GL_TRUE,  4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_SNORM, &copyVertexData<GLshort, 4, 0>);
+
+    // GL_UNSIGNED_SHORT -- un-normalized
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 1, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R16_UINT,           &copyVertexData<GLushort, 1, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 2, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R16G16_UINT,        &copyVertexData<GLushort, 2, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 3, VERTEX_CONVERT_BOTH, DXGI_FORMAT_R16G16B16A16_UINT,  &copyVertexData<GLushort, 3, 1>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_FALSE, 4, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R16G16B16A16_UINT,  &copyVertexData<GLushort, 4, 0>);
+
+    // GL_UNSIGNED_SHORT -- normalized
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE,  1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_UNORM,          &copyVertexData<GLushort, 1, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE,  2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_UNORM,       &copyVertexData<GLushort, 2, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE,  3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R16G16B16A16_UNORM, &copyVertexData<GLushort, 3, UINT16_MAX>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_SHORT, GL_TRUE,  4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_UNORM, &copyVertexData<GLushort, 4, 0>);
+
+    // GL_INT -- un-normalized
+    addVertexFormatInfo(&map, GL_INT,            GL_FALSE, 1, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32_SINT,           &copyVertexData<GLint, 1, 0>);
+    addVertexFormatInfo(&map, GL_INT,            GL_FALSE, 2, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32G32_SINT,        &copyVertexData<GLint, 2, 0>);
+    addVertexFormatInfo(&map, GL_INT,            GL_FALSE, 3, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32G32B32_SINT,     &copyVertexData<GLint, 3, 0>);
+    addVertexFormatInfo(&map, GL_INT,            GL_FALSE, 4, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32G32B32A32_SINT,  &copyVertexData<GLint, 4, 0>);
+
+    // GL_INT -- normalized
+    addVertexFormatInfo(&map, GL_INT,            GL_TRUE,  1, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32_FLOAT,          &copyToFloatVertexData<GLint, 1, true>);
+    addVertexFormatInfo(&map, GL_INT,            GL_TRUE,  2, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32_FLOAT,       &copyToFloatVertexData<GLint, 2, true>);
+    addVertexFormatInfo(&map, GL_INT,            GL_TRUE,  3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32_FLOAT,    &copyToFloatVertexData<GLint, 3, true>);
+    addVertexFormatInfo(&map, GL_INT,            GL_TRUE,  4, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32A32_FLOAT, &copyToFloatVertexData<GLint, 4, true>);
+
+    // GL_UNSIGNED_INT -- un-normalized
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_FALSE, 1, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32_UINT,           &copyVertexData<GLuint, 1, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_FALSE, 2, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32G32_UINT,        &copyVertexData<GLuint, 2, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_FALSE, 3, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32G32B32_UINT,     &copyVertexData<GLuint, 3, 0>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_FALSE, 4, VERTEX_CONVERT_GPU,  DXGI_FORMAT_R32G32B32A32_UINT,  &copyVertexData<GLuint, 4, 0>);
+
+    // GL_UNSIGNED_INT -- normalized
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_TRUE,  1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_FLOAT,          &copyToFloatVertexData<GLuint, 1, true>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_TRUE,  2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_FLOAT,       &copyToFloatVertexData<GLuint, 2, true>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_TRUE,  3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32_FLOAT,    &copyToFloatVertexData<GLuint, 3, true>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT,   GL_TRUE,  4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_FLOAT, &copyToFloatVertexData<GLuint, 4, true>);
+
+    // GL_FIXED
+    addVertexFormatInfo(&map, GL_FIXED,          GL_FALSE, 1, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32_FLOAT,          &copyFixedVertexData<1>);
+    addVertexFormatInfo(&map, GL_FIXED,          GL_FALSE, 2, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32_FLOAT,       &copyFixedVertexData<2>);
+    addVertexFormatInfo(&map, GL_FIXED,          GL_FALSE, 3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32_FLOAT,    &copyFixedVertexData<3>);
+    addVertexFormatInfo(&map, GL_FIXED,          GL_FALSE, 4, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32A32_FLOAT, &copyFixedVertexData<4>);
+
+    // GL_HALF_FLOAT
+    addVertexFormatInfo(&map, GL_HALF_FLOAT,     GL_FALSE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16_FLOAT,          &copyVertexData<GLhalf, 1, 0>);
+    addVertexFormatInfo(&map, GL_HALF_FLOAT,     GL_FALSE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16_FLOAT,       &copyVertexData<GLhalf, 2, 0>);
+    addVertexFormatInfo(&map, GL_HALF_FLOAT,     GL_FALSE, 3, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R16G16B16A16_FLOAT, &copyVertexData<GLhalf, 3, gl::Float16One>);
+    addVertexFormatInfo(&map, GL_HALF_FLOAT,     GL_FALSE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R16G16B16A16_FLOAT, &copyVertexData<GLhalf, 4, 0>);
+
+    // GL_FLOAT
+    addVertexFormatInfo(&map, GL_FLOAT,          GL_FALSE, 1, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32_FLOAT,          &copyVertexData<GLfloat, 1, 0>);
+    addVertexFormatInfo(&map, GL_FLOAT,          GL_FALSE, 2, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32_FLOAT,       &copyVertexData<GLfloat, 2, 0>);
+    addVertexFormatInfo(&map, GL_FLOAT,          GL_FALSE, 3, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32_FLOAT,    &copyVertexData<GLfloat, 3, 0>);
+    addVertexFormatInfo(&map, GL_FLOAT,          GL_FALSE, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R32G32B32A32_FLOAT, &copyVertexData<GLfloat, 4, 0>);
+
+    // GL_INT_2_10_10_10_REV
+    addVertexFormatInfo(&map, GL_INT_2_10_10_10_REV,          GL_FALSE,  4, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32A32_FLOAT, &copyPackedVertexData<true, false, true>);
+    addVertexFormatInfo(&map, GL_INT_2_10_10_10_REV,          GL_TRUE,   4, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32A32_FLOAT, &copyPackedVertexData<true, true,  true>);
+
+    // GL_UNSIGNED_INT_2_10_10_10_REV
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE,  4, VERTEX_CONVERT_CPU,  DXGI_FORMAT_R32G32B32A32_FLOAT, &copyPackedVertexData<false, false, true>);
+    addVertexFormatInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE,   4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UNORM,  &copyPackedUnsignedVertexData);
+
+    //
+    // Integer Formats
+    //
+
+    // GL_BYTE
+    addIntegerVertexFormatInfo(&map, GL_BYTE,           1, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R8_SINT,           &copyVertexData<GLbyte, 1, 0>);
+    addIntegerVertexFormatInfo(&map, GL_BYTE,           2, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R8G8_SINT,         &copyVertexData<GLbyte, 2, 0>);
+    addIntegerVertexFormatInfo(&map, GL_BYTE,           3, VERTEX_CONVERT_CPU,   DXGI_FORMAT_R8G8B8A8_SINT,     &copyVertexData<GLbyte, 3, 1>);
+    addIntegerVertexFormatInfo(&map, GL_BYTE,           4, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R8G8B8A8_SINT,     &copyVertexData<GLbyte, 4, 0>);
+
+    // GL_UNSIGNED_BYTE
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  1, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R8_UINT,           &copyVertexData<GLubyte, 1, 0>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  2, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R8G8_UINT,         &copyVertexData<GLubyte, 2, 0>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  3, VERTEX_CONVERT_CPU,   DXGI_FORMAT_R8G8B8A8_UINT,     &copyVertexData<GLubyte, 3, 1>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_BYTE,  4, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R8G8B8A8_UINT,     &copyVertexData<GLubyte, 4, 0>);
+
+    // GL_SHORT
+    addIntegerVertexFormatInfo(&map, GL_SHORT,          1, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R16_SINT,          &copyVertexData<GLshort, 1, 0>);
+    addIntegerVertexFormatInfo(&map, GL_SHORT,          2, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R16G16_SINT,       &copyVertexData<GLshort, 2, 0>);
+    addIntegerVertexFormatInfo(&map, GL_SHORT,          3, VERTEX_CONVERT_CPU,   DXGI_FORMAT_R16G16B16A16_SINT, &copyVertexData<GLshort, 3, 1>);
+    addIntegerVertexFormatInfo(&map, GL_SHORT,          4, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R16G16B16A16_SINT, &copyVertexData<GLshort, 4, 0>);
+
+    // GL_UNSIGNED_SHORT
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 1, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R16_UINT,          &copyVertexData<GLushort, 1, 0>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 2, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R16G16_UINT,       &copyVertexData<GLushort, 2, 0>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 3, VERTEX_CONVERT_CPU,   DXGI_FORMAT_R16G16B16A16_UINT, &copyVertexData<GLushort, 3, 1>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_SHORT, 4, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R16G16B16A16_UINT, &copyVertexData<GLushort, 4, 0>);
+
+    // GL_INT
+    addIntegerVertexFormatInfo(&map, GL_INT,            1, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32_SINT,          &copyVertexData<GLint, 1, 0>);
+    addIntegerVertexFormatInfo(&map, GL_INT,            2, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32G32_SINT,       &copyVertexData<GLint, 2, 0>);
+    addIntegerVertexFormatInfo(&map, GL_INT,            3, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32G32B32_SINT,    &copyVertexData<GLint, 3, 0>);
+    addIntegerVertexFormatInfo(&map, GL_INT,            4, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32G32B32A32_SINT, &copyVertexData<GLint, 4, 0>);
+
+    // GL_UNSIGNED_INT
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT,   1, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32_SINT,          &copyVertexData<GLuint, 1, 0>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT,   2, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32G32_SINT,       &copyVertexData<GLuint, 2, 0>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT,   3, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32G32B32_SINT,    &copyVertexData<GLuint, 3, 0>);
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT,   4, VERTEX_CONVERT_NONE,  DXGI_FORMAT_R32G32B32A32_SINT, &copyVertexData<GLuint, 4, 0>);
+
+    // GL_INT_2_10_10_10_REV
+    addIntegerVertexFormatInfo(&map, GL_INT_2_10_10_10_REV, 4, VERTEX_CONVERT_CPU, DXGI_FORMAT_R16G16B16A16_SINT, &copyPackedVertexData<true, true, false>);
+
+    // GL_UNSIGNED_INT_2_10_10_10_REV
+    addIntegerVertexFormatInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, 4, VERTEX_CONVERT_NONE, DXGI_FORMAT_R10G10B10A2_UINT, &copyPackedUnsignedVertexData);
+
+    return map;
+}
+
+static bool GetD3D11VertexFormatInfo(const gl::VertexFormat &vertexFormat, D3D11VertexFormatInfo *outVertexFormatInfo)
+{
+    static const D3D11VertexFormatInfoMap vertexFormatMap = BuildD3D11VertexFormatInfoMap();
+
+    D3D11VertexFormatInfoMap::const_iterator iter = vertexFormatMap.find(vertexFormat);
+    if (iter != vertexFormatMap.end())
+    {
+        if (outVertexFormatInfo)
+        {
+            *outVertexFormatInfo = iter->second;
+        }
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+VertexCopyFunction GetVertexCopyFunction(const gl::VertexFormat &vertexFormat)
+{
+    D3D11VertexFormatInfo vertexFormatInfo;
+    if (GetD3D11VertexFormatInfo(vertexFormat, &vertexFormatInfo))
+    {
+        return vertexFormatInfo.mCopyFunction;
+    }
+    else
+    {
+        UNREACHABLE();
+        return NULL;
+    }
+}
+
+size_t GetVertexElementSize(const gl::VertexFormat &vertexFormat)
+{
+    D3D11VertexFormatInfo vertexFormatInfo;
+    if (GetD3D11VertexFormatInfo(vertexFormat, &vertexFormatInfo))
+    {
+        // FIXME: should not need a client version, and is not a pixel!
+        return d3d11::GetFormatPixelBytes(vertexFormatInfo.mNativeFormat);
+    }
+    else
+    {
+        UNREACHABLE();
+        return 0;
+    }
+}
+
+rx::VertexConversionType GetVertexConversionType(const gl::VertexFormat &vertexFormat)
+{
+    D3D11VertexFormatInfo vertexFormatInfo;
+    if (GetD3D11VertexFormatInfo(vertexFormat, &vertexFormatInfo))
+    {
+        return vertexFormatInfo.mConversionType;
+    }
+    else
+    {
+        UNREACHABLE();
+        return VERTEX_CONVERT_NONE;
+    }
+}
+
+DXGI_FORMAT GetNativeVertexFormat(const gl::VertexFormat &vertexFormat)
+{
+    D3D11VertexFormatInfo vertexFormatInfo;
+    if (GetD3D11VertexFormatInfo(vertexFormat, &vertexFormatInfo))
+    {
+        return vertexFormatInfo.mNativeFormat;
+    }
+    else
+    {
+        UNREACHABLE();
+        return DXGI_FORMAT_UNKNOWN;
+    }
+}
+
+}
+
+namespace d3d11_gl
+{
+
+GLenum GetInternalFormat(DXGI_FORMAT format, GLuint clientVersion)
+{
+    if (clientVersion == 2)
+    {
+        static DXGIToESFormatMap es2FormatMap = BuildDXGIToES2FormatMap();
+        auto formatIt = es2FormatMap.find(format);
+        if (formatIt != es2FormatMap.end())
+        {
+            return formatIt->second;
+        }
+    }
+    else if (clientVersion == 3)
+    {
+        static DXGIToESFormatMap es3FormatMap = BuildDXGIToES3FormatMap();
+        auto formatIt = es3FormatMap.find(format);
+        if (formatIt != es3FormatMap.end())
+        {
+            return formatIt->second;
+        }
+    }
+
+    UNREACHABLE();
+    return GL_NONE;
+}
+
+}
+
+}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/formatutils11.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/formatutils11.h
new file mode 100644 (file)
index 0000000..d7ae4e0
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Copyright (c) 2013 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.
+//
+
+// formatutils11.h: Queries for GL image formats and their translations to D3D11
+// formats.
+
+#ifndef LIBGLESV2_RENDERER_FORMATUTILS11_H_
+#define LIBGLESV2_RENDERER_FORMATUTILS11_H_
+
+#include "libGLESv2/formatutils.h"
+
+namespace rx
+{
+
+class Renderer;
+
+namespace d3d11
+{
+
+typedef std::set<DXGI_FORMAT> DXGIFormatSet;
+
+MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format);
+LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type, GLuint clientVersion);
+
+GLuint GetFormatPixelBytes(DXGI_FORMAT format);
+GLuint GetBlockWidth(DXGI_FORMAT format);
+GLuint GetBlockHeight(DXGI_FORMAT format);
+GLenum GetComponentType(DXGI_FORMAT format);
+
+GLuint GetDepthBits(DXGI_FORMAT format);
+GLuint GetDepthOffset(DXGI_FORMAT format);
+GLuint GetStencilBits(DXGI_FORMAT format);
+GLuint GetStencilOffset(DXGI_FORMAT format);
+
+void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
+
+const DXGIFormatSet &GetAllUsedDXGIFormats();
+
+ColorReadFunction GetColorReadFunction(DXGI_FORMAT format);
+ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType);
+
+}
+
+namespace gl_d3d11
+{
+
+DXGI_FORMAT GetTexFormat(GLenum internalFormat, GLuint clientVersion);
+DXGI_FORMAT GetSRVFormat(GLenum internalFormat, GLuint clientVersion);
+DXGI_FORMAT GetRTVFormat(GLenum internalFormat, GLuint clientVersion);
+DXGI_FORMAT GetDSVFormat(GLenum internalFormat, GLuint clientVersion);
+DXGI_FORMAT GetRenderableFormat(GLenum internalFormat, GLuint clientVersion);
+
+DXGI_FORMAT GetSwizzleTexFormat(GLint internalFormat, const Renderer *renderer);
+DXGI_FORMAT GetSwizzleSRVFormat(GLint internalFormat, const Renderer *renderer);
+DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat, const Renderer *renderer);
+
+bool RequiresTextureDataInitialization(GLint internalFormat);
+InitializeTextureDataFunction GetTextureDataInitializationFunction(GLint internalFormat);
+
+VertexCopyFunction GetVertexCopyFunction(const gl::VertexFormat &vertexFormat);
+size_t GetVertexElementSize(const gl::VertexFormat &vertexFormat);
+VertexConversionType GetVertexConversionType(const gl::VertexFormat &vertexFormat);
+DXGI_FORMAT GetNativeVertexFormat(const gl::VertexFormat &vertexFormat);
+
+}
+
+namespace d3d11_gl
+{
+
+GLenum GetInternalFormat(DXGI_FORMAT format, GLuint clientVersion);
+
+}
+
+}
+
+#endif // LIBGLESV2_RENDERER_FORMATUTILS11_H_
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/BufferToTexture11.hlsl b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/BufferToTexture11.hlsl
new file mode 100644 (file)
index 0000000..20e6623
--- /dev/null
@@ -0,0 +1,76 @@
+Buffer<float4>    Buffer4F  : register(t0);
+Buffer<int4>      Buffer4I  : register(t0);
+Buffer<uint4>     Buffer4UI : register(t0);
+
+struct VS_OUTPUT
+{
+    float4 position : SV_Position;
+    uint index      : TEXCOORD0;
+    uint slice      : LAYER;
+};
+
+struct GS_OUTPUT
+{
+    float4 position : SV_Position;
+    uint index      : TEXCOORD0;
+    uint slice      : SV_RenderTargetArrayIndex;
+};
+
+cbuffer BufferCopyParams : register(b0)
+{
+    uint FirstPixelOffset;
+    uint PixelsPerRow;
+    uint RowStride;
+    uint RowsPerSlice;
+    float2 PositionOffset;
+    float2 PositionScale;
+    int2 TexLocationOffset;
+    int2 TexLocationScale;
+}
+
+void ComputePositionAndIndex(uint vertexID, out VS_OUTPUT outVertex)
+{
+    uint PixelsPerSlice = PixelsPerRow * RowsPerSlice;
+    uint SliceStride    = RowStride * RowsPerSlice;
+
+    uint slice          = vertexID / PixelsPerSlice;
+    uint sliceOffset    = slice * PixelsPerSlice;
+    uint row            = (vertexID - sliceOffset) / PixelsPerRow;
+    uint col            = vertexID - sliceOffset - (row * PixelsPerRow);
+
+    float2 coords       = float2(float(col), float(row));
+
+    outVertex.position  = float4(PositionOffset + PositionScale * coords, 0.0f, 1.0f);
+    outVertex.index     = FirstPixelOffset + slice * SliceStride + row * RowStride + col;
+    outVertex.slice     = slice;
+}
+
+void VS_BufferToTexture(in uint vertexID : SV_VertexID, out VS_OUTPUT outVertex)
+{
+    ComputePositionAndIndex(vertexID, outVertex);
+}
+
+[maxvertexcount(1)]
+void GS_BufferToTexture(point VS_OUTPUT inVertex[1], inout PointStream<GS_OUTPUT> outStream)
+{
+    GS_OUTPUT outVertex;
+    outVertex.position  = inVertex[0].position;
+    outVertex.index     = inVertex[0].index;
+    outVertex.slice     = inVertex[0].slice;
+    outStream.Append(outVertex);
+}
+
+float4 PS_BufferToTexture_4F(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
+{
+    return Buffer4F.Load(inIndex);
+}
+
+int4 PS_BufferToTexture_4I(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
+{
+    return Buffer4I.Load(inIndex);
+}
+
+uint4 PS_BufferToTexture_4UI(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
+{
+    return Buffer4UI.Load(inIndex);
+}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough11.hlsl b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough11.hlsl
deleted file mode 100644 (file)
index 43b7801..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-Texture2D Texture : register(t0);
-SamplerState Sampler : register(s0);
-
-void VS_Passthrough( in float2  inPosition :    POSITION,  in float2  inTexCoord : TEXCOORD0,
-                    out float4 outPosition : SV_POSITION, out float2 outTexCoord : TEXCOORD0)
-{
-    outPosition = float4(inPosition, 0.0f, 1.0f);
-    outTexCoord = inTexCoord;
-}
-
-float4 PS_PassthroughRGBA(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
-    return Texture.Sample(Sampler, inTexCoord).rgba;
-}
-
-float4 PS_PassthroughRGB(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
-    return float4(Texture.Sample(Sampler, inTexCoord).rgb, 1.0f);
-}
-
-float4 PS_PassthroughLum(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
-    return float4(Texture.Sample(Sampler, inTexCoord).rrr, 1.0f);
-}
-
-float4 PS_PassthroughLumAlpha(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
-{
-    return Texture.Sample(Sampler, inTexCoord).rrra;
-}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough3D11.hlsl b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Passthrough3D11.hlsl
new file mode 100644 (file)
index 0000000..c23c903
--- /dev/null
@@ -0,0 +1,146 @@
+Texture3D<float4> TextureF  : register(t0);
+Texture3D<uint4>  TextureUI : register(t0);
+Texture3D<int4>   TextureI  : register(t0);
+
+SamplerState      Sampler   : register(s0);
+
+struct VS_INPUT
+{
+    float2 Position : POSITION;
+    uint   Layer    : LAYER;
+    float3 TexCoord : TEXCOORD;
+};
+
+struct VS_OUTPUT
+{
+    float4 Position : SV_POSITION;
+    uint   Layer    : LAYER;
+    float3 TexCoord : TEXCOORD;
+};
+
+struct GS_OUTPUT
+{
+    float4 Position : SV_POSITION;
+    uint   Layer    : SV_RENDERTARGETARRAYINDEX;
+    float3 TexCoord : TEXCOORD;
+};
+
+VS_OUTPUT VS_Passthrough3D(VS_INPUT input)
+{
+    VS_OUTPUT output;
+
+    output.Position = float4(input.Position, 0.0f, 1.0f);
+    output.Layer = input.Layer;
+    output.TexCoord = input.TexCoord;
+
+    return output;
+}
+
+[maxvertexcount(3)]
+void GS_Passthrough3D(triangle VS_OUTPUT input[3], inout TriangleStream<GS_OUTPUT> outputStream)
+{
+    GS_OUTPUT output;
+
+    for (int i = 0; i < 3; i++)
+    {
+        output.Position = input[i].Position;
+        output.Layer = input[i].Layer;
+        output.TexCoord = input[i].TexCoord;
+
+        outputStream.Append(output);
+    }
+}
+
+float4 PS_PassthroughRGBA3D(GS_OUTPUT input) : SV_TARGET0
+{
+    return TextureF.Sample(Sampler, input.TexCoord).rgba;
+}
+
+uint4 PS_PassthroughRGBA3DUI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureUI.GetDimensions(size.x, size.y, size.z);
+
+    return TextureUI.Load(int4(size * input.TexCoord, 0)).rgba;
+}
+
+int4 PS_PassthroughRGBA3DI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureI.GetDimensions(size.x, size.y, size.z);
+
+    return TextureI.Load(int4(size * input.TexCoord, 0)).rgba;
+}
+
+float4 PS_PassthroughRGB3D(GS_OUTPUT input) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, input.TexCoord).rgb, 1.0f);
+}
+
+uint4 PS_PassthroughRGB3DUI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureUI.GetDimensions(size.x, size.y, size.z);
+
+    return uint4(TextureUI.Load(int4(size * input.TexCoord, 0)).rgb, 0);
+}
+
+int4 PS_PassthroughRGB3DI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureI.GetDimensions(size.x, size.y, size.z);
+
+    return int4(TextureI.Load(int4(size * input.TexCoord, 0)).rgb, 0);
+}
+
+float4 PS_PassthroughRG3D(GS_OUTPUT input) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, input.TexCoord).rg, 0.0f, 1.0f);
+}
+
+uint4 PS_PassthroughRG3DUI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureUI.GetDimensions(size.x, size.y, size.z);
+
+    return uint4(TextureUI.Load(int4(size * input.TexCoord, 0)).rg, 0, 0);
+}
+
+int4 PS_PassthroughRG3DI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureI.GetDimensions(size.x, size.y, size.z);
+
+    return int4(TextureI.Load(int4(size * input.TexCoord, 0)).rg, 0, 0);
+}
+
+float4 PS_PassthroughR3D(GS_OUTPUT input) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, input.TexCoord).r, 0.0f, 0.0f, 1.0f);
+}
+
+uint4 PS_PassthroughR3DUI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureUI.GetDimensions(size.x, size.y, size.z);
+
+    return uint4(TextureUI.Load(int4(size * input.TexCoord, 0)).r, 0, 0, 0);
+}
+
+int4 PS_PassthroughR3DI(GS_OUTPUT input) : SV_TARGET0
+{
+    uint3 size;
+    TextureI.GetDimensions(size.x, size.y, size.z);
+
+    return int4(TextureI.Load(int4(size * input.TexCoord, 0)).r, 0, 0, 0);
+}
+
+float4 PS_PassthroughLum3D(GS_OUTPUT input) : SV_TARGET0
+{
+    return float4(TextureF.Sample(Sampler, input.TexCoord).rrr, 1.0f);
+}
+
+float4 PS_PassthroughLumAlpha3D(GS_OUTPUT input) : SV_TARGET0
+{
+    return TextureF.Sample(Sampler, input.TexCoord).rrra;
+}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Swizzle11.hlsl b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/Swizzle11.hlsl
new file mode 100644 (file)
index 0000000..505e222
--- /dev/null
@@ -0,0 +1,99 @@
+Texture2D<float4> TextureF2D  : register(t0);
+Texture2D<uint4>  TextureUI2D : register(t0);
+Texture2D<int4>   TextureI2D  : register(t0);
+
+Texture3D<float4> TextureF3D  : register(t0);
+Texture3D<uint4>  TextureUI3D : register(t0);
+Texture3D<int4>   TextureI3D  : register(t0);
+
+Texture2DArray<float4> TextureF2DArray  : register(t0);
+Texture2DArray<uint4>  TextureUI2DArray : register(t0);
+Texture2DArray<int4>   TextureI2DArray  : register(t0);
+
+SamplerState Sampler          : register(s0);
+
+cbuffer SwizzleProperties     : register(b0)
+{
+    uint4 SwizzleIndices      : packoffset(c0);
+}
+
+float4 SwizzleLookup(in float4 sample)
+{
+    float lookup[6] = { sample[0], sample[1], sample[2], sample[3], 0.0f, 1.0f };
+    return float4(lookup[SwizzleIndices[0]], lookup[SwizzleIndices[1]], lookup[SwizzleIndices[2]], lookup[SwizzleIndices[3]]);
+}
+
+int4 SwizzleLookup(in int4 sample)
+{
+    int lookup[6] = { sample[0], sample[1], sample[2], sample[3], 0.0f, 1.0f };
+    return int4(lookup[SwizzleIndices[0]], lookup[SwizzleIndices[1]], lookup[SwizzleIndices[2]], lookup[SwizzleIndices[3]]);
+}
+
+uint4 SwizzleLookup(in uint4 sample)
+{
+    uint lookup[6] = { sample[0], sample[1], sample[2], sample[3], 0.0f, 1.0f };
+    return uint4(lookup[SwizzleIndices[0]], lookup[SwizzleIndices[1]], lookup[SwizzleIndices[2]], lookup[SwizzleIndices[3]]);
+}
+
+float4 PS_SwizzleF2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return SwizzleLookup(TextureF2D.Sample(Sampler, inTexCoord));
+}
+
+int4 PS_SwizzleI2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureI2D.GetDimensions(size.x, size.y);
+
+    return SwizzleLookup(TextureI2D.Load(int3(size * inTexCoord, 0)));
+}
+
+uint4 PS_SwizzleUI2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint2 size;
+    TextureUI2D.GetDimensions(size.x, size.y);
+
+    return SwizzleLookup(TextureUI2D.Load(int3(size * inTexCoord, 0)));
+}
+
+float4 PS_SwizzleF3D(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return SwizzleLookup(TextureF3D.Sample(Sampler, inTexCoord));
+}
+
+int4 PS_SwizzleI3D(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint3 size;
+    TextureI3D.GetDimensions(size.x, size.y, size.z);
+
+    return SwizzleLookup(TextureI3D.Load(int4(size * inTexCoord, 0)));
+}
+
+uint4 PS_SwizzleUI3D(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint3 size;
+    TextureUI3D.GetDimensions(size.x, size.y, size.z);
+
+    return SwizzleLookup(TextureUI3D.Load(int4(size * inTexCoord, 0)));
+}
+
+float4 PS_SwizzleF2DArray(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    return SwizzleLookup(TextureF2DArray.Sample(Sampler, float3(inTexCoord.xy, inLayer)));
+}
+
+int4 PS_SwizzleI2DArray(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint3 size;
+    TextureI2DArray.GetDimensions(size.x, size.y, size.z);
+
+    return SwizzleLookup(TextureI2DArray.Load(int4(size.xy * inTexCoord.xy, inLayer, 0)));
+}
+
+uint4 PS_SwizzleUI2DArray(in float4 inPosition : SV_POSITION, in uint inLayer : SV_RENDERTARGETARRAYINDEX, in float3 inTexCoord : TEXCOORD0) : SV_TARGET0
+{
+    uint3 size;
+    TextureUI2DArray.GetDimensions(size.x, size.y, size.z);
+
+    return SwizzleLookup(TextureUI2DArray.Load(int4(size.xy * inTexCoord.xy, inLayer, 0)));
+}
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_gs.h
new file mode 100644 (file)
index 0000000..8259bc8
--- /dev/null
@@ -0,0 +1,166 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+//
+///
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float   xyzw
+// TEXCOORD                 0   x           1     NONE    uint   x   
+// LAYER                    0    y          1     NONE    uint    y  
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float   xyzw
+// TEXCOORD                 0   x           1     NONE    uint   x   
+// SV_RenderTargetArrayIndex     0    y          1  RTINDEX    uint    y  
+//
+gs_4_0
+dcl_input_siv v[1][0].xyzw, position
+dcl_input v[1][1].x
+dcl_input v[1][1].y
+dcl_inputprimitive point 
+dcl_outputtopology pointlist 
+dcl_output_siv o0.xyzw, position
+dcl_output o1.x
+dcl_output_siv o1.y, rendertarget_array_index
+dcl_maxout 1
+mov o0.xyzw, v[0][0].xyzw
+mov o1.x, v[0][1].x
+mov o1.y, v[0][1].y
+emit 
+ret 
+// Approximately 5 instruction slots used
+#endif
+
+const BYTE g_GS_BufferToTexture[] =
+{
+     68,  88,  66,  67,  76, 247, 
+     16,  54, 179, 210,  24, 242, 
+    185, 199,  67, 148, 241, 107, 
+     16,   2,   1,   0,   0,   0, 
+    212,   2,   0,   0,   5,   0, 
+      0,   0,  52,   0,   0,   0, 
+    140,   0,   0,   0,   0,   1, 
+      0,   0, 136,   1,   0,   0, 
+     88,   2,   0,   0,  82,  68, 
+     69,  70,  80,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+     83,  71,   0,   1,   0,   0, 
+     28,   0,   0,   0,  77, 105, 
+     99, 114, 111, 115, 111, 102, 
+    116,  32,  40,  82,  41,  32, 
+     72,  76,  83,  76,  32,  83, 
+    104,  97, 100, 101, 114,  32, 
+     67, 111, 109, 112, 105, 108, 
+    101, 114,  32,  57,  46,  51, 
+     48,  46,  57,  50,  48,  48, 
+     46,  49,  54,  51,  56,  52, 
+      0, 171,  73,  83,  71,  78, 
+    108,   0,   0,   0,   3,   0, 
+      0,   0,   8,   0,   0,   0, 
+     80,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,  15,   0,   0, 
+     92,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,   1,   1,   0,   0, 
+    101,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,   2,   2,   0,   0, 
+     83,  86,  95,  80, 111, 115, 
+    105, 116, 105, 111, 110,   0, 
+     84,  69,  88,  67,  79,  79, 
+     82,  68,   0,  76,  65,  89, 
+     69,  82,   0, 171,  79,  83, 
+     71,  78, 128,   0,   0,   0, 
+      3,   0,   0,   0,   8,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  92,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   1,  14, 
+      0,   0, 101,   0,   0,   0, 
+      0,   0,   0,   0,   4,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   2,  13, 
+      0,   0,  83,  86,  95,  80, 
+    111, 115, 105, 116, 105, 111, 
+    110,   0,  84,  69,  88,  67, 
+     79,  79,  82,  68,   0,  83, 
+     86,  95,  82, 101, 110, 100, 
+    101, 114,  84,  97, 114, 103, 
+    101, 116,  65, 114, 114,  97, 
+    121,  73, 110, 100, 101, 120, 
+      0, 171,  83,  72,  68,  82, 
+    200,   0,   0,   0,  64,   0, 
+      2,   0,  50,   0,   0,   0, 
+     97,   0,   0,   5, 242,  16, 
+     32,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,  95,   0,   0,   4, 
+     18,  16,  32,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+     95,   0,   0,   4,  34,  16, 
+     32,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,  93,   8, 
+      0,   1,  92,   8,   0,   1, 
+    103,   0,   0,   4, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0, 101,   0, 
+      0,   3,  18,  32,  16,   0, 
+      1,   0,   0,   0, 103,   0, 
+      0,   4,  34,  32,  16,   0, 
+      1,   0,   0,   0,   4,   0, 
+      0,   0,  94,   0,   0,   2, 
+      1,   0,   0,   0,  54,   0, 
+      0,   6, 242,  32,  16,   0, 
+      0,   0,   0,   0,  70,  30, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  54,   0, 
+      0,   6,  18,  32,  16,   0, 
+      1,   0,   0,   0,  10,  16, 
+     32,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,  54,   0, 
+      0,   6,  34,  32,  16,   0, 
+      1,   0,   0,   0,  26,  16, 
+     32,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,  19,   0, 
+      0,   1,  62,   0,   0,   1, 
+     83,  84,  65,  84, 116,   0, 
+      0,   0,   5,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   6,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      2,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0
+};
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4f.h
new file mode 100644 (file)
index 0000000..ce4ca08
--- /dev/null
@@ -0,0 +1,223 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+//
+///
+// Buffer Definitions: 
+//
+// cbuffer BufferCopyParams
+// {
+//
+//   uint FirstPixelOffset;             // Offset:    0 Size:     4 [unused]
+//   uint PixelsPerRow;                 // Offset:    4 Size:     4 [unused]
+//   uint RowStride;                    // Offset:    8 Size:     4 [unused]
+//   uint RowsPerSlice;                 // Offset:   12 Size:     4 [unused]
+//   float2 PositionOffset;             // Offset:   16 Size:     8 [unused]
+//   float2 PositionScale;              // Offset:   24 Size:     8 [unused]
+//   int2 TexLocationOffset;            // Offset:   32 Size:     8 [unused]
+//   int2 TexLocationScale;             // Offset:   40 Size:     8 [unused]
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// Buffer4F                          texture  float4         buf    0        1
+// BufferCopyParams                  cbuffer      NA          NA    0        1
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float       
+// TEXCOORD                 0   x           1     NONE    uint   x   
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Target                0   xyzw        0   TARGET   float   xyzw
+//
+ps_4_0
+dcl_constantbuffer cb0[1], immediateIndexed
+dcl_resource_buffer (float,float,float,float) t0
+dcl_input_ps constant v1.x
+dcl_output o0.xyzw
+ld o0.xyzw, v1.xxxx, t0.xyzw
+ret 
+// Approximately 2 instruction slots used
+#endif
+
+const BYTE g_PS_BufferToTexture_4F[] =
+{
+     68,  88,  66,  67, 161, 212, 
+     38, 156, 243,  82,  97,  91, 
+    138,   4,  55, 121,  28,  62, 
+    245, 159,   1,   0,   0,   0, 
+    216,   3,   0,   0,   5,   0, 
+      0,   0,  52,   0,   0,   0, 
+    104,   2,   0,   0, 192,   2, 
+      0,   0, 244,   2,   0,   0, 
+     92,   3,   0,   0,  82,  68, 
+     69,  70,  44,   2,   0,   0, 
+      1,   0,   0,   0, 120,   0, 
+      0,   0,   2,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    255, 255,   0,   1,   0,   0, 
+    249,   1,   0,   0,  92,   0, 
+      0,   0,   2,   0,   0,   0, 
+      5,   0,   0,   0,   1,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,  13,   0,   0,   0, 
+    101,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,  66, 117, 102, 102, 
+    101, 114,  52,  70,   0,  66, 
+    117, 102, 102, 101, 114,  67, 
+    111, 112, 121,  80,  97, 114, 
+     97, 109, 115,   0, 171, 171, 
+    101,   0,   0,   0,   8,   0, 
+      0,   0, 144,   0,   0,   0, 
+     48,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     80,   1,   0,   0,   0,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 100,   1, 
+      0,   0,   0,   0,   0,   0, 
+    116,   1,   0,   0,   4,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 100,   1, 
+      0,   0,   0,   0,   0,   0, 
+    129,   1,   0,   0,   8,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 100,   1, 
+      0,   0,   0,   0,   0,   0, 
+    139,   1,   0,   0,  12,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 100,   1, 
+      0,   0,   0,   0,   0,   0, 
+    152,   1,   0,   0,  16,   0, 
+      0,   0,   8,   0,   0,   0, 
+      0,   0,   0,   0, 168,   1, 
+      0,   0,   0,   0,   0,   0, 
+    184,   1,   0,   0,  24,   0, 
+      0,   0,   8,   0,   0,   0, 
+      0,   0,   0,   0, 168,   1, 
+      0,   0,   0,   0,   0,   0, 
+    198,   1,   0,   0,  32,   0, 
+      0,   0,   8,   0,   0,   0, 
+      0,   0,   0,   0, 216,   1, 
+      0,   0,   0,   0,   0,   0, 
+    232,   1,   0,   0,  40,   0, 
+      0,   0,   8,   0,   0,   0, 
+      0,   0,   0,   0, 216,   1, 
+      0,   0,   0,   0,   0,   0, 
+     70, 105, 114, 115, 116,  80, 
+    105, 120, 101, 108,  79, 102, 
+    102, 115, 101, 116,   0, 171, 
+    171, 171,   0,   0,  19,   0, 
+      1,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     80, 105, 120, 101, 108, 115, 
+     80, 101, 114,  82, 111, 119, 
+      0,  82, 111, 119,  83, 116, 
+    114, 105, 100, 101,   0,  82, 
+    111, 119, 115,  80, 101, 114, 
+     83, 108, 105,  99, 101,   0, 
+     80, 111, 115, 105, 116, 105, 
+    111, 110,  79, 102, 102, 115, 
+    101, 116,   0, 171,   1,   0, 
+      3,   0,   1,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  80, 111, 115, 105, 
+    116, 105, 111, 110,  83,  99, 
+     97, 108, 101,   0,  84, 101, 
+    120,  76, 111,  99,  97, 116, 
+    105, 111, 110,  79, 102, 102, 
+    115, 101, 116,   0,   1,   0, 
+      2,   0,   1,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  84, 101, 120,  76, 
+    111,  99,  97, 116, 105, 111, 
+    110,  83,  99,  97, 108, 101, 
+      0,  77, 105,  99, 114, 111, 
+    115, 111, 102, 116,  32,  40, 
+     82,  41,  32,  72,  76,  83, 
+     76,  32,  83, 104,  97, 100, 
+    101, 114,  32,  67, 111, 109, 
+    112, 105, 108, 101, 114,  32, 
+     57,  46,  51,  48,  46,  57, 
+     50,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0,  73,  83, 
+     71,  78,  80,   0,   0,   0, 
+      2,   0,   0,   0,   8,   0, 
+      0,   0,  56,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  68,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   1,   1, 
+      0,   0,  83,  86,  95,  80, 
+    111, 115, 105, 116, 105, 111, 
+    110,   0,  84,  69,  88,  67, 
+     79,  79,  82,  68,   0, 171, 
+    171, 171,  79,  83,  71,  78, 
+     44,   0,   0,   0,   1,   0, 
+      0,   0,   8,   0,   0,   0, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     83,  86,  95,  84,  97, 114, 
+    103, 101, 116,   0, 171, 171, 
+     83,  72,  68,  82,  96,   0, 
+      0,   0,  64,   0,   0,   0, 
+     24,   0,   0,   0,  89,   0, 
+      0,   4,  70, 142,  32,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,  88,   8,   0,   4, 
+      0, 112,  16,   0,   0,   0, 
+      0,   0,  85,  85,   0,   0, 
+     98,   8,   0,   3,  18,  16, 
+     16,   0,   1,   0,   0,   0, 
+    101,   0,   0,   3, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+     45,   0,   0,   7, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+      6,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      0,   0,   0,   0,  62,   0, 
+      0,   1,  83,  84,  65,  84, 
+    116,   0,   0,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0
+};
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4i.h
new file mode 100644 (file)
index 0000000..666930a
--- /dev/null
@@ -0,0 +1,129 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+//
+///
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// Buffer4I                          texture   sint4         buf    0        1
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float       
+// TEXCOORD                 0   x           1     NONE    uint   x   
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Target                0   xyzw        0   TARGET     int   xyzw
+//
+ps_4_0
+dcl_resource_buffer (sint,sint,sint,sint) t0
+dcl_input_ps constant v1.x
+dcl_output o0.xyzw
+ld o0.xyzw, v1.xxxx, t0.xyzw
+ret 
+// Approximately 2 instruction slots used
+#endif
+
+const BYTE g_PS_BufferToTexture_4I[] =
+{
+     68,  88,  66,  67, 178, 234, 
+    204, 249, 218,  40, 155, 155, 
+    252,  18, 110,  38, 237, 186, 
+    217, 231,   1,   0,   0,   0, 
+     20,   2,   0,   0,   5,   0, 
+      0,   0,  52,   0,   0,   0, 
+    180,   0,   0,   0,  12,   1, 
+      0,   0,  64,   1,   0,   0, 
+    152,   1,   0,   0,  82,  68, 
+     69,  70, 120,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    255, 255,   0,   1,   0,   0, 
+     69,   0,   0,   0,  60,   0, 
+      0,   0,   2,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,  13,   0,   0,   0, 
+     66, 117, 102, 102, 101, 114, 
+     52,  73,   0,  77, 105,  99, 
+    114, 111, 115, 111, 102, 116, 
+     32,  40,  82,  41,  32,  72, 
+     76,  83,  76,  32,  83, 104, 
+     97, 100, 101, 114,  32,  67, 
+    111, 109, 112, 105, 108, 101, 
+    114,  32,  57,  46,  51,  48, 
+     46,  57,  50,  48,  48,  46, 
+     49,  54,  51,  56,  52,   0, 
+     73,  83,  71,  78,  80,   0, 
+      0,   0,   2,   0,   0,   0, 
+      8,   0,   0,   0,  56,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+     15,   0,   0,   0,  68,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   1,   0,   0,  83,  86, 
+     95,  80, 111, 115, 105, 116, 
+    105, 111, 110,   0,  84,  69, 
+     88,  67,  79,  79,  82,  68, 
+      0, 171, 171, 171,  79,  83, 
+     71,  78,  44,   0,   0,   0, 
+      1,   0,   0,   0,   8,   0, 
+      0,   0,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   2,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  83,  86,  95,  84, 
+     97, 114, 103, 101, 116,   0, 
+    171, 171,  83,  72,  68,  82, 
+     80,   0,   0,   0,  64,   0, 
+      0,   0,  20,   0,   0,   0, 
+     88,   8,   0,   4,   0, 112, 
+     16,   0,   0,   0,   0,   0, 
+     51,  51,   0,   0,  98,   8, 
+      0,   3,  18,  16,  16,   0, 
+      1,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0,  45,   0, 
+      0,   7, 242,  32,  16,   0, 
+      0,   0,   0,   0,   6,  16, 
+     16,   0,   1,   0,   0,   0, 
+     70, 126,  16,   0,   0,   0, 
+      0,   0,  62,   0,   0,   1, 
+     83,  84,  65,  84, 116,   0, 
+      0,   0,   2,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   2,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0
+};
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_ps_4ui.h
new file mode 100644 (file)
index 0000000..1c3a3e1
--- /dev/null
@@ -0,0 +1,130 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+//
+///
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// Buffer4UI                         texture   uint4         buf    0        1
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float       
+// TEXCOORD                 0   x           1     NONE    uint   x   
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Target                0   xyzw        0   TARGET    uint   xyzw
+//
+ps_4_0
+dcl_resource_buffer (uint,uint,uint,uint) t0
+dcl_input_ps constant v1.x
+dcl_output o0.xyzw
+ld o0.xyzw, v1.xxxx, t0.xyzw
+ret 
+// Approximately 2 instruction slots used
+#endif
+
+const BYTE g_PS_BufferToTexture_4UI[] =
+{
+     68,  88,  66,  67, 209, 204, 
+    134,  75,  28, 212, 134, 131, 
+    219,  18,  16, 227,  99,  23, 
+    205, 131,   1,   0,   0,   0, 
+     24,   2,   0,   0,   5,   0, 
+      0,   0,  52,   0,   0,   0, 
+    184,   0,   0,   0,  16,   1, 
+      0,   0,  68,   1,   0,   0, 
+    156,   1,   0,   0,  82,  68, 
+     69,  70, 124,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    255, 255,   0,   1,   0,   0, 
+     70,   0,   0,   0,  60,   0, 
+      0,   0,   2,   0,   0,   0, 
+      4,   0,   0,   0,   1,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,  13,   0,   0,   0, 
+     66, 117, 102, 102, 101, 114, 
+     52,  85,  73,   0,  77, 105, 
+     99, 114, 111, 115, 111, 102, 
+    116,  32,  40,  82,  41,  32, 
+     72,  76,  83,  76,  32,  83, 
+    104,  97, 100, 101, 114,  32, 
+     67, 111, 109, 112, 105, 108, 
+    101, 114,  32,  57,  46,  51, 
+     48,  46,  57,  50,  48,  48, 
+     46,  49,  54,  51,  56,  52, 
+      0, 171, 171, 171,  73,  83, 
+     71,  78,  80,   0,   0,   0, 
+      2,   0,   0,   0,   8,   0, 
+      0,   0,  56,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  68,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   1,   1, 
+      0,   0,  83,  86,  95,  80, 
+    111, 115, 105, 116, 105, 111, 
+    110,   0,  84,  69,  88,  67, 
+     79,  79,  82,  68,   0, 171, 
+    171, 171,  79,  83,  71,  78, 
+     44,   0,   0,   0,   1,   0, 
+      0,   0,   8,   0,   0,   0, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     83,  86,  95,  84,  97, 114, 
+    103, 101, 116,   0, 171, 171, 
+     83,  72,  68,  82,  80,   0, 
+      0,   0,  64,   0,   0,   0, 
+     20,   0,   0,   0,  88,   8, 
+      0,   4,   0, 112,  16,   0, 
+      0,   0,   0,   0,  68,  68, 
+      0,   0,  98,   8,   0,   3, 
+     18,  16,  16,   0,   1,   0, 
+      0,   0, 101,   0,   0,   3, 
+    242,  32,  16,   0,   0,   0, 
+      0,   0,  45,   0,   0,   7, 
+    242,  32,  16,   0,   0,   0, 
+      0,   0,   6,  16,  16,   0, 
+      1,   0,   0,   0,  70, 126, 
+     16,   0,   0,   0,   0,   0, 
+     62,   0,   0,   1,  83,  84, 
+     65,  84, 116,   0,   0,   0, 
+      2,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      2,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0
+};
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h b/Source/ThirdParty/ANGLE/src/libGLESv2/renderer/d3d11/shaders/compiled/buffertotexture11_vs.h
new file mode 100644 (file)
index 0000000..1331f3a
--- /dev/null
@@ -0,0 +1,303 @@
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+//
+///
+// Buffer Definitions: 
+//
+// cbuffer BufferCopyParams
+// {
+//
+//   uint FirstPixelOffset;             // Offset:    0 Size:     4
+//   uint PixelsPerRow;                 // Offset:    4 Size:     4
+//   uint RowStride;                    // Offset:    8 Size:     4
+//   uint RowsPerSlice;                 // Offset:   12 Size:     4
+//   float2 PositionOffset;             // Offset:   16 Size:     8
+//   float2 PositionScale;              // Offset:   24 Size:     8
+//   int2 TexLocationOffset;            // Offset:   32 Size:     8 [unused]
+//   int2 TexLocationScale;             // Offset:   40 Size:     8 [unused]
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// BufferCopyParams                  cbuffer      NA          NA    0        1
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_VertexID              0   x           0   VERTID    uint   x   
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float   xyzw
+// TEXCOORD                 0   x           1     NONE    uint   x   
+// LAYER                    0    y          1     NONE    uint    y  
+//
+vs_4_0
+dcl_constantbuffer cb0[2], immediateIndexed
+dcl_input_sgv v0.x, vertex_id
+dcl_output_siv o0.xyzw, position
+dcl_output o1.x
+dcl_output o1.y
+dcl_temps 2
+mov o0.zw, l(0,0,0,1.000000)
+imul null, r0.xy, cb0[0].wwww, cb0[0].yzyy
+udiv r0.z, null, v0.x, r0.x
+imad r0.x, -r0.z, r0.x, v0.x
+imad r0.y, r0.z, r0.y, cb0[0].x
+mov o1.y, r0.z
+udiv r0.z, null, r0.x, cb0[0].y
+imad r0.x, -r0.z, cb0[0].y, r0.x
+utof r1.xy, r0.xzxx
+imad r0.y, r0.z, cb0[0].z, r0.y
+iadd o1.x, r0.x, r0.y
+mad o0.xy, cb0[1].zwzz, r1.xyxx, cb0[1].xyxx
+ret 
+// Approximately 13 instruction slots used
+#endif
+
+const BYTE g_VS_BufferToTexture[] =
+{
+     68,  88,  66,  67, 158,  32, 
+    140,  89, 212, 226, 251, 197, 
+    186, 151,  46, 176, 250,  58, 
+     75, 228,   1,   0,   0,   0, 
+    104,   5,   0,   0,   5,   0, 
+      0,   0,  52,   0,   0,   0, 
+     64,   2,   0,   0, 116,   2, 
+      0,   0, 232,   2,   0,   0, 
+    236,   4,   0,   0,  82,  68, 
+     69,  70,   4,   2,   0,   0, 
+      1,   0,   0,   0,  80,   0, 
+      0,   0,   1,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    254, 255,   0,   1,   0,   0, 
+    209,   1,   0,   0,  60,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+     66, 117, 102, 102, 101, 114, 
+     67, 111, 112, 121,  80,  97, 
+    114,  97, 109, 115,   0, 171, 
+    171, 171,  60,   0,   0,   0, 
+      8,   0,   0,   0, 104,   0, 
+      0,   0,  48,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  40,   1,   0,   0, 
+      0,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     60,   1,   0,   0,   0,   0, 
+      0,   0,  76,   1,   0,   0, 
+      4,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     60,   1,   0,   0,   0,   0, 
+      0,   0,  89,   1,   0,   0, 
+      8,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     60,   1,   0,   0,   0,   0, 
+      0,   0,  99,   1,   0,   0, 
+     12,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     60,   1,   0,   0,   0,   0, 
+      0,   0, 112,   1,   0,   0, 
+     16,   0,   0,   0,   8,   0, 
+      0,   0,   2,   0,   0,   0, 
+    128,   1,   0,   0,   0,   0, 
+      0,   0, 144,   1,   0,   0, 
+     24,   0,   0,   0,   8,   0, 
+      0,   0,   2,   0,   0,   0, 
+    128,   1,   0,   0,   0,   0, 
+      0,   0, 158,   1,   0,   0, 
+     32,   0,   0,   0,   8,   0, 
+      0,   0,   0,   0,   0,   0, 
+    176,   1,   0,   0,   0,   0, 
+      0,   0, 192,   1,   0,   0, 
+     40,   0,   0,   0,   8,   0, 
+      0,   0,   0,   0,   0,   0, 
+    176,   1,   0,   0,   0,   0, 
+      0,   0,  70, 105, 114, 115, 
+    116,  80, 105, 120, 101, 108, 
+     79, 102, 102, 115, 101, 116, 
+      0, 171, 171, 171,   0,   0, 
+     19,   0,   1,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  80, 105, 120, 101, 
+    108, 115,  80, 101, 114,  82, 
+    111, 119,   0,  82, 111, 119, 
+     83, 116, 114, 105, 100, 101, 
+      0,  82, 111, 119, 115,  80, 
+    101, 114,  83, 108, 105,  99, 
+    101,   0,  80, 111, 115, 105, 
+    116, 105, 111, 110,  79, 102, 
+    102, 115, 101, 116,   0, 171, 
+      1,   0,   3,   0,   1,   0, 
+      2,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  80, 111, 
+    115, 105, 116, 105, 111, 110, 
+     83,  99,  97, 108, 101,   0, 
+     84, 101, 120,  76, 111,  99, 
+     97, 116, 105, 111, 110,  79, 
+    102, 102, 115, 101, 116,   0, 
+      1,   0,   2,   0,   1,   0, 
+      2,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  84, 101, 
+    120,  76, 111,  99,  97, 116, 
+    105, 111, 110,  83,  99,  97, 
+    108, 101,   0,  77, 105,  99, 
+    114, 111, 115, 111, 102, 116, 
+     32,  40,  82,  41,  32,  72, 
+     76,  83,  76,  32,  83, 104, 
+     97, 100, 101, 114,  32,  67, 
+    111, 109, 112, 105, 108, 101, 
+    114,  32,  57,  46,  51,  48, 
+     46,  57,  50,  48,  48,  46, 
+     49,  54,  51,  56,  52,   0, 
+     73,  83,  71,  78,  44,   0, 
+      0,   0,   1,   0,   0,   0, 
+      8,   0,   0,   0,  32,   0, 
+      0,   0,   0,   0,   0,   0, 
+      6,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   1,   0,   0,  83,  86, 
+     95,  86, 101, 114, 116, 101, 
+    120,  73,  68,   0,  79,  83, 
+     71,  78, 108,   0,   0,   0, 
+      3,   0,   0,   0,   8,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  92,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   1,  14, 
+      0,   0, 101,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   2,  13, 
+      0,   0,  83,  86,  95,  80, 
+    111, 115, 105, 116, 105, 111, 
+    110,   0,  84,  69,  88,  67, 
+     79,  79,  82,  68,   0,  76, 
+     65,  89,  69,  82,   0, 171, 
+     83,  72,  68,  82, 252,   1, 
+      0,   0,  64,   0,   1,   0, 
+    127,   0,   0,   0,  89,   0, 
+      0,   4,  70, 142,  32,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,  96,   0,   0,   4, 
+     18,  16,  16,   0,   0,   0, 
+      0,   0,   6,   0,   0,   0, 
+    103,   0,   0,   4, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0, 101,   0, 
+      0,   3,  18,  32,  16,   0, 
+      1,   0,   0,   0, 101,   0, 
+      0,   3,  34,  32,  16,   0, 
+      1,   0,   0,   0, 104,   0, 
+      0,   2,   2,   0,   0,   0, 
+     54,   0,   0,   8, 194,  32, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    128,  63,  38,   0,   0,  10, 
+      0, 208,   0,   0,  50,   0, 
+     16,   0,   0,   0,   0,   0, 
+    246, 143,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    150, 133,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     78,   0,   0,   8,  66,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0, 208,   0,   0,  10,  16, 
+     16,   0,   0,   0,   0,   0, 
+     10,   0,  16,   0,   0,   0, 
+      0,   0,  35,   0,   0,  10, 
+     18,   0,  16,   0,   0,   0, 
+      0,   0,  42,   0,  16, 128, 
+     65,   0,   0,   0,   0,   0, 
+      0,   0,  10,   0,  16,   0, 
+      0,   0,   0,   0,  10,  16, 
+     16,   0,   0,   0,   0,   0, 
+     35,   0,   0,  10,  34,   0, 
+     16,   0,   0,   0,   0,   0, 
+     42,   0,  16,   0,   0,   0, 
+      0,   0,  26,   0,  16,   0, 
+      0,   0,   0,   0,  10, 128, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  54,   0, 
+      0,   5,  34,  32,  16,   0, 
+      1,   0,   0,   0,  42,   0, 
+     16,   0,   0,   0,   0,   0, 
+     78,   0,   0,   9,  66,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0, 208,   0,   0,  10,   0, 
+     16,   0,   0,   0,   0,   0, 
+     26, 128,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     35,   0,   0,  11,  18,   0, 
+     16,   0,   0,   0,   0,   0, 
+     42,   0,  16, 128,  65,   0, 
+      0,   0,   0,   0,   0,   0, 
+     26, 128,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     10,   0,  16,   0,   0,   0, 
+      0,   0,  86,   0,   0,   5, 
+     50,   0,  16,   0,   1,   0, 
+      0,   0, 134,   0,  16,   0, 
+      0,   0,   0,   0,  35,   0, 
+      0,  10,  34,   0,  16,   0, 
+      0,   0,   0,   0,  42,   0, 
+     16,   0,   0,   0,   0,   0, 
+     42, 128,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     26,   0,  16,   0,   0,   0, 
+      0,   0,  30,   0,   0,   7, 
+     18,  32,  16,   0,   1,   0, 
+      0,   0,  10,   0,  16,   0, 
+      0,   0,   0,   0,  26,   0, 
+     16,   0,   0,   0,   0,   0, 
+     50,   0,   0,  11,  50,  32, 
+     16,   0,   0,   0,   0,   0, 
+    230, 138,  32,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     70,   0,  16,   0,   1,   0, 
+      0,   0,  70, 128,  32,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,  62,   0,   0,   1, 
+     83,  84,  65,  84, 116,   0, 
+      0,   0,  13,   0,   0,   0, 
+      2,   0,   0,   0,   0,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,   2,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0
+};
-#if 0\r
-//\r
-// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384\r
-//\r
-//\r
-///\r
-//\r
-// Input signature:\r
-//\r
-// Name                 Index   Mask Register SysValue  Format   Used\r
-// -------------------- ----- ------ -------- -------- ------- ------\r
-// SV_POSITION              0   xyzw        0      POS   float       \r
-// COLOR                    0   xyzw        1     NONE   float   xyzw\r
-//\r
-//\r
-// Output signature:\r
-//\r
-// Name                 Index   Mask Register SysValue  Format   Used\r
-// -------------------- ----- ------ -------- -------- ------- ------\r
-// SV_TARGET                0   xyzw        0   TARGET   float   xyzw\r
-// SV_TARGET                1   xyzw        1   TARGET   float   xyzw\r
-// SV_TARGET                2   xyzw        2   TARGET   float   xyzw\r
-// SV_TARGET                3   xyzw        3   TARGET   float   xyzw\r
-// SV_TARGET                4   xyzw        4   TARGET   float   xyzw\r
-// SV_TARGET                5   xyzw        5   TARGET   float   xyzw\r
-// SV_TARGET                6   xyzw        6   TARGET   float   xyzw\r
-// SV_TARGET                7   xyzw        7   TARGET   float   xyzw\r
-//\r
-ps_4_0\r
-dcl_input_ps linear v1.xyzw\r
-dcl_output o0.xyzw\r
-dcl_output o1.xyzw\r
-dcl_output o2.xyzw\r
-dcl_output o3.xyzw\r
-dcl_output o4.xyzw\r
-dcl_output o5.xyzw\r
-dcl_output o6.xyzw\r
-dcl_output o7.xyzw\r
-mov o0.xyzw, v1.xyzw\r
-mov o1.xyzw, v1.xyzw\r
-mov o2.xyzw, v1.xyzw\r
-mov o3.xyzw, v1.xyzw\r
-mov o4.xyzw, v1.xyzw\r
-mov o5.xyzw, v1.xyzw\r
-mov o6.xyzw, v1.xyzw\r
-mov o7.xyzw, v1.xyzw\r
-ret \r
-// Approximately 9 instruction slots used\r
-#endif\r
-\r
-const BYTE g_PS_ClearMultiple[] =\r
-{\r
-     68,  88,  66,  67,  92,  54, \r
-    120, 105, 166, 196, 132, 158, \r
-    209,  33, 185, 122,   8, 189, \r
-    145, 114,   1,   0,   0,   0, \r
-     88,   3,   0,   0,   5,   0, \r
-      0,   0,  52,   0,   0,   0, \r
-    140,   0,   0,   0, 224,   0, \r
-      0,   0, 188,   1,   0,   0, \r
-    220,   2,   0,   0,  82,  68, \r
-     69,  70,  80,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-     28,   0,   0,   0,   0,   4, \r
-    255, 255,   0,   1,   0,   0, \r
-     28,   0,   0,   0,  77, 105, \r
-     99, 114, 111, 115, 111, 102, \r
-    116,  32,  40,  82,  41,  32, \r
-     72,  76,  83,  76,  32,  83, \r
-    104,  97, 100, 101, 114,  32, \r
-     67, 111, 109, 112, 105, 108, \r
-    101, 114,  32,  57,  46,  51, \r
-     48,  46,  57,  50,  48,  48, \r
-     46,  49,  54,  51,  56,  52, \r
-      0, 171,  73,  83,  71,  78, \r
-     76,   0,   0,   0,   2,   0, \r
-      0,   0,   8,   0,   0,   0, \r
-     56,   0,   0,   0,   0,   0, \r
-      0,   0,   1,   0,   0,   0, \r
-      3,   0,   0,   0,   0,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-     68,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   1,   0, \r
-      0,   0,  15,  15,   0,   0, \r
-     83,  86,  95,  80,  79,  83, \r
-     73,  84,  73,  79,  78,   0, \r
-     67,  79,  76,  79,  82,   0, \r
-    171, 171,  79,  83,  71,  78, \r
-    212,   0,   0,   0,   8,   0, \r
-      0,   0,   8,   0,   0,   0, \r
-    200,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   0,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-    200,   0,   0,   0,   1,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   1,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-    200,   0,   0,   0,   2,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   2,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-    200,   0,   0,   0,   3,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   3,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-    200,   0,   0,   0,   4,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   4,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-    200,   0,   0,   0,   5,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   5,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-    200,   0,   0,   0,   6,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   6,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-    200,   0,   0,   0,   7,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      3,   0,   0,   0,   7,   0, \r
-      0,   0,  15,   0,   0,   0, \r
-     83,  86,  95,  84,  65,  82, \r
-     71,  69,  84,   0, 171, 171, \r
-     83,  72,  68,  82,  24,   1, \r
-      0,   0,  64,   0,   0,   0, \r
-     70,   0,   0,   0,  98,  16, \r
-      0,   3, 242,  16,  16,   0, \r
-      1,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      0,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      1,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      2,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      3,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      4,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      5,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      6,   0,   0,   0, 101,   0, \r
-      0,   3, 242,  32,  16,   0, \r
-      7,   0,   0,   0,  54,   0, \r
-      0,   5, 242,  32,  16,   0, \r
-      0,   0,   0,   0,  70,  30, \r
-     16,   0,   1,   0,   0,   0, \r
-     54,   0,   0,   5, 242,  32, \r
-     16,   0,   1,   0,   0,   0, \r
-     70,  30,  16,   0,   1,   0, \r
-      0,   0,  54,   0,   0,   5, \r
-    242,  32,  16,   0,   2,   0, \r
-      0,   0,  70,  30,  16,   0, \r
-      1,   0,   0,   0,  54,   0, \r
-      0,   5, 242,  32,  16,   0, \r
-      3,   0,   0,   0,  70,  30, \r
-     16,   0,   1,   0,   0,   0, \r
-     54,   0,   0,   5, 242,  32, \r
-     16,   0,   4,   0,   0,   0, \r
-     70,  30,  16,   0,   1,   0, \r
-      0,   0,  54,   0,   0,   5, \r
-    242,  32,  16,   0,   5,   0, \r
-      0,   0,  70,  30,  16,   0, \r
-      1,   0,   0,   0,  54,   0, \r
-      0,   5, 242,  32,  16,   0, \r
-      6,   0,   0,   0,  70,  30, \r
-     16,   0,   1,   0,   0,   0, \r
-     54,   0,   0,   5, 242,  32, \r
-     16,   0,   7,   0,   0,   0, \r
-     70,  30,  16,   0,   1,   0, \r
-      0,   0,  62,   0,   0,   1, \r
-     83,  84,  65,  84, 116,   0, \r
-      0,   0,   9,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   9,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      1,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      9,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0,   0,   0, \r
-      0,   0,   0,   0\r
-};\r
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
+//
+//
+///
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float       
+// COLOR                    0   xyzw        1     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
+// SV_TARGET                1   xyzw        1   TARGET   float   xyzw
+// SV_TARGET                2   xyzw        2   TARGET   float   xyzw
+// SV_TARGET                3   xyzw        3   TARGET   float   xyzw
+// SV_TARGET                4   xyzw        4   TARGET   float   xyzw
+// SV_TARGET                5   xyzw        5   TARGET   float   xyzw
+// SV_TARGET                6   xyzw        6   TARGET   float   xyzw
+// SV_TARGET                7   xyzw        7   TARGET   float   xyzw
+//
+ps_4_0
+dcl_input_ps linear v1.xyzw
+dcl_output o0.xyzw
+dcl_output o1.xyzw
+dcl_output o2.xyzw
+dcl_output o3.xyzw
+dcl_output o4.xyzw
+dcl_output o5.xyzw
+dcl_output o6.xyzw
+dcl_output o7.xyzw
+mov o0.xyzw, v1.xyzw
+mov o1.xyzw, v1.xyzw
+mov o2.xyzw, v1.xyzw
+mov o3.xyzw, v1.xyzw
+mov o4.xyzw, v1.xyzw
+mov o5.xyzw, v1.xyzw
+mov o6.xyzw, v1.xyzw
+mov o7.xyzw, v1.xyzw
+ret 
+// Approximately 9 instruction slots used
+#endif
+
+const BYTE g_PS_ClearFloat[] =
+{
+     68,  88,  66,  67,  92,  54, 
+    120, 105, 166, 196, 132, 158, 
+    209,  33, 185, 122,   8, 189, 
+    145, 114,   1,   0,   0,   0, 
+     88,   3,   0,   0,   5,   0, 
+      0,   0,  52,   0,   0,   0, 
+    140,   0,   0,   0, 224,   0, 
+      0,   0, 188,   1,   0,   0, 
+    220,   2,   0,   0,  82,  68, 
+     69,  70,  80,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    255, 255,   0,   1,   0,   0, 
+     28,   0,   0,   0,  77, 105, 
+     99, 114, 111, 115, 111, 102, 
+    116,  32,  40,  82,  41,  32, 
+     72,  76,  83,  76,  32,  83, 
+    104,  97, 100, 101, 114,  32, 
+     67, 111, 109, 112, 105, 108, 
+    101, 114,  32,  57,  46,  51, 
+     48,  46,  57,  50,  48,  48, 
+     46,  49,  54,  51,  56,  52, 
+      0, 171,  73,  83,  71,  78, 
+     76,   0,   0,   0,   2,   0, 
+      0,   0,   8,   0,   0,   0, 
+     56,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     68,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0,  15,  15,   0,   0, 
+     83,  86,  95,  80,  79,  83, 
+     73,  84,  73,  79,  78,   0, 
+     67,  79,  76,  79,  82,   0, 
+    171, 171,  79,  83,  71,  78, 
+    212,   0,   0,   0,   8,   0, 
+      0,   0,   8,   0,   0,   0, 
+    200,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+    200,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0,  15,   0,   0,   0, 
+    200,   0,   0,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   2,   0, 
+      0,   0,  15,   0,   0,   0, 
+    200,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   3,   0, 
+      0,   0,  15,   0,   0,   0, 
+    200,   0,   0,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   4,   0, 
+      0,   0,  15,   0,   0,   0, 
+    200,   0,   0,   0,   5,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   5,   0, 
+      0,   0,  15,   0,   0,   0, 
+    200,   0,   0,   0,   6,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   6,   0, 
+      0,   0,  15,   0,   0,   0, 
+    200,   0,   0,   0,   7,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   7,   0, 
+      0,   0,  15,   0,   0,   0, 
+     83,  86,  95,  84,  65,  82, 
+     71,  69,  84,   0, 171, 171, 
+     83,  72,  68,  82,  24,   1, 
+      0,   0,  64,   0,   0,   0, 
+     70,   0,   0,   0,  98,  16, 
+      0,   3, 242,  16,  16,   0, 
+      1,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0, 101,